【发布时间】:2022-10-05 10:17:28
【问题描述】:
我不能用通常的 window.read(timeout=) 来做到这一点,因为我在屏幕上有一个秒更新的时钟。而且我只需要在 24 小时内更新这两个元素一次。就像它可以在 Tkinter 中完成一样。
sunrise.after(24*60*60, sunrise)
sunset.after(24*60*60, sunrise)
【问题讨论】:
标签: pysimplegui
我不能用通常的 window.read(timeout=) 来做到这一点,因为我在屏幕上有一个秒更新的时钟。而且我只需要在 24 小时内更新这两个元素一次。就像它可以在 Tkinter 中完成一样。
sunrise.after(24*60*60, sunrise)
sunset.after(24*60*60, sunrise)
【问题讨论】:
标签: pysimplegui
你可以打电话给window.TKroot.after 做同样的事情。
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()
【讨论】: