Issue
can I use a return statement from a slot function to provide input to a different 'lambda'd' slot?
something along the lines of the following which I know does not work - as X and Y seem to just be boolean:
class : mainwindow(QtGui.QMainWindow, Ui_test):
def __init__ (self, parent = None):
super(mainwindow,self).__init__(parent)
self.setupUi(self)
X = QtCore.QObject.connect(self.actionOpenX, OtCore.SIGNAL("triggered()", self.file_dialog)
Y = QtCore.QObject.connect(self.actionOpenY, OtCore.SIGNAL("triggered()", self.file_dialog)
QtCore.QObject.connect(self.actionProcess, QtCore.SIGNAL("triggered()", lambda : self.updateUi(X,Y))
def update_Ui(self, X, Y):
for line in X:
for line in Y:
"do something"
def file_dialog(self)
filedlg = QtGui.QFileDialog(self)
self.filename = filedlg.getOpenFileName()
return self.filename
I am sure something like this is possible and I am having serious brain freeze atm.
many thanks in advance for any help
Solution
The return value of QObject.connect
is simply a boolean that indicates whether the connection succeeded or failed. It has nothing to do with the return value of the slot.
It seems from your example code that you want to get some filenames from the user in one step, and then process them in a separate second step.
In order to do this, the filenames need to be kept somewhere until the user decides to start the processing step. One common way to do this is to display the chosen filenames in a list-widget, or group of line-edits so they can be retrieved later. Alternatively, the filenames could simply be appended to an internal list (i.e. a private attribute of the class instance).
Answered By - ekhumoro
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.