[Tutor] How to access a method defined in one class from another class (which is a thread) in Python3?
Alan Gauld
alan.gauld at btinternet.com
Fri Aug 9 00:30:15 CEST 2013
On 08/08/13 23:02, eryksun wrote:
>> 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?
He may not, but he is creating them! But it is possible he does want
multiple duplicate windows, one monitoring each thread. (eg progress
dialogs on an FTP program). Since I don't know the context I'm
assuming he knows how many windows he wants!
If he does want just one then he needs to reference the global object in
his run() method... But that brings us back into the land of
synchronisation issues and threadsafe locks etc.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list