From: Dr. B. <dr....@gm...> - 2005-01-02 22:21:32
|
I have a question about PythonCard. I would like to have a PythonCard interface call a python script that monitors a video image looking for motion. While both scripts run well independently ,I can not get the Card program to open the PythonVideo script. Does anybody have an idea about this problems' solution? Thanks PS I am new to both Python and PythonCard so please explain your answer in simple words. -- G. Byron Brooks EE MD |
From: Andy T. <an...@ha...> - 2005-01-03 00:05:04
|
Dr. Brooks wrote: > I have a question about PythonCard. > I would like to have a PythonCard interface call a python script that > monitors a video image looking for motion. While both scripts run well > independently ,I can not get the Card program to open the PythonVideo > script. > Does anybody have an idea about this problems' solution? Thanks > PS I am new to both Python and PythonCard so please explain your > answer in simple words. > We probably need a bit more information to help you out. How are you calling your PythonVideo script? What errors, if anything, are you seeing when your PythonCard application tries to call it? Perhaps you can put a copy of the appropriate block of code from your PythonCard application in an email. Along with any error or informational messages that you see. Regards, Andy -- ----------------------------------------------------------------------- From the desk of Andrew J Todd esq. "So I curtailed my Walpoling activities, sallied forth and infiltrated your place of purveyance to negotiate the vending of some cheesy comestibles." - Monty Python. -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.298 / Virus Database: 265.6.7 - Release Date: 30/12/04 |
From: Andy T. <an...@ha...> - 2005-01-24 10:20:19
|
Dr. Brooks wrote: > Mr. Todd > Thank you for your interest . > While preparing an email in reply to your request for more information > I launched the PythonCard script from the Pythonwin 2.3.2 interface > and the PythonVideo image window opened. I have since changed my > default python launching program to Pythonw (from python 2.3.4) and > all works well. > > However I do have another question. > What I am trying to do is have a user interface to a modified > Evolutions ER1 robot. This interface accepts voice input from Dragon > Speak NatLink and opens a TCP IP socket and RS232 Com port to my > robot. It also allows to user to issue commands to the robot's > Behavior program (a python script). I would like to have the robot's > behavior program run and send and receive input from the user > interface. Unfortunately I do not understand the method by which the > PythonCard GUI communications with other modules. Can I have my my > behavior program run and communicate with the TextArea of the GUI? > Can the Behavior Module Call elements of the GUI ? > It seems that the GUI runs in a loop and thus prevents the Behavior > Module from executing in parallel. A pointer to an example or > tutorial would be greatly appreciated. > > Again Thank for Your Interest > > On Mon, 03 Jan 2005 11:06:35 +1100, Andy Todd <an...@ha...> wrote: [snip] >> The answer is a qualified 'depends'. Yes, PythonCard (well, actually wxPython) executes in a loop and is essentially the controlling process whenever it runs. What you can do, though is import your behaviour program and call it from your PythonCard application, e.g. import myProgram class MyApp(model.background): def on_<component>_<event name>(self, event): myProgram.do_something() etc ... Where it may be troublesome is if your application is asynchronous. This means that you ask it to do something and then have to keep checking if it has finished. If that is the case then the documentation on Timers and Threads may be useful to you; http://pythoncard.sourceforge.net/timers-threads.html If any of your calls are synchronous (i.e. return control to PythonCard when they have finished) then writing the program is easier. Just included in your PythonCard program anything that you would normally type at the Python prompt. I've cc'ed this message to the PythonCard users list as you will always get good feedback from the good people there. They will generally be more prompt in answering your questions, as you can see I get round to my email in fits and starts and your chances of a useful and timely reply increase with the number of people who see it. Regards, Andy -- -------------------------------------------------------------------------------- From the desk of Andrew J Todd esq - http://www.halfcooked.com/ |
From: Kevin A. <al...@se...> - 2005-03-07 01:39:49
|
I hope Andy's answer below gave you the info you needed. If you just want to call a short script and get a result then calling it from within a handler is probably the right thing to do. However, the application will be unresponsive until the handler finishes. For longer tasks you probably want to start a separate thread for the script. There are examples of using threads in the PythonCard samples. If you need a script to run continuously and communicate with your GUI and let each stay responsive then again you probably want to use a thread and probably pass data back and forth between the threads using the Queue module. Again, there are a number of samples that do this, so just use the findfiles tool to search for Queue in the samples. http://docs.python.org/lib/module-Queue.html http://docs.python.org/lib/module-threading.html I would like to hear more about your project, it sounds fun. Is there any info up on the web...? ka On Jan 24, 2005, at 2:20 AM, Andy Todd wrote: > Dr. Brooks wrote: >> Mr. Todd >> Thank you for your interest . >> While preparing an email in reply to your request for more information >> I launched the PythonCard script from the Pythonwin 2.3.2 interface >> and the PythonVideo image window opened. I have since changed my >> default python launching program to Pythonw (from python 2.3.4) and >> all works well. >> However I do have another question. >> What I am trying to do is have a user interface to a modified >> Evolutions ER1 robot. This interface accepts voice input from Dragon >> Speak NatLink and opens a TCP IP socket and RS232 Com port to my >> robot. It also allows to user to issue commands to the robot's >> Behavior program (a python script). I would like to have the robot's >> behavior program run and send and receive input from the user >> interface. Unfortunately I do not understand the method by which the >> PythonCard GUI communications with other modules. Can I have my my >> behavior program run and communicate with the TextArea of the GUI? >> Can the Behavior Module Call elements of the GUI ? >> It seems that the GUI runs in a loop and thus prevents the Behavior >> Module from executing in parallel. A pointer to an example or >> tutorial would be greatly appreciated. >> Again Thank for Your Interest >> On Mon, 03 Jan 2005 11:06:35 +1100, Andy Todd <an...@ha...> >> wrote: > [snip] >>> > > The answer is a qualified 'depends'. Yes, PythonCard (well, actually > wxPython) executes in a loop and is essentially the controlling > process whenever it runs. > > What you can do, though is import your behaviour program and call it > from your PythonCard application, e.g. > > import myProgram > > class MyApp(model.background): > > def on_<component>_<event name>(self, event): > myProgram.do_something() > > etc ... > > Where it may be troublesome is if your application is asynchronous. > This means that you ask it to do something and then have to keep > checking if it has finished. If that is the case then the > documentation on Timers and Threads may be useful to you; > > http://pythoncard.sourceforge.net/timers-threads.html > > If any of your calls are synchronous (i.e. return control to > PythonCard when they have finished) then writing the program is > easier. Just included in your PythonCard program anything that you > would normally type at the Python prompt. > > I've cc'ed this message to the PythonCard users list as you will > always get good feedback from the good people there. They will > generally be more prompt in answering your questions, as you can see I > get round to my email in fits and starts and your chances of a useful > and timely reply increase with the number of people who see it. > > Regards, > Andy |