Commit c3f21e4d authored by Béuren Bechlin's avatar Béuren Bechlin

Gerenciamento de configurações criado.

parent 442f3add
from json import dump, load
CONFIG_PATH = '../config/'
class ConfigurationManagement(Object):
def __init__(self):
class ConfigManag:
state = False
microc = dict()
@classmethod
def load(cls, CONFIG_PATH = 'config/'):
try:
with open((CONFIG_PATH + 'microcontroller.json'), 'r') as f:
config = load(f)
baud_rate = config['baud_rate']
cls.microc = load(f)
f.close()
except IOError:
baud_rate = [9600, 115220]
cls.microc['baud_rate'] = [9600, 115220]
cls.state = True
self.microc =
@classmethod
def getBaudRate(cls):
return cls.microc['baud_rate'].copy()
import sys
sys.path.append('../')
from configmanag import ConfigManag
from serialutils import ListSerialPorts
from PyQt4 import QtGui, QtCore
from json import load
RESOURCES_PATH = '../resources/'
CONFIG_PATH = '../config/'
class LogSpecWidget(QtGui.QWidget):
class LogSpecWidget(QtGui.QDialog):
def __init__(self, pattern = None):
super(LogSpecWidget, self).__init__(pattern)
wid_layout = QtGui.QVBoxLayout(self)
hbox = QtGui.QHBoxLayout()
hbox.addStretch(1)
hbox.addWidget(self.SerialCommGB())
hbox.addStretch(1)
wid_layout.addLayout(hbox)
hbox = QtGui.QHBoxLayout()
hbox.addStretch(1)
hbox.addWidget(self.FileAndTimeGB())
hbox.addStretch(1)
wid_layout.addLayout(hbox)
wid_layout.addStretch(1)
self.ok_btt = QtGui.QPushButton("OK")
self.cancel_btt = QtGui.QPushButton("Cancel")
hbox = QtGui.QHBoxLayout()
hbox.addStretch(1)
hbox.addWidget(self.ok_btt)
hbox.addWidget(self.cancel_btt)
wid_layout.addLayout(hbox)
def SerialCommGB(self):
vbox = QtGui.QVBoxLayout()
hbox = QtGui.QHBoxLayout()
......@@ -48,14 +72,8 @@ class LogSpecWidget(QtGui.QWidget):
self.baud_rate_cb = QtGui.QComboBox(self)
self.baud_rate_cb.setMinimumWidth(60)
try:
with open((CONFIG_PATH + 'microcontroller.json'), 'r') as f:
config = load(f)
baud_rate = config['baud_rate']
f.close()
except IOError:
baud_rate = [9600, 115220]
for item in baud_rate:
ConfigManag().load('../config/')
for item in ConfigManag().getBaudRate():
self.baud_rate_cb.addItem(str(item))
hbox = QtGui.QHBoxLayout()
......@@ -66,8 +84,11 @@ class LogSpecWidget(QtGui.QWidget):
vbox.addStretch(0.05)
gbox = QtGui.QGroupBox('Serial Comm')
gbox.setMaximumWidth(320)
gbox.setLayout(vbox)
wid_layout.addWidget(gbox)
return gbox
def FileAndTimeGB(self):
vbox = QtGui.QVBoxLayout()
self.save_file_cb = QtGui.QCheckBox(self)
......@@ -82,7 +103,7 @@ class LogSpecWidget(QtGui.QWidget):
vbox.addLayout(hbox)
self.file_path_le = QtGui.QLineEdit(self)
self.file_path_le.setMinimumWidth(120)
self.file_path_le.setMinimumWidth(150)
lbl = QtGui.QLabel(self)
lbl.setText('File Name:')
self.file_explorer_btt = QtGui.QToolButton(self)
......@@ -122,17 +143,9 @@ class LogSpecWidget(QtGui.QWidget):
self.unlimetedTime(self.unlimeted_time_cb.checkState())
gbox = QtGui.QGroupBox('File and Timming')
gbox.setMaximumWidth(320)
gbox.setLayout(vbox)
wid_layout.addWidget(gbox)
self.ok_btt = QtGui.QPushButton("OK")
self.cancel_btt = QtGui.QPushButton("Cancel")
hbox = QtGui.QHBoxLayout()
hbox.addStretch(1)
hbox.addWidget(self.ok_btt)
hbox.addWidget(self.cancel_btt)
wid_layout.addLayout(hbox)
return gbox
def refreshPorts(self):
busy = QtGui.QMovie(RESOURCES_PATH + 'busy2.gif')
......@@ -188,5 +201,6 @@ if __name__ == '__main__':
import sys
app = QtGui.QApplication(sys.argv)
main_w = LogSpecWidget()
main_w.setFixedSize(400, 300)
main_w.show()
sys.exit(app.exec_())
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment