Skip to content

Commit

Permalink
GUI: bug fix JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
MLsmd committed Aug 15, 2017
1 parent e39cc9f commit 3b735bd
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 76 deletions.
14 changes: 9 additions & 5 deletions python/GUI/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from PyQt4 import QtGui
from PyQt4.QtCore import QTimer
from PyQt4 import QtCore
import sys
import time
import user_frontend
Expand All @@ -18,9 +19,9 @@ class DABstep(QtGui.QMainWindow, user_frontend.Ui_MainWindow):
def __init__(self, parent=None):
super(DABstep, self).__init__(parent)
self.setupUi(self)

# window title
self.setWindowTitle("DABstep - A DAB/DAB+ transceiver app")
self.resize(5000, 5000)
# show logo if it exists
if os.path.exists("DAB_logo.png"):
self.label_logo.setText("<img src=\"DAB_logo.png\">")
Expand Down Expand Up @@ -418,13 +419,13 @@ def set_volume(self):
self.my_receiver.set_volume(float(self.slider_volume.value()) / 100)

def get_ensemble_info(self):
json = self.my_receiver.get_ensemble_info()
if json is "":
self.json = self.my_receiver.get_ensemble_info()
if self.json is "":
return {"unknown":{"country_ID":0}}
else:
# load string (json) with ensemble info and convert it to dictionary
# string structure example: "{\"SWR_BW_N\":{\"country_ID\":1}}"
self.ensemble_info = json.loads(json)
self.ensemble_info = json.loads(self.json)
json.dumps(self.ensemble_info)
return self.ensemble_info

Expand Down Expand Up @@ -495,7 +496,7 @@ def dev_mode_init(self):
#self.time_plot.hide()
# constellation plot
self.constellation = sip.wrapinstance(self.my_receiver.constellation_plot.pyqwidget(), QtGui.QWidget)
self.vertical_layout_dev_mode_right.addWidget(self.constellation)
self.horitontal_layout_dev_mode_bottom.addWidget(self.constellation)
self.constellation.hide()
# if dev mode is initialized, we can enable the dev mode open button
self.btn_dev_mode_open.setEnabled(True)
Expand Down Expand Up @@ -523,6 +524,9 @@ def dev_mode_close(self):
self.waterfall_plot.hide()
self.constellation.hide()
self.label_firecode.hide()
print "key"
self.resize(2000, 2000)


def update_firecode(self):
if self.dev_mode_active:
Expand Down
48 changes: 24 additions & 24 deletions python/GUI/user_frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,10 @@ def setupUi(self, MainWindow):
self.verticalLayout_7.setObjectName(_fromUtf8("verticalLayout_7"))
self.horizontalLayout_27 = QtGui.QHBoxLayout()
self.horizontalLayout_27.setSizeConstraint(QtGui.QLayout.SetDefaultConstraint)
self.horizontalLayout_27.setSpacing(6)
self.horizontalLayout_27.setObjectName(_fromUtf8("horizontalLayout_27"))
self.label_ensemble = QtGui.QLabel(self.tab_reception)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.label_ensemble.sizePolicy().hasHeightForWidth())
Expand All @@ -179,8 +180,6 @@ def setupUi(self, MainWindow):
self.verticalLayout_10 = QtGui.QVBoxLayout()
self.verticalLayout_10.setSizeConstraint(QtGui.QLayout.SetDefaultConstraint)
self.verticalLayout_10.setObjectName(_fromUtf8("verticalLayout_10"))
spacerItem3 = QtGui.QSpacerItem(20, 0, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.verticalLayout_10.addItem(spacerItem3)
self.horizontalLayout_28 = QtGui.QHBoxLayout()
self.horizontalLayout_28.setSizeConstraint(QtGui.QLayout.SetDefaultConstraint)
self.horizontalLayout_28.setObjectName(_fromUtf8("horizontalLayout_28"))
Expand All @@ -203,10 +202,13 @@ def setupUi(self, MainWindow):
self.label_country.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_country.setObjectName(_fromUtf8("label_country"))
self.verticalLayout_10.addWidget(self.label_country)
spacerItem4 = QtGui.QSpacerItem(20, 0, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.verticalLayout_10.addItem(spacerItem4)
self.horizontalLayout_27.addLayout(self.verticalLayout_10)
self.verticalLayout_7.addLayout(self.horizontalLayout_27)
self.line_11 = QtGui.QFrame(self.tab_reception)
self.line_11.setFrameShape(QtGui.QFrame.HLine)
self.line_11.setFrameShadow(QtGui.QFrame.Sunken)
self.line_11.setObjectName(_fromUtf8("line_11"))
self.verticalLayout_7.addWidget(self.line_11)
self.horizontalLayout_23 = QtGui.QHBoxLayout()
self.horizontalLayout_23.setObjectName(_fromUtf8("horizontalLayout_23"))
self.bar_snr = QtGui.QProgressBar(self.tab_reception)
Expand Down Expand Up @@ -272,8 +274,6 @@ def setupUi(self, MainWindow):
self.line_7.setFrameShadow(QtGui.QFrame.Sunken)
self.line_7.setObjectName(_fromUtf8("line_7"))
self.verticalLayout_7.addWidget(self.line_7)
spacerItem5 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.verticalLayout_7.addItem(spacerItem5)
self.horizontalLayout_26 = QtGui.QHBoxLayout()
self.horizontalLayout_26.setObjectName(_fromUtf8("horizontalLayout_26"))
self.btn_init = QtGui.QPushButton(self.tab_reception)
Expand All @@ -297,10 +297,10 @@ def setupUi(self, MainWindow):
self.line_9.setFrameShadow(QtGui.QFrame.Sunken)
self.line_9.setObjectName(_fromUtf8("line_9"))
self.verticalLayout_7.addWidget(self.line_9)
spacerItem3 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.verticalLayout_7.addItem(spacerItem3)
self.label_2 = QtGui.QLabel(self.tab_reception)
font = QtGui.QFont()
font.setFamily(_fromUtf8("Abyssinica SIL"))
font.setPointSize(12)
font.setBold(True)
font.setWeight(75)
self.label_2.setFont(font)
Expand Down Expand Up @@ -366,8 +366,8 @@ def setupUi(self, MainWindow):
self.t_rbtn_USRP.setChecked(True)
self.t_rbtn_USRP.setObjectName(_fromUtf8("t_rbtn_USRP"))
self.horizontalLayout_9.addWidget(self.t_rbtn_USRP)
spacerItem6 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.horizontalLayout_9.addItem(spacerItem6)
spacerItem4 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.horizontalLayout_9.addItem(spacerItem4)
self.t_label_frequency = QtGui.QLabel(self.tab_transmission)
self.t_label_frequency.setObjectName(_fromUtf8("t_label_frequency"))
self.horizontalLayout_9.addWidget(self.t_label_frequency)
Expand Down Expand Up @@ -413,8 +413,8 @@ def setupUi(self, MainWindow):
self.verticalLayout_5.addLayout(self.horizontalLayout_10)
self.horizontalLayout_31 = QtGui.QHBoxLayout()
self.horizontalLayout_31.setObjectName(_fromUtf8("horizontalLayout_31"))
spacerItem7 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.horizontalLayout_31.addItem(spacerItem7)
spacerItem5 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.horizontalLayout_31.addItem(spacerItem5)
self.label_8 = QtGui.QLabel(self.tab_transmission)
self.label_8.setObjectName(_fromUtf8("label_8"))
self.horizontalLayout_31.addWidget(self.label_8)
Expand Down Expand Up @@ -856,8 +856,8 @@ def setupUi(self, MainWindow):
self.line.setFrameShadow(QtGui.QFrame.Sunken)
self.line.setObjectName(_fromUtf8("line"))
self.formLayout_2.setWidget(3, QtGui.QFormLayout.LabelRole, self.line)
spacerItem8 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.formLayout_2.setItem(8, QtGui.QFormLayout.FieldRole, spacerItem8)
spacerItem6 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.formLayout_2.setItem(8, QtGui.QFormLayout.FieldRole, spacerItem6)
self.verticalLayout_8.addLayout(self.formLayout_2)
self.horizontalLayout_22 = QtGui.QHBoxLayout()
self.horizontalLayout_22.setObjectName(_fromUtf8("horizontalLayout_22"))
Expand All @@ -872,8 +872,8 @@ def setupUi(self, MainWindow):
self.t_label_status = QtGui.QLabel(self.tab_transmission)
self.t_label_status.setObjectName(_fromUtf8("t_label_status"))
self.horizontalLayout_22.addWidget(self.t_label_status)
spacerItem9 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.horizontalLayout_22.addItem(spacerItem9)
spacerItem7 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.horizontalLayout_22.addItem(spacerItem7)
self.verticalLayout_8.addLayout(self.horizontalLayout_22)
self.line_10 = QtGui.QFrame(self.tab_transmission)
self.line_10.setFrameShape(QtGui.QFrame.HLine)
Expand Down Expand Up @@ -932,10 +932,10 @@ def setupUi(self, MainWindow):
self.verticalLayout_3.addLayout(self.horizontalLayout_7)
self.mode_tabs.addTab(self.tab_transmission, _fromUtf8(""))
self.verticalLayout.addWidget(self.mode_tabs)
self.horizontalLayout_29 = QtGui.QHBoxLayout()
self.horizontalLayout_29.setObjectName(_fromUtf8("horizontalLayout_29"))
spacerItem10 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.horizontalLayout_29.addItem(spacerItem10)
self.horitontal_layout_dev_mode_bottom = QtGui.QHBoxLayout()
self.horitontal_layout_dev_mode_bottom.setObjectName(_fromUtf8("horitontal_layout_dev_mode_bottom"))
spacerItem8 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.horitontal_layout_dev_mode_bottom.addItem(spacerItem8)
self.label_firecode = QtGui.QLabel(self.centralwidget)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
Expand All @@ -950,16 +950,16 @@ def setupUi(self, MainWindow):
self.label_firecode.setMidLineWidth(0)
self.label_firecode.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop)
self.label_firecode.setObjectName(_fromUtf8("label_firecode"))
self.horizontalLayout_29.addWidget(self.label_firecode)
self.verticalLayout.addLayout(self.horizontalLayout_29)
self.horitontal_layout_dev_mode_bottom.addWidget(self.label_firecode)
self.verticalLayout.addLayout(self.horitontal_layout_dev_mode_bottom)
MainWindow.setCentralWidget(self.centralwidget)
self.statusBar = QtGui.QStatusBar(MainWindow)
self.statusBar.setAutoFillBackground(False)
self.statusBar.setObjectName(_fromUtf8("statusBar"))
MainWindow.setStatusBar(self.statusBar)

self.retranslateUi(MainWindow)
self.mode_tabs.setCurrentIndex(1)
self.mode_tabs.setCurrentIndex(0)
QtCore.QMetaObject.connectSlotsByName(MainWindow)

def retranslateUi(self, MainWindow):
Expand Down
76 changes: 29 additions & 47 deletions python/GUI/user_frontend.ui
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
<bool>true</bool>
</property>
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="tab_reception">
<attribute name="title">
Expand Down Expand Up @@ -297,13 +297,16 @@
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_27">
<property name="spacing">
<number>6</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QLabel" name="label_ensemble">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
Expand All @@ -326,19 +329,6 @@
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_28">
<property name="sizeConstraint">
Expand Down Expand Up @@ -382,23 +372,17 @@
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_11">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_23">
<item>
Expand Down Expand Up @@ -532,22 +516,6 @@
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_26">
<item>
Expand Down Expand Up @@ -594,12 +562,26 @@
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<family>Abyssinica SIL</family>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
Expand Down Expand Up @@ -1898,7 +1880,7 @@
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_29">
<layout class="QHBoxLayout" name="horitontal_layout_dev_mode_bottom">
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
Expand Down

0 comments on commit 3b735bd

Please sign in to comment.