Advertisement
timber101

HeroNameCreatorMk2

Aug 6th, 2019
229
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.82 KB | None
  1. # Colin Hero Name maker
  2. from guizero import App, Text, ButtonGroup, Combo, PushButton, TextBox, CheckBox, ListBox, Slider, Picture
  3. #from tkinter import ttk
  4. app = App(title = "Colins Second Hero Name Maker", width = 700, height = 800, bg="cyan")
  5.  
  6.  
  7. # function definitions here
  8. def make_hero_name():
  9.     adjective = bgp_adjective.value
  10.     colour = txt_colour.value
  11.     animal = cmb_animal.value
  12.     places = ""
  13.     if cbx_space.value == 1:
  14.         places = places + " Space - "
  15.     if cbx_mount.value == 1:
  16.         places = places + " Mountains - "
  17.     if cbx_sea.value == 1:
  18.         places = places + " Sea - "
  19.     if cbx_caves.value == 1:
  20.         places = places + " Caves - "
  21.    
  22.     food = lsb_food.value
  23.     yob = sld_yob.value
  24.     age = 2019 - yob
  25.        
  26.     hero = adjective + " " + colour + " " +animal
  27.     lbl_output.value = "You are .....  The " + hero + ".  And you like these places" + places
  28.     lbl_output2.value = "your favourite food is .. " + str(food) + " Born in ... " + str(yob) + "  Making you " + str(age) + " this year"
  29.  
  30. def dark_mode():
  31.     if darkmode == 1:
  32.         app.bg="black"
  33.         app.text_color="white"
  34.         msg1.text_color="white"
  35.         msg2.text_color="white"
  36.         msg3.text_color="white"
  37.         msg4.text_color="white"
  38.         msg5.text_color="white"
  39.     else:
  40.         app.bg="cyan"
  41.         app.text_color="black"
  42.         msg1.text_color="black"
  43.         msg2.text_color="black"
  44.         msg3.text_color="black"
  45.         msg4.text_color="black"
  46.         msg5.text_color="black"
  47. app.update()
  48.  
  49. # gui widgets here
  50. # pict = Picture(app, image="C:\CCLauncher\images\code-club-logo-.png")
  51.  
  52. msg1 = Text(app, text = "select one describing word below")
  53. bgp_adjective = ButtonGroup (app, options = ["Superdooper", "Cranky", "wonderfull", "colourful"], selected = "Cranky")
  54.  
  55. msg2 = Text(app, text = "enter a colour")
  56. txt_colour = TextBox(app)
  57.  
  58. msg3 = Text( app, "Pick an Animal below")
  59. cmb_animal = Combo(app, options=["Frog","Cat","Fish","Cow","Pig"])
  60.  
  61. msg4 = Text(app, text = "select a place(s)")
  62. cbx_space = CheckBox(app, text="Space")
  63. cbx_mount = CheckBox(app, text="Mountains")
  64. cbx_sea = CheckBox(app, text="Ocean")
  65. cbx_caves = CheckBox(app, text="Caves")
  66.  
  67. msg5 = Text(app, text = "Pick favourite food")
  68. lsb_food = ListBox(app, items = ["Beans","Grapes","Marmalade","Tofu","Cheese"], multiselect = True)
  69.  
  70. msg6 = Text(app, text = "select your year of Birth")
  71. sld_yob = Slider(app, start=1900, end=2010, horizontal = False)
  72.  
  73. btn_name_name = PushButton(app, text ='create my hero name', command = make_hero_name)
  74. lbl_output = Text(app, text="A hero name will appear here")
  75. lbl_output2 = Text(app, text="Personal data will appear here")
  76.  
  77. darkmode = CheckBox(app, text="Click for Dark Mode", command=dark_mode)  
  78. # triggers here
  79.  
  80. # draw the gui onscreen
  81. app.display()
Advertisement
RAW Paste Data Copied
Advertisement