Advertisement
Guest User

Updated guizero - Hero name generator from guizero import Ap

a guest
Jan 23rd, 2020
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. Updated guizero - Hero name generator from guizero import App
  2.  
  3. ▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼
  4.  
  5. if ( 'You Need More' == TRUE || 'You Need More' == 1 )
  6. {
  7.  
  8. GOTO http://www.fl-y.com/ifyouneedmore
  9.  
  10. }
  11. endif
  12.  
  13. ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲
  14.  
  15.  
  16. # guizero - hero name generator
  17. from guizero import app, text, buttongroup, combo, pushbutton, textbox, checkbox, picture, box, slider
  18. app = app(title="hero-o-matic", width = 600, height = 600)
  19. # function definitions for your events go here.
  20. box1 = box(app, align="top", width=1000, height=200, border=1)
  21. box1.bg = "blue"
  22. box2 = box(app, align="top", width=1000, height=200, border=2)
  23. box2.bg = "pink"
  24. box3 = box(app, align="top", width=1000, height=200, border=3)
  25. box3.bg = "brown"
  26. def night_or_day_mode():
  27. if darkmode.value == 1:
  28. app.bg = "black"
  29. app.text_color = "white"
  30. else:
  31. app.bg = "white"
  32. app.text_color = "black"
  33. def slider_changed(slider_value):
  34. message5.size = slider_value
  35. def make_hero_name():
  36. adjective = bgp_adjective.value
  37. colour = txt_colour.value
  38. animal = cmb_animal.value
  39. mood = txt_mood.value
  40. hero = adjective + " " + colour + " " + animal + " in a "+ mood + " mood"
  41. ## message5.size = slider_value
  42. message5.value = "you are... the " + hero + "."
  43. # your gui widgets go here
  44. picture = picture(box1, image="test.gif")
  45. darkmode = checkbox (box1, text ="night mode", command = night_or_day_mode)
  46. message1 = text(box2, text="choose an adjective")
  47. bgp_adjective = buttongroup(app, options=["amazing", "bonny", "charming", "delightful"], selected="amazing")
  48. message2 = text(box2, text="enter a colour?")
  49. txt_colour = textbox(box2)
  50. message3 = text(box2, text="pick an animal")
  51. cmb_animal = combo(box2, options=["aardvark", "badger", "cat", "dolphin", "lion"], selected="aardvark", width=20)
  52. message4 = text(box2, text="enter a mood?")
  53. txt_mood = textbox(box2)
  54. message5 = text(box3, text="a hero name will appear here")
  55. btn_make_name = pushbutton(box3, text='make me a hero', command=make_hero_name)
  56. slider = slider(box3, command=slider_changed)
  57. # set up event triggers here
  58. # show the gui on the screen, start listening to events.
  59. app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement