-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathqt_field_test_main.py
109 lines (88 loc) · 3.39 KB
/
qt_field_test_main.py
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# -*- coding: UTF-8 -*-
import sys
import os
from LogDecoderTabview import LogDecoderTabview
from MainWindowTabview import MainWindowTabview
import qdarkstyle
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from SupportingWindows import AboutMessageBox
import getpass
VERSION = '0.4 Alpha'
LAST_UPDATE = '2019.03.23'
class QuectelDebugLogAnalyzer(QMainWindow):
def __init__(self):
super(QuectelDebugLogAnalyzer, self).__init__()
self.version = VERSION
self.title = 'Quectel UE Debug Log Analyzer ' + self.version
self.left = 50
self.top = 50
self.width = 1480
self.height = 940
self.max_width = 1920
self.max_height = 1440
self.min_width = 980
self.min_height = 750
# small screen device rendering
my_desktop = QDesktopWidget()
screen = my_desktop.screenGeometry()
screen_height = screen.height()
print('[DEBUG] Screen resolution:', screen.width(), 'x', screen_height)
self.small_screen_flag = False
if screen_height < 1000:
self.small_screen_flag = True
self.init_ui()
def init_ui(self):
self.setWindowIcon(QIcon('./assets/img/mouse.png'))
self.setWindowTitle(self.title)
self.setGeometry(self.left, self.top,
self.width, self.height)
if self.small_screen_flag:
self.setGeometry(20, 25, self.width, 738)
self.setMaximumSize(self.max_width, self.max_height)
self.setMinimumSize(self.min_width, self.min_height)
# status bar
self.statusBar().showMessage('Everything works well. A status bar makes a complete GUI software.')
# menu bar
main_menu = self.menuBar()
file_menu = main_menu.addMenu('File')
help_menu = main_menu.addMenu('Help')
# buttons in menu bar
exit_button = QAction(QIcon('./assets/img/exit_button.png'), 'Exit', self)
exit_button.setShortcut('Ctrl+Q')
exit_button.setStatusTip('Exit Coverage Measurement Logger')
exit_button.triggered.connect(self.close)
file_menu.addAction(exit_button)
about_button = QAction(QIcon('./assets/img/info.png'), 'About', self)
about_button.triggered.connect(self.about_page)
help_menu.addAction(about_button)
# add tabView
# self.main_view = LogDecoderTabview()
# self.setCentralWidget(self.main_view)
self.table_widget = MainWindowTabview()
self.setCentralWidget(self.table_widget)
self.show()
@pyqtSlot(name='SHOW_ABOUT_DIALOG')
def about_page(self):
about_dialog = AboutMessageBox()
about_dialog.exec_()
def run():
# Do some system/computer specific settings
my_name = getpass.getuser()
print('[DEBUG] Username:', my_name)
if my_name == 'lenovo':
os.putenv('QT_SCALE_FACTOR', '1.0')
elif my_name == 'SequoiaX':
os.putenv('QT_SCALE_FACTOR', '1.0')
# Create the app
my_app = QApplication(sys.argv)
# Change the fonts
if sys.platform != 'linux':
local_font = QFont('Segoe UI', 9) # 'Segoe UI'
my_app.setFont(local_font)
# my_app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5()) # dark mode. You need to run `pip install qdarkstyle` first.
ex = QuectelDebugLogAnalyzer()
sys.exit(my_app.exec_())
if __name__ == '__main__':
run()