Advertisement
timber101

HeroNameCreatorMk2WithBoxesEnlarged

Aug 7th, 2019
299
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Colin Hero Name maker with boxes n colour
  2. from guizero import  App, Text, ButtonGroup, Combo, PushButton, TextBox, CheckBox, ListBox, Slider, Picture, Box
  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. box1 = Box(app, border = 1, width = 300, height = 250)
  52. box1.bg ="green"
  53. msg1 = Text(box1, text = "select one describing word below")
  54. bgp_adjective = ButtonGroup (box1, options = ["Superdooper", "Cranky", "wonderfull", "colourful"], selected = "Cranky")
  55.  
  56. msg2 = Text(box1, text = "enter a colour")
  57. txt_colour = TextBox(box1)
  58.  
  59. msg3 = Text(box1, "Pick an Animal below")
  60. cmb_animal = Combo(box1, options=["Frog","Cat","Fish","Cow","Pig"])
  61.  
  62. box2 = Box(app, border = 1,width = 300, height = 150)
  63. box2.bg ="grey"
  64.  
  65. msg4 = Text(box2, text = "select a place(s)")
  66. cbx_space = CheckBox(box2, text="Space")
  67. cbx_mount = CheckBox(box2, text="Mountains")
  68. cbx_sea = CheckBox(box2, text="Ocean")
  69. cbx_caves = CheckBox(box2, text="Caves")
  70.  
  71. box3 = Box(app, border = 1, width = 300, height = 270)
  72. box3.bg = "light blue"
  73. box3.font = "helevicta"
  74. msg5 = Text(box3, text = "Pick favourite food. ctrl click to multi select")
  75. lsb_food = ListBox(box3, items = ["Beans","Grapes","Marmalade","Tofu","Cheese"], multiselect = True, width=100, height = 80, scrollbar = True)
  76.  
  77. msg6 = Text(box3, text = "Select your year of Birth")
  78. sld_yob = Slider(box3, start=1900, end=2010, horizontal = False)
  79.  
  80. box4 = Box(app,border = 1, width = "fill", height = 100)
  81. btn_name_name = PushButton(box4, text ='create my hero name', command = make_hero_name)
  82. lbl_output = Text(box4, text="A hero name will appear here")
  83. lbl_output.wrap = True
  84. lbl_output2 = Text(box4, text="Personal data will appear here")
  85.  
  86. #darkmode = CheckBox(app, text="Click for Dark Mode", command=dark_mode)
  87. # triggers here
  88.  
  89. # draw the gui onscreen
  90. app.display()
Advertisement
RAW Paste Data Copied
Advertisement