[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] A basic but critical problem in beginning of pyt

From: nansai hu
Subject: Re: [Discuss-gnuradio] A basic but critical problem in beginning of python code
Date: Sat, 5 Sep 2009 14:13:45 -0400

Josh & others´╝Ü
Thanks for your help, I am just use the first way under your mentioned, means I modified a generated py file, and I use start function instead run(ture) function in the last line.
But, after this job,the items added in GRC before is not displayed anymore.(I used a slider item to control the freq, after change run() to start() in the last line, the slider is missing while executing)

2009/9/5 Josh Blum <address@hidden>
In the wx gui code (generated by grc), the last line in the py file is tb.Run(True). This effectively calls start() on the flow graph and blocks in the wx main loop:

---from top_block_gui.py---
#start flow graph
if start: self.start()
#blocking main loop

For a wxgui app, you have to block in MainLoop(). However....

A) One option is to make your own threading.Thread class and pass it an instance of your top block. Your thread will run in the background while the main thread blocks at MainLoop().

B) An even better idea would be to make your own grc block wrapper that will invoke this thread. You dont need to have an actual gnuradio block in this xml wrapper, any python code is possible. A great example is the xmlrpc server block: http://gnuradio.org/trac/browser/gnuradio/trunk/grc/blocks/xmlrpc_server.xml

With option *A*: this would require modifications to a generated py file. If you generate the file again, you have to re-do the modifications.

However, with option *B*: grc can generate the py file with your thread + custom logic. All the information is captured in the saved grc file, so you do not need to modify the "output py file".


nansai hu wrote:
So that is the reason for use .run() the gui will display if you py file is
modified by a grc file, but if use the .start() function, no gui display
even in same program?

if it is ture,how can I add some logic after the program started?
I mean if I use start() function ,the code after start() could be executed
(use run function these code could not be executed),but the GUI silde or
ratiobottom item which add to file by GRC previously could not be displayed?

Is there anyway to have both GUI item and some logic after program could be
available in same time?

2009/9/5 Josh Blum <address@hidden>

run() is a blocking call.
start() is a non-blocking call.

Also, I believe run() will exit when a block returns -1 in its work method.


nansai hu wrote:

 When run a python script file, as we know main function will be run
We send the class to a object "tb",for instance. Then we have two ways to
let the program run.
One is call tb.run() function,and other is call tb.start() function.Could
somebody told me the difference bewteen these?

In my coding experience, use .run() the gui will display if you py file is
modified by a grc file, but if use the .start() function, no gui display
even in same program.


Discuss-gnuradio mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]