Makes PySide a little smarter.
SmartSide is one of many available ways to have PySide signals connected in a easy way.
Example of what it can do for you
Suppose you have designed a GUI using Qt Designer
Compile it with:
pyside-uic.exe myform.ui -o myform_ui.py #if you have resources included compile them too pyside-rcc.exe myresources.qrc -o myresources_rc.py
Then use a code like this to show your form and bind some signals:
from PySide.QtGui import * from PySide.QtCore import * import sys from myform_ui import * from smartside import * class MyApplication(QtGui.QMainWindow, Ui_MainWindow, SmartSide): def __init__(self, parent=None): super(MyApplication, self).__init__(parent) self.setupUi(self) self.auto_connect() #will respond to stateChanged signal from checkBox widget def _on_checkBox__stateChanged(self): print 'check', self.sender().isChecked() #will respond to pressed signal of btn_add widget def _on_btn_add__pressed(self): print 'btn_add was pressed' #list some widgets and can also use regex `regex`, to select multiples #start _ is mandatory _myfuncs = 'btn_base, btn_format, `btn_.+log.+`, btn_sqr' #will respond to clicked signal of all widget listed above def _when_myfuncs__clicked(self): print 'multiples', self.sender() if __name__ == "__main__": app = QtGui.QApplication(sys.argv) window = MyApplication() window.show() #uncomment line below to print a list of ALL signals available on your form #window.print_all_signals() sys.exit(app.exec_())
Your form is supposed to be called Ui_MainWindow
First we use setupUi as usual to create the interface.
Then auto_connect will connect member functions to signals when they match.
The last case use a multiple connection, so more then one widgets will call the same callback function. You can also use regex to select related widgets. In the example above we have selected a few widgets by its explicit name and also all widget whose name starts with ‘btn_’ and have ‘log’ in some part of its name. All of them are going to be connected to _when_myfuncs__clicked.
A few other functions are planed for future versions.
- https://github.com/xgvargas/smartside - please use this space if you found a problem or think any other task on PySide can be simplified.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size & hash SHA256 hash help||File type||Python version||Upload date|
|smartside-0.1.0-py2.7.egg (6.0 kB) Copy SHA256 hash SHA256||Egg||2.7|
|smartside-0.1.0.tar.gz (7.9 kB) Copy SHA256 hash SHA256||Source||None|
|smartside-0.1.0.zip (12.1 kB) Copy SHA256 hash SHA256||Source||None|