I'm working with pyforms to create a tab widget and I want to get and set the current active tab. Consider this example:
self.formset = [{
'Person A': ['_firstname', '_lastname'],
'Person B': ['_firstname', '_lastname'] }]
so we get 2 tabs Person A
and Person B
. If I switch between them I would like to be informed with something similar to PyQt function currentIndex()
. So far I havn't been able to find a method in the pyforms documentation, is there a way to accomplish this just using pyforms?
The main issue in getting or setting the current index of your tab widget is to get access to the QTabWidget created by pyforms when the layout is generated. Once you have access to it, you simply call the setCurrentIndex(int)/currentIndex() of the widget.
A (dirty) quick fix to this is to modify the
BaseWidget.py
located in the pyforms module files which can be<VIRTUALENV_DIR>/lib/python3.6/site-packages/pyforms/gui
when using virtualenv.Note the additional :
Then in the code of your widget/app (subclass of BasicWidget) :