Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. # BS_TicTacToe_01.py
  2. # Source: Martin O’Hanlon: 3.5 Grid layouts
  3. # - https://www.futurelearn.com/courses/programming-with-guis
  4.  
  5. from guizero import App, Box, PushButton, Text
  6.  
  7. app = App(title="BS_TicTacToe_01.py", width=900, height=500)
  8.  
  9. # Event handlers -------------------------------------------------------------------------
  10.  
  11. # Create widgets -------------------------------------------------------------------------
  12.  
  13. box = Box(app, layout="grid", width=400, height=400)
  14.  
  15. button1 = PushButton(box, text="X", grid=[0,0]) # Row 1: top
  16. button2 = PushButton(box, text=" O", grid=[1,0])
  17. button3 = PushButton(box, text=" ", grid=[2,0])
  18.  
  19. button4 = PushButton(box, text=" ", grid=[0,1]) # Row 2: middle
  20. button5 = PushButton(box, text=" ", grid=[1,1])
  21. button6 = PushButton(box, text=" ", grid=[2,1])
  22.  
  23. button7 = PushButton(box, text=" ", grid=[0,2]) # Row 3: bottom
  24. button8 = PushButton(box, text=" ", grid=[1,2])
  25. button9 = PushButton(box, text=" ", grid=[2,2])
  26.  
  27. # Set properties -------------------------------------------------------------------------
  28.  
  29. box.text_size = 30
  30.  
  31. # Run ------------------------------------------------------------------------------------
  32.  
  33. app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement