简体   繁体   English

如何在PyGTK中创建一个没有标题栏图标的模态对话框?

[英]How do I create a modal dialog with no title bar icon in PyGTK?

Using PyGTK on Windows, I want to create a modal dialog that does not have a title bar icon, per Microsoft's user interface guidelines for dialogs . 在Windows上使用PyGTK,我想根据Microsoft的对话框用户界面指南创建一个没有标题栏图标的模式对话框 The guidelines specify that most dialog boxes should not have title bar icons (except dialogs that implement a main window or utility, and appear on the taskbar). 指南指定大多数对话框不应具有标题栏图标(实现主窗口或实用程序的对话框除外,并显示在任务栏上)。

A lack of title bar icon is distinct from a blank icon because the dialog title is justified fully to the left and there is no place to left-click for the Window's context menu (you have to right-click the title bar). 缺少标题栏图标与空白图标不同,因为对话框标题完全向左对齐,并且没有地方左键单击窗口的上下文菜单(您必须右键单击标题栏)。

I thought the following code would work: 我认为以下代码可行:

import gtk

win = gtk.Window()
win.set_icon(None)
win.connect("delete-event",gtk.main_quit)

dia = gtk.Dialog(parent=win, flags=gtk.DIALOG_MODAL)
dia.set_skip_taskbar_hint(True)
dia.set_icon(None)
win.show()
dia.show()

gtk.main()

The dialog this code displays is modal and doesn't show up on the taskbar. 此代码显示的对话框是模态的,不会显示在任务栏上。 However, it still has an icon on its title bar, which I don't want. 但是,它的标题栏上仍然有一个图标,我不想要它。 I know Windows is capable of showing a dialog without an icon because most of the error messages in the Windows shell don't have them. 我知道Windows能够显示没有图标的对话框,因为Windows shell中的大多数错误消息都没有。

I also tested the above code on GNU/Linux and it behaves the same way... modal dialog with no taskbar hint, but it still has a title bar icon. 我还在GNU / Linux上测试了上面的代码,它的行为方式相同...没有任务栏提示的模态对话框,但它仍然有一个标题栏图标。

I would be happy with a hack as an answer for now, but I intend to file a bug for GTK/PyGTK if there is no clean way to do this. 我现在很乐意将黑客作为答案,但如果没有干净的方法,我打算为GTK / PyGTK提交一个错误。

Try this 试试这个

window = gtk.Window()
dialog = gtk.Dialog()

dialog.set_modal(True)
dialog.set_transient_for(window)
dialog.set_decorated(False)

window.show()
dialog.show()

gtk.main()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM