I'm talking about <<NotebookTabChanged>>
event that ttk.Notebook
can be bound to. Say I have:
def tabChanged(self, event):
print "tab changed"
And say I want to manually trigger this method. What I actually mean by this is, say I have a basic, tabbed GUI and there's a start button which makes plots when you click it. There are plots on each tab and when you change tabs, <<NotebookTabChanged>>
is triggered, which is an automatically created event by ttk.Notebook
. I already have a self.tabChanged
method for this case. What I wanna do is, I wanna make my start button trigger this event so I don't have to create a new method just for the button which will do the exact same thing as self.tabChanged
. So I need a way of triggering the event through a button click, but remember, that event is ttk.Notebook
's own event and apparently it was designed to be used with tabs, not buttons. Is there a way to trigger <<NotebookTabChanged>>
manually with a button click?
您可以使用event_generate生成虚拟事件(例如,以<<
和>>
开头和结尾的事件):
self.the_notebook.event_generate("<<NotebookTabChanged>>")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.