Python Gtk3,如何向MessageDialog插入响应(按钮)?

2024-04-20 13:14:40 发布

您现在位置:Python中文网/ 问答频道 /正文

有时我需要向MessageDialog插入新的响应(按钮),但我不知道如何才能做到这一点。例如msg_dialog.insert_response(Gtk.STOCK_OK, Gtk.ResponseType.OK, 2)

谢谢


Tags: gtkresponsestockokmsg按钮dialoginsert
1条回答
网友
1楼 · 发布于 2024-04-20 13:14:40

您要查找的方法是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.

相关问题 更多 >