forked from garyjohnson/ci_screen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_window.py
More file actions
38 lines (28 loc) · 1.18 KB
/
main_window.py
File metadata and controls
38 lines (28 loc) · 1.18 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
try:
import ConfigParser as config
except:
import configparser as config
from PyQt5.Qt import QUrl, QQuickView, Qt, QWindow, QVariant, pyqtProperty, pyqtSignal
class MainWindow(QQuickView):
rotation_changed = pyqtSignal()
def __init__(self, *args, **kwargs):
super(QQuickView, self).__init__()
self._rotation = self.get_rotation()
self.engine().rootContext().setContextProperty('screenRotation', QVariant(self.rotation))
self.setSource(QUrl('main.qml'))
self.setHeight(self.screen().size().height())
self.setWidth(self.screen().size().width())
self.setResizeMode(QQuickView.SizeRootObjectToView)
self.setFlags(Qt.WindowFullscreenButtonHint)
@pyqtProperty(int, notify=rotation_changed)
def rotation(self):
return self._rotation
@rotation.setter
def rotation(self, value):
self._rotation = value
self.rotation_changed.emit()
def get_rotation(self):
config_parser = config.SafeConfigParser(allow_no_value=False)
with open('ci_screen.cfg') as config_file:
config_parser.readfp(config_file)
return int(config_parser.get('general', 'rotation'))