forked from realpython/materials
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
45 lines (34 loc) · 1.15 KB
/
Copy pathapp.py
File metadata and controls
45 lines (34 loc) · 1.15 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
import sys
from PyQt5.QtWidgets import QApplication, QDialog, QMainWindow, QMessageBox
from PyQt5.uic import loadUi
from main_window_ui import Ui_MainWindow
class Window(QMainWindow, Ui_MainWindow):
def __init__(self, parent=None):
super().__init__(parent)
self.setupUi(self)
self.connectSignalsSlots()
def connectSignalsSlots(self):
self.action_Exit.triggered.connect(self.close)
self.action_Find_Replace.triggered.connect(self.findAndReplace)
self.action_About.triggered.connect(self.about)
def findAndReplace(self):
dialog = FindReplaceDialog(self)
dialog.exec()
def about(self):
QMessageBox.about(
self,
"About Sample Editor",
"<p>A sample text editor app built with:</p>"
"<p>- PyQt</p>"
"<p>- Qt Designer</p>"
"<p>- Python</p>",
)
class FindReplaceDialog(QDialog):
def __init__(self, parent=None):
super().__init__(parent)
loadUi("ui/find_replace.ui", self)
if __name__ == "__main__":
app = QApplication(sys.argv)
win = Window()
win.show()
sys.exit(app.exec())