# Revision history [back]

Hello,

Have not looked in depth at your code but this will get what you are looking for. Have set this per your request of the button action for the Page Action button.

First you want dialog to be global. This is to allow access to it for the event(s). Next you want a class set for the listener:

from com.sun.star.awt import XActionListener
class ActionListener(unohelper.Base, XActionListener):
def __init__(self):
pass
def disposing(self, ev):
pass
def actionPerformed(self, ev):
oControl = dialog.getControl("tabController")
active_tab = oControl.getActiveTabID()


Next change:

 dialog.getControl("btn_action").addActionListener(ButtonEvent())


To:

oControl = dialog.getControl("btn_action")
listener = ActionListener()


When the button is pressed the selected tab is available as active_tab in the actionPerformed definition. Event is also available (ev). Did not put further code there, just access to the data.

Thanks for the heads up on tabs. Will have to look closer into this. Have had at least one other question on this but did not find the answer. This helps.

Hello,

Have not looked in depth at your code but this will get what you are looking for. Have set this per your request of the button action for the Page Action button.

First you want dialog to be global. This is to allow access to it for the event(s). Next you Edited 2018-11-30 (to remove global):

You want a class set for the button listener:

from com.sun.star.awt import XActionListener
class ActionListener(unohelper.Base, XActionListener):
def __init__(self):
pass
__init__(self, dialog):
self.my_dialog = dialog
def disposing(self, ev):
pass
def actionPerformed(self, ev):
oControl = dialog.getControl("tabController")
self.my_dialog.getControl("tabController")
active_tab = oControl.getActiveTabID()


Next change:

 dialog.getControl("btn_action").addActionListener(ButtonEvent())


To:

oControl = dialog.getControl("btn_action")
listener = ActionListener()


oControl = dialog.getControl("btn_action")
oControl.removeActionListener(ActionListener(dialog))


Before:

dialog.dispose()


When the button is pressed the selected tab is available as active_tab in the actionPerformed definition. Event is also available (ev). Did not put further code there, just access to the data.

Thanks for the heads up on tabs. Will have to look closer into this. Have had at least one other question on this but did not find the answer. This helps.

The above gets you what was needed but still looking into XSimpleTabController and also looking at XTabPageContainerListener.