Wednesday, 15 May 2013

user interface - Python: Creating Default Argument for Pushbutton Connected Function -


I have a kupashubutan by which the function is triggered:

self. PbLoad.clicked .connect (self.loadData)

This works great, however I would like to give a default argument to that function if I want to manually load the code (For debugging). I tried:

  def loaddata (self, fileName = none): If the file name is none: fileName = QtGui.QFileDialog.getOpenFileName (manually, 'Open data File select ','), if file name: self.filename = fileName self.parseFilename ()  

Although it breaks my button and it stops the work Similarly, if I add the button instead:

self.pbLoad.clicked.connect (self.loadData ())

button pressed As soon as the GUI has been started. How can I work out any ideas without announcing an additional cover? Thank you.

You need consistency between the signal and the slot.

In that case, your signal does not send any parameters, your slot should not contain any parameters.

I use a cover function as slot and call the actual actual function you want to test. About self.pbLoad.clicked.connect (self.loadData ())

When you try to link the function to the button, So you actually call the function: In that case, you add your button to the return value of the function, which is none, therefore, the button is not connecting.

I am using this:

  def __init__ (self): self.pbLoad.clicked.connect (self.buttonClickedSlot) def buttonclaimslot (self): self. LoadData () def load data (self, filename = none): .....  

No comments:

Post a Comment