Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Colin Hero Name maker with boxes n colour
- from guizero import App, Text, ButtonGroup, Combo, PushButton, TextBox, CheckBox, ListBox, Slider, Picture, Box
- #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")
- box1 = Box(app, border = 1, width = 300, height = 250)
- box1.bg ="green"
- msg1 = Text(box1, text = "select one describing word below")
- bgp_adjective = ButtonGroup (box1, options = ["Superdooper", "Cranky", "wonderfull", "colourful"], selected = "Cranky")
- msg2 = Text(box1, text = "enter a colour")
- txt_colour = TextBox(box1)
- msg3 = Text(box1, "Pick an Animal below")
- cmb_animal = Combo(box1, options=["Frog","Cat","Fish","Cow","Pig"])
- box2 = Box(app, border = 1,width = 300, height = 150)
- box2.bg ="grey"
- msg4 = Text(box2, text = "select a place(s)")
- cbx_space = CheckBox(box2, text="Space")
- cbx_mount = CheckBox(box2, text="Mountains")
- cbx_sea = CheckBox(box2, text="Ocean")
- cbx_caves = CheckBox(box2, text="Caves")
- box3 = Box(app, border = 1, width = 300, height = 270)
- box3.bg = "light blue"
- box3.font = "helevicta"
- msg5 = Text(box3, text = "Pick favourite food. ctrl click to multi select")
- lsb_food = ListBox(box3, items = ["Beans","Grapes","Marmalade","Tofu","Cheese"], multiselect = True, width=100, height = 80, scrollbar = True)
- msg6 = Text(box3, text = "Select your year of Birth")
- sld_yob = Slider(box3, start=1900, end=2010, horizontal = False)
- box4 = Box(app,border = 1, width = 300, height = 100)
- btn_name_name = PushButton(box4, text ='create my hero name', command = make_hero_name)
- lbl_output = Text(box4, text="A hero name will appear here")
- lbl_output.wrap = True
- lbl_output2 = Text(box4, 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