每次选择某个选项卡时 Gtk Notebook 调用函数
Gtk Notebook call function every time a certain tab is selected
我想要笔记本上的选项卡,其功能与按钮几乎相同。每次我 select 这个选项卡都应该执行某个作业(例如 print('something') )。
如何让它在每次打开时执行?现在它只在启动时执行一次,仅此而已。
如果有人对这个问题有一些建议,我将非常感谢您的帮助!
您可以使用 switch-page
信号。
回调原型包含页码 ID,以便您可以确定要切换到哪个页面。
void user_function (GtkNotebook *notebook,
GtkWidget *page,
guint page_num,
gpointer user_data)
您正在寻找 switch-page
signal:
def callback(notebook, tab, index):
if index == index_of_the_tab:
print('selected')
# alternatively:
# if tab is the_tab:
# print('selected')
notebook.connect('switch-page', callback)
我想要笔记本上的选项卡,其功能与按钮几乎相同。每次我 select 这个选项卡都应该执行某个作业(例如 print('something') )。
如何让它在每次打开时执行?现在它只在启动时执行一次,仅此而已。
如果有人对这个问题有一些建议,我将非常感谢您的帮助!
您可以使用 switch-page
信号。
回调原型包含页码 ID,以便您可以确定要切换到哪个页面。
void user_function (GtkNotebook *notebook, GtkWidget *page, guint page_num, gpointer user_data)
您正在寻找 switch-page
signal:
def callback(notebook, tab, index):
if index == index_of_the_tab:
print('selected')
# alternatively:
# if tab is the_tab:
# print('selected')
notebook.connect('switch-page', callback)