Advertisement
timber101

HeroNameCreator

Aug 6th, 2019
219
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.56 KB | None
  1. # Colin Hero Name maker
  2. from guizero import App, Text, ButtonGroup, Combo, PushButton, TextBox, CheckBox
  3. #from tkinter import ttk
  4. app = App(title = "Colins Hero Name Maker")
  5.  
  6. # function definitions here
  7. def make_hero_name():
  8.     adjective = bgp_adjective.value
  9.     colour = txt_colour.value
  10.     animal = cmb_animal.value
  11.     places = ""
  12.     if cbx_space.value == 1:
  13.         places = places + " Space - "
  14.     if cbx_mount.value == 1:
  15.         places = places + " Mountains - "
  16.     if cbx_sea.value == 1:
  17.         places = places + " Sea - "
  18.     if cbx_caves.value == 1:
  19.         places = places + " Caves - "
  20.        
  21.     hero = adjective + " " + colour + " " +animal
  22.     lbl_output.value = "You are .....  The " + hero + ".  And you like these places" + places
  23.    
  24.  
  25. # gui widgets here
  26. msg1 = Text(app, text = "select one describing word below")
  27. bgp_adjective = ButtonGroup (app, options = ["Superdooper", "Cranky", "wonderfull", "colourful"], selected = "Cranky")
  28.  
  29. msg2 = Text(app, text = "enter a colour")
  30. txt_colour = TextBox(app)
  31.  
  32. msg3 = Text( app, "Pick an Animal below")
  33. cmb_animal = Combo(app, options=["Frog","Cat","Fish","Cow","Pig"])
  34.  
  35. msg4 = Text(app, text = "select a place(s)")
  36. cbx_space = CheckBox(app, text="Space")
  37. cbx_mount = CheckBox(app, text="Mountains")
  38. cbx_sea = CheckBox(app, text="Ocean")
  39. cbx_caves = CheckBox(app, text="Caves")
  40.  
  41. btn_name_name = PushButton(app, text ='create my hero name', command = make_hero_name)
  42. lbl_output = Text(app, text="A hero name will appear here")
  43.  
  44. # triggers here
  45.  
  46. # draw the gui onscreen
  47. app.display()
Advertisement
RAW Paste Data Copied
Advertisement