Advertisement
Guest User

Hero and Companion Name Creator

a guest
Dec 7th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.34 KB | None | 0 0
  1. from guizero import App, Text, ButtonGroup, Combo, PushButton, TextBox, CheckBox, ListBox, Slider, Box, MenuBar, Window, Picture
  2. app = App(title="Hero-O-Matic", height=500, width=500, layout="auto") #Creation of App
  3.  
  4. #windows
  5. wdw_hn = Window(app, visible=False, title="Hero Creator")       #This is the window for the Hero Creator
  6. wdw_cn = Window(app, visible=False, title="Companion Creator")  #This Window is for the companion creator
  7.  
  8.  
  9.  
  10. """
  11. Main App Functions
  12. """
  13. def Highlight_hn():
  14.     btn_hn.bg = "light green"
  15.  
  16. def Unlight_hn():      
  17.     if sld_dm.value == 0:
  18.         btn_hn.bg= None
  19.     else:
  20.         btn_hn.bg = "#403f3f"
  21.        
  22. def Highlight_cn():    
  23.     btn_cn.bg = "Light Green"
  24.  
  25. def Unlight_cn():      
  26.     if sld_dm.value == 0:
  27.         btn_cn.bg= None
  28.     else:
  29.         btn_cn.bg = "#403f3f"
  30.  
  31. def herovis():        
  32.     wdw_hn.visible = True
  33.  
  34. def compvis():
  35.     wdw_cn.visible = True
  36.  
  37. def heroclose():
  38.     wdw_hn.visible = False
  39.  
  40. def compclose():
  41.     wdw_cn.visible = False
  42.  
  43. def darkmode():
  44.     if sld_dm.value != 0:
  45.         wdw_cn.bg="#403f3f"
  46.         wdw_hn.bg="#403f3f"
  47.         app.bg="#403f3f"
  48.         #app widgets
  49.         lbl_1.text_color = "white"
  50.         lbl_2.text_color = "white"
  51.         lbl_3.text_color = "white"
  52.         sld_dm.text_color = "white"
  53.         btn_hn.text_color = "white"
  54.         btn_cn.text_color = "white"
  55.         #Hero Window widgets
  56.         message1.text_color = "white"
  57.         message2.text_color = "white"
  58.         message3.text_color = "white"
  59.         bgp_hn_adjective.text_color = "white"
  60.         txt_hn_colour.text_color = "white"
  61.         cmb_hn_animal.text_color = "white"
  62.         btn_make_name.text_color = "white"
  63.         btn_hn_close.text_color = "white"
  64.         #Companion Window Widgets
  65.         message1_cn.text_color = "white"
  66.         message2_cn.text_color = "white"
  67.         message3_cn.text_color = "white"
  68.         cmb_cn_insect.text_color = "white"
  69.         txt_cn_sex.text_color = "white"
  70.         bgp_cn_number.text_color = "white"
  71.         btn_cn_close.text_color = "white"
  72.         btn_make_name_cn.text_color = "white"
  73.     else:
  74.         wdw_cn.bg=None
  75.         wdw_hn.bg=None
  76.         app.bg=None
  77.         #app widgets
  78.         lbl_1.text_color = None
  79.         lbl_2.text_color = None
  80.         lbl_3.text_color = None
  81.         sld_dm.text_color = None
  82.         btn_hn.text_color = None
  83.         btn_cn.text_color = None
  84.         #Hero Window widgets
  85.         message1.text_color = None
  86.         message2.text_color = None
  87.         message3.text_color = None
  88.         bgp_hn_adjective.text_color = None
  89.         txt_hn_colour.text_color = None
  90.         cmb_hn_animal.text_color = None
  91.         btn_make_name.text_color = None
  92.         btn_hn_close.text_color = None
  93.         #Companion Window Widgets
  94.         message1_cn.text_color = None
  95.         message2_cn.text_color = None
  96.         message3_cn.text_color = None
  97.         cmb_cn_insect.text_color = None
  98.         txt_cn_sex.text_color = None
  99.         bgp_cn_number.text_color = None
  100.         btn_cn_close.text_color = None
  101.         btn_make_name_cn.text_color = None
  102.  
  103.  
  104. def hero_go():
  105.     adjective = bgp_hn_adjective.value
  106.     colour = txt_hn_colour.value
  107.     animal = cmb_hn_animal.value
  108.     hero = adjective +" "+ colour +" "+ animal
  109.     hero_output = "Your are... " + hero + ".\n"
  110.     btn_hn.disable()
  111.     wdw_hn.visible = False
  112.     lbl_2.append(hero_output)
  113.  
  114. def comp_go():
  115.     comp_insect = cmb_cn_insect.value
  116.     comp_sex = txt_cn_sex.value
  117.     comp_numeral = bgp_cn_number.value
  118.     companion = comp_insect +" "+ comp_sex +" "+ comp_numeral
  119.     comp_output = "Your companion is..." + companion + ".\n"
  120.     btn_cn.disable()
  121.     wdw_cn.visible = False
  122.     lbl_2.append(comp_output)
  123.  
  124. """
  125. -----------------------
  126. General App
  127. -----------------------
  128. """
  129.  
  130. box1 = Box(app, layout="auto", align="top", border = 3, height=30, width="fill", enabled=True, visible=True)    #Box with border that contains the text
  131.  
  132. lbl_1 = Text(box1, text="Which name do you want to create?", font="Comic Sans MS") # Text inside the Box
  133.  
  134. btn_hn = PushButton(app, align="top", text="Create your Hero Name", command=herovis, width="fill") #Button for choosing what to do
  135. btn_cn = PushButton(app, align="top", text="Create your Companion's Name", command=compvis, width="fill")       #Button for Choosing what to do
  136.  
  137. sld_dm = Slider(app, align="bottom", command=darkmode, end=1) #The Dark Mode slider
  138. lbl_3 = Text(app, text="Dark Mode:", align="bottom")
  139.  
  140. lbl_2 = Text(app, text="The names you created will appear here:\n", font="Comic Sans MS")
  141.  
  142.  
  143. """
  144. ----------------------
  145. Hero Window Widgets
  146. ----------------------
  147. """
  148. message1 = Text(wdw_hn, text="Choose an adjective")
  149. bgp_hn_adjective = ListBox(wdw_hn, items=["Amazing", "Bonny", "Charming", "Delightful", "Terrifying", "Gruesome", "Unsafe", "Positive", "Dumb"], selected="Amazing")
  150.  
  151. message2 = Text(wdw_hn, text="Enter a colour")
  152. txt_hn_colour = TextBox(wdw_hn)
  153.  
  154. message3 = Text(wdw_hn, text="Pick an animal")
  155. cmb_hn_animal = Combo(wdw_hn, options=["Aardvark", "Badger", "Cat", "Dolphin", "Velociraptor", "Dog"], selected="Aardvark", width=20)
  156.  
  157. btn_make_name = PushButton(wdw_hn,command=hero_go ,text='Make me a hero\n(Watch out, can\'t be changed later)')
  158.  
  159. btn_hn_close = PushButton(wdw_hn, align="bottom", text="Close", height=1, width="fill", command=heroclose)
  160.  
  161.  
  162.  
  163. """
  164. ----------------------
  165. Companion Window Widgets
  166. ----------------------
  167. """
  168.  
  169. message3_cn = Text(wdw_cn, text="Pick an insect")
  170. cmb_cn_insect = Combo(wdw_cn, options=["Ant", "Bee", "Wasp", "Bug"], selected="Aardvark", width=20)
  171.  
  172. message2_cn = Text(wdw_cn, text="Choose whether your companion should be a boy or a girl")
  173. txt_cn_sex = ButtonGroup(wdw_cn, options=["Boy", "Girl"])
  174.  
  175. message1_cn = Text(wdw_cn, text="Choose a numeral")
  176. bgp_cn_number = Combo(wdw_cn, options=["the 1st", "the 2nd", "the 3rd", "the 4th", "the 5th"], selected="the 1st")
  177.  
  178. btn_make_name_cn = PushButton(wdw_cn,command=comp_go ,text='Make my Companion\n(Watch out, can\'t be changed later)')
  179.  
  180. btn_cn_close = PushButton(wdw_cn, align="bottom", text="Close", height=1, width="fill", command=compclose)
  181.  
  182.  
  183.  
  184. '''
  185. ---------------------
  186. Triggers
  187. ---------------------
  188. '''
  189.  
  190. btn_hn.when_mouse_enters = Highlight_hn
  191. btn_hn.when_mouse_leaves = Unlight_hn
  192.  
  193. btn_cn.when_mouse_enters = Highlight_cn
  194. btn_cn.when_mouse_leaves = Unlight_cn
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement