JAWarr

Align boxes and widgets

Aug 19th, 2020
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.15 KB | None | 0 0
  1. # If you put one or more widget into a Box, does this change the layout? J.Warr 19/08/202
  2.  
  3. from guizero import *
  4.  
  5. # this time we have not set the layout to auto as it is default
  6. app = App(title="align", width="400", height="200", bg="black")
  7.  
  8. top = Box(app, align="top", width="fill")
  9. top.bg="cyan"
  10. bottom = Box(app, align="bottom", width="fill")
  11. bottom.bg="yellow"
  12. left = Box(app, align="left", width="fill")
  13. left.bg="pink"
  14. right = Box(app, align="right", width="fill")
  15. right.bg="lightgreen"
  16.  
  17.  
  18. # create a series of widgets each with a different alignment
  19. top_text = Text(top, text="at the top", align="bottom")
  20. top_button = PushButton(top, text="Top", align="top")
  21. top_button.bg="yellow"
  22. bottom_text = Text(bottom, text="at the bottom", align="top")
  23. bottom_button = PushButton(bottom, text="Bottom", align="bottom")
  24. bottom_button.bg="cyan"
  25. left_button = PushButton(left, text="Left", align="left")
  26. left_text = Text(left, text="to the left", align="left")
  27. left_button.bg="lightgreen"
  28. right_button = PushButton(right, text="Right", align="right")
  29. right_text = Text(right, text="to the right", align="right")
  30. right_button.bg="pink"
  31.  
  32. app.display()
  33.  
Advertisement
Add Comment
Please, Sign In to add comment