Advertisement
davidhellam

Python: Five Points

Aug 11th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.63 KB | None | 0 0
  1. from guizero import Box, App, PushButton, TextBox, Text, info
  2.  
  3. import random
  4.  
  5. def act0():
  6.     info("Clicked Button","Button Clicked")
  7.  
  8. def act1():
  9.     tx_head.value = "What is a GUI?"
  10.     tx_body1.value = "A Graphical User Interface (GUI) usually"
  11.     tx_body2.value = "includes four main features:"
  12.     tx_body3.value = ""
  13.     tx_body4.value = "* Windows"
  14.     tx_body5.value = "* Icons"
  15.     tx_body6.value = "* Menus and"
  16.     tx_body7.value = "* Pointers"
  17.  
  18. def act2():
  19.     tx_head.value = "Advantages"
  20.     tx_body1.value = "One advantage of a GUI is that users"
  21.     tx_body2.value = "don\'t need to learn a language and"
  22.     tx_body3.value = "its syntax."
  23.     tx_body4.value = ""
  24.     tx_body5.value = "For a user who cannot type quickly,"
  25.     tx_body6.value = "it is easier to point, click and drag"
  26.     tx_body7.value = "to complete common functions."
  27.  
  28. def act3():
  29.     tx_head.value = "Disadvantages"
  30.     tx_body1.value = "A GUI needs far more resources"
  31.     tx_body2.value = "compared to a Command Line"
  32.     tx_body3.value = "Interface."
  33.     tx_body4.value = ""
  34.     tx_body5.value = "Older, slower systems may not"
  35.     tx_body6.value = "be able to run a modern GUI"
  36.     tx_body7.value = "efficiently."
  37.  
  38. def act4():
  39.     tx_head.value = "GUI Controls"
  40.     tx_body1.value = "Many programming languages have"
  41.     tx_body2.value = "libraries of commonly used controls. "
  42.     tx_body3.value = ""
  43.     tx_body4.value = "A widely tested and flexible set"
  44.     tx_body5.value = "of tools saves huge amounts of time"
  45.     tx_body6.value = "and effort for busy developers."
  46.     tx_body7.value = ""
  47.  
  48. def act5():
  49.     tx_head.value = "Common Widgets"
  50.     tx_body1.value = "Fequently used GUI controls include:"
  51.     tx_body2.value = ""
  52.     tx_body3.value = "* Buttons and Toggles"
  53.     tx_body4.value = "* Text boxes and Labels"
  54.     tx_body5.value = "* Check boxes and Radio buttons"
  55.     tx_body6.value = "* Sliders"
  56.     tx_body7.value = "* Combo boxes"
  57.    
  58. app = App(width=640, height=480, layout="grid", title="Five Points!")
  59.  
  60. title = Box(app, width=640, height=40, grid=[0,0,2,1])
  61. canvas = Box(app, width=560, height=400, grid=[0,1])
  62. buttons = Box(app, width=80, height=400, grid=[1,1])
  63. footer = Box(app, width=640, height=40, grid=[0,2,2,1])
  64.  
  65. title.bg=(0,0,0)
  66. canvas.bg=(204,204,204)
  67. buttons.bg=(153,0,0)
  68. footer.bg=(0,0,0)
  69. buttons.text_color=(204,204,204)
  70.  
  71. bt_nav1 = PushButton(buttons,text="1", width="fill", height="fill", command=act1)
  72. bt_nav2 = PushButton(buttons,text="2", width="fill", height="fill", command=act2)
  73. bt_nav3 = PushButton(buttons,text="3", width="fill", height="fill", command=act3)
  74. bt_nav4 = PushButton(buttons,text="4", width="fill", height="fill", command=act4)
  75. bt_nav5 = PushButton(buttons,text="5", width="fill", height="fill", command=act5)
  76. #bt_nav6 = PushButton(buttons,text="6", command=act0)
  77. #bt_nav7 = PushButton(buttons,text="7", command=act0)
  78. #bt_nav8 = PushButton(buttons,text="8", command=act0)
  79. #bt_nav9 = PushButton(buttons,text="9", command=act0)
  80.  
  81. tx_head = Text(canvas, color=(0,0,102), size=36, text="Five Points")
  82. tx_body1 = Text(canvas, color=(0,0,51),size=20, align="top", text="")
  83. tx_body2 = Text(canvas, color=(0,0,51),size=20, align="top", text="")
  84. tx_body3 = Text(canvas, color=(0,0,51),size=20, align="top", text="Click on any of the")
  85. tx_body4 = Text(canvas, color=(0,0,51),size=20, align="top", text="five numbered buttons")
  86. tx_body5 = Text(canvas, color=(0,0,51),size=20, align="top", text="on the right to learn about")
  87. tx_body6 = Text(canvas, color=(0,0,51),size=20, align="top", text="GUI controls")
  88. tx_body7 = Text(canvas, color=(0,0,51),size=20, align="top", text="")
  89.  
  90. app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement