473,287 Members | 1,709 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

Event for multithread help advice

I have two threads going
class guiThread(threading.Thread)
class mainThread(threading.Thread)

Within the guiThread, I have an instance of class GUIFramework(Frame)
in this Tkinter instance I have a ListBox.

The second thread, mainThread, has an instance of a custom class the
will need to send out text or other objects to the gui.

What is the best or easiest way to send, let's say text, from
mainThread to the guiThread ListBox?

Should I use a custom Event class, pubsub, or Queue?

This is the way I have things right now (not in its entirety):
-----
start.py
import threading
import thread
import time
import GUIFramework
import myFoo
class guiThread(threading.Thread):
def __init__(self, threadID, name):
self.threadID = threadID
self.name = name
self.guiFrame = GUIFramework(master=None)
threading.Thread.__init__(self)
def run(self):
print "Starting " + self.name
self.guiFrame.mainloop()
print "Exiting " + self.name

class mainThread(threading.Thread):
def __init__(self, threadID, name):
self.threadID = threadID
self.name = name
self.myFoo = myFoo()
threading.Thread.__init__(self)
def run(self):
print "Starting " + self.name
self.myFoo.alive()
print "Exiting " + self.name

def start():
""" Start """
#Create new threads
threadgui = guiThread(1, "threadgui")
threadmain= carlThread(2, "threadmain")
#Start new Threads
threadgui.start()
threadmain.run()
while threadmain.isAlive():
if not threadgui.isAlive():
doExit = 1
pass
print "Exiting Main Thread"

if __name__ == '__main__':
start()

-----
I've tried a fews things but I really haven't had any luck.
--
Thanks, Joe
Oct 27 '07 #1
1 1220
In article <ma**************************************@python.o rg>,
JoeSox <jo****@gmail.comwrote:
>
I have two threads going
class guiThread(threading.Thread)
class mainThread(threading.Thread)

Within the guiThread, I have an instance of class GUIFramework(Frame)
in this Tkinter instance I have a ListBox.

The second thread, mainThread, has an instance of a custom class the
will need to send out text or other objects to the gui.

What is the best or easiest way to send, let's say text, from
mainThread to the guiThread ListBox?

Should I use a custom Event class, pubsub, or Queue?
Well, I'd recommend a Queue, but that's partly because I have an example
already made up:
http://www.pythoncraft.com/OSCON2001/FibThreaded.py
--
Aahz (aa**@pythoncraft.com) <* http://www.pythoncraft.com/

"Typing is cheap. Thinking is expensive." --Roy Smith
Oct 30 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: haptiK | last post by:
Hello, can i use php to multithread mail() or something similar? in my company i need to send multiple copies of email to a few hundred ppl affilated and on my list. instead of calling mail...
0
by: r_obert | last post by:
Hello, I'm trying to create a worker thread for my VC++ program, and was wondering whether I should be linking with the Multithread /MT or Multithread DLL /MD option? I'm not quite sure, in...
5
by: Simon Middlemiss | last post by:
I am writting a program to manage DTS packages which is based on the code example at the following link http:\\www.support.microsoft.com/?kbid=319985. I need to do things in a Windows Forms...
0
by: Kevin Jiang | last post by:
the injected line is this: struct __EventingCriticalSectionStub { void Lock() { } void Unlock() { }
1
by: M.C | last post by:
Following is a snap-shot of compiler created code when using UEM, use /Fx: struct __EventCriticalSectionStub { void Lock() {} void Unlock() {} }; ....
5
by: Ekempd | last post by:
Hi I need some advice about this situation an how I'm current handling it I hava a ASP.NET solution that in some point start multiples lenghty verification agains diferent databases, my big...
0
by: fred | last post by:
I need some help in trying to understand how to make myCollection (inherited from CollectionBase) multithread safe. Taking my implementation of the Add Sub and a readonly property Item. Public...
6
by: jmartin | last post by:
Hi, I have made a multithread version of a program (load a file into database), and with two processors I get the double of time in the multithread than in the process (unithread) version. I...
2
by: tikcireviva | last post by:
Hi Guys, I've done a mulithread queue implementation on stl<queue>, my developement environment is on VC6 as well as FC3. Let's talks about the win32 side. The suspected memory leak is find...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.