Skip to content

Commit

Permalink
childrenform and qrc finished
Browse files Browse the repository at this point in the history
  • Loading branch information
iSteveyang committed Dec 18, 2019
1 parent 667e244 commit c2b173b
Show file tree
Hide file tree
Showing 28 changed files with 5,365 additions and 15 deletions.
7 changes: 3 additions & 4 deletions .idea/PyQt5.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
7 changes: 4 additions & 3 deletions Chapter03/mainWin/MainForm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

# Form implementation generated from reading ui file 'MainForm.ui'
#
# Created by: PyQt5 UI code generator 5.6
# 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")
Expand All @@ -16,7 +18,7 @@ def setupUi(self, MainWindow):
self.centralwidget.setObjectName("centralwidget")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 608, 23))
self.menubar.setGeometry(QtCore.QRect(0, 0, 608, 22))
self.menubar.setObjectName("menubar")
self.menu = QtWidgets.QMenu(self.menubar)
self.menu.setObjectName("menu")
Expand Down Expand Up @@ -60,4 +62,3 @@ def retranslateUi(self, MainWindow):
self.fileCloseAction.setText(_translate("MainWindow", "关闭"))
self.fileCloseAction.setShortcut(_translate("MainWindow", "Alt+C"))
self.addWinAction.setText(_translate("MainWindow", "添加窗体"))

2 changes: 1 addition & 1 deletion Chapter03/mainWin/MainForm.ui
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<x>0</x>
<y>0</y>
<width>608</width>
<height>23</height>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menu">
Expand Down
Binary file modified Chapter03/mainWin/__pycache__/MainForm.cpython-37.pyc
Binary file not shown.
Binary file added LearningProject/childrenForm/.DS_Store
Binary file not shown.
40 changes: 40 additions & 0 deletions LearningProject/childrenForm/CallMainWin02.py
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_())
23 changes: 23 additions & 0 deletions LearningProject/childrenForm/ChildrenForm2.py
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"))
19 changes: 19 additions & 0 deletions LearningProject/childrenForm/ChildrenForm2.ui
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>
71 changes: 71 additions & 0 deletions LearningProject/childrenForm/MainForm2.py
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"))
102 changes: 102 additions & 0 deletions LearningProject/childrenForm/MainForm2.ui
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>文件(&amp;F)</string>
</property>
<addaction name="fileOpenAction"/>
<addaction name="fileNewAction"/>
<addaction name="fileCloseAction"/>
</widget>
<widget class="QMenu" name="menu_E">
<property name="title">
<string>编辑(&amp;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 not shown.
Binary file not shown.
Loading

0 comments on commit c2b173b

Please sign in to comment.