Python GUI Tkinter窗口震动/抖动
使用场景
一般用于提示未输入、未选择、未导入等未操作,未完全操作的场景提示
代码(下次有时间优化)
def shake_window():
coordinate_x = (root.winfo_x())
coordinate_y = (root.winfo_y())
print(f'当前窗口坐标:X:{coordinate_x} - Y{coordinate_y}')
swing_value = 50
for frequency in range(2):
root.geometry(f'+{coordinate_x + swing_value}+{coordinate_y}')
root.update()
time.sleep(0.02)
root.geometry(f'+{coordinate_x}+{coordinate_y}')
root.update()
time.sleep(0.02)
root.geometry(f'+{coordinate_x - swing_value}+{coordinate_y}')
root.update()
time.sleep(0.02)
root.geometry(f'+{coordinate_x}+{coordinate_y}')
root.update()
time.sleep(0.02)
coordinate_x = (root.winfo_x())
coordinate_y = (root.winfo_y())
print(f'当前窗口坐标:X:{coordinate_x} - Y{coordinate_y}')
|