-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathui.py
More file actions
72 lines (52 loc) · 2.45 KB
/
ui.py
File metadata and controls
72 lines (52 loc) · 2.45 KB
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
65
66
67
68
69
import logging, yaml, importlib
from PyQt5 import QtCore
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
class FloatArea(QMdiArea):
global label
_modules = []
_widgets = []
global cfg
def __init__(self, parent=None):
super(FloatArea, self).__init__(parent)
with open("config.yml", 'r') as ymlfile:
self.cfg = yaml.load(ymlfile)
self.maximumSize()
self.setupBackground()
self.initWidgets()
def setupBackground(self):
label = QLabel("")
if 'background' in self.cfg['general']:
if self.cfg['general']['background'][0] == '#':
label.setStyleSheet("QLabel"
"{ background-color: " +
self.cfg['general']['background'] + "; "
"border:1px solid rgb(0,0,0); }")
else:
label.setStyleSheet("QLabel"
"{ border-image: url("+
self.cfg['general']['background']+"); "
"border:1px solid rgb(0,0,0); }")
self._blub = self.addSubWindow(label, Qt.FramelessWindowHint | Qt.WindowDoesNotAcceptFocus)
self._blub.setFocusPolicy(Qt.NoFocus)
def resizeEvent(self, QResizeEvent):
logging.info('Area.resizeEvent central widget size w ' + str(self.width()) + " h " + str(self.width()))
self._blub.resize(self.width(),self.height())
def importWidget(self, index, key):
logging.info(self.cfg['widgets'][key]['class'])
#Import modules
self._modules.append(importlib.import_module('widgets.'+key))
logging.info("module " + str(self._modules[index]))
#Create and store instance
self._widgets.append(getattr(self._modules[index], self.cfg['widgets'][key]['class'])(self.cfg['widgets'][key]))
#Add widget to main window
logging.info("widgets " + str(self._widgets[index]))
_subwindow = self.addSubWindow(self._widgets[index])
#Set subwindow containing widget transparent
_subwindow.setWindowFlags(QtCore.Qt.FramelessWindowHint)
_subwindow.setAttribute(QtCore.Qt.WA_TranslucentBackground)
self._widgets[index].configure()
def initWidgets(self):
for index, key in enumerate(self.cfg['widgets']):
logging.info("index " + str(index) + ' key ' + key)
self.importWidget(index, key)