Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Import the GUI widgets that you'll be using, and create the 'app' for your program.
- from guizero import App, Text, PushButton, TextBox, info,ButtonGroup,Combo,Picture,CheckBox,Box
- app = App(title="Hero Name Generator", width="640", height="620", bg="white")
- # Function definitions for your events go here.
- def btn_go_clicked():
- name = f"{bgAdjective1.value} {txt_colour.value} {bgAdjective2.value} {cbo_animal.value}"
- lbl_hero.value = name
- # Your GUI widgets go here
- boxImage = Box(app, align = 'top', width = 'fill')
- img1 = Picture(boxImage, image = "sh_small.jpg", align = "left")
- box5 = Box(app, width = 'fill',height = 10, align = 'top')
- box5.bg='black'
- box1 = Box(app, width = 'fill',height = 150, align='top' )
- boxAdjectives1 = Box(box1, align='left', width = 320, height = 150)
- boxAdjectives1.bg = 'honeydew'
- lblAdjective1 = Text(boxAdjectives1, text="ADJECTIVE 1",color = 'red')
- bgAdjective1 = ButtonGroup(boxAdjectives1, options=["Amazingly", "Smilingly", "Bouncingly","Dastardly"], )
- box5 = Box(app, width = 'fill',height = 10, align = 'top')
- boxAdjectives2 = Box(box1, align='left', width = 320, height = 150)
- boxAdjectives2.bg = 'cyan'
- lblAdjective2 = Text(boxAdjectives2, text="ADJECTIVE 1",color = 'red')
- bgAdjective2 = ButtonGroup(boxAdjectives2, options=["amazing", "happy", "awesome","grumpy","smiley"])
- box5 = Box(app, width = 'fill',height = 10, align = 'top')
- box2 = Box(app, width = 'fill',height = 50, align='top' )
- box2.bg = 'thistle1'
- lbl_colour = Text(box2,text="COLOUR",align="left",color='red',width=20)
- txt_colour = TextBox(box2, width=20, align="left")
- txt_colour.text_size = 14
- lbl_colour1 = Text(box2,text="type in your colour",align="left")
- box5 = Box(app, width = 'fill',height = 10, align = 'top')
- box3 = Box(app, width = 'fill',height = 50, align='top' )
- box3.bg = 'paleturquoise1'
- lbl_animal = Text(box3,text="ANIMAL",align="left",width = 20)
- cbo_animal = Combo(box3, options=["Chicken", "Cow", "Sheep", "Lion","Monkey"],align="left",width = 40)
- box5 = Box(app, width = 'fill',height = 10, align = 'top')
- box4 = Box(app, width = 'fill',height = 80, align='top' )
- box4.bg = 'white'
- btn_go = PushButton(box4, command=btn_go_clicked, width="30",text="Go")
- lbl_hero = Text(app,text=" ", color="red",size=24, width = 'fill' )
- # Show the GUI on the screen
- app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement