Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from guizero import App, Text, ButtonGroup, Combo, PushButton, TextBox, CheckBox, ListBox, Slider, Box, MenuBar, Window, Picture
- app = App(title="Hero-O-Matic", height=500, width=500, layout="auto") #Creation of App
- #windows
- wdw_hn = Window(app, visible=False, title="Hero Creator") #This is the window for the Hero Creator
- wdw_cn = Window(app, visible=False, title="Companion Creator") #This Window is for the companion creator
- """
- Main App Functions
- """
- def Highlight_hn():
- btn_hn.bg = "light green"
- def Unlight_hn():
- if sld_dm.value == 0:
- btn_hn.bg= None
- else:
- btn_hn.bg = "#403f3f"
- def Highlight_cn():
- btn_cn.bg = "Light Green"
- def Unlight_cn():
- if sld_dm.value == 0:
- btn_cn.bg= None
- else:
- btn_cn.bg = "#403f3f"
- def herovis():
- wdw_hn.visible = True
- def compvis():
- wdw_cn.visible = True
- def heroclose():
- wdw_hn.visible = False
- def compclose():
- wdw_cn.visible = False
- def darkmode():
- if sld_dm.value != 0:
- wdw_cn.bg="#403f3f"
- wdw_hn.bg="#403f3f"
- app.bg="#403f3f"
- #app widgets
- lbl_1.text_color = "white"
- lbl_2.text_color = "white"
- lbl_3.text_color = "white"
- sld_dm.text_color = "white"
- btn_hn.text_color = "white"
- btn_cn.text_color = "white"
- #Hero Window widgets
- message1.text_color = "white"
- message2.text_color = "white"
- message3.text_color = "white"
- bgp_hn_adjective.text_color = "white"
- txt_hn_colour.text_color = "white"
- cmb_hn_animal.text_color = "white"
- btn_make_name.text_color = "white"
- btn_hn_close.text_color = "white"
- #Companion Window Widgets
- message1_cn.text_color = "white"
- message2_cn.text_color = "white"
- message3_cn.text_color = "white"
- cmb_cn_insect.text_color = "white"
- txt_cn_sex.text_color = "white"
- bgp_cn_number.text_color = "white"
- btn_cn_close.text_color = "white"
- btn_make_name_cn.text_color = "white"
- else:
- wdw_cn.bg=None
- wdw_hn.bg=None
- app.bg=None
- #app widgets
- lbl_1.text_color = None
- lbl_2.text_color = None
- lbl_3.text_color = None
- sld_dm.text_color = None
- btn_hn.text_color = None
- btn_cn.text_color = None
- #Hero Window widgets
- message1.text_color = None
- message2.text_color = None
- message3.text_color = None
- bgp_hn_adjective.text_color = None
- txt_hn_colour.text_color = None
- cmb_hn_animal.text_color = None
- btn_make_name.text_color = None
- btn_hn_close.text_color = None
- #Companion Window Widgets
- message1_cn.text_color = None
- message2_cn.text_color = None
- message3_cn.text_color = None
- cmb_cn_insect.text_color = None
- txt_cn_sex.text_color = None
- bgp_cn_number.text_color = None
- btn_cn_close.text_color = None
- btn_make_name_cn.text_color = None
- def hero_go():
- adjective = bgp_hn_adjective.value
- colour = txt_hn_colour.value
- animal = cmb_hn_animal.value
- hero = adjective +" "+ colour +" "+ animal
- hero_output = "Your are... " + hero + ".\n"
- btn_hn.disable()
- wdw_hn.visible = False
- lbl_2.append(hero_output)
- def comp_go():
- comp_insect = cmb_cn_insect.value
- comp_sex = txt_cn_sex.value
- comp_numeral = bgp_cn_number.value
- companion = comp_insect +" "+ comp_sex +" "+ comp_numeral
- comp_output = "Your companion is..." + companion + ".\n"
- btn_cn.disable()
- wdw_cn.visible = False
- lbl_2.append(comp_output)
- """
- -----------------------
- General App
- -----------------------
- """
- box1 = Box(app, layout="auto", align="top", border = 3, height=30, width="fill", enabled=True, visible=True) #Box with border that contains the text
- lbl_1 = Text(box1, text="Which name do you want to create?", font="Comic Sans MS") # Text inside the Box
- btn_hn = PushButton(app, align="top", text="Create your Hero Name", command=herovis, width="fill") #Button for choosing what to do
- btn_cn = PushButton(app, align="top", text="Create your Companion's Name", command=compvis, width="fill") #Button for Choosing what to do
- sld_dm = Slider(app, align="bottom", command=darkmode, end=1) #The Dark Mode slider
- lbl_3 = Text(app, text="Dark Mode:", align="bottom")
- lbl_2 = Text(app, text="The names you created will appear here:\n", font="Comic Sans MS")
- """
- ----------------------
- Hero Window Widgets
- ----------------------
- """
- message1 = Text(wdw_hn, text="Choose an adjective")
- bgp_hn_adjective = ListBox(wdw_hn, items=["Amazing", "Bonny", "Charming", "Delightful", "Terrifying", "Gruesome", "Unsafe", "Positive", "Dumb"], selected="Amazing")
- message2 = Text(wdw_hn, text="Enter a colour")
- txt_hn_colour = TextBox(wdw_hn)
- message3 = Text(wdw_hn, text="Pick an animal")
- cmb_hn_animal = Combo(wdw_hn, options=["Aardvark", "Badger", "Cat", "Dolphin", "Velociraptor", "Dog"], selected="Aardvark", width=20)
- btn_make_name = PushButton(wdw_hn,command=hero_go ,text='Make me a hero\n(Watch out, can\'t be changed later)')
- btn_hn_close = PushButton(wdw_hn, align="bottom", text="Close", height=1, width="fill", command=heroclose)
- """
- ----------------------
- Companion Window Widgets
- ----------------------
- """
- message3_cn = Text(wdw_cn, text="Pick an insect")
- cmb_cn_insect = Combo(wdw_cn, options=["Ant", "Bee", "Wasp", "Bug"], selected="Aardvark", width=20)
- message2_cn = Text(wdw_cn, text="Choose whether your companion should be a boy or a girl")
- txt_cn_sex = ButtonGroup(wdw_cn, options=["Boy", "Girl"])
- message1_cn = Text(wdw_cn, text="Choose a numeral")
- bgp_cn_number = Combo(wdw_cn, options=["the 1st", "the 2nd", "the 3rd", "the 4th", "the 5th"], selected="the 1st")
- btn_make_name_cn = PushButton(wdw_cn,command=comp_go ,text='Make my Companion\n(Watch out, can\'t be changed later)')
- btn_cn_close = PushButton(wdw_cn, align="bottom", text="Close", height=1, width="fill", command=compclose)
- '''
- ---------------------
- Triggers
- ---------------------
- '''
- btn_hn.when_mouse_enters = Highlight_hn
- btn_hn.when_mouse_leaves = Unlight_hn
- btn_cn.when_mouse_enters = Highlight_cn
- btn_cn.when_mouse_leaves = Unlight_cn
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement