如何在 PyGTK 中创建没有标题栏图标的模式对话框?
在 Windows 上使用 PyGTK,我想创建一个没有标题栏图标的模式对话框,根据 Microsoft 的 对话框的用户界面指南。该准则指定大多数对话框不应具有标题栏图标(实现主窗口或实用程序并显示在任务栏上的对话框除外)。
缺少标题栏图标与空白图标不同,因为对话框标题完全靠左对齐,并且没有左键单击窗口上下文菜单的位置(您必须右键单击标题栏)。
我认为以下代码可以工作:
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()
此代码显示的对话框是模态的,不会显示在任务栏上。但是,它的标题栏上仍然有一个图标,这是我不想要的。我知道 Windows 能够显示没有图标的对话框,因为 Windows shell 中的大多数错误消息都没有图标。
我还在 GNU/Linux 上测试了上面的代码,它的行为方式相同...模式对话框没有任务栏提示,但它仍然有一个标题栏图标。
我现在很乐意用 hack 作为答案,但如果没有干净的方法来做到这一点,我打算为 GTK/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. 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.
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.
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个
Try this