Thanks! I defined a function, as you suggested, to call when the button was clicked. But then I also had to use self.fileDialog from within the function. Not sure how I could avoid using fileDialog.
I also defined global variable (under the class) and assigned it to the filename, so I could access it from within the main class. The following works: QtCore.QObject.connect(self.toolButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.getFileName) def getFileName(self): self.fileDialog = QtGui.QFileDialog() path = self.fileDialog.getOpenFileName() print(" File Selected: ", path) self.lineEdit.setText(path) self.XmlFileName = path Thanks. On Mon, May 27, 2013 at 6:01 AM, Matthew Ngaha <chigga...@gmail.com> wrote: > Sorry for the forward, i forgot to reply to tutor > > On Mon, May 27, 2013 at 3:53 AM, Sunitha Misra <sunith...@gmail.com> > wrote: > > > self.fileDialog = QtGui.QFileDialog() > > > > QtCore.QObject.connect(self.toolButton, > > QtCore.SIGNAL(_fromUtf8("clicked()")), self.fileDialog.getOpenFileName) > > > > i think the way youre doing it won't allow you to get the filename as > you are calling it through a signal. > > Things you can do: > > 1) dont use self.fileDialog.getOpenFileName as a slot like you are > doing. Create a function and call it when the toolbar's button is > clicked, then in that function assign the filename to the return value > of self.fileDialog.getOpenFileName. > > 2) if the only thing your self.fileDialog is doing is responding to > the toolbar's button, don't create it at all. do what i said in #1 and > assign a filename variable to the full method of the dialog. What im > saying is there might be no need to create the self.fileDialog > instance variable at all. > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor