Advertisement
xavicano

Untitled

Jul 31st, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.65 KB | None | 0 0
  1. # guizero - Hero name generator
  2. from guizero import App, Text, ButtonGroup, Combo, PushButton, TextBox, CheckBox, ListBox, Picture
  3.  
  4. app = App(title="Hero-o-matic",width=500, height=500)
  5.  
  6. #picture = Picture(app, image="Yomo.png")
  7. # Function definitions for your events go here.
  8.  
  9. def make_hero_name():
  10.     superb=""
  11.     adjective = bgp_adjective.value
  12.     colour = txt_colour.value
  13.     animal = cmb_animal.value
  14.     hero = adjective + " " + colour + " " + animal
  15.     eat =listbox.value
  16.  
  17.     if checkbox.value==1:
  18.         superb=" superb"    
  19.     lbl_output.value = "You are"+superb+"... The " + hero + " that likes to eat "+ eat + "."
  20.    
  21. def make_darkmode():
  22.     if darkmode.value==1:
  23.         app.bg="black"
  24.         app.text_color="white"
  25.     else:
  26.         app.bg="gray"
  27.         app.text_color="black"
  28.  
  29.  
  30. # Your GUI widgets go here
  31. message1 = Text(app, text="Choose an adjective")
  32. bgp_adjective = Combo(app, options=["Amazing", "Bonny", "Charming", "Delightful", "Dangerous","Dierce"], selected="Amazing", width=20)
  33.  
  34. message2 = Text(app, text="Enter a colour?")
  35. txt_colour = TextBox(app)
  36.  
  37. message3 = Text(app, text="Pick an animal")
  38. cmb_animal = ButtonGroup(app, options=["Aardvark", "Badger", "Cat", "Dolphin", "Velociraptor"], selected="Aardvark")
  39.  
  40. btn_make_name = PushButton(app, text='Make me a hero', command=make_hero_name)
  41. lbl_output = Text(app, text="A hero name will appear here")
  42.  
  43. checkbox = CheckBox(app, text="Superb")
  44.  
  45. listbox = ListBox(app, items=["Beef", "Chicken", "Fish", "Vegetarian"], scrollbar=True, height="fill")
  46. darkmode = CheckBox(app, text="DarkMode",command=make_darkmode)
  47.  
  48. # Set up event triggers here
  49.  
  50. # Show the GUI on the screen, start listening to events.
  51. app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement