anatoly techtonik  committed 3b4ebfc transform function that handles signal to method

  • Participants
  • Parent commits d071ed6

Comments (0)

Files changed (1)


 # The code is placed into public domain by anatoly techtonik
 # Feel free to copy/paste wherever you like
-# Absolutely minimal example of PySide application with button calling dialog
-# More info about Qt dialogs:
+# Minimal PySide application with button for choosing color to paint itself
 from PySide.QtGui import QApplication, QPushButton, QColorDialog, QMessageBox,\
-def choose_color():
+class ButtonPainter(object):
+  def choose_color(self):
     # Select color
     color  = QColorDialog().getColor()
 # Create top level window/button
 button = QPushButton('Choose Color')
-# Call function that invokes color selection dialog when the button is clicked
+# button.clicked.connect() doesn't support passing custom parameters to
+# handler function (reference to the  button that we want to paint), so we
+# create object that will hold this parameter
+button_painter = ButtonPainter()