Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[Bug] Grabbing a window by the Title bar causes the window.read to block until the window is released

未关闭
#6,278 11 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
python
领域
desktop

调研方向

未指定源文件或测试。首先运行提供的 Windows 11/Python 3.10.6 tkinter 重现程序,并比较拖动标题栏与 CTRL+left-click。完成的标准是确定在正常拖动标题栏期间 window.read(timeout=500) 是否可以继续返回,并记录或修正该行为。

由索引模型根据 Issue 内容生成。

描述

Bug Port - TK
Type of Issue: Bug

Operating System

Windows 11

PySimpleGUI Port (tkinter, Qt, Wx, Web)

Versions

Version information can be obtained by calling sg.main_get_debug_data()
Or you can print each version shown in ()

Python version

Python 3.10.6

PySimpleGUI Version

PySimpleGUI 4.60.4

GUI Version

tkinter 8.6.12


Your Experience In Months or Years (optional)

4 Years Python programming experience

5 Years Programming experience overall

Have used another Python GUI Framework? (tkinter, Qt, etc) (yes/no is fine)
No, i have not

Anything else you think would be helpful?


Troubleshooting

These items may solve your problem. Please check those you've done by changing - [ ] to - [X]

  • Searched main docs for your problem www.PySimpleGUI.org
  • Looked for Demo Programs that are similar to your goal. It is recommend you use the Demo Browser! Demos.PySimpleGUI.org
  • If not tkinter - looked for Demo Programs for specific port
  • For non tkinter - Looked at readme for your specific port if not PySimpleGUI (Qt, WX, Remi)
  • Run your program outside of your debugger (from a command line)
  • Searched through Issues (open and closed) to see if already reported Issues.PySimpleGUI.org
  • Have upgraded to the latest release of PySimpleGUI on PyPI (lastest official version)
  • Tried using the PySimpleGUI.py file on GitHub. Your problem may have already been fixed but not released
Detailed Description

I recently ran i some problems with too long runtimes in the main event loop, causing problems if windows are closed and the program is currently somewhere between detecting closed windows and interacting with the (now closed) window.
To track the time each loop takes i simply printed the runtime to the console.

While doing so, i noticed that, despite setting a timeout on window.read, the event looped halted when i was moving the window. I looked a bit into it and apparently the window.read() blocks when the title bar is clicked. as soon as i release the mouse button, it continues.

This error does not occur when moving the window with CTRL-MOUSE_LEFT.

Code To Duplicate

A short program that isolates and demonstrates the problem

import PySimpleGUI as sg

#used to measure event loop time
import datetime 


#just to have something in the layout
layout = [[sg.Text("Lorem ipsum")]]#just to have something in the layout

#create the window. size is important as we need space to grab it by the titlebar
window = sg.Window("Timing test window", layout, size=(300, 100), finalize=True)

#set the timeout value
TIMEOUT = 500

#initialize the variable
startTime = datetime.datetime.now()

while True:
    #calculate the time of one event loop, output is in milliseconds
    runTime = round((datetime.datetime.now() - startTime).total_seconds()*1000 - TIMEOUT, 1)

    #output the last event loops time
    print(runTime, "ms")

    #set the new startTime
    startTime = datetime.datetime.now()

    #run the event loop
    event, values = window.read(timeout=TIMEOUT)

    if event == sg.WIN_CLOSED:
        exit("Window closed")


Watcha Makin?

Im a Student working in a company between semesters and have been tasked with creating a program to write certain Tables to the EEPROM of the devices we are selling

主要语言
Python
星标
13.8k
派生
1.8k
PR 合并指标
30 天内没有已合并 PR

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

PySimpleGUI/PySimpleGUI 的其他 Issue

查看 PySimpleGUI/PySimpleGUI 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。