tkinter.simpledialog: KeyError when a dialog is opened while a window not created by tkinter holds the grab
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Bug report
simpledialog.SimpleDialog.go() and Dialog use _temp_grab_focus(), which calls grab_current() and focus_get() to restore the previous grab and focus afterwards. Both convert the Tcl window name with _nametowidget(), which raises KeyError for windows which were not created by tkinter, such as the native message box (.__tk__messagebox) or Tk's file dialogs on X11.
import tkinter
from tkinter import messagebox, simpledialog
root = tkinter.Tk()
root.after(300, lambda: simpledialog.SimpleDialog(root, text='hi', buttons=['OK']).go())
messagebox.showinfo('t', 'm', parent=root)
KeyError: '__tk__messagebox'
This happens in IDLE when a dialog is opened from an event delivered while a message box is shown (#153481). Regression from #151848 (3.16).
Linked PRs
- gh-157677
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず tkinter.simpledialog.SimpleDialog.go()、Dialog、_temp_grab_focus() を読み、その後、提供されている messagebox と simpledialog の再現コードを実行します。non-tk ウィンドウが grab を保持している状態でダイアログを開いても KeyError が発生せず、以前の grab と focus が復元されれば修正は完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- desktop
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 25/100