开发者

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. 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.


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()
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