Demo updates with new theme calls

This commit is contained in:
PySimpleGUI 2019-12-24 18:52:47 -05:00
parent 52700b0780
commit 5484b047c0
96 changed files with 3530 additions and 228 deletions

View file

@ -8,24 +8,25 @@ import PySimpleGUI as sg
see in things like editors
"""
# image_file = r'Color-names.png'
image_file = None # image is optional
# image_file = None # image is optional
image_file = r'C:\Python\PycharmProjects\GooeyGUI\logo200.png' # image is optional
layout = [[sg.Graph(
canvas_size=(400, 400),
graph_bottom_left=(0, 400),
graph_top_right=(400, 0),
key="-GRAPH-",
change_submits=True, # mouse click events
drag_submits=True),],
[sg.Text(key='info', size=(60, 1))]]
canvas_size=(400, 400),
graph_bottom_left=(0, 0),
graph_top_right=(400, 400),
key="-GRAPH-",
change_submits=True, # mouse click events
background_color='lightblue',
drag_submits=True), ],
[sg.Text(key='info', size=(60, 1))]]
window = sg.Window("draw rect on image", layout, finalize=True)
# get the graph element for ease of use later
graph = window["-GRAPH-"] # type: sg.Graph
graph = window["-GRAPH-"] # type: sg.Graph
graph.draw_image(image_file, location=(0,0)) if image_file else None
graph.draw_image(image_file, location=(0,400)) if image_file else None
dragging = False
start_point = end_point = prior_rect = None
@ -34,8 +35,8 @@ while True:
if event is None:
break # exit
if event == "-GRAPH-": # if there's a "Graph" event, then it's a mouse
if event == "-GRAPH-": # if there's a "Graph" event, then it's a mouse
x, y = values["-GRAPH-"]
if not dragging:
start_point = (x, y)
@ -46,12 +47,12 @@ while True:
graph.delete_figure(prior_rect)
if None not in (start_point, end_point):
prior_rect = graph.draw_rectangle(start_point, end_point, line_color='red')
elif event.endswith('+UP'): # The drawing has ended because mouse up
elif event.endswith('+UP'): # The drawing has ended because mouse up
info = window["info"]
info.update(value=f"grabbed rectangle from {start_point} to {end_point}")
start_point, end_point = None, None # enable grabbing a new rect
start_point, end_point = None, None # enable grabbing a new rect
dragging = False
else:
print("unhandled event", event, values)