marcux 0 Light Poster

Hi all!
I am building a small app with pygtk as the gui.
I have a thread that communicates over the network and when the user clicks a button I want a variable to be updated in my communication thread.
I have made a class that subclasses Thread:

class ComClass(threading.Thread):
    def __init__(self):
        ...call superclass...
        myVar = "x"

    def run(self):
        ...

    perhaps
    def updateVar(value):
        myVar = value

If I want to update myVar can I just make a function as "updateVar"
if I in the "run" code answers on a specific ip port and sends myVar.
Is that solution working, or will I have problems?
Should I use queues?
Make a queue, give it to my ComClass, write the changed value "from the GUI" to the queue and check in my ComClass if queue is not empty read in value and put it in myVar.
Is that a good way to do it?
I need a bit of guidence on threads.....
Many thanks in advance!
Marcus

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.