SHARE
TWEET

Untitled

a guest Dec 8th, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # guizero - Hero name generator
  2. from guizero import App, Text, ButtonGroup, Combo, PushButton, TextBox, CheckBox, Picture, ListBox
  3. app = App(title="Central Europe Hero-o-matic :-) ", height=660, width=720)
  4.  
  5. # Function definitions go here.
  6. def make_hero_name():
  7.     ckb_second_adjective_str=""
  8.     if ckb_second_adjective.value == 1:
  9.         ckb_second_adjective_str = ckb_second_adjective.text
  10.     adjective = cmb_adjective.value
  11.     colour = txt_colour.value
  12.     animal = cmb_animal.value
  13.     great_name = lbx_add_gname.value
  14.     hero = adjective + " " + colour + " " + ckb_second_adjective_str + " " + animal + " " + great_name
  15.     lbl_output.text_size = 18
  16.     lbl_output.value = "You are... The " + hero + "."
  17.    
  18. def dark_mode():
  19.     if ckb_dark_mode.value == 1:
  20.         app.bg = "black"
  21.         app.text_color = "white"
  22.     else:
  23.         app.bg = "light grey"
  24.         app.text_color = "black"
  25. # GUI widgets go here
  26. pic = Picture(app, image="wolverine.png")
  27.  
  28. ckb_dark_mode = CheckBox(app, text="Dark Mode", command=dark_mode)
  29.  
  30. message1 = Text(app, text="Choose an adjective")
  31. cmb_adjective = Combo(app, options=["Patriotic", "Persistent","Heroic","Brave", "Steadfast", "National"], selected="Patriotic", width=20)
  32.  
  33. message2 = Text(app, text="Enter a colour?")
  34. txt_colour = TextBox(app)
  35.  
  36. message3 = Text(app, text="Pick an animal")
  37. cmb_animal = Combo(app, options=["Wolf", "Wolverine" , "Bear", "Boar", "Eagle", "Moose", "Deer"], selected="Wolverine", width=20)
  38.  
  39. message4 = Text(app, text="Choose a second adjective")
  40. ckb_second_adjective = CheckBox(app, text="Mighty")
  41.  
  42. message5 = Text(app, text="Additional great name")
  43. lbx_add_gname = ListBox(app, items=["The Great Warrior", "The Best Hunter", "The Sky Conqueror"], height = 80, width=160)
  44.  
  45. lbl_output = Text(app, text="A hero name will appear here")
  46.  
  47. # Set up event triggers here
  48. btn_make_name = PushButton(app, text='Make me a hero', command=make_hero_name)
  49.  
  50. # Show the GUI on the screen, start listening to events.
  51. app.display()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top