Advertisement
JDpaste

Python GUI guizero: Box layout header/sidebar

Sep 28th, 2019
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.20 KB | None | 0 0
  1. from guizero import App, Box, PushButton, Text, TextBox, ButtonGroup, Slider
  2. app = App( height=600, width=800)
  3. """
  4. This GUI is split into 3 Box(es).
  5. - Header, Sidebar, and Content
  6. """
  7. #--------------
  8. boxHeader = Box(app, align="top", width="fill", height=150, border=1)
  9. boxHeader.bg="yellow"
  10. boxHeader.text_color="blue"
  11. # - add widgets to Box
  12. txtHeader_h2 = Text(boxHeader, text="Header", width="fill")
  13. txtHeader_h2.text_size = 24
  14. txtHeader_h2.bg="#000000"
  15. txtHeader_h2.text_color="white"
  16.  
  17. """
  18. button01_2 = PushButton(boxHeader, text="Red")
  19. button01_2.bg="red"
  20. button01_2.text_color="white"
  21. """
  22. txtHeader_slider = Text(boxHeader, text="Change contrast")
  23.  
  24. slider = Slider(boxHeader, width=400, height=20)
  25. slider.value = 50
  26. slider.bg = "#ff4a6e"
  27. slider.text_color = "#000000"
  28. slider.text_size = 14
  29. #---------------
  30. boxSidebar = Box(app, align="left", width=160, height="fill", border=1)
  31. boxSidebar.bg="#DDDDDD"
  32. boxSidebar.text_color="#000000"
  33.  
  34. # - add widgets to Box
  35. txtSidebar_h2 = Text(boxSidebar, text="Sidebar", width="fill")
  36. txtSidebar_h2.text_size = 18
  37. txtSidebar_h2.bg="cyan"
  38. txtSidebar_h2.text_color="white"
  39.  
  40. txtSidebar_sub1 = Text(boxSidebar, text="News type ..")
  41. txtSidebar_sub1.text_size = 14
  42.  
  43. choice02_1 = ButtonGroup(boxSidebar, options=["World", "National", "Local"], selected="World")
  44. #---------------
  45. boxContent = Box(app, align="right", width="fill", height="fill", border=1)
  46. boxContent.bg="white"
  47. boxContent.text_color="#000000"
  48. # - add widgets to Box
  49. txtContent_h2 = Text(boxContent, text="Main Content", width="fill")
  50. txtContent_h2.text_size = 20
  51. txtContent_h2.bg="#000000"
  52. txtContent_h2.text_color="white"
  53.  
  54. txtContent_h3 = Text(boxContent, text="Please enter your news ..", width="fill")
  55. txtContent_h3.text_size = 14
  56. txtContent_h3.bg="white"
  57. txtContent_h3.text_color="blue"
  58.  
  59. txtContent_in = TextBox(boxContent, text="", multiline=True, height=8, width=90)
  60. txtContent_in.text_size = 14
  61. txtContent_in.bg="#CCCC00"
  62. txtContent_in.text_color="white"
  63.  
  64. buttonSubmit = PushButton(boxContent, text="Submit story ..")
  65. buttonSubmit.bg="red"
  66. buttonSubmit.text_color="white"
  67. #   -------
  68. txtContent_in.focus() # put text cursor in TextBox, ready for user input ..
  69. app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement