diff --git a/software/back.png b/software/back.png new file mode 100644 index 0000000..659cd90 Binary files /dev/null and b/software/back.png differ diff --git a/software/main.py b/software/main.py index ff36e4f..3a5719f 100644 --- a/software/main.py +++ b/software/main.py @@ -1,23 +1,60 @@ #!/usr/bin/python from PyQt4.QtCore import pyqtSlot +from PyQt4.QtGui import QIcon from PyQt4.QtGui import QMainWindow from PyQt4.QtGui import QMessageBox from PyQt4.QtGui import QPixmap +from PyQt4.QtGui import QPushButton from mainUi import Ui_MainWindow +class ModuleButton(QPushButton): + + def __init__(self, mod, parent): + super(ModuleButton, self).__init__(QIcon("modules/%s.png" % mod.__class__.__name__), mod.title, parent) + self.setMinimumHeight(50) + self.mod = mod + self.form = parent + self.clicked.connect(self.on_clicked) + + def on_clicked(self): + self.form.ui.areaChoose.hide() + self.form.ui.btnExit.hide() + self.form.ui.btnBack.show() + self.form.ui.lblTitle.setText(self.mod.title) + self.mod.setup(self.form.ui.areaModule) + class Main(QMainWindow): def __init__(self): QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self) + self.ui.btnBack.hide() + self.ui.areaModule.hide() + self.addModuleButtons() @pyqtSlot() - def on_actionExit_triggered(self): + def on_btnExit_clicked(self): self.close() @pyqtSlot() - def on_actionAbout_triggered(self): + def on_btnBack_clicked(self): + self.ui.lblTitle.setText('EduBRM') + # TODO: erase everything from self.ui.areaModule + self.ui.areaChoose.show() + self.ui.areaModule.hide() + self.ui.btnExit.show() + self.ui.btnBack.hide() + + @pyqtSlot() + def on_btnAbout_clicked(self): box = QMessageBox(QMessageBox.NoIcon, "About EduBRM", "EduBRM by Hackerspace brmlab\n\nhttp://brmlab.cz/\n\nSee README for more information.", QMessageBox.Ok) box.setIconPixmap(QPixmap( ":/icons/icon.png")) box.exec_() + + def addModuleButtons(self): + import modules + for mod in modules.list(): + c = self.ui.gridLayout.count() + btn = ModuleButton(mod, self) + self.ui.gridLayout.addWidget(btn, c / 2, c % 2) diff --git a/software/main.ui b/software/main.ui index 701b9bb..0ef6680 100644 --- a/software/main.ui +++ b/software/main.ui @@ -10,6 +10,18 @@ 600 + + + 800 + 600 + + + + + 800 + 600 + + EduBRM @@ -18,64 +30,164 @@ :/icons/icon.png:/icons/icon.png - + 10 10 - 501 - 201 + 81 + 41 - + &Exit + + + + :/icons/exit.png:/icons/exit.png + + + + 710 + 10 + 81 + 41 + + + + &About + + + + :/icons/about.png:/icons/about.png + + + + + + 10 + 60 + 781 + 531 + + + + QFrame::NoFrame + + + true + + + + + 0 + 0 + 781 + 531 + + + + + + 0 + 0 + 781 + 531 + + + + + 10 + + + 10 + + + + + + + + + 100 + 10 + 601 + 41 + + + + + 24 + 75 + true + true + + + + EduBRM + + + Qt::AlignCenter + + + + + + 10 + 10 + 81 + 41 + + + + &Back + + + + :/icons/back.png:/icons/back.png + + + + + + 10 + 60 + 781 + 531 + + + + QFrame::NoFrame + + + true + + + + + 0 + 0 + 781 + 531 + + + + + lblTitle + areaModule + btnExit + btnAbout + areaChoose + btnBack - - - - 0 - 0 - 800 - 22 - - - - - &File - - - - - - &Help - - - - - - - - - - - :/icons/about.png:/icons/about.png - - - &About ... - - - - - - :/icons/exit.png:/icons/exit.png - - - E&xit - - + + btnAbout + btnExit + areaChoose + diff --git a/software/modules/ModuleA.png b/software/modules/ModuleA.png new file mode 100644 index 0000000..af7cef4 Binary files /dev/null and b/software/modules/ModuleA.png differ diff --git a/software/modules/ModuleA.py b/software/modules/ModuleA.py index 8367a46..c1b970d 100644 --- a/software/modules/ModuleA.py +++ b/software/modules/ModuleA.py @@ -2,7 +2,8 @@ from module import Module class ModuleA(Module): - group = "Acko" title = "Acko" - board = 1 - desc = "Toto je Acko" + + def setup(self, area): + print 'setup A' + print area diff --git a/software/modules/ModuleB.png b/software/modules/ModuleB.png new file mode 100644 index 0000000..494d785 Binary files /dev/null and b/software/modules/ModuleB.png differ diff --git a/software/modules/ModuleB.py b/software/modules/ModuleB.py index 452491c..6259e63 100644 --- a/software/modules/ModuleB.py +++ b/software/modules/ModuleB.py @@ -2,7 +2,8 @@ from module import Module class ModuleB(Module): - group = "Bcko" title = "Bcko" - board = 1 - desc = "Toto je Bcko" + + def setup(self, area): + print 'setup B' + print area diff --git a/software/modules/module.py b/software/modules/module.py index 8744a13..359328f 100644 --- a/software/modules/module.py +++ b/software/modules/module.py @@ -1,6 +1,6 @@ class Module(): - group = "" - title = "" - board = 1 - desc = "" + title = '' + + def start(self, area): + raise Exception('not implemented') diff --git a/software/resources.qrc b/software/resources.qrc index df30a20..13d046b 100644 --- a/software/resources.qrc +++ b/software/resources.qrc @@ -1,7 +1,10 @@ + back.png exit.png about.png icon.png + modules/ModuleA.png + modules/ModuleB.png