2

I'm working on a small utility application in Python.

The networking is gonna send and receive messages. The GUI is gonna display the messages from the GUI and provide user input for entering messages to be sent. There's also a storage part as I call it, which is gonna get all the network messages and save them in some kind of database to provide some kind of search later.

What my question is, what would be the best way to design this? For sure all them have to happen in separate threads, but what I'm wondering is how to pass information between them the best way? What kind of signal passing / thread locking available in Python should I use to avoid possible problems?

Rodia
  • 1,407
  • 8
  • 22
  • 29
kender
  • 85,663
  • 26
  • 103
  • 145
  • Is there a strict requirement to use python or are you open to other languages? Tcl and Tk, for example, can do all the above easily without the need for threads. And to me, no threads means less complexity which is always a Good Thing. – Bryan Oakley Mar 31 '09 at 13:29
  • I'm using an api-library to communicate with remote network services there... the API i got implemented in python and c++ – kender Mar 31 '09 at 13:37

2 Answers2

2

One, probably the best, solution for this problem is to use Twisted. It supports all the GUI toolkits.

Ali Afshar
  • 40,967
  • 12
  • 95
  • 109
1

I think that you could use a Queue for passing messages between the GUI and the network threads.

As for GUI and threads in general, you might find the PyGTK and Threading article interesting.

Cristian Ciupitu
  • 20,270
  • 7
  • 50
  • 76