471,348 Members | 1,691 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Get data from a Queue to a wxtextcontrol

Hello, from linux I have created an interactive telnet session with a chess server.

With a combination of the threading, pexpect and Queue modules I put all recieved data into a queue.

The only way I can think of getting the data from the queue to a
wxtextcontrol is to have a wx.timer (set to a short interval) keep inspecting the queue.

This method seems to work OK, but I am wondering if there is a 'better' method than using a timer.

If wx.timer is the only method, if I use an interval of 1 will the timer just run as fast as possible or should I try to find an exact value (eg 100) ?
Jun 7 '07 #1
5 1662
bartonc
6,596 Expert 4TB
Hello, from linux I have created an interactive telnet session with a chess server.

With a combination of the threading, pexpect and Queue modules I put all recieved data into a queue.

The only way I can think of getting the data from the queue to a
wxtextcontrol is to have a wx.timer (set to a short interval) keep inspecting the queue.

This method seems to work OK, but I am wondering if there is a 'better' method than using a timer.

If wx.timer is the only method, if I use an interval of 1 will the timer just run as fast as possible or should I try to find an exact value (eg 100) ?
I like the idea of using a wxTimer to keep the display current with data that may be changing in the background. In fact, I use this technique often. I don't think that it's a good idea to run "as fast as possible", though. You only want to run fast enough (probably twice as fast as it takes for new data to arrive) to keep up with the changes in the data. I'd say that if you're entering the OnTimerN() handler and finding an empty queue more than 4 times for every time you find new data in the queue, you'll save processing overhead by cutting the value down (perhaps in half).

Just my opinion, though.
Jun 7 '07 #2
I like the idea of using a wxTimer to keep the display current with data that may be changing in the background. In fact, I use this technique often. I don't think that it's a good idea to run "as fast as possible", though. You only want to run fast enough (probably twice as fast as it takes for new data to arrive) to keep up with the changes in the data. I'd say that if you're entering the OnTimerN() handler and finding an empty queue more than 4 times for every time you find new data in the queue, you'll save processing overhead by cutting the value down (perhaps in half).

Just my opinion, though.
That's interesting, I hate the idea of wasting resources, BUT the data from the server is 'arratic' at best. Sometimes 20secs between lines then 50 lines arrive together.
Thanks for the tips, I'll have to experiment a bit more.
Jun 7 '07 #3
bartonc
6,596 Expert 4TB
That's interesting, I hate the idea of wasting resources, BUT the data from the server is 'arratic' at best. Sometimes 20secs between lines then 50 lines arrive together.
Thanks for the tips, I'll have to experiment a bit more.
That make sense. I'm used to processes that require more regular servicing (like sampling analog data).
Jun 7 '07 #4
That make sense. I'm used to processes that require more regular servicing (like sampling analog data).
Brilliant! I followed your previous advise on counting the number of times timer tries to read an empty queue. After a bit of tweaking my code works so much better.
Thanks
Jun 8 '07 #5
bartonc
6,596 Expert 4TB
Brilliant! I followed your previous advise on counting the number of times timer tries to read an empty queue. After a bit of tweaking my code works so much better.
Thanks
It makes me very happy that we can share and exchange our Python experience and knowledge this way. This forum is beginning to shape into the Python help forum of my dreams.

Thank you so much for your participation.
Jun 8 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Brian Alexander | last post: by
6 posts views Thread by herrcho | last post: by
10 posts views Thread by # include | last post: by
4 posts views Thread by Boki | last post: by
5 posts views Thread by akenato | last post: by
9 posts views Thread by =?Utf-8?B?U2hhdW5P?= | last post: by
reply views Thread by Ronak mishra | last post: by

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.