Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run after delta time #164

Closed
jason990420 opened this issue Apr 13, 2022 · 0 comments
Closed

Run after delta time #164

jason990420 opened this issue Apr 13, 2022 · 0 comments
Labels
tkinter tkinter required Window sg.Window

Comments

@jason990420
Copy link
Owner

import PySimpleGUI as sg

width, height = size = 480, 480

layout = [
    [sg.Graph(size, (0, 0), size, background_color='blue', key='GRAPH')],
    [sg.Slider(range=(1, 20), default_value=4, orientation='h', expand_x=True, enable_events=True, key='SLIDER')],
]
window = sg.Window('Title', layout, finalize=True)
graph:sg.Graph = window['GRAPH']
d, step, figure = 0, 4, None

def rotate():
    global d, figure, step
    if figure:
        graph.delete_figure(figure)
    points = [(d, height-1), (width-1, height-1-d), (width-1-d, 0), (0, d)]
    figure = graph.draw_polygon(points, fill_color='green')
    d = (d+step) % width
    window.TKroot.after(20, rotate)

rotate()

while True:

    event, values = window.read()

    if event == sg.WIN_CLOSED or event == 'Exit':
        break
    elif event == 'SLIDER':
        step = values[event]

window.close()

python_tXdQeFIaAE

@jason990420 jason990420 added Window sg.Window tkinter tkinter required labels Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tkinter tkinter required Window sg.Window
Projects
None yet
Development

No branches or pull requests

1 participant