Advertisement
brendan-stanford

flag-alignment

Oct 6th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. from guizero import App, Text, Box, PushButton, TextBox
  2.  
  3. app = App()
  4.  
  5. # Divide the flag into two sections, a top layer containing the cross and a red block
  6. # and a bottom, red layer.
  7.  
  8. flags = Box(app, height = "fill", width = "fill")
  9. top = Box(flags, align="top", width="fill", height = "fill")
  10. bottom = Box(flags, align = "bottom", width="fill", height="fill")
  11.  
  12. # Create a box to contain the cross, aligned left in the top layer.
  13. cross = Box(top, align="top", height = "fill", width = "fill")
  14.  
  15. # Two boxes are needed to construct the cross.
  16. flag = Box(cross)
  17. # Set the background to white.
  18. flag.bg = "white"
  19. # Make the upper parts of the cross out of four equal sized, red blocks.
  20. first = Text(flag, bg="red", align="top", height=1, width=3)
  21. second = Text(flag, bg="red", align="left", height=1, width=3)
  22. third = Text(flag, bg="red", align="left", height=1, width=3)
  23. fourth = Text(flag, bg="red", align="left", height=1, width=3)
  24. # Create the second box directly below the first, so that the final piece
  25. # of the cross will be added to the bottom of the cross. Try running the
  26. # program without this box to see where it would automatically be placed.
  27. flag_cont = Box(cross)
  28. # Set the background to white
  29. flag_cont.bg = "white"
  30. # Complete the flag
  31. fifth = Text(flag_cont, bg="white", align="left", height=1, width=3)
  32. sixth = Text(flag_cont, bg="red", align="left", height=1, width=3)
  33. seventh = Text(flag_cont, bg="white", align="left", height=1, width=3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement