Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Colin Hero Name maker
- from guizero import App, Text, ButtonGroup, Combo, PushButton, TextBox, CheckBox, ListBox, Slider, Picture
- #from tkinter import ttk
- app = App(title = "Colins Second Hero Name Maker", width = 700, height = 800, bg="cyan")
- # function definitions here
- def make_hero_name():
- adjective = bgp_adjective.value
- colour = txt_colour.value
- animal = cmb_animal.value
- places = ""
- if cbx_space.value == 1:
- places = places + " Space - "
- if cbx_mount.value == 1:
- places = places + " Mountains - "
- if cbx_sea.value == 1:
- places = places + " Sea - "
- if cbx_caves.value == 1:
- places = places + " Caves - "
- food = lsb_food.value
- yob = sld_yob.value
- age = 2019 - yob
- hero = adjective + " " + colour + " " +animal
- lbl_output.value = "You are ..... The " + hero + ". And you like these places" + places
- lbl_output2.value = "your favourite food is .. " + str(food) + " Born in ... " + str(yob) + " Making you " + str(age) + " this year"
- def dark_mode():
- if darkmode == 1:
- app.bg="black"
- app.text_color="white"
- msg1.text_color="white"
- msg2.text_color="white"
- msg3.text_color="white"
- msg4.text_color="white"
- msg5.text_color="white"
- else:
- app.bg="cyan"
- app.text_color="black"
- msg1.text_color="black"
- msg2.text_color="black"
- msg3.text_color="black"
- msg4.text_color="black"
- msg5.text_color="black"
- app.update()
- # gui widgets here
- # pict = Picture(app, image="C:\CCLauncher\images\code-club-logo-.png")
- msg1 = Text(app, text = "select one describing word below")
- bgp_adjective = ButtonGroup (app, options = ["Superdooper", "Cranky", "wonderfull", "colourful"], selected = "Cranky")
- msg2 = Text(app, text = "enter a colour")
- txt_colour = TextBox(app)
- msg3 = Text( app, "Pick an Animal below")
- cmb_animal = Combo(app, options=["Frog","Cat","Fish","Cow","Pig"])
- msg4 = Text(app, text = "select a place(s)")
- cbx_space = CheckBox(app, text="Space")
- cbx_mount = CheckBox(app, text="Mountains")
- cbx_sea = CheckBox(app, text="Ocean")
- cbx_caves = CheckBox(app, text="Caves")
- msg5 = Text(app, text = "Pick favourite food")
- lsb_food = ListBox(app, items = ["Beans","Grapes","Marmalade","Tofu","Cheese"], multiselect = True)
- msg6 = Text(app, text = "select your year of Birth")
- sld_yob = Slider(app, start=1900, end=2010, horizontal = False)
- btn_name_name = PushButton(app, text ='create my hero name', command = make_hero_name)
- lbl_output = Text(app, text="A hero name will appear here")
- lbl_output2 = Text(app, text="Personal data will appear here")
- darkmode = CheckBox(app, text="Click for Dark Mode", command=dark_mode)
- # triggers here
- # draw the gui onscreen
- app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement