Thank you 'velociraptor Genjix' for your advice to read the page.
I did read it and it looks nice, but the very first example of hello
World (I show the listing of it, obtained via clipboard from the
wiki/Signals_and_Slots_in_PySide) did not work, at least for me.
Listing of Hello World, first example:
***************************************
import sys
from PySide import QtCore, QtGui
# define a function that will be used as a slot
def sayHello():
print 'Hello world!'
app = QtGui.QApplication(sys.argv)
button = QtGui.QPushButton('Say hello!')
# connect the clicked signal to the sayHello slot
button.clicked.connect(sayHello)
button.show()
sys.exit(app.exec_())
***************************************
I was disappointed with it and for that reason started to look at the
psep100. IMHO it is counterproductive to show examples that do not
work... Perhaps they do work for some people, but not for me!
Worse still, I for one, could not understand the example, so I changed
it to what for me is a minimum "Hi world" that works from CLI, and
which I can understand:
****************************************
#!/usr/bin/env python
import sys
from PySide import QtCore, QtGui
# define a function that will be used as a slot
class Form(QtGui.QDialog):
def __init__(self, parent=None):
super(Form, self).__init__(parent)
self.message = QtGui.QLineEdit('watch this space for
message!')
button = QtGui.QPushButton('Say hello!')
button.clicked.connect(self.sayHello)
layout = QtGui.QVBoxLayout()
layout.addWidget(self.message)
layout.addWidget(button)
self.setLayout(layout)
def sayHello(self):
self.message.setText( 'Hello world!')
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
form = Form()
form.show()
app.exec_()
****************************************
So signals and slots do work OK in PySide and one "client" is happy!
I am sure that quite a bit of the text in the above listing could be
eliminated, but IMHO it is better to show examples that do work for
all, rather than smart, shorter examples that fail some. BTW, does it
really work for you?
Many thanks for taking the trouble to communicate.
OldAl.
On Thursday 28 October 2010 13:38:56 velociraptor Genjix wrote:
>
> read
this, http://developer.qt.nokia.com/wiki/Signals_and_Slots_in_PySide
>
>snip(...)
--
Algis Kabaila
http://akabaila.pcug.org.au/
_______________________________________________
PySide mailing list
[email protected]
http://lists.openbossa.org/listinfo/pyside