Ok, here would be my plan of attack. I would have 2 threads running. The first thread is the one that imports the report into the database. This thread should run continuously (think while(True) loop). Use the Python threading library for this thread. When this thread reads a report and loads it into the database, it will analyze the data. Once the thread is done with the analysis, it will alert the main GUI thread to any change in data and it will display to the user accordingly. The alert can be anything you want (flag, update function, etc.). Personally I would do a standard observer interface, but that is up to you.
The GUI thread is the main GUI. This thread should handle all of the user interactions. It's event model should be completely separate from the backend thread except for whatever update mechanism you choose to link the two together. This thread needs to stay separate and devoted to user interface items else the GUI will bog down drastically. Note that this configuration assumes that the time for analysis is shorter than the time between reports. If it is longer, you need a third thread for analysis. One more thing...If your backend thread is checking for a new report and just running a couple of lines of code, it is a good idea to use time.sleep to shut the thread down for a slight amount of time (1/8 or 1/4 second should do). If you don't do this the thread will spike your processor usage while it idly checks for a new report. I hope this helps. Let me know if anything is not clear. Contact me off list if you need specific examples. Cheers, Nate L. On 6/15/07, Gary Thompson <[EMAIL PROTECTED]> wrote: > G'day Nate, > Thanks for you reply. My plan is not so much process intensive, but is > used for monitoring. Here is the plan: > - My application is a journal type application which I want to "link" to > other software over a network. > - This other software will periodically generate a html report on a > windows PC > - When this report has been generated, I want my application to import > the data into the database (already done) and analyse it in the background. > - If there is new data requiring user attention, based on the import, > then I want to be able to Pop up a data entry form for a user to make a > comment regarding the changes. The data entry is fairly time critical, > which is why I want the database application to make is as easy as > possible for the user. The user will know to expect a form to jump up > which will require their attention. > > I hope this makes sense, I can detail further if required. > > Thank you for you help and attention to this. > Gary. > > > Nate Lowrie wrote: > > I have done this on several occasions. In fact, if your program is > > doing something that will take a long time, like reading and > > processing data, another thread is necessary in order to keep the GUI > > from bogging down. Dabo plays well with the Python threading > > libraries. > > > > When I have used separate threads, I have found that I don't need to > > tap into the dabo event model at all. It can process stuff on it's > > own and communicate user requests to the backend logic with the > > backend even worrying about it's existence. Can you elaborate on what > > you are planning on doing? I can probably recommend a course of > > action if you can provide some more detail. > > > > Cheers, > > > > Nate L. > > > > On 6/14/07, Gary Thompson <[EMAIL PROTECTED]> wrote: > > > >> Hi, > >> I have a requirement to use threading with additional threads > >> interacting with the GUI. I've read a mention in the FAQ that I can go > >> down to wxPython level, but then that doesn't take into account the Dabo > >> Event Model. Basically, I'm interested in finding out more about this. > >> > >> I'm happy to use what ever infrastructure exists within dabo to allow me > >> to register events with the main GUI loop (perhaps adding events to a > >> queue?). I'll dig into the source code, but any help would be great. > >> > >> Is there a way I can create my own event objects which the main program > >> can respond to? > >> > >> Thank you, > >> > >> Gary. > >> > >> > >> [excessive quoting removed by server] _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users Searchable Archives: http://leafe.com/archives/search/dabo-users This message: http://leafe.com/archives/byMID/dabo-users/[EMAIL PROTECTED]
