Python Gtk3,如何向 MessageDialog 插入响应(按钮)?
Python Gtk3, How can I insert a Response (Button) to MessageDialog?
有时我需要向 MessageDialog
插入新的响应(按钮),但我不知道该怎么做。例如 msg_dialog.insert_response(Gtk.STOCK_OK, Gtk.ResponseType.OK, 2)
谢谢
您要找的方法是Gtk.Dialog.add_button:
Adds a button with the given text and sets things up so that clicking
the button will emit the Gtk.Dialog ::response signal with the given
response_id. The button is appended to the end of the dialog’s action
area. The button widget is returned, but usually you don’t need it.
如果要添加多个按钮,可以使用Gtk.Dialog.add_buttons:
The add_buttons() method adds several buttons to the Gtk.Dialog using
the button data passed as arguments to the method. This method is the
same as calling the Gtk.Dialog.add_button() repeatedly.
The button data pairs - button text (or stock ID) and a response ID integer are passed individually. For example:
dialog.add_buttons(Gtk.STOCK_OPEN, 42, "Close", Gtk.ResponseType.CLOSE)
will add “Open” and “Close” buttons to dialog.
有时我需要向 MessageDialog
插入新的响应(按钮),但我不知道该怎么做。例如 msg_dialog.insert_response(Gtk.STOCK_OK, Gtk.ResponseType.OK, 2)
谢谢
您要找的方法是Gtk.Dialog.add_button:
Adds a button with the given text and sets things up so that clicking the button will emit the Gtk.Dialog ::response signal with the given response_id. The button is appended to the end of the dialog’s action area. The button widget is returned, but usually you don’t need it.
如果要添加多个按钮,可以使用Gtk.Dialog.add_buttons:
The add_buttons() method adds several buttons to the Gtk.Dialog using the button data passed as arguments to the method. This method is the same as calling the Gtk.Dialog.add_button() repeatedly.
The button data pairs - button text (or stock ID) and a response ID integer are passed individually. For example:
dialog.add_buttons(Gtk.STOCK_OPEN, 42, "Close", Gtk.ResponseType.CLOSE)
will add “Open” and “Close” buttons to dialog.