Advertisement
Mori007

myassigment

Feb 3rd, 2021
750
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.63 KB | None | 0 0
  1. from guizero import App, Text, ButtonGroup, Combo, PushButton, TextBox, CheckBox, Slider
  2.  
  3. app = App(title='Superhero', width=500, height=500)
  4.  
  5. # Function definition making the hero
  6. def make_hero_name():
  7.     adjective = cmb_adjective.value
  8.     hero = btg_hero.value
  9.     fans = txtbox_fan.value
  10.     myhero = adjective +" "+ hero
  11.     lbl_ouput.value = "The hero is " + myhero + " and His fan is " + fans
  12.  
  13. # Function definition of the bgcolor    
  14. def check():
  15.     if dark_colour.value ==1:
  16.         app.bg ='black'
  17.         app.text_color='white'
  18.     else:
  19.         app.bg ='white'
  20.         app.text_color='black'
  21.  
  22. # Function definition of the slider
  23. def slider_changed(slider_value):
  24.     txtbox_fan.value = slider_value
  25.  
  26.  
  27. # Widget component
  28. message1 = Text(app, text='Choose an adjective...', size=12, font='Arial')
  29. cmb_adjective = Combo(app, options=["Strong", "Fast", "Bravely", "Agility", "Hard"],selected="Strong", width=15, visible=True)
  30.  
  31. message2 = Text(app, text='Pick an Superhero', size=12, font='Arial')
  32. btg_hero = ButtonGroup(app, options=["Superman", "Wolverine", "Batman", "Lighting", "Thor", "Captain America"], selected="Superman", visible=True)
  33.  
  34. message3 = Text(app, text='Click the mode', size=12, font='Arial')
  35. dark_colour = CheckBox(app, text='Dark Mode', command=check)
  36.  
  37. message4 = Text(app, text='How many fans of the hero?', size=12, font='Arial')
  38. slider = Slider(app, command=slider_changed)
  39. txtbox_fan = TextBox(app, width=3)
  40.  
  41. btn_make_name = PushButton(app, text='Your Choice', command=make_hero_name)
  42. lbl_ouput = Text(app, text="A hero name will appear here")
  43.  
  44. # Display to the screen
  45. app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement