Python save every entry in list=[] on tkinter - list

I'm still new with python gui programming.
I want to open two list . one for entry on the other for the button . Than i want to extend this. But my problem is i get only one value . i want to save e.g.
list_one_entryfield=[100,32,53] and list_two_button=[100,200]
-with extend->newList=[100,32,53,100,200]
my code:
def txtOk(EN_number):
EN_number = txtDisplay.get()
#print(EN_number)
listEN=[]
listEN.append(EN_number)
print(listEN)
return listEN
def addNumber(BN_number):
#print(BN_number)
listBN=[]
listBN.append(BN_number)
print(listBN)
return listBN
BN_txtOk= Button(frame2,text ='OK',bg = 'green',fg='white', padx=38, pady= 8, bd= 8, command = lambda : txtOk(txtDisplay))
BN_txtOk.grid(row=0, column= 0)
frame3= Frame(root1)
frame3.configure(bg='light blue')
frame3.pack(side=TOP)
BN_water= Button(frame3, text ='100ml',bg ='blue',fg = 'white',padx=8, pady= 8, bd= 8, command = lambda : addNumber('100'))
BN_water.pack(side = LEFT)
BN_water1= Button(frame3, text ='200ml',bg ='blue',fg = 'white',padx=8, pady= 8, bd= 8, command = lambda : addNumber('200'))
BN_water1.pack(side = LEFT)
BN_water2= Button(frame3, text ='300ml',bg ='blue',fg = 'white',padx=8, pady= 8, bd= 8, command = lambda : addNumber('300'))
BN_water2.pack(side = LEFT)
BN_water3= Button(frame3, text ='0,5L',bg ='blue',fg = 'white',padx=8, pady= 8, bd= 8, command = lambda : addNumber('500'))
BN_water3.pack(side = LEFT)
BN_water4= Button(frame3, text ='1L',bg ='blue',fg = 'white',padx=8, pady= 8, bd= 8, command = lambda : addNumber('1000'))
BN_water4.pack(side = LEFT)

To convert your program to a .exe file you can use py2exe: http://www.py2exe.org/.
This should create a .exe file that can run on any Windows computer (no need to install python there).
Edit: note that when you convert your program the user will not see your print statements. You can convert them to a Tkinter messagebox:
from tkinter import messagebox
messagebox.showinfo("water drink program", "You drank enough water")

Related

Error exchanging list of floats in a topic

I think that the issue is silly.
I'd like to run the code on two computers and I need to use a list. I followed this Tutorials
I used my PC as a talker and computer of the robot as a listener.
when running the code on my PC, the output is good as I needed.
[INFO] [1574230834.705510]: [3.0, 2.1]
[INFO] [1574230834.805443]: [3.0, 2.1]
but once running the code on the computer of the robot, the output is:
Traceback (most recent call last):
File "/home/redhwan/learn.py", line 28, in <module>
talker()
File "/home/redhwan/learn.py", line 23, in talker
pub.publish(position.data)
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/topics.py", line 886, in publish
raise ROSSerializationException(str(e))
rospy.exceptions.ROSSerializationException: <class 'struct.error'>: 'required argument is not a float' when writing 'data: [3.0, 2.1]'
full code on PC:
#!/usr/bin/env python
import rospy
from std_msgs.msg import Float32
x = 3.0
y = 2.1
def talker():
# if a == None:
pub = rospy.Publisher('position', Float32, queue_size=10)
rospy.init_node('talker', anonymous=True)
# rospy.init_node('talker')
rate = rospy.Rate(10) # 10hz
while not rospy.is_shutdown():
position = Float32()
a = [x,y]
# a = x
position.data = list(a)
# position.data = a
# hello_str = [5.0 , 6.1]
rospy.loginfo(position.data)
pub.publish(position.data)
rate.sleep()
if __name__ == '__main__':
try:
talker()
except rospy.ROSInterruptException:
pass
full code on the computer of the robot:
#!/usr/bin/env python
import rospy
from std_msgs.msg import Float32
def callback(data):
# a = list(data)
a = data.data
print a
def listener():
rospy.init_node('listener', anonymous=True)
rospy.Subscriber("position", Float32, callback)
# spin() simply keeps python from exiting until this node is stopped
rospy.spin()
if __name__ == '__main__':
listener()
when using one number as float everything is OK.
I understand how to publish and subscribe to them separately as the float but I'd like to do it as list
Any ideas or suggestion, it would be appreciated.
When you exchange messages in ROS is preferred to adopt standard messages if there is something relatively simple. Of course, when you develop more sophisticated systems (or modules), you can implement your own custom messages.
So in the case of float array, Float32MultiArray is your friend.
Populating the message in one side will look like that (just an example using a 2 elements float32 array) in C++:
.
.
.
while (ros::ok())
{
std_msgs::Float32MultiArray velocities;
velocities.layout.dim.push_back(std_msgs::MultiArrayDimension());
velocities.layout.dim[0].label = "velocities";
velocities.layout.dim[0].size = 2;
velocities.layout.dim[0].stride = 1;
velocities.data.clear();
velocities.data.push_back(count % 255);
velocities.data.push_back(-(count % 255));
velocities_demo_pub.publish(velocities);
ros::spinOnce();
loop_rate.sleep();
++count;
}
.
.
.
in Python for 8 elements array an example will look like:
.
.
.
while not rospy.is_shutdown():
# compose the multiarray message
pwmVelocities = Float32MultiArray()
myLayout = MultiArrayLayout()
myMultiArrayDimension = MultiArrayDimension()
myMultiArrayDimension.label = "motion_cmd"
myMultiArrayDimension.size = 1
myMultiArrayDimension.stride = 8
myLayout.dim = [myMultiArrayDimension]
myLayout.data_offset = 0
pwmVelocities.layout = myLayout
pwmVelocities.data = [0, 10.0, 0, 10.0, 0, 10.0, 0, 10.0]
# publish the message and log in terminal
pub.publish(pwmVelocities)
rospy.loginfo("I'm publishing: [%f, %f, %f, %f, %f, %f, %f, %f]" % (pwmVelocities.data[0], pwmVelocities.data[1],
pwmVelocities.data[2], pwmVelocities.data[3], pwmVelocities.data[4], pwmVelocities.data[5],
pwmVelocities.data[6], pwmVelocities.data[7]))
# repeat
r.sleep()
.
.
.
and on the other side your callback (in C++), will look like:
.
.
.
void hardware_interface::velocity_callback(const std_msgs::Float32MultiArray::ConstPtr &msg) {
//velocities.clear();
if (velocities.size() == 0) {
velocities.push_back(msg->data[0]);
velocities.push_back(msg->data[1]);
} else {
velocities[0] = msg->data[0];
velocities[1] = msg->data[1];
}
vel1 = msg->data[0];
vel2 = msg->data[1];
//ROS_INFO("Vel_left: [%f] - Vel_right: [%f]", vel1 , vel2);
}
.
.
.
Hope that you got an idea...if you need something more drop me a line!

How can I make a button print in the display I created? (Tkinter)

I have been working on an app in python for a teacher at my school. What I want it to do is have a simple GUI and a way I can type in a word and it will print the words value in the same slot i typed the word.(kind of like a calculator) A=1 B=2 C=3 etc. It is fairly simple, as i am a beginner, but I can't quite get my button to show the value of the words I type in. If anyone could help it would be great!
Thanks!
Here is my code so far:
from Tkinter import *
import sys
def dollaramount():
print sum(map(" abcdefghijklmnopqrstuvwxyz".index, raw_input().lower()))
root = Tk()
frame = Frame(root)
frame.pack()
num1=StringVar()
topframe = Frame(root)
topframe.pack(side=TOP)
txtDisplay=Entry(frame, textvariable = num1, bd= 20, insertwidth= 1, font= 30, bg="white", fg="black")
txtDisplay.pack(side=TOP)
button1 = Button(topframe, padx=16, pady=16, bd=8, text="=", bg="white", fg="black", command=dollaramount)
button1.pack(side=LEFT)
root.mainloop()
I guess what you want is the following:
from Tkinter import *
import sys
def dollaramount():
# get the word written in the entry
word = num1.get()
# compute its value
val = sum(map(" abcdefghijklmnopqrstuvwxyz".index, word.lower()))
# display its value in the entry
num1.set("%s=%i" % (word, val))
root = Tk()
frame = Frame(root)
frame.pack()
num1=StringVar(root)
topframe = Frame(root)
topframe.pack(side=TOP)
txtDisplay=Entry(frame, textvariable = num1, bd= 20, insertwidth= 1, font= 30, bg="white", fg="black")
txtDisplay.pack(side=TOP)
button1 = Button(topframe, padx=16, pady=16, bd=8, text="=", bg="white", fg="black", command=dollaramount)
button1.pack(side=LEFT)
root.mainloop()
Your dollaramount function was not working because you used command line specific functions print and raw_input instead of using the set and get methods of the StringVar. I commented the code so that you can understand what it does.

