-
Notifications
You must be signed in to change notification settings - Fork 0
/
notepad.py
283 lines (277 loc) · 15.8 KB
/
notepad.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'notepad.ui'
#
# Created by: PyQt5 UI code generator 5.11.3
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(586, 490)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/icon/notepad.jpg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
MainWindow.setWindowIcon(icon)
MainWindow.setLayoutDirection(QtCore.Qt.LeftToRight)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
self.gridLayout.setContentsMargins(0, 0, 0, 0)
self.gridLayout.setSpacing(0)
self.gridLayout.setObjectName("gridLayout")
self.horizontalScrollBar = QtWidgets.QScrollBar(self.centralwidget)
self.horizontalScrollBar.setEnabled(False)
self.horizontalScrollBar.setOrientation(QtCore.Qt.Horizontal)
self.horizontalScrollBar.setObjectName("horizontalScrollBar")
self.gridLayout.addWidget(self.horizontalScrollBar, 1, 0, 1, 1)
self.verticalScrollBar = QtWidgets.QScrollBar(self.centralwidget)
self.verticalScrollBar.setEnabled(False)
self.verticalScrollBar.setCursor(QtGui.QCursor(QtCore.Qt.SizeAllCursor))
self.verticalScrollBar.setMouseTracking(False)
self.verticalScrollBar.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu)
self.verticalScrollBar.setAcceptDrops(True)
self.verticalScrollBar.setOrientation(QtCore.Qt.Vertical)
self.verticalScrollBar.setObjectName("verticalScrollBar")
self.gridLayout.addWidget(self.verticalScrollBar, 0, 1, 1, 1)
self.textEdit = QtWidgets.QTextEdit(self.centralwidget)
font = QtGui.QFont()
font.setFamily("微软雅黑")
font.setPointSize(12)
self.textEdit.setFont(font)
self.textEdit.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.textEdit.setStyleSheet("border:none;")
self.textEdit.setObjectName("textEdit")
self.gridLayout.addWidget(self.textEdit, 0, 0, 1, 1)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 586, 23))
self.menubar.setObjectName("menubar")
self.menu = QtWidgets.QMenu(self.menubar)
self.menu.setObjectName("menu")
self.menu_E = QtWidgets.QMenu(self.menubar)
self.menu_E.setObjectName("menu_E")
self.menu_O = QtWidgets.QMenu(self.menubar)
self.menu_O.setObjectName("menu_O")
self.menu_V = QtWidgets.QMenu(self.menubar)
self.menu_V.setObjectName("menu_V")
self.menu_Z = QtWidgets.QMenu(self.menu_V)
self.menu_Z.setObjectName("menu_Z")
self.menu_H = QtWidgets.QMenu(self.menubar)
self.menu_H.setObjectName("menu_H")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setMinimumSize(QtCore.QSize(0, 20))
self.statusbar.setMaximumSize(QtCore.QSize(16777215, 20))
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.actionnew = QtWidgets.QAction(MainWindow)
self.actionnew.setObjectName("actionnew")
self.actionnre = QtWidgets.QAction(MainWindow)
self.actionnre.setObjectName("actionnre")
self.action_O = QtWidgets.QAction(MainWindow)
self.action_O.setObjectName("action_O")
self.action_S = QtWidgets.QAction(MainWindow)
self.action_S.setObjectName("action_S")
self.action_A = QtWidgets.QAction(MainWindow)
self.action_A.setObjectName("action_A")
self.action_U = QtWidgets.QAction(MainWindow)
self.action_U.setObjectName("action_U")
self.action_P = QtWidgets.QAction(MainWindow)
self.action_P.setObjectName("action_P")
self.action_X = QtWidgets.QAction(MainWindow)
self.action_X.setObjectName("action_X")
self.action_U_Ctrl_Z = QtWidgets.QAction(MainWindow)
self.action_U_Ctrl_Z.setObjectName("action_U_Ctrl_Z")
self.action_T_Ctrl_X = QtWidgets.QAction(MainWindow)
self.action_T_Ctrl_X.setEnabled(True)
self.action_T_Ctrl_X.setObjectName("action_T_Ctrl_X")
self.action_C_Ctrl_C = QtWidgets.QAction(MainWindow)
self.action_C_Ctrl_C.setEnabled(True)
self.action_C_Ctrl_C.setObjectName("action_C_Ctrl_C")
self.action_V_Ctrl_V = QtWidgets.QAction(MainWindow)
self.action_V_Ctrl_V.setObjectName("action_V_Ctrl_V")
self.action_L_Del = QtWidgets.QAction(MainWindow)
self.action_L_Del.setEnabled(True)
self.action_L_Del.setObjectName("action_L_Del")
self.action_Bing_Ctrl_E = QtWidgets.QAction(MainWindow)
self.action_Bing_Ctrl_E.setObjectName("action_Bing_Ctrl_E")
self.action_F_Ctrl_F = QtWidgets.QAction(MainWindow)
self.action_F_Ctrl_F.setObjectName("action_F_Ctrl_F")
self.action_N_F3 = QtWidgets.QAction(MainWindow)
self.action_N_F3.setObjectName("action_N_F3")
self.action_N_Shift_F3 = QtWidgets.QAction(MainWindow)
self.action_N_Shift_F3.setObjectName("action_N_Shift_F3")
self.action_R_Ctrl_H = QtWidgets.QAction(MainWindow)
self.action_R_Ctrl_H.setObjectName("action_R_Ctrl_H")
self.action_G_Ctrl_G = QtWidgets.QAction(MainWindow)
self.action_G_Ctrl_G.setObjectName("action_G_Ctrl_G")
self.action_A_Ctrl_A = QtWidgets.QAction(MainWindow)
self.action_A_Ctrl_A.setObjectName("action_A_Ctrl_A")
self.action_D_F5 = QtWidgets.QAction(MainWindow)
self.action_D_F5.setObjectName("action_D_F5")
self.action_W = QtWidgets.QAction(MainWindow)
self.action_W.setCheckable(True)
self.action_W.setChecked(True)
self.action_W.setObjectName("action_W")
self.action_F = QtWidgets.QAction(MainWindow)
self.action_F.setObjectName("action_F")
self.action_S_2 = QtWidgets.QAction(MainWindow)
self.action_S_2.setCheckable(True)
self.action_S_2.setChecked(True)
self.action_S_2.setObjectName("action_S_2")
self.action_I_Ctrl = QtWidgets.QAction(MainWindow)
self.action_I_Ctrl.setObjectName("action_I_Ctrl")
self.action_O_Ctrl = QtWidgets.QAction(MainWindow)
self.action_O_Ctrl.setObjectName("action_O_Ctrl")
self.action_Ctrl_0 = QtWidgets.QAction(MainWindow)
self.action_Ctrl_0.setObjectName("action_Ctrl_0")
self.action_H = QtWidgets.QAction(MainWindow)
self.action_H.setObjectName("action_H")
self.action_F_2 = QtWidgets.QAction(MainWindow)
self.action_F_2.setObjectName("action_F_2")
self.action_A_2 = QtWidgets.QAction(MainWindow)
self.action_A_2.setObjectName("action_A_2")
self.action_FC = QtWidgets.QAction(MainWindow)
self.action_FC.setObjectName("action_FC")
self.menu.addAction(self.actionnew)
self.menu.addAction(self.actionnre)
self.menu.addAction(self.action_O)
self.menu.addAction(self.action_S)
self.menu.addAction(self.action_A)
self.menu.addSeparator()
self.menu.addAction(self.action_U)
self.menu.addAction(self.action_P)
self.menu.addSeparator()
self.menu.addAction(self.action_X)
self.menu_E.addAction(self.action_U_Ctrl_Z)
self.menu_E.addSeparator()
self.menu_E.addAction(self.action_T_Ctrl_X)
self.menu_E.addAction(self.action_C_Ctrl_C)
self.menu_E.addAction(self.action_V_Ctrl_V)
self.menu_E.addAction(self.action_L_Del)
self.menu_E.addSeparator()
self.menu_E.addAction(self.action_Bing_Ctrl_E)
self.menu_E.addAction(self.action_F_Ctrl_F)
self.menu_E.addAction(self.action_N_F3)
self.menu_E.addAction(self.action_N_Shift_F3)
self.menu_E.addAction(self.action_R_Ctrl_H)
self.menu_E.addAction(self.action_G_Ctrl_G)
self.menu_E.addSeparator()
self.menu_E.addAction(self.action_A_Ctrl_A)
self.menu_E.addAction(self.action_D_F5)
self.menu_O.addAction(self.action_W)
self.menu_O.addAction(self.action_F)
self.menu_O.addAction(self.action_FC)
self.menu_Z.addAction(self.action_I_Ctrl)
self.menu_Z.addAction(self.action_O_Ctrl)
self.menu_Z.addAction(self.action_Ctrl_0)
self.menu_V.addAction(self.menu_Z.menuAction())
self.menu_V.addAction(self.action_S_2)
self.menu_H.addAction(self.action_H)
self.menu_H.addAction(self.action_F_2)
self.menu_H.addSeparator()
self.menu_H.addAction(self.action_A_2)
self.menubar.addAction(self.menu.menuAction())
self.menubar.addAction(self.menu_E.menuAction())
self.menubar.addAction(self.menu_O.menuAction())
self.menubar.addAction(self.menu_V.menuAction())
self.menubar.addAction(self.menu_H.menuAction())
self.retranslateUi(MainWindow)
self.action_O.triggered.connect(MainWindow.openfile)
self.actionnew.triggered.connect(MainWindow.newfile)
self.actionnre.triggered.connect(MainWindow.newwindow)
self.action_S.triggered.connect(MainWindow.savefile)
self.action_A.triggered.connect(MainWindow.savefileas)
self.action_U.triggered.connect(MainWindow.setpage)
self.action_P.triggered.connect(MainWindow.printfile)
self.action_X.triggered.connect(MainWindow.exitfile)
self.textEdit.textChanged.connect(MainWindow.textchanged)
self.action_U_Ctrl_Z.triggered.connect(MainWindow.revokeedit)
self.action_Bing_Ctrl_E.triggered.connect(MainWindow.searchbybing)
self.action_F_Ctrl_F.triggered.connect(MainWindow.findedit)
self.action_N_F3.triggered.connect(MainWindow.findnext)
self.action_N_Shift_F3.triggered.connect(MainWindow.findlast)
self.action_R_Ctrl_H.triggered.connect(MainWindow.repalceedit)
self.action_G_Ctrl_G.triggered.connect(MainWindow.transto)
self.action_D_F5.triggered.connect(MainWindow.datetimeeidt)
self.action_V_Ctrl_V.triggered.connect(MainWindow.pasteredit)
self.action_T_Ctrl_X.triggered.connect(MainWindow.cutedit)
self.action_C_Ctrl_C.triggered.connect(MainWindow.copyedit)
self.action_L_Del.triggered.connect(MainWindow.deledit)
self.action_A_Ctrl_A.triggered.connect(MainWindow.selectall)
self.textEdit.selectionChanged.connect(MainWindow.selectedchanged)
self.action_F.triggered.connect(MainWindow.set_font)
self.action_W.triggered.connect(MainWindow.auto_linefeed)
self.action_FC.triggered.connect(MainWindow.set_color)
self.action_I_Ctrl.triggered.connect(MainWindow.enlarge)
self.action_O_Ctrl.triggered.connect(MainWindow.narrow)
self.action_Ctrl_0.triggered.connect(MainWindow.restore_size)
self.action_S_2.triggered.connect(MainWindow.change_status)
self.action_H.triggered.connect(MainWindow.gethelp)
self.action_A_2.triggered.connect(MainWindow.about_notepad)
self.action_F_2.triggered.connect(MainWindow.feedback)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "-记事本"))
self.menu.setTitle(_translate("MainWindow", "文件&(F)"))
self.menu_E.setTitle(_translate("MainWindow", "编辑&(E)"))
self.menu_O.setTitle(_translate("MainWindow", "格式&(O)"))
self.menu_V.setTitle(_translate("MainWindow", "查看&(V)"))
self.menu_Z.setTitle(_translate("MainWindow", "缩放&(Z)"))
self.menu_H.setTitle(_translate("MainWindow", "帮助&(H)"))
self.actionnew.setText(_translate("MainWindow", "新建(N)"))
self.actionnew.setShortcut(_translate("MainWindow", "Ctrl+N"))
self.actionnre.setText(_translate("MainWindow", "新窗口(W)"))
self.actionnre.setShortcut(_translate("MainWindow", "Ctrl+Shift+N"))
self.action_O.setText(_translate("MainWindow", "打开(O)..."))
self.action_O.setShortcut(_translate("MainWindow", "Ctrl+O"))
self.action_S.setText(_translate("MainWindow", "保存(S)"))
self.action_S.setShortcut(_translate("MainWindow", "Ctrl+S"))
self.action_A.setText(_translate("MainWindow", "另存为(A)..."))
self.action_A.setShortcut(_translate("MainWindow", "Ctrl+Shift+S"))
self.action_U.setText(_translate("MainWindow", "页面设置(U)..."))
self.action_P.setText(_translate("MainWindow", "打印(P)..."))
self.action_X.setText(_translate("MainWindow", "退出(X)"))
self.action_U_Ctrl_Z.setText(_translate("MainWindow", "撤销(U)"))
self.action_U_Ctrl_Z.setShortcut(_translate("MainWindow", "Ctrl+Z"))
self.action_T_Ctrl_X.setText(_translate("MainWindow", "剪切(T)"))
self.action_T_Ctrl_X.setShortcut(_translate("MainWindow", "Ctrl+X"))
self.action_C_Ctrl_C.setText(_translate("MainWindow", "复制(C)"))
self.action_C_Ctrl_C.setShortcut(_translate("MainWindow", "Ctrl+C"))
self.action_V_Ctrl_V.setText(_translate("MainWindow", "粘贴(P)"))
self.action_V_Ctrl_V.setToolTip(_translate("MainWindow", "粘贴(P)"))
self.action_V_Ctrl_V.setShortcut(_translate("MainWindow", "Ctrl+V"))
self.action_L_Del.setText(_translate("MainWindow", "删除(L)"))
self.action_L_Del.setShortcut(_translate("MainWindow", "Del"))
self.action_Bing_Ctrl_E.setText(_translate("MainWindow", "使用Bing搜索..."))
self.action_Bing_Ctrl_E.setShortcut(_translate("MainWindow", "Ctrl+E"))
self.action_F_Ctrl_F.setText(_translate("MainWindow", "查找(F)"))
self.action_F_Ctrl_F.setShortcut(_translate("MainWindow", "Ctrl+F"))
self.action_N_F3.setText(_translate("MainWindow", "查找下一个(N)"))
self.action_N_F3.setShortcut(_translate("MainWindow", "F3"))
self.action_N_Shift_F3.setText(_translate("MainWindow", "查找上一个(N)"))
self.action_N_Shift_F3.setShortcut(_translate("MainWindow", "Shift+F3"))
self.action_R_Ctrl_H.setText(_translate("MainWindow", "替换(R)"))
self.action_R_Ctrl_H.setShortcut(_translate("MainWindow", "Ctrl+H"))
self.action_G_Ctrl_G.setText(_translate("MainWindow", "转到(G)..."))
self.action_G_Ctrl_G.setShortcut(_translate("MainWindow", "Ctrl+G"))
self.action_A_Ctrl_A.setText(_translate("MainWindow", "全选(A)"))
self.action_A_Ctrl_A.setShortcut(_translate("MainWindow", "Ctrl+A"))
self.action_D_F5.setText(_translate("MainWindow", "时间/日期(D)"))
self.action_D_F5.setShortcut(_translate("MainWindow", "F5"))
self.action_W.setText(_translate("MainWindow", "自动换行(W)"))
self.action_F.setText(_translate("MainWindow", "字体(F)..."))
self.action_S_2.setText(_translate("MainWindow", "状态栏&(S)"))
self.action_I_Ctrl.setText(_translate("MainWindow", "放大&(I)"))
self.action_I_Ctrl.setShortcut(_translate("MainWindow", "Ctrl+Shift+="))
self.action_O_Ctrl.setText(_translate("MainWindow", "缩小&(O)"))
self.action_O_Ctrl.setShortcut(_translate("MainWindow", "Ctrl+Shift+-"))
self.action_Ctrl_0.setText(_translate("MainWindow", "恢复默认缩放"))
self.action_Ctrl_0.setShortcut(_translate("MainWindow", "Ctrl+0"))
self.action_H.setText(_translate("MainWindow", "查看帮助&(H)"))
self.action_F_2.setText(_translate("MainWindow", "发送反馈&(F)"))
self.action_A_2.setText(_translate("MainWindow", "关于记事本&(A)"))
self.action_FC.setText(_translate("MainWindow", "字体颜色(C)"))
self.action_FC.setToolTip(_translate("MainWindow", "字体颜色"))
import notepadqrc_rc