From ddc89d166431436b2ca1079be4b1a8acffd308a4 Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Wed, 17 Feb 2016 23:47:43 +0300 Subject: [PATCH] settins + mainscreen 1/6 --- src/mainscreen.py | 66 +++++++++++++++++++++++++++++++++++++++++++++++ src/settings.py | 5 +++- 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/src/mainscreen.py b/src/mainscreen.py index e69de29..e585deb 100644 --- a/src/mainscreen.py +++ b/src/mainscreen.py @@ -0,0 +1,66 @@ +# -*- coding: utf-8 -*- + +import sys +from PySide import QtGui, QtCore + + +class MainWindow(QtGui.QWidget): + + def __init__(self): + super(MainWindow, self).__init__() + self.initUI() + + def setup_left_top(self, Form): + Form.setObjectName("Form") + Form.resize(500, 300) + Form.setMinimumSize(QtCore.QSize(250, 100)) + Form.setMaximumSize(QtCore.QSize(250, 100)) + Form.setBaseSize(QtCore.QSize(2500, 100)) + self.graphicsView = QtGui.QGraphicsView(Form) + self.graphicsView.setGeometry(QtCore.QRect(10, 20, 64, 64)) + self.graphicsView.setMinimumSize(QtCore.QSize(64, 64)) + self.graphicsView.setMaximumSize(QtCore.QSize(64, 64)) + self.graphicsView.setBaseSize(QtCore.QSize(64, 64)) + self.graphicsView.setObjectName("graphicsView") + self.label = QtGui.QLabel(Form) + self.label.setGeometry(QtCore.QRect(80, 30, 191, 17)) + font = QtGui.QFont() + font.setFamily("Times New Roman") + font.setPointSize(18) + font.setWeight(75) + font.setBold(True) + self.label.setFont(font) + self.label.setObjectName("label") + self.label_2 = QtGui.QLabel(Form) + self.label_2.setGeometry(QtCore.QRect(80, 60, 191, 17)) + font = QtGui.QFont() + font.setFamily("Times New Roman") + font.setPointSize(16) + font.setWeight(50) + font.setBold(False) + self.label_2.setFont(font) + self.label_2.setObjectName("label_2") + self.graphicsView_2 = QtGui.QGraphicsView(Form) + self.graphicsView_2.setGeometry(QtCore.QRect(200, 34, 64, 64)) + self.graphicsView_2.setMinimumSize(QtCore.QSize(32, 32)) + self.graphicsView_2.setMaximumSize(QtCore.QSize(32, 32)) + self.graphicsView_2.setBaseSize(QtCore.QSize(32, 32)) + self.graphicsView_2.setObjectName("graphicsView_2") + + def initUI(self): + + grid = QtGui.QGridLayout() + name = QtGui.QWidget() + self.setup_left_top(name) + grid.addWidget(name, 0, 0) + + self.setLayout(grid) + self.setMinimumSize(200, 200) + self.setGeometry(300, 300, 300, 200) + self.setWindowTitle('Toxygen') + self.show() + +if __name__ == '__main__': + app = QtGui.QApplication(sys.argv) + ex = MainWindow() + sys.exit(app.exec_()) diff --git a/src/settings.py b/src/settings.py index 8dd1e76..ef68c4c 100644 --- a/src/settings.py +++ b/src/settings.py @@ -7,13 +7,13 @@ class Settings(object): def __init__(self): self.path = Settings.get_default_path() + 'toxygen.json' - # TODO: create new if old not found if os.path.exists(self.path): with open(self.path) as fl: data = fl.read() self.data = json.loads(data) else: self.create_default_settings() + self.save() def create_default_settings(self): self.data = { @@ -40,6 +40,9 @@ class Settings(object): def __get__(self, attr): return self.data[attr] + def __set__(self, attr, value): + self.data[attr] = value + def save(self): text = json.dumps(self.data) with open(self.path, 'w') as fl: