-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.py
64 lines (59 loc) · 2.1 KB
/
settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
#
# This file is part of Camino.
# Copyright (C) 2017 Manuel Luitz <[email protected]>
#
# Camino is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Camino is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Camino. If not, see <http://www.gnu.org/licenses/>.
#
from PyQt4 import QtGui,QtCore
import settings_window
class Units():
units = 0
def setMetric(self):
self.units = 0
def setImperial(self):
self.units = 1
def isMetric(self):
return self.units == 0
def isImperial(self):
return self.units == 1
def get(self):
if self.isMetric():
return self.metric()
elif self.isImperial():
return self.imperial()
def set(self, text):
if text == self.metric(): self.setMetric()
if text == self.imperial(): self.setImperial()
def metric(self):
return "Metric"
def imperial(self):
return "Imperial"
class Settings(QtGui.QMainWindow, settings_window.Ui_MainWindow):
serial_port = '/dev/ttyACM0'
units = Units()
def __init__(self, parent=None):
super(Settings, self).__init__(parent)
self.setupUi(self)
self.pushButtonApply.clicked.connect(self.applySettings)
def applySettings(self):
self.serial_port = self.lineEditSerialDevice.text()
self.units.set(self.comboBoxUnits.currentText())
def show(self):
super(Settings, self).show()
self.lineEditSerialDevice.setText(self.serial_port)
index = self.comboBoxUnits.findText(self.units.get(), QtCore.Qt.MatchFixedString)
if index >= 0:
self.comboBoxUnits.setCurrentIndex(index)