Skip to main content

Makes PySide a little smarter.

Project description

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.

More comming

A few other functions are planed for future versions.

Development:

https://github.com/xgvargas/smartside - please use this space if you found a problem or think any other task on PySide can be simplified.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

smartside-0.1.1.zip (12.1 kB view details)

Uploaded Source

smartside-0.1.1.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

smartside-0.1.1-py2.7.egg (6.0 kB view details)

Uploaded Egg

File details

Details for the file smartside-0.1.1.zip.

File metadata

  • Download URL: smartside-0.1.1.zip
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for smartside-0.1.1.zip
Algorithm Hash digest
SHA256 7f0aeb939f91b8ecb8bc011ab1eb1d9c71c2037082b31d364d591c74ebb0d375
MD5 0f205008b93449d8ce0002d368ccf418
BLAKE2b-256 d62392e066425c4ff6a5d80d0aba1da5985aa152dab99f81609f4242f8a24902

See more details on using hashes here.

File details

Details for the file smartside-0.1.1.tar.gz.

File metadata

  • Download URL: smartside-0.1.1.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for smartside-0.1.1.tar.gz
Algorithm Hash digest
SHA256 862abcebbb0c9edb292e57cefe75e7ff2e4e6b99c151f089764750a21649f94d
MD5 8583ffbdc3b369b1c648d30b0c2336cb
BLAKE2b-256 5e309ca531473ca6d4aeb2c8600ef96271842c97185425d30625f002747954f4

See more details on using hashes here.

File details

Details for the file smartside-0.1.1-py2.7.egg.

File metadata

  • Download URL: smartside-0.1.1-py2.7.egg
  • Upload date:
  • Size: 6.0 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for smartside-0.1.1-py2.7.egg
Algorithm Hash digest
SHA256 d546e39efed3043a2ff3b67330b780c1df920ce496ebe544498fe0405734da3b
MD5 aed2b6873c2396504bc1887c29d3ff26
BLAKE2b-256 907ac043b49f8266ac4994e8f9f81017886cf42f95fecf5e3555cb0e51ed02a2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page