QT GUI Message Edit Box: Difference between revisions

From GNU Radio
Jump to navigation Jump to search
(Created page with "Category:Block Docs Category:Stub Docs This is the template for the "Page-per-block Docs". This first section should describe what the block...")
 
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[Category:Block Docs]]
[[Category:Block Docs]]
[[Category:Stub Docs]]
The Message Edit Box is a QT widget which manages data through message passing interfaces. The interface ports are Polymorphic Types (PMT), which are opaque data types designed as generic containers of data.
This is the template for the [[:Category:Block_Docs|"Page-per-block Docs"]]. This first section should describe what the block does and how to use it, using however many paragraphs necessary.  Note that the title of the wiki page should match the block's name in GRC, i.e. the one defined in the block's .grc file.  Look at the [[FFT]] Block for a good example.


As this is a basic template, it's also in the [[:Category:Stub_Docs|"Stub Docs category"]]. Please improve it.
The 'msg' output port produces messages based on the text in the input field(s) and the data type set by the type argument. The data types are checked, and WARN log messages are produced when the data is in the wrong format.
       
The value of the input field(s) can be updated programmatically through the 'val' input message port. It is also checked for the correct data type.
       
The <q>is_pair</q> argument determines if the input field handles a key:value pair. If set to True, two input fields are created with the left for the key and right for the value. The key is always assumed to be a string and the value is restricted by the data type setting as above.
       
The block can take a default value. Because the block is capable of handling multiple data types, the default value is entered as a string in the same format as the user enters it into the Value input field of the widget.
       
Complex numbers are handled a bit differently. Because the Boost lexical_cast function is used, complex numbers MUST be in the form "(a,b)" to represent "a + jb". Note that a space is not valid after the comma, so "(1.23,10.56)" is correct while "(1.23, 10.56)" is not.
       
The <q>static</q> mode prevents the user from changing the data type or the key used in the widget. If also in <q>pair</q> mode, the key is not displayed and so must be set in the constructor. It is an error if using <q>static</q> and <q>pair</q> modes with no default key set.
 
=== Message Ports ===
 
; msg (output):
: Produces a PMT message from the data in the input field. If the data is not of the correct type and the conversion fails, the block produces a log WARN message, but does not output the data.
 
; val (input):
: Accepts PMT messages to update the value in the input field(s). The messages are first checked for the correct type (integer, float, string, or complex), and then converted to string(s) to display in the input field(s). When using <q>is_pair</q>, the PMT is checked to make sure it is a valid PMT pair. Then the key is extracted as a string and the value is processed according to the data type.


== Parameters ==
== Parameters ==
(''R''): <span class="plainlinks">[https://wiki.gnuradio.org/index.php/GNURadioCompanion#Variable_Controls ''Run-time adjustable'']</span>


; Param 1 (''R'')
; Value
: Description of parameter, provide any tips or recommended values. Note that the name of the parameter above should match the param's label that shows up in grc (e.g. Sample Rate).
: The default value of the message. This is entered as a string regardless of the type and converted internally.
 
; Label
: A label to identify the input field on the screen.
 
; Pair Mode
: <q>True</q> If a key:value pair.
 
; Static Mode
: <q>True</q> If the key input field is a static text box (cannot be edited live).


; Param 2
; Key
: blah blah blah
: <q>True</q> If the key used in a key:value pair message.
 
; GUI Hint
: See [[GUI Hint]] for information on how to arrange multiple QT GUIs on the screen.


== Example Flowgraph ==
== Example Flowgraph ==


Insert description of flowgraph here, then show a screenshot of the flowgraph and the output if there is an interesting GUI. Currently we have no standard method of uploading the actual flowgraph to the wiki or git repo, unfortunately.  The plan is to have an example flowgraph showing how the block might be used, for every block, and the flowgraphs will live in the git repo.
This flowgraph shows how a Message Edit Box can send a string. When the string has been processed by the Embedded Python Block, the 'clear input' port sends a null string back to the 'val' port of the Message Edit Box to clear the input field. In the flowgraph, the text is sent through a Throttle to a File Sink, sending the output to the user terminal (/dev/stdout).
 
[[File:Epy demo.png]]
 
Other examples:
 
* [[Embedded Python Block]]
* https://github.com/duggabe/gr-morse-code-gen


== Source Files ==
== Source Files ==


; C++ files
; C++ files
: [https://github.com/gnuradio/gnuradio TODO]
: [https://github.com/gnuradio/gnuradio/blob/master/gr-qtgui/lib/edit_box_msg_impl.cc]


; Header files
; Header files
: [https://github.com/gnuradio/gnuradio TODO]
: [https://github.com/gnuradio/gnuradio/blob/master/gr-qtgui/lib/edit_box_msg_impl.h]


; Public header files
; Public header files
: [https://github.com/gnuradio/gnuradio TODO]
: [https://github.com/gnuradio/gnuradio/blob/master/gr-qtgui/include/gnuradio/qtgui/edit_box_msg.h]


; Block definition
; Block definition
: [https://github.com/gnuradio/gnuradio TODO]
: [https://github.com/gnuradio/gnuradio/blob/master/gr-qtgui/grc/qtgui_edit_box_msg.block.yml]

Latest revision as of 22:03, 15 April 2020

The Message Edit Box is a QT widget which manages data through message passing interfaces. The interface ports are Polymorphic Types (PMT), which are opaque data types designed as generic containers of data.

The 'msg' output port produces messages based on the text in the input field(s) and the data type set by the type argument. The data types are checked, and WARN log messages are produced when the data is in the wrong format.

The value of the input field(s) can be updated programmatically through the 'val' input message port. It is also checked for the correct data type.

The is_pair argument determines if the input field handles a key:value pair. If set to True, two input fields are created with the left for the key and right for the value. The key is always assumed to be a string and the value is restricted by the data type setting as above.

The block can take a default value. Because the block is capable of handling multiple data types, the default value is entered as a string in the same format as the user enters it into the Value input field of the widget.

Complex numbers are handled a bit differently. Because the Boost lexical_cast function is used, complex numbers MUST be in the form "(a,b)" to represent "a + jb". Note that a space is not valid after the comma, so "(1.23,10.56)" is correct while "(1.23, 10.56)" is not.

The static mode prevents the user from changing the data type or the key used in the widget. If also in pair mode, the key is not displayed and so must be set in the constructor. It is an error if using static and pair modes with no default key set.

Message Ports

msg (output)
Produces a PMT message from the data in the input field. If the data is not of the correct type and the conversion fails, the block produces a log WARN message, but does not output the data.
val (input)
Accepts PMT messages to update the value in the input field(s). The messages are first checked for the correct type (integer, float, string, or complex), and then converted to string(s) to display in the input field(s). When using is_pair, the PMT is checked to make sure it is a valid PMT pair. Then the key is extracted as a string and the value is processed according to the data type.

Parameters

Value
The default value of the message. This is entered as a string regardless of the type and converted internally.
Label
A label to identify the input field on the screen.
Pair Mode
True If a key:value pair.
Static Mode
True If the key input field is a static text box (cannot be edited live).
Key
True If the key used in a key:value pair message.
GUI Hint
See GUI Hint for information on how to arrange multiple QT GUIs on the screen.

Example Flowgraph

This flowgraph shows how a Message Edit Box can send a string. When the string has been processed by the Embedded Python Block, the 'clear input' port sends a null string back to the 'val' port of the Message Edit Box to clear the input field. In the flowgraph, the text is sent through a Throttle to a File Sink, sending the output to the user terminal (/dev/stdout).

Epy demo.png

Other examples:

Source Files

C++ files
[1]
Header files
[2]
Public header files
[3]
Block definition
[4]