Passing text from a function to a gui

I've got a GUI function in a file 'test_gui.py', which is adapted from one of Bryan Oakley's answers to a question regarding getting text from a Tkinter entry box.
import sys
import os
import Tkinter as tk
class testing(tk.Tk):
def __init__(self):
tk.Tk.__init__(self)
self.label1 = tk.Label(self, text = "Enter benchmark version")
self.label2 = tk.Label(self, text = "Enter test_suite (a for all)")
self.label3 = tk.Label(self, text = "Enter sub_suite t or w")
self.entry1 = tk.Entry(self)
self.entry2 = tk.Entry(self)
self.entry3 = tk.Entry(self)
self.button = tk.Button(self, text="Get", command=self.on_button)
self.button.grid(row = 4, column = 0)
self.label1.grid(row = 1, column = 0)
self.label2.grid(row = 2, column = 0)
self.label3.grid(row = 3, column = 0)
self.entry1.grid(row = 1, column = 1)
self.entry2.grid(row = 2, column = 1)
self.entry3.grid(row = 3, column = 1)
def on_button(self):
benchmark = self.entry1.get()
test_suite = self.entry2.get()
sub_suite = self.entry3.get()
home_path=os.path.dirname(os.path.abspath(__file__))
path = os.path.join(home_path, sub_suite, 'results')
sys.path.insert(0, path)
import compare_data as compare
compare.compare_results(benchmark, test_suite)
self.label4 = tk.Label(self, text=fil)
self.button2.grid(row = 5, column = 10)
app = testing()
app.mainloop()
and I need to pass it 'fil' from a different function which is run after pressing button through the function compare_results. In this function I've got:
import test_gui
test_gui.testing(fil)
To do this I think I need to define on_button as
def on_button(self, fil)
But then this returns the error that on_button requires two arguments. If I give fil a default value it will pass that to the label on pressing the button.
Is there a way of passing text from a function run through a gui back to the gui?
You can use lambda to pass more arguments to the button command.
So instead of
command = self.on_button
You could use
command = lambda: self.on_button(fil)
To pass 'fil' to the on_button function.
Is this what you had in mind?

AttributeError: 'QSlider' object has no attribute 'subtractStep'

I am getting an error when I try to run this code:
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'scaler_gui_3.ui'
#
# Created: Thu May 14 13:05:28 2015
# by: PyQt4 UI code generator 4.11.3
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName(_fromUtf8("Form"))
Form.resize(270, 219)
self.gridLayout_2 = QtGui.QGridLayout(Form)
self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2"))
self.horizontalSliderFrames = QtGui.QSlider(Form)
self.horizontalSliderFrames.setOrientation(QtCore.Qt.Horizontal)
self.horizontalSliderFrames.setObjectName(_fromUtf8("horizontalSliderFrames"))
self.gridLayout_2.addWidget(self.horizontalSliderFrames, 1, 0, 1, 1)
self.gridLayout = QtGui.QGridLayout()
self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
self.verticalScrollBarIW = QtGui.QScrollBar(Form)
self.verticalScrollBarIW.setOrientation(QtCore.Qt.Vertical)
self.verticalScrollBarIW.setObjectName(_fromUtf8("verticalScrollBarIW"))
self.gridLayout.addWidget(self.verticalScrollBarIW, 0, 2, 1, 1)
self.verticalLayout_2 = QtGui.QVBoxLayout()
self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2"))
self.labelMain = QtGui.QLabel(Form)
self.labelMain.setObjectName(_fromUtf8("labelMain"))
self.verticalLayout_2.addWidget(self.labelMain)
self.horizontalScrollBarIW = QtGui.QScrollBar(Form)
self.horizontalScrollBarIW.setOrientation(QtCore.Qt.Horizontal)
self.horizontalScrollBarIW.setObjectName(_fromUtf8("horizontalScrollBarIW"))
self.verticalLayout_2.addWidget(self.horizontalScrollBarIW)
self.gridLayout.addLayout(self.verticalLayout_2, 0, 0, 1, 1)
spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.gridLayout.addItem(spacerItem, 0, 1, 1, 1)
self.gridLayout_2.addLayout(self.gridLayout, 0, 0, 1, 1)
self.horizontalLayout_2 = QtGui.QHBoxLayout()
self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2"))
self.gridLayout_2.addLayout(self.horizontalLayout_2, 6, 1, 1, 1)
self.verticalLayout = QtGui.QVBoxLayout()
self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
self.horizontalLayout_3 = QtGui.QHBoxLayout()
self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3"))
self.labelSmallIW = QtGui.QLabel(Form)
self.labelSmallIW.setObjectName(_fromUtf8("labelSmallIW"))
self.horizontalLayout_3.addWidget(self.labelSmallIW)
self.labelBigIW = QtGui.QLabel(Form)
self.labelBigIW.setObjectName(_fromUtf8("labelBigIW"))
self.horizontalLayout_3.addWidget(self.labelBigIW)
self.pushButton = QtGui.QPushButton(Form)
self.pushButton.setObjectName(_fromUtf8("pushButton"))
self.horizontalLayout_3.addWidget(self.pushButton)
self.verticalLayout.addLayout(self.horizontalLayout_3)
self.gridLayout_2.addLayout(self.verticalLayout, 4, 0, 1, 1)
self.horizontalLayout = QtGui.QHBoxLayout()
self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
self.toolButtonLoad = QtGui.QToolButton(Form)
self.toolButtonLoad.setObjectName(_fromUtf8("toolButtonLoad"))
self.horizontalLayout.addWidget(self.toolButtonLoad)
self.prevButton = QtGui.QPushButton(Form)
self.prevButton.setObjectName(_fromUtf8("prevButton"))
self.horizontalLayout.addWidget(self.prevButton)
self.nextButton = QtGui.QPushButton(Form)
self.nextButton.setObjectName(_fromUtf8("nextButton"))
self.horizontalLayout.addWidget(self.nextButton)
self.gridLayout_2.addLayout(self.horizontalLayout, 2, 0, 1, 1)
self.checkBox = QtGui.QCheckBox(Form)
self.checkBox.setObjectName(_fromUtf8("checkBox"))
self.gridLayout_2.addWidget(self.checkBox, 5, 0, 1, 1)
self.retranslateUi(Form)
QtCore.QObject.connect(self.prevButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.horizontalSliderFrames.subtractStep)
QtCore.QObject.connect(self.nextButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.horizontalSliderFrames.addStep)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
Form.setWindowTitle(_translate("Form", "Form", None))
self.labelMain.setText(_translate("Form", "TextLabel", None))
self.labelSmallIW.setText(_translate("Form", "TextLabel", None))
self.labelBigIW.setText(_translate("Form", "TextLabel", None))
self.pushButton.setText(_translate("Form", "PushButton", None))
self.toolButtonLoad.setText(_translate("Form", "...", None))
self.prevButton.setText(_translate("Form", "<", None))
self.nextButton.setText(_translate("Form", ">", None))
self.checkBox.setText(_translate("Form", "CheckBox", None))
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
app.setStyle('cleanlooks')
Form = QtGui.QWidget()
ui = Ui_Form()
ui.setupUi(Form)
Form.show()
sys.exit(app.exec_())
It seems like similar error happen to other people due to some "class related problems" which I have no idea about. I do not understand why it seems to work fine when I "run" in from Geany text editor, but not when I run it from terminal using python my_gui.py I get this error :
Traceback (most recent call last):
File "gui_template.ui.py", line 136, in <module>
ui = Ui_Form()
File "gui_template.ui.py", line 39, in __init__
self.setupUi(self)
File "gui_template.ui.py", line 89, in setupUi
QtCore.QObject.connect(self.prevButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.horizontalSliderFrames.subtractStep)
AttributeError: 'QSlider' object has no attribute 'subtractStep'
I also tried creating a seperate .py file in a similar fashion to how this person does it:
https://youtu.be/FcX2FsPlVeI?t=10m25s
However, I still get the same error... Any ideas?
The addStep and subtractStep slots are deprecated members of QSlider. They are only there to provide backwards compatibility with Qt3.
It seems you must be trying to run the example script using builds of Qt4/PyQt4 that do not include such deprecated APIs.
The documentation suggests using the setValue slot instead. But that requires passing an appropriate increment/decrement value, so it's not really a drop-in replacement (especially if you're connecting the signals via Qt Designer).
If you wanted to fix the example, you'd have to replace the two signal/slot connections with something like:
def setSlider(delta):
self.horizontalSliderFrames.setValue(
self.horizontalSliderFrames.value() +
delta * self.horizontalSliderFrames.singleStep())
self.prevButton.clicked.connect(lambda: setSlider(-1))
self.nextButton.clicked.connect(lambda: setSlider(+1))

