Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from guizero import App, Text, ButtonGroup, Combo, PushButton, TextBox, CheckBox, Slider
- app = App(title='Superhero', width=500, height=500)
- # Function definition making the hero
- def make_hero_name():
- adjective = cmb_adjective.value
- hero = btg_hero.value
- fans = txtbox_fan.value
- myhero = adjective +" "+ hero
- lbl_ouput.value = "The hero is " + myhero + " and His fan is " + fans
- # Function definition of the bgcolor
- def check():
- if dark_colour.value ==1:
- app.bg ='black'
- app.text_color='white'
- else:
- app.bg ='white'
- app.text_color='black'
- # Function definition of the slider
- def slider_changed(slider_value):
- txtbox_fan.value = slider_value
- # Widget component
- message1 = Text(app, text='Choose an adjective...', size=12, font='Arial')
- cmb_adjective = Combo(app, options=["Strong", "Fast", "Bravely", "Agility", "Hard"],selected="Strong", width=15, visible=True)
- message2 = Text(app, text='Pick an Superhero', size=12, font='Arial')
- btg_hero = ButtonGroup(app, options=["Superman", "Wolverine", "Batman", "Lighting", "Thor", "Captain America"], selected="Superman", visible=True)
- message3 = Text(app, text='Click the mode', size=12, font='Arial')
- dark_colour = CheckBox(app, text='Dark Mode', command=check)
- message4 = Text(app, text='How many fans of the hero?', size=12, font='Arial')
- slider = Slider(app, command=slider_changed)
- txtbox_fan = TextBox(app, width=3)
- btn_make_name = PushButton(app, text='Your Choice', command=make_hero_name)
- lbl_ouput = Text(app, text="A hero name will appear here")
- # Display to the screen
- app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement