gtk dialog

来源:互联网 发布:无损音乐下载 知乎 编辑:程序博客网 时间:2024/06/16 09:37

gtk-filechooser-dialog-example.py     gtk-filechooser-button-example.py  

shen@ShenUbuntu13.04 (~/pygtknotebook/examples/more-pygtk)


为什么  GtkFileChooserDialog  can not be inspect but in GtkFileChooserButton , it Can


因为GtkFileChooserButton的GtkFileChooserDialog 被设置为 gtk_window_set_modal()  gtk_window_set_transient_for 每次用gtkparasite inspect它们的时候需要 set_modal(False)


import gtk.gdkroot = gtk.gdk.get_default_root_window()for id in root.property_get('_NET_CLIENT_LIST')[2]:    w = gtk.gdk.window_foreign_new(id)    if w:        print(w.property_get('WM_NAME')[2])
        if w.property_get('WM_NAME')[2] == 'tile of what window you want':
            w.set_modal(False)   # 为了让Gtkparasite 获取 能 inspect它

Description

Dialog boxes are a convenient way to prompt the user for a small amount of input, e.g. to display a message, ask a question, or anything else that does not require extensive effort on the user's part. Dialogs are organized as a window split vertically. The top section is a gtk.VBox, and is where widgets such as a gtk.Label or a gtk.Entry should be packed. The bottom area is known as the action_area which is generally used for packing buttons into the dialog which may perform functions such as cancel, ok, or apply. The two areas are separated by a gtk.HSeparator.

The gtk.Dialog boxes are created with a call to gtk.Dialog() that sets the dialog title, some convenient flags, and adds simple buttons. In a newly created dialog, the two primary areas of the window can be accessed as the vbox and action_area attributes, as can be seen from the example, below.

import gtklabel = gtk.Label("Nice label")dialog = gtk.Dialog("My dialog",                   None,                   gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,                   (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,                    gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))dialog.vbox.pack_start(label)label.show()checkbox = gtk.CheckButton("Useless checkbox")dialog.action_area.pack_end(checkbox)checkbox.show()response = dialog.run()dialog.destroy()

A modal dialog (that is, one which freezes the rest of the application from user input), can be created by passing the gtk.DIALOG_MODAL flag to the gtk.Dialog() constructor or by calling set_modal() on the dialog.

If you add buttons to gtk.Dialog using gtk.Dialog(), add_button(), or add_action_widget(), clicking the button will emit a signal called "response" with a response ID that you specified. PyGTK will never assign a meaning to positive response IDs; these are entirely user-defined. But for convenience, you can use the pre-defined GTK Response Type Constants (these all have values less than zero).

If a dialog receives a delete event, the "response" signal will be emitted with a response ID of gtk.RESPONSE_DELETE_EVENT.

If you want to block waiting for a dialog to return before returning control flow to your code, you can call run(). This function enters a recursive main loop and waits for the user to respond to the dialog, returning the response ID corresponding to the button the user clicked.


gtk.Window.set_transient_for

    def set_transient_for(parent)

parent :

the parent window or None to remove the transient parent

The set_transient_for() method sets the window as a transient window for the window specified by parent. Dialog windows should be set transient for the main application window they were spawned from. This allows window managers to keep the dialog on top of the main window, or center the dialog over the main window. The gtk.Dialog() constructor and other convenience functions in PyGTK will sometimes call the set_transient_for() method on your behalf.

On Windows, this method will and put the child window on top of the parent, much as the window manager would have done on X.


0 0
原创粉丝点击