473,738 Members | 2,492 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Event for multithread help advice

I have two threads going
class guiThread(threa ding.Thread)
class mainThread(thre ading.Thread)

Within the guiThread, I have an instance of class GUIFramework(Fr ame)
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(threa ding.Thread):
def __init__(self, threadID, name):
self.threadID = threadID
self.name = name
self.guiFrame = GUIFramework(ma ster=None)
threading.Threa d.__init__(self )
def run(self):
print "Starting " + self.name
self.guiFrame.m ainloop()
print "Exiting " + self.name

class mainThread(thre ading.Thread):
def __init__(self, threadID, name):
self.threadID = threadID
self.name = name
self.myFoo = myFoo()
threading.Threa d.__init__(self )
def run(self):
print "Starting " + self.name
self.myFoo.aliv e()
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.isAl ive():
if not threadgui.isAli ve():
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 1236
In article <ma************ *************** ***********@pyt hon.org>,
JoeSox <jo****@gmail.c omwrote:
>
I have two threads going
class guiThread(threa ding.Thread)
class mainThread(thre ading.Thread)

Within the guiThread, I have an instance of class GUIFramework(Fr ame)
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**@pythoncra ft.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
8618
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 over and over again i would like to thread this process. could someone point me to some documentation or perhaps an example of
0
1862
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 layman's terms, what the difference is. When I build with Multithread DLL, the linker complains about not being able to find a bunch of "unresolved external symbols" associated with nafxcwd.lib.
5
3264
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 Application when various things occur in the package so I have written some custom events to reraise the events caught in the PackageEventsSink class. I also have a listview in details mode with several columns, my problem is that when I try and...
0
1100
by: Kevin Jiang | last post by:
the injected line is this: struct __EventingCriticalSectionStub { void Lock() { } void Unlock() { }
1
1380
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
1378
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 challenge is that the user click in a button "start process" and close the explorer windows... and in the backgroud all the required query are executed, when the user is back, maybe two hours late the process is finish .. I currently hadlle this...
0
1314
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 Sub Add(ByVal aDoc As myDocument) List.Add(aDoc) End Sub Can I make this multithread safe by and is this the best way to do it.
6
2824
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 have done the test of creating a unique thread that does the same code that the process version of the program and it takes more time that the process without creating the thread.
2
5306
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 after I've run through my unit test cases. Test Case:
0
8787
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9473
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9259
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8208
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6750
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6053
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4569
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3279
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.