Re: [pygtk] Quick notebook question...
self.notebook.connect('switch-page', self.on_notebook_switch) def on_notebook_switch(self, notebook, page_ptr, page_num, data=None): page = self.notebook.get_nth_page(page_num) ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Quick notebook question...
Hi Tom & Brian. That was exactly what I was looking for. Works perfectly!! Many thanks to both of you. Rob M. www.slots24.com Brian wrote: On Wed, 2005-02-11 at 13:53 -0500, Thomas Mills Hinkle wrote: On 11/2/05, Rob Marino <[EMAIL PROTECTED]> wrote: Hi all. Quick question regarding notebook signals: I have an app with a notebook. I need to detect when a user switches to another page. Problem is this - when I detect the 'switch_page' signal and use notebook.get_current_page() I'm getting the page that the user *was *on. The other signals like 'switch_page' and 'change_current_page' don't seem to be being fired at all. I need a way to detect the page the user has selected after he has switched to it. How is this done please? Today seems to be my day for sharing ugly solutions with the list... here's what I do: def hackish_notebook_switcher_handler (*args): # because the switch page signal happens before switching... # we'll need to look for the switch with an idle call gobject.idle_add(self.notebookChangeCB) def notebookChangeCB (*args): page=self.notebook.get_current_page() # Do something with the page... self.notebook.connect('switch-page',hackish_notebook_switcher_handler) Yeah, as I said not pretty. Knowing myself, I imagine I looked pretty hard for a better solution before implementing that, so this may be what you have to do. If not, someone please show me the better way too! Tom Here is how we do it without a hack. self.notebook.connect("switch-page", self.switch_page) def switch_page(self, notebook, page, page_num): """callback function changes the current_page setting in the term structure""" dprint("TERMINAL: switch_page; page_num = %d" %page_num) self.term.current_tab = self.term.visible_tablist[page_num] if self.term.auto_scroll[self.term.current_tab]: self.scroll_current_view() return You should be able to decipher the above code snipit without more explanation. We have a number of tabs that may or may not be visible. The pygtk reference page: http://www.pygtk.org/pygtk2reference/class-gtknotebook.html and the pertinent info: The "switch-page" gtk.Notebook Signal def callback(notebook, page, page_num, user_param1, ...) notebook : the notebook that received the signal page : the new current page page_num : the index of the new current page user_param1 : the first user parameter (if any) specified with the connect() method ... : additional user parameters (if any) The "switch-page" signal is emitted when the notebook page is changed. Note the page parameter is a GPointer and not usable within PyGTK. Use the page_num parameter to retrieve the new current page using the get_nth_page() method. -- O__ _/`.\ `=( ' ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Quick notebook question...
On Wed, 2005-02-11 at 13:53 -0500, Thomas Mills Hinkle wrote: > On 11/2/05, Rob Marino <[EMAIL PROTECTED]> wrote: > > Hi all. > > > > Quick question regarding notebook signals: > > > > I have an app with a notebook. I need to detect when a user switches to > > another page. > > > > Problem is this - when I detect the 'switch_page' signal and use > > notebook.get_current_page() I'm getting the page that the user *was *on. > > > > The other signals like 'switch_page' and 'change_current_page' don't > > seem to be being fired at all. I need a way to detect the page the > > user has selected after he has switched to it. > > > > How is this done please? > > Today seems to be my day for sharing ugly solutions with the list... > here's what I do: > > def hackish_notebook_switcher_handler (*args): > # because the switch page signal happens before switching... > # we'll need to look for the switch with an idle call > gobject.idle_add(self.notebookChangeCB) > > def notebookChangeCB (*args): >page=self.notebook.get_current_page() ># Do something with the page... > > > self.notebook.connect('switch-page',hackish_notebook_switcher_handler) > > Yeah, as I said not pretty. > > Knowing myself, I imagine I looked pretty hard for a better solution > before implementing that, so this may be what you have to do. > > If not, someone please show me the better way too! > > Tom Here is how we do it without a hack. self.notebook.connect("switch-page", self.switch_page) def switch_page(self, notebook, page, page_num): """callback function changes the current_page setting in the term structure""" dprint("TERMINAL: switch_page; page_num = %d" %page_num) self.term.current_tab = self.term.visible_tablist[page_num] if self.term.auto_scroll[self.term.current_tab]: self.scroll_current_view() return You should be able to decipher the above code snipit without more explanation. We have a number of tabs that may or may not be visible. The pygtk reference page: http://www.pygtk.org/pygtk2reference/class-gtknotebook.html and the pertinent info: The "switch-page" gtk.Notebook Signal def callback(notebook, page, page_num, user_param1, ...) notebook : the notebook that received the signal page : the new current page page_num : the index of the new current page user_param1 : the first user parameter (if any) specified with the connect() method ... : additional user parameters (if any) The "switch-page" signal is emitted when the notebook page is changed. Note the page parameter is a GPointer and not usable within PyGTK. Use the page_num parameter to retrieve the new current page using the get_nth_page() method. -- Brian <[EMAIL PROTECTED]> ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Quick notebook question...
On 11/2/05, Rob Marino <[EMAIL PROTECTED]> wrote: > Hi all. > > Quick question regarding notebook signals: > > I have an app with a notebook. I need to detect when a user switches to > another page. > > Problem is this - when I detect the 'switch_page' signal and use > notebook.get_current_page() I'm getting the page that the user *was *on. > > The other signals like 'switch_page' and 'change_current_page' don't > seem to be being fired at all. I need a way to detect the page the > user has selected after he has switched to it. > > How is this done please? Today seems to be my day for sharing ugly solutions with the list... here's what I do: def hackish_notebook_switcher_handler (*args): # because the switch page signal happens before switching... # we'll need to look for the switch with an idle call gobject.idle_add(self.notebookChangeCB) def notebookChangeCB (*args): page=self.notebook.get_current_page() # Do something with the page... self.notebook.connect('switch-page',hackish_notebook_switcher_handler) Yeah, as I said not pretty. Knowing myself, I imagine I looked pretty hard for a better solution before implementing that, so this may be what you have to do. If not, someone please show me the better way too! Tom ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
[pygtk] Quick notebook question...
Hi all. Quick question regarding notebook signals: I have an app with a notebook. I need to detect when a user switches to another page. Problem is this - when I detect the 'switch_page' signal and use notebook.get_current_page() I'm getting the page that the user *was *on. The other signals like 'switch_page' and 'change_current_page' don't seem to be being fired at all. I need a way to detect the page the user has selected after he has switched to it. How is this done please? Thanks. Rob M. (www.slots24.com) ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/