Attribute error while executing a python code

I am a student and working on GNU Radio.
I have a python code which i want to run in GNU radio companion but i am unable to search for the right block to execute that code...can anyone help me with that??When I execute the same python code(not in GNU), I get the following error:
AttributeError: 'top_block_sptr' object has no attribute 'wxgui_'
the code is as shown:
#!/usr/bin/env python
from gnuradio import blocks
from gnuradio import eng_notation
from gnuradio import gr
from gnuradio import uhd
#from gnuradio import window
from gnuradio.eng_option import eng_option
#from gnuradio.gr import firdes
from gnuradio.wxgui import forms
from gnuradio.wxgui import waterfallsink2
from grc_gnuradio import wxgui as grc_wxgui
from optparse import OptionParser
import wx
class top_block(grc_wxgui.top_block_gui):
def __init__(self):
grc_wxgui.top_block_gui.__init__(self, title="Top Block")
_icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))
##################################################
# Variables
###
###############################################
self.variable_slider_1 = variable_slider_1 = 32
self.variable_slider_0 = variable_slider_0 = 0
self.samp_rate = samp_rate = 21e6
self.gain = gain = variable_slider_1
self.delay_length = delay_length= variable_slider_0
##################################################
# Blocks
##################################################
self.wxgui_waterfallsink2_0_0 = waterfallsink2.waterfall_sink_c(
self.GetWin(),
baseband_freq=0,
dynamic_range=100,
ref_level=0,
ref_scale=2.0,
sample_rate=samp_rate,
fft_size=512,
fft_rate=15,
average=False,
avg_alpha=None,
title="Output Waterfall Plot",
)
self.GridAdd(self.wxgui_waterfallsink2_0_0.win, 0, 10, 10, 10)
self.wxgui_
waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
self.GetWin(),
baseband_freq=0,
dynamic_range=100,
ref_level=0,
ref_scale=2.0,
sample_rate=samp_rate,
fft_size=512,
fft_rate=15,
average=False,
avg_alpha=None,
title="Input Waterfall Plot",
)
self.GridAdd(self.wxgui_waterfallsink2_0.win, 0, 0, 10, 10)
_variable_slider_1_sizer = wx.BoxSizer(wx.VERTICAL)
self._variable_slider_1_text_box = forms.text_box(
parent=self.GetWin(),
sizer=_variable_slider_1_sizer,
value=self.variable_slider_1,
callback=self.set_variable_slider_1,
label="Output Gain",
converter=forms.float_converter(),
proportion=0,
)
self._variable_slider_1_slider = forms.slider(
parent=self.GetWin(),
sizer=_variable_slider_1_sizer,
value=self.variable_slider_1,
callback=self.set_variable_slider_1,
minimum=0,
maximum=32,
num_steps=31,
style=wx.SL_HORIZONTAL,
cast=float,
proportion=1,
)
self.GridAdd(_variable_slider_1_sizer, 12, 10, 1, 9)
_variable_sl
ider_0_sizer = wx.BoxSizer(wx.VERTICAL)
self._variable_slider_0_text_box = forms.text_box(
parent=self.GetWin(),
sizer=_variable_slider_0_sizer,
value=self.variable_slider_0,
callback=self.set_variable_slider_0,
label="Delay Length",
converter=forms.int_converter(),
proportion=0,
)
self._variable_slider_0_slider = forms.slider(
parent=self.GetWin(),
sizer=_variable_slider_0_sizer,
value=self.variable_slider_0,
callback=self.set_variable_slider_0,
minimum=0,
maximum=710000,
num_steps=1000,
style=wx.SL_HORIZONTAL,
cast=int,
proportion=1,
)
self.GridAdd(_variable_slider_0_sizer, 10, 10, 1, 9)
self.uhd_usrp_source_0 = uhd.usrp_source(
device_addr="",
stream_args=uhd.stream_args(
cpu_format="fc32",
channels=range(1),
),
)
self.uhd_usrp_source_0.set_samp_rate(samp_rate)
self.uhd_usrp_source_0.set_center_freq(2.28e9, 0)
self.uhd_usrp_source_0.set_gain(0, 0)
self.uhd_usrp_sink_0 = uhd.usrp_sink(
device_addr="",
stream_args
=uhd.stream_args(
cpu_format="fc32",
channels=range(1),
),
)
self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
self.uhd_usrp_sink_0.set_center_freq(2.28e9, 0)
self.uhd_usrp_sink_0.set_gain(gain, 0)
self.gr_file_source_0_0 = gr.file_source(
gr.sizeof_gr_complex*1,
"/home/ubuntu/radar-rx3.capture", True)
self.gr_file_source_0 = gr.file_source(gr.sizeof_gr_complex*1,
"/home/ubuntu/radar-rx3.capture", True)
self.gr_delay_0_0 = gr.delay(gr.sizeof_gr_complex*1, delay_length)
self.blocks_mult
iply_xx_0 = blocks.multiply_vcc(1)
##################################################
# Connections
##################################################
self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_waterfallsink2_0, 0))
self.connect((self.gr_file_source_0_0, 0), (self.gr_delay_0_0, 0))
self.connect((self.gr_file_source_0, 0), (self.blocks_multiply_xx_0, 0))
self.connect((self.gr_delay_0_0, 0), (self.blocks_multiply_xx_0, 1))
self.connect((self.blocks_multiply_xx_0, 0), (self.uhd_usrp_sink_0, 0))
self.connect((self.blocks_multiply_xx_0, 0), (self.wxgui_waterfallsink2_0_0, 0))
def get_variable_slider_1(self):
return self.variable_slider_1
def set_variable_slider_1(self, variable_slider_1):
self.variable_slider_1 = variable_slider_1
self.set_gain(self.variable_slider_1)
self._variable_slider_1_slider.set_value(self.variable_slider_1)
self._variable_slider_1_text_box.set_value(self.variable_slider_1)
def get_variable_slider_0(self):
return self.variable_slider_0
def set_variable_slider_0(self, variable_slider_0):
self.variable_slider_0 = variable_slider_0
self.set_delay_length(self.variable_slider_0)
self._variable_slider_0_slider.set_value(self.variable_slider_0)
self._variable_slider_0_text_box.set_value(self.variable_slider_0)
def get_samp_rate(self):
return self.samp_rate
def set_samp_rate(self, samp_rate):
self.samp_rate = samp_rate
self.wxgui_waterfallsink2_0.set_sample_rate(self.samp_rate)
self.wxgui_waterfallsink2_0_0.set_sample_rate(self.samp_rate)
self.uhd_usrp_sink_0.set_samp_rate(self.samp_rate)
self.uhd_usrp_source_0.set_samp_rate(self.samp_rate)
def get_gain(self):
return self.gain
def set_gain(self, gain):
self.gain = gain
self.uhd_usrp_sink_0.set_gain(self.gain, 0)
def get_delay_length(self):
return self.delay_length
def set_delay_length(self, delay_length):
self.delay_length = delay_length
self.gr_delay_0_0.set_delay(self.delay_length)
if __name__ == '__main__':
parser = OptionParser(option_class=eng_option,usage="%prog: [options]")
(options, args) = parser.parse_args()
tb = top_block()
tb.Run(True)
There's an erroneous line break in
self.wxgui_
waterfallsink2_0 = waterfallsink2.waterfall_sink_c(...
remove the wrong line breaks, and it should work. If in doubt, re-generate the python file using the GNU Radio Companion. Make sure your editor doesn't add line breaks where he should not.