2018-09-27 20:24:09 +00:00
|
|
|
#!/usr/bin/env python
|
2019-10-23 20:10:03 +00:00
|
|
|
import PySimpleGUI as sg
|
2018-08-26 19:29:12 +00:00
|
|
|
|
|
|
|
layout = [
|
2019-10-23 20:10:03 +00:00
|
|
|
[sg.Canvas(size=(150, 150), background_color='red', key='canvas')],
|
|
|
|
[sg.Text('Change circle color to:'), sg.Button('Red'), sg.Button('Blue')]
|
|
|
|
]
|
2018-08-26 19:29:12 +00:00
|
|
|
|
2019-10-23 20:10:03 +00:00
|
|
|
window = sg.Window('Canvas test', layout, finalize=True)
|
2018-08-26 19:29:12 +00:00
|
|
|
|
2019-10-23 20:10:03 +00:00
|
|
|
cir = window['canvas'].TKCanvas.create_oval(50, 50, 100, 100)
|
2018-08-26 19:29:12 +00:00
|
|
|
|
|
|
|
while True:
|
2019-10-23 20:10:03 +00:00
|
|
|
event, values = window.read()
|
2020-05-07 10:22:59 +00:00
|
|
|
if event == sg.WIN_CLOSED:
|
2018-09-04 23:43:22 +00:00
|
|
|
break
|
2019-06-26 15:09:42 +00:00
|
|
|
if event in ('Blue', 'Red'):
|
2019-10-23 20:10:03 +00:00
|
|
|
window['canvas'].TKCanvas.itemconfig(cir, fill=event)
|