Advertisement
Guest User

flag.py

a guest
Dec 12th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.39 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. top = Box(app, align="top", width="fill")
  9. bottom = Box(app, width="fill", height="fill")
  10.  
  11. # Create a box to contain the cross, aligned left in the top layer.
  12. cross = Box(top, align="left")
  13.  
  14. # Two boxes are needed to construct the cross.
  15. flag = Box(cross)
  16. # Set the background to white.
  17. flag.bg = "white"
  18. # Make the upper parts of the cross out of four equal sized, red blocks.
  19. first = Text(flag, bg="red", align="top", height=1, width=3)
  20. second = Text(flag, bg="green", align="left", height=1, width=3)
  21. third = Text(flag, bg="blue", align="left", height=1, width=3)
  22. fourth = Text(flag, bg="yellow", align="left", height=1, width=3)
  23. # Create the second box directly below the first, so that the final piece
  24. # of the cross will be added to the bottom of the cross. Try running the
  25. # program without this box to see where it would automatically be placed.
  26. flag_cont = Box(cross)
  27. # Set the background to white
  28. flag_cont.bg = "black"
  29. # Complete the flag
  30. fifth = Text(flag_cont, height=1, width=3, align="bottom", bg="purple")
  31.  
  32. # Fill in the rest of the flag red
  33. fill = Text(top, align="left", height="fill", width="fill", bg="orange")
  34. fill_cont = Text(bottom, height="fill", width="fill", bg="red")
  35.  
  36. app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement