Advertisement
xavicano

Untitled

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