You can edit the embedded block code directly, and it may import other code.

As for including the same code multiple times, you would probably want to
create a hier block (click on the block, type "c") from your embedded
python block, then reuse it wherever you want.

On Thu, Jan 5, 2023 at 9:34 PM wieniawski <wieniaw...@outlook.com> wrote:

> thx.
>
> I get understand the whole thing.
>
> Take https://wiki.gnuradio.org/index.php?title=Creating_Your_First_Block this
> for example.
>
> When I choose an editor to edit the epy_block, it is temporally saved in
> C:\User\[user name]\AppData\Local\Temp\epy_block_0_[some char].py. This
> file is temp file.
>
> The real descriptions will be copied to grc file:
>
> If I changed the temp file, the grc file changed correspondingly. (This is
> what you said "Embedded python blocks should go wherever the flowgraph
> goes").
> Even I remove the temp file, after I reopen the grc file, another new temp
> python will be opened(copied in temp directory) with the same code in grc.
> However, the temp python file's name changed, with suffix
> changed. for example, from epy_block_0_n8bgjds3 to epy_block_0_usl3fla6,
> and I guess the suffix is a time stamp. Am I right?
>
> So
> 1. I can edit the grc file's _source_code directly to update the python
> code(block code)?
> 2. Is there any way that use a include way? take above as example, can I
> write like this in grc file:
> _source_code: "include epy_block.py" // or "import epy_block.py"
> or even better:
> _source_code: "include some_dir/my_own_name.py" // or "import
> some_dir/my_own_name.py"
> And I should make sure in some_dir, there is a file named my_own_name.py,
> which describes the block function.
> I know this definitely does not work. But I wish to.
> My aim is that:
> 1. I only write python file one time.
> 2. it can be instanced in grc block many times but maybe with different
> parameter input.
> 3. grc only describes the interconnection of blocks and parameters, the
> real implement is in python file, and then I can use swig to import my C++
> code, when I need to accelerate the simulation(calculation).
>
> Thanks a lot!
>
> ---- Replied Message ----
> From Jeff Long<willco...@gmail.com> <willco...@gmail.com>
> Date 1/5/2023 21:07
> To GNURadio Discussion List<discuss-gnuradio@gnu.org>
> <discuss-gnuradio@gnu.org>
> Subject Re: change grc hier blocks root directory
> Embedded python blocks should go wherever the flowgraph goes. The name can
> be set using ID in the GRC block.
>
> Please keep the discussion on the mailing list - thanks.
>
> On Wed, Jan 4, 2023 at 9:59 PM wieniawski <wieniaw...@outlook.com> wrote:
>
>> thx
>>
>> GRC_HIER_PATH EnvVar works quite well!
>>
>> However, GRC_BLOCKS_PATH doesnot work.
>>
>> the python block file still generated under [user
>> home]/AppData/Local/Temp/[python_block_name].py (in windows)
>>
>> And the [python_block_name] is named as epy_block_0_[some number].py, can
>> I change both the directory and the name.
>>
>> I searched the grc file by epy_block:
>>
>>
>> Which does not specify the epy_block name and directory. Where does these
>> information specified?
>>
>> Thx.
>>
>>
>>
>> ---- Replied Message ----
>> From Jeff Long<willco...@gmail.com> <willco...@gmail.com>
>> Date 1/5/2023 06:55
>> To discuss-gnuradio@gnu.org<discuss-gnuradio@gnu.org>
>> <discuss-gnuradio@gnu.org>
>> Subject Re: change grc hier blocks root directory
>> Environment variables:
>>   GRC_HIER_PATH defaults to ~/.grc_gnuradio
>>   GRC_BLOCKS_PATH can be used to specify an additional path
>>
>> On Wed, Jan 4, 2023 at 8:00 AM wieniawski <wieniaw...@outlook.com> wrote:
>>
>>> hi,
>>>
>>> I have generated some GRC Hier Blocks, and as you know, they are located
>>> in [user home]/.grc_gnuradio.
>>>
>>> My question is can I change the root directory of GRC Hier Blocks?
>>>
>>> Thx!
>>>
>>> wieniawski
>>> wieniaw...@outlook.com
>>>
>>> <https://maas.mail.163.com/dashi-web-extend/html/proSignature.html?ftlId=1&name=wieniawski&uid=wieniawski%40outlook.com&iconUrl=https%3A%2F%2Fmail-online.nosdn.127.net%2Fqiyelogo%2FdefaultAvatar.png&items=%5B%22wieniawski%40outlook.com%22%5D>
>>>
>>

Reply via email to