-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainWindow.py
More file actions
95 lines (80 loc) · 3.61 KB
/
mainWindow.py
File metadata and controls
95 lines (80 loc) · 3.61 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
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
import os
import time
from PyQt5 import QtCore, QtGui, QtWidgets
from settings import settings
class UIMainWindow(object):
def setupUi(self, MainWindow: QtWidgets.QWidget):
self.MainWindow = MainWindow
self.MainWindow.setObjectName("MainWindow")
self.MainWindow.resize(*settings.baseWindowSize)
self.layout = QtWidgets.QVBoxLayout(self.MainWindow)
self.layout.setObjectName("layout")
self.layout.setContentsMargins(*settings.windowContentMargin)
MainWindow.setLayout(self.layout)
#timer
self.timer = QtCore.QTimer(self.MainWindow)
self.timer.setInterval(1000)
self.timer.timeout.connect(self.updateClock)
self.timer.start()
# layout of welcome
self.welcome = QtWidgets.QHBoxLayout(self.MainWindow)
self.welcome.setObjectName("welcome")
self.layout.addLayout(self.welcome)
#welcome text
self.welcomeText = QtWidgets.QLabel(self.MainWindow)
font = QtGui.QFont()
font.setFamily("Microsoft YaHei UI")
font.setPointSize(36)
font.setBold(True)
font.setWeight(75)
self.welcomeText.setFont(font)
self.welcomeText.setWhatsThis("")
self.welcomeText.setTextFormat(QtCore.Qt.RichText)
self.welcomeText.setScaledContents(False)
self.welcomeText.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter)
self.welcomeText.setIndent(4)
self.welcomeText.setMaximumHeight(70)
self.welcomeText.setObjectName("welcomeText")
self.welcome.addWidget(self.welcomeText)
#clock
self.time = QtWidgets.QLCDNumber(self.MainWindow)
self.time.setObjectName("time")
self.time.setDigitCount(8)
self.time.setMaximumHeight(70)
self.updateClock()
self.welcome.addWidget(self.time)
#welcome picture
self.welcomePic = QtWidgets.QLabel(self.MainWindow)
self.welcomePic.setText("")
self.welcomePic.setPixmap(QtGui.QPixmap(".\\resource\\welcome.png"))
self.welcomePic.setScaledContents(True)
self.welcomePic.setObjectName("welcomePic")
self.welcomePic.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
self.layout.addWidget(self.welcomePic)
# control layout
self.buttons = QtWidgets.QHBoxLayout()
self.buttons.setObjectName("buttons")
self.layout.addLayout(self.buttons)
#help button
self.helpButton = QtWidgets.QPushButton(self.MainWindow)
self.helpButton.setObjectName("helpButton")
self.buttons.addWidget(self.helpButton)
self.helpButton.clicked.connect(self.openHelp)
#exit button
self.exitButton = QtWidgets.QPushButton(self.MainWindow)
self.exitButton.setObjectName("exitButton")
self.buttons.addWidget(self.exitButton)
self.exitButton.clicked.connect(QtWidgets.QApplication.instance().quit)
self.retranslateUi()
QtCore.QMetaObject.connectSlotsByName(self.MainWindow)
def retranslateUi(self):
_translate = QtCore.QCoreApplication.translate
self.MainWindow.setWindowTitle(_translate("MainWindow", "EasyNote简单笔记"))
self.welcomeText.setText(_translate("MainWindow", "欢迎!"))
self.exitButton.setText(_translate("MainWindow", "退出"))
self.helpButton.setText(_translate("MainWindow", "帮助"))
def updateClock(self):
self.time.display(time.strftime("%H:%M:%S"))
def openHelp(self):
if os.path.isfile('.\\resource\\help.html'):
os.system(".\\resource\\help.html")