work on user interface

This commit is contained in:
Pavol Rusnak 2011-04-01 19:25:29 +02:00
parent 333079d8a7
commit 68d5066b23
9 changed files with 213 additions and 59 deletions

BIN
software/back.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 655 B

View file

@ -1,23 +1,60 @@
#!/usr/bin/python #!/usr/bin/python
from PyQt4.QtCore import pyqtSlot from PyQt4.QtCore import pyqtSlot
from PyQt4.QtGui import QIcon
from PyQt4.QtGui import QMainWindow from PyQt4.QtGui import QMainWindow
from PyQt4.QtGui import QMessageBox from PyQt4.QtGui import QMessageBox
from PyQt4.QtGui import QPixmap from PyQt4.QtGui import QPixmap
from PyQt4.QtGui import QPushButton
from mainUi import Ui_MainWindow 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): class Main(QMainWindow):
def __init__(self): def __init__(self):
QMainWindow.__init__(self) QMainWindow.__init__(self)
self.ui = Ui_MainWindow() self.ui = Ui_MainWindow()
self.ui.setupUi(self) self.ui.setupUi(self)
self.ui.btnBack.hide()
self.ui.areaModule.hide()
self.addModuleButtons()
@pyqtSlot() @pyqtSlot()
def on_actionExit_triggered(self): def on_btnExit_clicked(self):
self.close() self.close()
@pyqtSlot() @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 = 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.setIconPixmap(QPixmap( ":/icons/icon.png"))
box.exec_() 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)

View file

@ -10,6 +10,18 @@
<height>600</height> <height>600</height>
</rect> </rect>
</property> </property>
<property name="minimumSize">
<size>
<width>800</width>
<height>600</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>800</width>
<height>600</height>
</size>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>EduBRM</string> <string>EduBRM</string>
</property> </property>
@ -18,64 +30,164 @@
<normaloff>:/icons/icon.png</normaloff>:/icons/icon.png</iconset> <normaloff>:/icons/icon.png</normaloff>:/icons/icon.png</iconset>
</property> </property>
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<widget class="QLabel" name="txtDesc"> <widget class="QPushButton" name="btnExit">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>10</y> <y>10</y>
<width>501</width> <width>81</width>
<height>201</height> <height>41</height>
</rect> </rect>
</property> </property>
<property name="text"> <property name="text">
<string/> <string>&amp;Exit</string>
</property> </property>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menu_File">
<property name="title">
<string>&amp;File</string>
</property>
<addaction name="actionExit"/>
</widget>
<widget class="QMenu" name="menu_Help">
<property name="title">
<string>&amp;Help</string>
</property>
<addaction name="actionAbout"/>
</widget>
<addaction name="menu_File"/>
<addaction name="menu_Help"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<action name="actionAbout">
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/icons/about.png</normaloff>:/icons/about.png</iconset>
</property>
<property name="text">
<string>&amp;About ...</string>
</property>
</action>
<action name="actionExit">
<property name="icon"> <property name="icon">
<iconset resource="resources.qrc"> <iconset resource="resources.qrc">
<normaloff>:/icons/exit.png</normaloff>:/icons/exit.png</iconset> <normaloff>:/icons/exit.png</normaloff>:/icons/exit.png</iconset>
</property> </property>
<property name="text">
<string>E&amp;xit</string>
</property>
</action>
</widget> </widget>
<widget class="QPushButton" name="btnAbout">
<property name="geometry">
<rect>
<x>710</x>
<y>10</y>
<width>81</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>&amp;About</string>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/icons/about.png</normaloff>:/icons/about.png</iconset>
</property>
</widget>
<widget class="QScrollArea" name="areaChoose">
<property name="geometry">
<rect>
<x>10</x>
<y>60</y>
<width>781</width>
<height>531</height>
</rect>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="areaChooseContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>781</width>
<height>531</height>
</rect>
</property>
<widget class="QWidget" name="gridLayoutWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>781</width>
<height>531</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>10</number>
</property>
<property name="spacing">
<number>10</number>
</property>
</layout>
</widget>
</widget>
</widget>
<widget class="QLabel" name="lblTitle">
<property name="geometry">
<rect>
<x>100</x>
<y>10</y>
<width>601</width>
<height>41</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>24</pointsize>
<weight>75</weight>
<bold>true</bold>
<kerning>true</kerning>
</font>
</property>
<property name="text">
<string>EduBRM</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QPushButton" name="btnBack">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>81</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>&amp;Back</string>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/icons/back.png</normaloff>:/icons/back.png</iconset>
</property>
</widget>
<widget class="QScrollArea" name="areaModule">
<property name="geometry">
<rect>
<x>10</x>
<y>60</y>
<width>781</width>
<height>531</height>
</rect>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="areaModuleContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>781</width>
<height>531</height>
</rect>
</property>
</widget>
</widget>
<zorder>lblTitle</zorder>
<zorder>areaModule</zorder>
<zorder>btnExit</zorder>
<zorder>btnAbout</zorder>
<zorder>areaChoose</zorder>
<zorder>btnBack</zorder>
</widget>
</widget>
<tabstops>
<tabstop>btnAbout</tabstop>
<tabstop>btnExit</tabstop>
<tabstop>areaChoose</tabstop>
</tabstops>
<resources> <resources>
<include location="resources.qrc"/> <include location="resources.qrc"/>
</resources> </resources>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View file

@ -2,7 +2,8 @@ from module import Module
class ModuleA(Module): class ModuleA(Module):
group = "Acko"
title = "Acko" title = "Acko"
board = 1
desc = "Toto je Acko" def setup(self, area):
print 'setup A'
print area

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View file

@ -2,7 +2,8 @@ from module import Module
class ModuleB(Module): class ModuleB(Module):
group = "Bcko"
title = "Bcko" title = "Bcko"
board = 1
desc = "Toto je Bcko" def setup(self, area):
print 'setup B'
print area

View file

@ -1,6 +1,6 @@
class Module(): class Module():
group = "" title = ''
title = ""
board = 1 def start(self, area):
desc = "" raise Exception('not implemented')

View file

@ -1,7 +1,10 @@
<RCC> <RCC>
<qresource prefix="icons"> <qresource prefix="icons">
<file>back.png</file>
<file>exit.png</file> <file>exit.png</file>
<file>about.png</file> <file>about.png</file>
<file>icon.png</file> <file>icon.png</file>
<file>modules/ModuleA.png</file>
<file>modules/ModuleB.png</file>
</qresource> </qresource>
</RCC> </RCC>