Skip to content

Instantly share code, notes, and snippets.

@LairdStreak
Forked from MikeTheWatchGuy/GridExample.py
Created December 16, 2018 20:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LairdStreak/f369629c19d493c838123a6e233d5c6a to your computer and use it in GitHub Desktop.
Save LairdStreak/f369629c19d493c838123a6e233d5c6a to your computer and use it in GitHub Desktop.
import PySimpleGUI as sg
layout = [ [sg.Text('Drawing on a 400x400 Grid')],
[sg.Graph((400,400), (0,0), (400,400), key='GRAPH')],
[sg.Button('Go')]
]
window = sg.Window('My new window').Layout(layout)
graph = window.Element('GRAPH')
while True: # Event Loop
event, values = window.Read()
if event is None:
break
for i in range(1,10):
top_left = (i*25, i*25)
bot_right = (i*25+20, i*25-20)
graph.DrawRectangle(top_left, bot_right, fill_color='red', line_color='red')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment