trial-and-error, I think I am getting closer to a solution. However, I
get the following error with my new code:
```
QWidget: Must construct a QApplication before a QWidget
```
If I declare a new QApplication, I don't know how to tie it to anything.
Here is my revised code:
```
# Embedded Python Block
import numpy as np
from gnuradio import gr
from gnuradio import qtgui
import sip
import sys
import signal
from PyQt5 import Qt
from PyQt5 import QtGui
from PyQt5.QtWidgets import (QWidget, QLineEdit, QPushButton,
QTextEdit, QGridLayout, QApplication)
d_buffer = ""
textboxValue = ""
class cons_in (gr.sync_block):
def __init__(self):
gr.sync_block.__init__(self,
name='Console Input', # will show up in GRC
in_sig=None,
out_sig=[np.byte])
self.initUI()
def initUI(self):
# create text display area
self.textarea = QTextEdit(QWidget=None)
self.textarea.setReadOnly(True)
# create input text area
self.textbox = QLineEdit(QWidget=None)
self.textbox.editingFinished.connect(self.onEnter)
self.textbox.setFocus()
grid = QGridLayout()
grid.setSpacing(10)
grid.addWidget(self.textarea, 0, 0, 5, 1)
grid.addWidget(self.textbox, 5, 0)
self.setLayout(grid)
self.show()
def onEnter(self):
global d_buffer
global textboxValue
textboxValue = self.textbox.text()
d_buffer += (textboxValue + "\n")
self.textarea.setText(d_buffer)
self.textbox.setText("")
def work(self, input_items, output_items):
global textboxValue
# <send textboxValue to output port>
_num_elem = len(textboxValue)
for x in range (_num_elem):
output_items[0][x] = textboxValue[x]
return (_num_elem)
```
A stand-alone version of the code works properly.
Any help is appreciated!
Thanks,
--
Barry Duggan
On Tue, 24 Sep 2019 20:15:41 -0400, Barry Duggan wrote:
Hi,
My flowgraph has an Embedded Python block feeding a Throttle feeding a
Text sink (https://github.com/dl1ksv/gr-display). In my Embedded Python
block I have a QLineEdit widget and a QTextEdit widget. The user input
is fed to the output port.
<snip>
_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
No comments:
Post a Comment