[Tutor] How to access a method defined in one class from another class (which is a thread) in Python3?

eryksun eryksun at gmail.com
Fri Aug 9 00:02:27 CEST 2013


On Thu, Aug 8, 2013 at 5:47 PM, Alan Gauld <alan.gauld at btinternet.com> wrote:
> On 08/08/13 22:03, SM wrote:
>
>> [SM] Sorry that I didn't add that part. setupUI is called from the main
>> as below:
>>
>> if __name__ == "__main__":
>>      import sys
>>      app = QtGui.QApplication(sys.argv)
>>      MainWindow = QtGui.QMainWindow()
>>      ui = Ui_MainWindow()
>>      ui.setupUi(MainWindow)
>>      MainWindow.show()
>>      sys.exit(app.exec_())
>>
>> Wonder if it is necessary to call it through __init__.
>
>
> Thats the problem.
> You are creating a new instance inside your run() method but
> the call in main() only sets it for the instance created in
> main. It won't set it up for any other instance. You need
> to call it every time you create a new object. Unless....
>
> If you put it in init() it will be called every time you
> create a new instance. Much safer.

I'm confused. Why does the OP want multiple instances of the user
interface widgets?


More information about the Tutor mailing list