forked from cxinping/PyQt5
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
667e244
commit c2b173b
Showing
28 changed files
with
5,365 additions
and
15 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import sys | ||
from PyQt5.QtWidgets import QApplication, QMainWindow, QWidget, QFileDialog | ||
from MainForm2 import Ui_MainWindow | ||
from ChildrenForm2 import Ui_ChildrenForm | ||
|
||
class MainForm(QMainWindow, Ui_MainWindow): | ||
def __init__(self): | ||
super(MainForm, self).__init__() | ||
self.setupUi(self) | ||
|
||
self.child = ChildrenForm() | ||
self.fileCloseAction.triggered.connect(self.close) | ||
self.fileOpenAction.triggered.connect(self.openMsg) | ||
|
||
# 点击actionTst,子窗口就会显示在主窗口的MaingridLayout中 | ||
self.addWinAction.triggered.connect(self.childShow) | ||
|
||
def childShow(self): | ||
# 添加子窗口 | ||
self.MaingridLayout.addWidget(self.child) | ||
self.child.show() | ||
|
||
def openMsg(self): | ||
file, ok = QFileDialog.getOpenFileName(self, "打开", "./", "All Files (*);;Text Files (*.txt)") | ||
# 在状态栏显示文件地址 | ||
self.statusbar.showMessage(file) | ||
|
||
class ChildrenForm(QWidget, Ui_ChildrenForm): | ||
def __init__(self): | ||
super(ChildrenForm, self).__init__() | ||
self.setupUi(self) | ||
|
||
|
||
if __name__ == "__main__": | ||
app = QApplication(sys.argv) | ||
win = MainForm() | ||
win.show() | ||
sys.exit(app.exec_()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# Form implementation generated from reading ui file 'ChildrenForm2.ui' | ||
# | ||
# Created by: PyQt5 UI code generator 5.13.1 | ||
# | ||
# WARNING! All changes made in this file will be lost! | ||
|
||
|
||
from PyQt5 import QtCore, QtGui, QtWidgets | ||
|
||
|
||
class Ui_ChildrenForm(object): | ||
def setupUi(self, ChildrenForm): | ||
ChildrenForm.setObjectName("ChildrenForm") | ||
ChildrenForm.resize(472, 334) | ||
|
||
self.retranslateUi(ChildrenForm) | ||
QtCore.QMetaObject.connectSlotsByName(ChildrenForm) | ||
|
||
def retranslateUi(self, ChildrenForm): | ||
_translate = QtCore.QCoreApplication.translate | ||
ChildrenForm.setWindowTitle(_translate("ChildrenForm", "Form")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>ChildrenForm</class> | ||
<widget class="QWidget" name="ChildrenForm"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>472</width> | ||
<height>334</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Form</string> | ||
</property> | ||
</widget> | ||
<resources/> | ||
<connections/> | ||
</ui> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# Form implementation generated from reading ui file 'MainForm2.ui' | ||
# | ||
# Created by: PyQt5 UI code generator 5.13.1 | ||
# | ||
# 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(608, 500) | ||
self.centralwidget = QtWidgets.QWidget(MainWindow) | ||
self.centralwidget.setObjectName("centralwidget") | ||
self.gridLayoutWidget = QtWidgets.QWidget(self.centralwidget) | ||
self.gridLayoutWidget.setGeometry(QtCore.QRect(-1, -1, 511, 401)) | ||
self.gridLayoutWidget.setObjectName("gridLayoutWidget") | ||
self.MaingridLayout = QtWidgets.QGridLayout(self.gridLayoutWidget) | ||
self.MaingridLayout.setContentsMargins(0, 0, 0, 0) | ||
self.MaingridLayout.setObjectName("MaingridLayout") | ||
MainWindow.setCentralWidget(self.centralwidget) | ||
self.menubar = QtWidgets.QMenuBar(MainWindow) | ||
self.menubar.setGeometry(QtCore.QRect(0, 0, 608, 22)) | ||
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") | ||
MainWindow.setMenuBar(self.menubar) | ||
self.statusbar = QtWidgets.QStatusBar(MainWindow) | ||
self.statusbar.setObjectName("statusbar") | ||
MainWindow.setStatusBar(self.statusbar) | ||
self.toolBar = QtWidgets.QToolBar(MainWindow) | ||
self.toolBar.setObjectName("toolBar") | ||
MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar) | ||
self.fileOpenAction = QtWidgets.QAction(MainWindow) | ||
self.fileOpenAction.setObjectName("fileOpenAction") | ||
self.fileNewAction = QtWidgets.QAction(MainWindow) | ||
self.fileNewAction.setObjectName("fileNewAction") | ||
self.fileCloseAction = QtWidgets.QAction(MainWindow) | ||
self.fileCloseAction.setObjectName("fileCloseAction") | ||
self.addWinAction = QtWidgets.QAction(MainWindow) | ||
self.addWinAction.setObjectName("addWinAction") | ||
self.menu.addAction(self.fileOpenAction) | ||
self.menu.addAction(self.fileNewAction) | ||
self.menu.addAction(self.fileCloseAction) | ||
self.menubar.addAction(self.menu.menuAction()) | ||
self.menubar.addAction(self.menu_E.menuAction()) | ||
self.toolBar.addAction(self.addWinAction) | ||
|
||
self.retranslateUi(MainWindow) | ||
QtCore.QMetaObject.connectSlotsByName(MainWindow) | ||
|
||
def retranslateUi(self, MainWindow): | ||
_translate = QtCore.QCoreApplication.translate | ||
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) | ||
self.menu.setTitle(_translate("MainWindow", "文件(&F)")) | ||
self.menu_E.setTitle(_translate("MainWindow", "编辑(&E)")) | ||
self.toolBar.setWindowTitle(_translate("MainWindow", "toolBar")) | ||
self.fileOpenAction.setText(_translate("MainWindow", "打开")) | ||
self.fileOpenAction.setShortcut(_translate("MainWindow", "Alt+O")) | ||
self.fileNewAction.setText(_translate("MainWindow", "新建")) | ||
self.fileNewAction.setShortcut(_translate("MainWindow", "Alt+N")) | ||
self.fileCloseAction.setText(_translate("MainWindow", "关闭")) | ||
self.fileCloseAction.setShortcut(_translate("MainWindow", "Alt+C")) | ||
self.addWinAction.setText(_translate("MainWindow", "添加窗体")) | ||
self.addWinAction.setShortcut(_translate("MainWindow", "Alt+A")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>MainWindow</class> | ||
<widget class="QMainWindow" name="MainWindow"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>608</width> | ||
<height>500</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>MainWindow</string> | ||
</property> | ||
<widget class="QWidget" name="centralwidget"> | ||
<widget class="QWidget" name="gridLayoutWidget"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>40</x> | ||
<y>10</y> | ||
<width>511</width> | ||
<height>401</height> | ||
</rect> | ||
</property> | ||
<layout class="QGridLayout" name="MaingridLayout"/> | ||
</widget> | ||
</widget> | ||
<widget class="QMenuBar" name="menubar"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>608</width> | ||
<height>22</height> | ||
</rect> | ||
</property> | ||
<widget class="QMenu" name="menu"> | ||
<property name="title"> | ||
<string>文件(&F)</string> | ||
</property> | ||
<addaction name="fileOpenAction"/> | ||
<addaction name="fileNewAction"/> | ||
<addaction name="fileCloseAction"/> | ||
</widget> | ||
<widget class="QMenu" name="menu_E"> | ||
<property name="title"> | ||
<string>编辑(&E)</string> | ||
</property> | ||
</widget> | ||
<addaction name="menu"/> | ||
<addaction name="menu_E"/> | ||
</widget> | ||
<widget class="QStatusBar" name="statusbar"/> | ||
<widget class="QToolBar" name="toolBar"> | ||
<property name="windowTitle"> | ||
<string>toolBar</string> | ||
</property> | ||
<attribute name="toolBarArea"> | ||
<enum>TopToolBarArea</enum> | ||
</attribute> | ||
<attribute name="toolBarBreak"> | ||
<bool>false</bool> | ||
</attribute> | ||
<addaction name="addWinAction"/> | ||
</widget> | ||
<action name="fileOpenAction"> | ||
<property name="text"> | ||
<string>打开</string> | ||
</property> | ||
<property name="shortcut"> | ||
<string>Alt+O</string> | ||
</property> | ||
</action> | ||
<action name="fileNewAction"> | ||
<property name="text"> | ||
<string>新建</string> | ||
</property> | ||
<property name="shortcut"> | ||
<string>Alt+N</string> | ||
</property> | ||
</action> | ||
<action name="fileCloseAction"> | ||
<property name="text"> | ||
<string>关闭</string> | ||
</property> | ||
<property name="shortcut"> | ||
<string>Alt+C</string> | ||
</property> | ||
</action> | ||
<action name="addWinAction"> | ||
<property name="text"> | ||
<string>添加窗体</string> | ||
</property> | ||
<property name="shortcut"> | ||
<string>Alt+A</string> | ||
</property> | ||
</action> | ||
</widget> | ||
<resources/> | ||
<connections/> | ||
</ui> |
Binary file not shown.
Binary file added
BIN
+903 Bytes
LearningProject/childrenForm/__pycache__/ChildrenForm2.cpython-37.pyc
Binary file not shown.
Binary file not shown.
Oops, something went wrong.