Advertisement
jolgri

Assignment 9 Flags in boxes

Jan 5th, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1.  
  2. from guizero import App, Text, Box, PushButton, TextBox
  3.  
  4. app = App()
  5.  
  6. # Divide the flag into two sections, a top layer containing the cross and a red block
  7. # and a bottom, red layer.
  8.  
  9. top = Box(app, align="top", width="fill")
  10. bottom = Box(app, width="fill", height="fill")
  11.  
  12. # Create a box to contain the cross, aligned left in the top layer.
  13. cross = Box(top, align="left")
  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.  
  28. flag_cont = Box(cross)
  29. # Set the background to white
  30. flag_cont.bg = "white"
  31. # Complete the flag
  32. fifth = Text(flag_cont, height=1, width=3, align="bottom", bg="red")
  33.  
  34. # Fill in the rest of the flag red
  35. fill = Text(top, align="left", height="fill", width="fill", bg="red")
  36. fill_cont = Text(bottom, height="fill", width="fill", bg="red")
  37.  
  38. flag2 = Box(cross)
  39. l1 = Text(flag2, bg="red", align="top", height="fill", width=10)
  40. l1 = Text(flag2, bg="yellow", align="top", height="fill", width=10)
  41. l2 = Text(flag2, bg="green", align="top", height="fill", width=10)
  42. l3 = Text(flag2, bg="red", align="top", height="fill", width=10)
  43.  
  44. app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement