如何使用 PyGTK3 在另一个模式对话框之上正确创建一个模式对话框,以便第二个对话框位于顶部?
我有一个 Windows-10 PyGTK3 应用程序(python 3.8 + GTK3.24),结构如下:它有一个非模式主窗口,它打开一个模式对话框(A),进而打开另一个模式对话框(B)。 我使用空地来设计所有三个窗口的布局和属性。
在应用程序启动时,我保留 GtkWindow A 的实例,如下所示:
def __init__(self):
self._main_window = builder.get_object("main_window")
...
def on_clicked_open_dialog_a(self, _widget):
dlg_a = DialogA(self._main_window)
dlg_a.run()
在对话框 A 中,我执行类似的操作:
def __init__(self, parent):
self._dialog = builder.get_object("dialog_a")
self._dialog.set_transient_for(parent)
...
def on_clicked_open_dialog_b(self, _widget):
dlg_b = DialogB(self._dialog)
dlg_b.run()
在对话框 B 中执行相同的操作:
def __init__(self, parent):
self._dialog = builder.get_object("dialog_b")
self._dialog.set_transient_for(parent)
我遇到的问题是,一旦我从对话框 A 打开对话框 B,对话框 A 就会停止运行就像一个正确的模态对话框:如果我单击它,它的窗口将变为活动状态,即使对话框 B 仍显示在其顶部(并且可以移动和最大化/最小化,但不能关闭), 像这样
,如果我用另一个窗口覆盖该应用程序并使用 Alt-Tab 来打开该应用程序返回后,对话框 A 位于顶部,我只能通过单击对话框 A 来访问对话框 B 如本图所示
我做错了什么,该如何解决?
I have a Windows-10 PyGTK3 app (python 3.8 + GTK3.24) structured as follows: it has a non-modal main window, which opens a modal dialog (A), which in turn opens another modal dialog (B).
I use glade for the layout and properties of all three windows.
On the app startup I retain the instance of the GtkWindow A as follows:
def __init__(self):
self._main_window = builder.get_object("main_window")
...
def on_clicked_open_dialog_a(self, _widget):
dlg_a = DialogA(self._main_window)
dlg_a.run()
In the dialog A, I do a similar thing:
def __init__(self, parent):
self._dialog = builder.get_object("dialog_a")
self._dialog.set_transient_for(parent)
...
def on_clicked_open_dialog_b(self, _widget):
dlg_b = DialogB(self._dialog)
dlg_b.run()
And the same thing in the dialog B:
def __init__(self, parent):
self._dialog = builder.get_object("dialog_b")
self._dialog.set_transient_for(parent)
This is what it is supposed to look like
The problem that I am running into is that once I open the Dialog B from the Dialog A, the Dialog A ceases to behave like a proper modal dialog: if I click it, its window becomes active, even though the Dialog B is still displayed on top of it (and it can be moved and maximized/minimized, but not closed),
like so
and if I cover the app with another window and use Alt-Tab to bring the app back, the Dialog A comes on top, and I can only access the Dialog B by clicking on the Dialog A
as appears on this diagram
What am I doing wrong, and how do I fix it, please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论