├── 1.gif ├── 3.gif ├── 3.png ├── 4.gif ├── 4.png ├── 5.gif ├── GUI ├── .idea │ ├── GUI.iml │ ├── misc.xml │ ├── modules.xml │ └── workspace.xml └── Basic-train │ ├── AdvanWin │ ├── Container │ │ ├── __pycache__ │ │ │ └── mainwindow.cpython-37.pyc │ │ ├── container.py │ │ ├── mainwindow.py │ │ └── mainwindow.ui │ ├── ViewWidget │ │ ├── __pycache__ │ │ │ └── mainwindow.cpython-37.pyc │ │ ├── control.py │ │ ├── icon.jpg │ │ ├── mainwindow.py │ │ └── mainwindow.ui │ └── WebPage │ │ ├── __pycache__ │ │ └── mainwindow.cpython-37.pyc │ │ ├── mainwindow.py │ │ ├── mainwindow.ui │ │ └── web.py │ ├── BasicWin │ ├── __pycache__ │ │ └── mainwindow.cpython-37.pyc │ ├── a.py │ ├── control.py │ ├── icon.jpg │ ├── mainwindow.py │ ├── mainwindow.ui │ └── test.data │ ├── DataBase │ ├── __pycache__ │ │ ├── mainwidget.cpython-37.pyc │ │ └── mainwindow.cpython-37.pyc │ ├── database.py │ ├── mainwidget.py │ ├── mainwidget.ui │ ├── mainwindow.py │ ├── mainwindow.ui │ └── table │ │ ├── test.db │ │ └── test1.db │ ├── MVC │ ├── MVC-demo │ │ ├── UI │ │ │ ├── __pycache__ │ │ │ │ ├── left_btn.cpython-38.pyc │ │ │ │ ├── leftbtn_ui.cpython-38.pyc │ │ │ │ ├── login.cpython-38.pyc │ │ │ │ ├── login_ui.cpython-38.pyc │ │ │ │ ├── main_window.cpython-38.pyc │ │ │ │ ├── main_window_ui.cpython-38.pyc │ │ │ │ └── verify_ui.cpython-38.pyc │ │ │ ├── leftbtn_ui.py │ │ │ ├── login_ui.py │ │ │ ├── main_window_ui.py │ │ │ └── verify_ui.py │ │ ├── control │ │ │ ├── __pycache__ │ │ │ │ ├── controller.cpython-38.pyc │ │ │ │ ├── left_btn_control.cpython-38.pyc │ │ │ │ ├── leftbtn_control.cpython-38.pyc │ │ │ │ ├── login_control.cpython-38.pyc │ │ │ │ ├── verify_control.cpython-38.pyc │ │ │ │ └── verify_ui_control.cpython-38.pyc │ │ │ ├── controller.py │ │ │ ├── leftbtn_control.py │ │ │ ├── login_control.py │ │ │ └── verify_control.py │ │ ├── main.py │ │ └── model │ │ │ ├── __pycache__ │ │ │ └── model.cpython-38.pyc │ │ │ └── model.py │ └── MVC-single-page │ │ ├── control │ │ ├── __pycache__ │ │ │ └── login_control.cpython-38.pyc │ │ └── login_control.py │ │ ├── main.py │ │ ├── model │ │ ├── __pycache__ │ │ │ └── model.cpython-38.pyc │ │ └── model.py │ │ └── view │ │ ├── __pycache__ │ │ └── login.cpython-38.pyc │ │ └── login.py │ ├── MatplotWidget │ ├── MatplotlibWidget.py │ ├── __pycache__ │ │ ├── MatplotlibWidget.cpython-37.pyc │ │ ├── mainwidget.cpython-37.pyc │ │ ├── mainwindow.cpython-37.pyc │ │ └── matplot.cpython-37.pyc │ ├── mainwidget.py │ ├── mainwidget.ui │ ├── mainwindow.py │ ├── mainwindow.ui │ └── matplot.py │ ├── Multi-Thread │ ├── Error.py │ ├── MWE.py │ ├── images │ │ └── loading.gif │ ├── qthread.py │ ├── timer.py │ └── wait.py │ ├── PyQtGraph │ ├── __pycache__ │ │ ├── mainwidget.cpython-37.pyc │ │ ├── mainwindow.cpython-37.pyc │ │ └── pyqtgraph.cpython-37.pyc │ ├── graph.py │ ├── mainwidget.py │ ├── mainwidget.ui │ ├── mainwindow.py │ └── mainwindow.ui │ ├── Pyecharts │ ├── .ipynb_checkpoints │ │ ├── html-checkpoint.ipynb │ │ ├── html_plot-checkpoint.py │ │ └── render-checkpoint.html │ ├── __pycache__ │ │ ├── mainwidget.cpython-37.pyc │ │ └── mainwindow.cpython-37.pyc │ ├── html.ipynb │ ├── html_plot.py │ ├── mainwidget.py │ ├── mainwidget.ui │ ├── mainwindow.py │ ├── mainwindow.ui │ ├── render.html │ └── test.html │ ├── QSS │ ├── QSS.py │ ├── __pycache__ │ │ ├── mainwidget.cpython-37.pyc │ │ └── mainwindow.cpython-37.pyc │ ├── black.qss │ ├── mainwidget.py │ ├── mainwidget.ui │ ├── mainwindow.py │ ├── mainwindow.ui │ └── white.qss │ ├── QtPandas │ ├── __pycache__ │ │ ├── mainwidget.cpython-37.pyc │ │ ├── mainwindow.cpython-37.pyc │ │ └── qtpandas.cpython-37.pyc │ ├── data.csv │ ├── mainwidget.py │ ├── mainwidget.ui │ ├── mainwindow.py │ ├── mainwindow.ui │ ├── qtpandas.py │ └── qtpandas │ │ ├── __init__.py │ │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── compat.cpython-37.pyc │ │ └── utils.cpython-37.pyc │ │ ├── _lib │ │ └── magic │ │ │ ├── db │ │ │ └── magic.mgc │ │ │ ├── libgcc_s_dw2-1.dll │ │ │ ├── libmagic-1.dll │ │ │ ├── libregex-1.dll │ │ │ ├── magic1.dll │ │ │ └── zlib1.dll │ │ ├── compat.py │ │ ├── encoding.py │ │ ├── excepthook.py │ │ ├── models │ │ ├── ColumnDtypeModel.py │ │ ├── DataFrameModel.py │ │ ├── DataFrameModelManager.py │ │ ├── DataSearch.py │ │ ├── ProgressThread.py │ │ ├── SupportedDtypes.py │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── ColumnDtypeModel.cpython-37.pyc │ │ │ ├── DataFrameModel.cpython-37.pyc │ │ │ ├── DataSearch.cpython-37.pyc │ │ │ ├── SupportedDtypes.cpython-37.pyc │ │ │ ├── __init__.cpython-37.pyc │ │ │ └── mime.cpython-37.pyc │ │ └── mime.py │ │ ├── ui │ │ ├── AddAttributesDialog.ui │ │ ├── AttributeTable.ui │ │ ├── __init__.py │ │ └── fallback │ │ │ ├── __init__.py │ │ │ └── easygui │ │ │ ├── __init__.py │ │ │ ├── boxes │ │ │ ├── __init__.py │ │ │ ├── about.py │ │ │ ├── base_boxes.py │ │ │ ├── derived_boxes.py │ │ │ ├── egstore.py │ │ │ ├── state.py │ │ │ ├── text_box.py │ │ │ ├── updatable_text_box.py │ │ │ └── utils.py │ │ │ └── easygui.py │ │ ├── utils.py │ │ └── views │ │ ├── BigIntSpinbox.py │ │ ├── CSVDialogs.py │ │ ├── CustomDelegates.py │ │ ├── DataTableView.py │ │ ├── EditDialogs.py │ │ ├── MultiFileDialogs.py │ │ ├── OverlayProgressView.py │ │ ├── __init__.py │ │ ├── __pycache__ │ │ ├── BigIntSpinbox.cpython-37.pyc │ │ ├── CSVDialogs.cpython-37.pyc │ │ ├── CustomDelegates.cpython-37.pyc │ │ ├── DataTableView.cpython-37.pyc │ │ ├── EditDialogs.cpython-37.pyc │ │ └── __init__.cpython-37.pyc │ │ └── _ui │ │ ├── AddAttributesDialog.ui │ │ ├── AttributeTable.ui │ │ ├── __init__.py │ │ ├── icons.qrc │ │ ├── icons │ │ ├── dialog-cancel.png │ │ ├── dialog-ok-apply.png │ │ ├── document-edit.png │ │ ├── document-open.png │ │ ├── document-save-as.png │ │ ├── edit-table-delete-column.png │ │ ├── edit-table-delete-row.png │ │ ├── edit-table-insert-column-right.png │ │ ├── edit-table-insert-row-below.png │ │ └── view-refresh.png │ │ └── icons_rc.py │ └── SiganlSlot │ ├── demo1.py │ └── demo2.py ├── LICENSE └── README.md /1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/1.gif -------------------------------------------------------------------------------- /3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/3.gif -------------------------------------------------------------------------------- /3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/3.png -------------------------------------------------------------------------------- /4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/4.gif -------------------------------------------------------------------------------- /4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/4.png -------------------------------------------------------------------------------- /5.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/5.gif -------------------------------------------------------------------------------- /GUI/.idea/GUI.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | -------------------------------------------------------------------------------- /GUI/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | -------------------------------------------------------------------------------- /GUI/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /GUI/Basic-train/AdvanWin/Container/__pycache__/mainwindow.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/AdvanWin/Container/__pycache__/mainwindow.cpython-37.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/AdvanWin/Container/container.py: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # -*- coding: UTF-8 -*- 3 | import sys 4 | import time 5 | import PyQt5 6 | # 基本控件都在这里面 7 | from PyQt5.QtWidgets import (QApplication, QMainWindow, QWidget, QTabWidget, QDesktopWidget, 8 | QFormLayout, QLineEdit, QStackedWidget, QHBoxLayout, QDockWidget, 9 | QMdiSubWindow, QMdiArea) 10 | from PyQt5.QtCore import Qt 11 | from PyQt5.QtGui import QColor, QPalette 12 | from mainwindow import Ui_MainWindow 13 | 14 | # 继承主窗口 Qmainwindow 和 自己画的界面 Ui_MainWindow 15 | class MyMainWindow(QMainWindow, Ui_MainWindow): 16 | 17 | def __init__(self, parent = None): 18 | super(MyMainWindow, self).__init__(parent) 19 | self.setupUi(self) 20 | self.resize(1200, 740) 21 | 22 | # 默认的状态栏 23 | self.status = self.statusBar() 24 | self.status.showMessage("你在主页面~") 25 | 26 | # 标题栏 27 | self.setWindowTitle("建模协会录入信息") 28 | 29 | # 窗口居中 30 | self.center() 31 | 32 | # 退出窗口 33 | self.quit_btn.clicked.connect(self.quit_act) 34 | 35 | # QTabWidget 多窗口使用 36 | self.tab1 = QWidget() 37 | self.tab2 = QWidget() 38 | self.tab3 = QWidget() 39 | self.line = QLineEdit() # line 要在调用之前创建 40 | self.tabWidget.addTab(self.tab1, "标题1") 41 | self.tabWidget.addTab(self.tab2, "标题2") 42 | self.tabWidget.addTab(self.tab3, "标题3") 43 | self.tab1_() 44 | self.tab2_() 45 | self.tab3_() 46 | # self.line = QLineEdit() 这里不对 47 | self.quit_btn_2.clicked.connect(self.display_line) 48 | 49 | # QStackedWidget 50 | self.listWidget.insertItem(0, "标题1") 51 | self.listWidget.insertItem(1, "标题2") 52 | self.listWidget.insertItem(2, "标题3") 53 | self.stack1 = QWidget() 54 | self.stack2 = QWidget() 55 | self.stack3 = QWidget() 56 | self.stack1_() 57 | self.stack2_() 58 | self.stack3_() 59 | self.stackedWidget.addWidget(self.stack1) 60 | self.stackedWidget.addWidget(self.stack2) 61 | self.stackedWidget.addWidget(self.stack3) 62 | self.listWidget.currentRowChanged.connect(self.display_stack) 63 | 64 | # QDockWidget 使用 浮动窗体 65 | # self.dockWidget = QDockWidget("test", self) 66 | self.dockWidget.setWidget(self.tabWidget) 67 | self.quit_btn_3.clicked.connect(self.display_dock) 68 | 69 | # 多文档界面 70 | self.mdi = QMdiArea() 71 | self.quit_btn_3.clicked.connect(self.new_win) 72 | # self.setCentralWidget(self.mdi) # 似乎不太好用 73 | 74 | # ScrollBar 的使用 (选择颜色) 75 | self.verticalScrollBar.setMaximum(255) 76 | self.verticalScrollBar_2.setMaximum(255) 77 | self.verticalScrollBar_3.setMaximum(255) 78 | self.verticalScrollBar_3.sliderMoved.connect(self.color_change) 79 | self.verticalScrollBar_2.sliderMoved.connect(self.color_change) 80 | self.verticalScrollBar.sliderMoved.connect(self.color_change) 81 | 82 | def color_change(self): 83 | c = QColor(self.verticalScrollBar.value(), self.verticalScrollBar_2.value(), 84 | self.verticalScrollBar_3.value()) 85 | palette = QPalette() 86 | palette.setColor(QPalette.Foreground, c) 87 | self.label.setPalette(palette) 88 | 89 | def new_win(self): 90 | sub = QMdiSubWindow() 91 | # sub.setWidget(self.listWidget) 92 | self.mdi.addSubWindow(sub) 93 | sub.show() 94 | 95 | # 用于关闭之后子按此打开悬浮窗口 96 | def display_dock(self): 97 | self.dockWidget.show() 98 | 99 | def display_stack(self, i): 100 | # print(i) 101 | self.stackedWidget.setCurrentIndex(i) 102 | 103 | def stack1_(self): 104 | layout = QFormLayout() 105 | layout.addRow("姓名", QLineEdit()) 106 | self.stack1.setLayout(layout) 107 | 108 | def stack2_(self): 109 | layout = QFormLayout() 110 | layout.addRow("年龄", QLineEdit()) 111 | self.stack2.setLayout(layout) 112 | 113 | def stack3_(self): 114 | layout = QFormLayout() 115 | layout.addRow("备注", QLineEdit()) 116 | self.stack3.setLayout(layout) 117 | 118 | def display_line(self): 119 | print(self.line.text()) 120 | 121 | def tab1_(self): 122 | layout = QFormLayout() 123 | layout.addRow("姓名", QLineEdit()) 124 | self.tab1.setLayout(layout) 125 | 126 | def tab2_(self): 127 | layout = QFormLayout() 128 | layout.addRow("年龄", self.line) 129 | self.tab2.setLayout(layout) 130 | 131 | def tab3_(self): 132 | layout = QFormLayout() 133 | layout.addRow("备注", QLineEdit()) 134 | self.tab3.setLayout(layout) 135 | 136 | def quit_act(self): 137 | # sender 是发送信号的对象 138 | sender = self.sender() 139 | print(sender.text() + '键被按下') 140 | qApp = QApplication.instance() 141 | qApp.quit() 142 | 143 | def center(self): 144 | ''' 145 | 获取桌面长宽 146 | 获取窗口长宽 147 | 移动 148 | ''' 149 | screen = QDesktopWidget().screenGeometry() 150 | size = self.geometry() 151 | self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2) 152 | 153 | 154 | if __name__ == "__main__": 155 | # 在shell中执行 156 | app = QApplication(sys.argv) 157 | mywin = MyMainWindow() 158 | mywin.show() 159 | # 开始主循环,直到退出 160 | sys.exit(app.exec()) -------------------------------------------------------------------------------- /GUI/Basic-train/AdvanWin/Container/mainwindow.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'mainwindow.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.13.1 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | 10 | from PyQt5 import QtCore, QtGui, QtWidgets 11 | 12 | 13 | class Ui_MainWindow(object): 14 | def setupUi(self, MainWindow): 15 | MainWindow.setObjectName("MainWindow") 16 | MainWindow.resize(1200, 740) 17 | self.centralwidget = QtWidgets.QWidget(MainWindow) 18 | self.centralwidget.setObjectName("centralwidget") 19 | self.quit_btn = QtWidgets.QPushButton(self.centralwidget) 20 | self.quit_btn.setGeometry(QtCore.QRect(1100, 660, 91, 34)) 21 | font = QtGui.QFont() 22 | font.setFamily("Palatino") 23 | font.setPointSize(14) 24 | self.quit_btn.setFont(font) 25 | self.quit_btn.setObjectName("quit_btn") 26 | self.tabWidget = QtWidgets.QTabWidget(self.centralwidget) 27 | self.tabWidget.setGeometry(QtCore.QRect(30, 210, 291, 211)) 28 | self.tabWidget.setObjectName("tabWidget") 29 | self.quit_btn_2 = QtWidgets.QPushButton(self.centralwidget) 30 | self.quit_btn_2.setGeometry(QtCore.QRect(350, 210, 91, 34)) 31 | font = QtGui.QFont() 32 | font.setFamily("Palatino") 33 | font.setPointSize(14) 34 | self.quit_btn_2.setFont(font) 35 | self.quit_btn_2.setObjectName("quit_btn_2") 36 | self.listWidget = QtWidgets.QListWidget(self.centralwidget) 37 | self.listWidget.setGeometry(QtCore.QRect(30, 10, 256, 192)) 38 | self.listWidget.setObjectName("listWidget") 39 | self.stackedWidget = QtWidgets.QStackedWidget(self.centralwidget) 40 | self.stackedWidget.setGeometry(QtCore.QRect(310, 20, 281, 51)) 41 | self.stackedWidget.setObjectName("stackedWidget") 42 | self.quit_btn_3 = QtWidgets.QPushButton(self.centralwidget) 43 | self.quit_btn_3.setGeometry(QtCore.QRect(350, 270, 91, 34)) 44 | font = QtGui.QFont() 45 | font.setFamily("Palatino") 46 | font.setPointSize(14) 47 | self.quit_btn_3.setFont(font) 48 | self.quit_btn_3.setObjectName("quit_btn_3") 49 | self.verticalScrollBar = QtWidgets.QScrollBar(self.centralwidget) 50 | self.verticalScrollBar.setGeometry(QtCore.QRect(890, 60, 16, 571)) 51 | self.verticalScrollBar.setOrientation(QtCore.Qt.Vertical) 52 | self.verticalScrollBar.setObjectName("verticalScrollBar") 53 | self.verticalScrollBar_2 = QtWidgets.QScrollBar(self.centralwidget) 54 | self.verticalScrollBar_2.setGeometry(QtCore.QRect(930, 60, 16, 491)) 55 | self.verticalScrollBar_2.setOrientation(QtCore.Qt.Vertical) 56 | self.verticalScrollBar_2.setObjectName("verticalScrollBar_2") 57 | self.verticalScrollBar_3 = QtWidgets.QScrollBar(self.centralwidget) 58 | self.verticalScrollBar_3.setGeometry(QtCore.QRect(980, 60, 16, 491)) 59 | self.verticalScrollBar_3.setOrientation(QtCore.Qt.Vertical) 60 | self.verticalScrollBar_3.setObjectName("verticalScrollBar_3") 61 | self.label = QtWidgets.QLabel(self.centralwidget) 62 | self.label.setGeometry(QtCore.QRect(620, 90, 181, 81)) 63 | font = QtGui.QFont() 64 | font.setPointSize(28) 65 | font.setBold(True) 66 | font.setWeight(75) 67 | self.label.setFont(font) 68 | self.label.setObjectName("label") 69 | MainWindow.setCentralWidget(self.centralwidget) 70 | self.menubar = QtWidgets.QMenuBar(MainWindow) 71 | self.menubar.setGeometry(QtCore.QRect(0, 0, 1200, 28)) 72 | self.menubar.setObjectName("menubar") 73 | MainWindow.setMenuBar(self.menubar) 74 | self.statusbar = QtWidgets.QStatusBar(MainWindow) 75 | self.statusbar.setObjectName("statusbar") 76 | MainWindow.setStatusBar(self.statusbar) 77 | self.dockWidget = QtWidgets.QDockWidget(MainWindow) 78 | self.dockWidget.setObjectName("dockWidget") 79 | self.dockWidgetContents_4 = QtWidgets.QWidget() 80 | self.dockWidgetContents_4.setObjectName("dockWidgetContents_4") 81 | self.dockWidget.setWidget(self.dockWidgetContents_4) 82 | MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(8), self.dockWidget) 83 | 84 | self.retranslateUi(MainWindow) 85 | self.tabWidget.setCurrentIndex(-1) 86 | self.stackedWidget.setCurrentIndex(-1) 87 | QtCore.QMetaObject.connectSlotsByName(MainWindow) 88 | 89 | def retranslateUi(self, MainWindow): 90 | _translate = QtCore.QCoreApplication.translate 91 | MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) 92 | self.quit_btn.setText(_translate("MainWindow", "退出")) 93 | self.quit_btn_2.setText(_translate("MainWindow", "显示")) 94 | self.quit_btn_3.setText(_translate("MainWindow", "新建")) 95 | self.label.setText(_translate("MainWindow", "color")) 96 | -------------------------------------------------------------------------------- /GUI/Basic-train/AdvanWin/Container/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 1200 10 | 740 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | 19 | 20 | 1100 21 | 660 22 | 91 23 | 34 24 | 25 | 26 | 27 | 28 | Palatino 29 | 14 30 | 31 | 32 | 33 | 退出 34 | 35 | 36 | 37 | 38 | 39 | 30 40 | 210 41 | 291 42 | 211 43 | 44 | 45 | 46 | -1 47 | 48 | 49 | 50 | 51 | 52 | 350 53 | 210 54 | 91 55 | 34 56 | 57 | 58 | 59 | 60 | Palatino 61 | 14 62 | 63 | 64 | 65 | 显示 66 | 67 | 68 | 69 | 70 | 71 | 30 72 | 10 73 | 256 74 | 192 75 | 76 | 77 | 78 | 79 | 80 | 81 | 310 82 | 20 83 | 281 84 | 51 85 | 86 | 87 | 88 | -1 89 | 90 | 91 | 92 | 93 | 94 | 350 95 | 270 96 | 91 97 | 34 98 | 99 | 100 | 101 | 102 | Palatino 103 | 14 104 | 105 | 106 | 107 | 新建 108 | 109 | 110 | 111 | 112 | 113 | 890 114 | 60 115 | 16 116 | 571 117 | 118 | 119 | 120 | Qt::Vertical 121 | 122 | 123 | 124 | 125 | 126 | 930 127 | 60 128 | 16 129 | 491 130 | 131 | 132 | 133 | Qt::Vertical 134 | 135 | 136 | 137 | 138 | 139 | 980 140 | 60 141 | 16 142 | 491 143 | 144 | 145 | 146 | Qt::Vertical 147 | 148 | 149 | 150 | 151 | 152 | 620 153 | 90 154 | 181 155 | 81 156 | 157 | 158 | 159 | 160 | 28 161 | 75 162 | true 163 | 164 | 165 | 166 | color 167 | 168 | 169 | 170 | 171 | 172 | 173 | 0 174 | 0 175 | 1200 176 | 28 177 | 178 | 179 | 180 | 181 | 182 | 183 | 8 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | -------------------------------------------------------------------------------- /GUI/Basic-train/AdvanWin/ViewWidget/__pycache__/mainwindow.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/AdvanWin/ViewWidget/__pycache__/mainwindow.cpython-37.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/AdvanWin/ViewWidget/icon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/AdvanWin/ViewWidget/icon.jpg -------------------------------------------------------------------------------- /GUI/Basic-train/AdvanWin/ViewWidget/mainwindow.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'mainwindow.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.13.1 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | 10 | from PyQt5 import QtCore, QtGui, QtWidgets 11 | 12 | 13 | class Ui_MainWindow(object): 14 | def setupUi(self, MainWindow): 15 | MainWindow.setObjectName("MainWindow") 16 | MainWindow.resize(1200, 740) 17 | self.centralwidget = QtWidgets.QWidget(MainWindow) 18 | self.centralwidget.setObjectName("centralwidget") 19 | self.quit_btn = QtWidgets.QPushButton(self.centralwidget) 20 | self.quit_btn.setGeometry(QtCore.QRect(1050, 640, 91, 34)) 21 | font = QtGui.QFont() 22 | font.setFamily("苹方") 23 | font.setPointSize(12) 24 | self.quit_btn.setFont(font) 25 | self.quit_btn.setObjectName("quit_btn") 26 | self.tableView = QtWidgets.QTableView(self.centralwidget) 27 | self.tableView.setGeometry(QtCore.QRect(30, 20, 571, 211)) 28 | font = QtGui.QFont() 29 | font.setFamily("苹方") 30 | font.setPointSize(16) 31 | self.tableView.setFont(font) 32 | self.tableView.setObjectName("tableView") 33 | self.listView = QtWidgets.QListView(self.centralwidget) 34 | self.listView.setGeometry(QtCore.QRect(40, 250, 191, 101)) 35 | self.listView.setObjectName("listView") 36 | self.tableWidget = QtWidgets.QTableWidget(self.centralwidget) 37 | self.tableWidget.setGeometry(QtCore.QRect(40, 380, 511, 291)) 38 | self.tableWidget.setObjectName("tableWidget") 39 | self.tableWidget.setColumnCount(0) 40 | self.tableWidget.setRowCount(0) 41 | self.pushButton = QtWidgets.QPushButton(self.centralwidget) 42 | self.pushButton.setGeometry(QtCore.QRect(360, 270, 91, 34)) 43 | font = QtGui.QFont() 44 | font.setPointSize(14) 45 | font.setBold(True) 46 | font.setWeight(75) 47 | self.pushButton.setFont(font) 48 | self.pushButton.setObjectName("pushButton") 49 | self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget) 50 | self.pushButton_2.setGeometry(QtCore.QRect(360, 320, 91, 34)) 51 | font = QtGui.QFont() 52 | font.setPointSize(14) 53 | font.setBold(True) 54 | font.setWeight(75) 55 | self.pushButton_2.setFont(font) 56 | self.pushButton_2.setObjectName("pushButton_2") 57 | self.tableView_2 = QtWidgets.QTableView(self.centralwidget) 58 | self.tableView_2.setGeometry(QtCore.QRect(700, 20, 311, 192)) 59 | self.tableView_2.setObjectName("tableView_2") 60 | self.treeWidget = QtWidgets.QTreeWidget(self.centralwidget) 61 | self.treeWidget.setGeometry(QtCore.QRect(710, 230, 441, 151)) 62 | self.treeWidget.setObjectName("treeWidget") 63 | self.treeView = QtWidgets.QTreeView(self.centralwidget) 64 | self.treeView.setGeometry(QtCore.QRect(600, 390, 561, 231)) 65 | self.treeView.setObjectName("treeView") 66 | MainWindow.setCentralWidget(self.centralwidget) 67 | self.menubar = QtWidgets.QMenuBar(MainWindow) 68 | self.menubar.setGeometry(QtCore.QRect(0, 0, 1200, 28)) 69 | self.menubar.setObjectName("menubar") 70 | MainWindow.setMenuBar(self.menubar) 71 | self.statusbar = QtWidgets.QStatusBar(MainWindow) 72 | self.statusbar.setObjectName("statusbar") 73 | MainWindow.setStatusBar(self.statusbar) 74 | 75 | self.retranslateUi(MainWindow) 76 | QtCore.QMetaObject.connectSlotsByName(MainWindow) 77 | 78 | def retranslateUi(self, MainWindow): 79 | _translate = QtCore.QCoreApplication.translate 80 | MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) 81 | self.quit_btn.setText(_translate("MainWindow", "退出")) 82 | self.pushButton.setText(_translate("MainWindow", "升序")) 83 | self.pushButton_2.setText(_translate("MainWindow", "降序")) 84 | self.treeWidget.headerItem().setText(0, _translate("MainWindow", "3")) 85 | -------------------------------------------------------------------------------- /GUI/Basic-train/AdvanWin/ViewWidget/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 1200 10 | 740 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | 19 | 20 | 1050 21 | 640 22 | 91 23 | 34 24 | 25 | 26 | 27 | 28 | 苹方 29 | 12 30 | 31 | 32 | 33 | 退出 34 | 35 | 36 | 37 | 38 | 39 | 30 40 | 20 41 | 571 42 | 211 43 | 44 | 45 | 46 | 47 | 苹方 48 | 16 49 | 50 | 51 | 52 | 53 | 54 | 55 | 40 56 | 250 57 | 191 58 | 101 59 | 60 | 61 | 62 | 63 | 64 | 65 | 40 66 | 380 67 | 511 68 | 291 69 | 70 | 71 | 72 | 73 | 74 | 75 | 360 76 | 270 77 | 91 78 | 34 79 | 80 | 81 | 82 | 83 | 14 84 | 75 85 | true 86 | 87 | 88 | 89 | 升序 90 | 91 | 92 | 93 | 94 | 95 | 360 96 | 320 97 | 91 98 | 34 99 | 100 | 101 | 102 | 103 | 14 104 | 75 105 | true 106 | 107 | 108 | 109 | 降序 110 | 111 | 112 | 113 | 114 | 115 | 700 116 | 20 117 | 311 118 | 192 119 | 120 | 121 | 122 | 123 | 124 | 125 | 710 126 | 230 127 | 441 128 | 151 129 | 130 | 131 | 132 | 133 | 3 134 | 135 | 136 | 137 | 138 | 139 | 140 | 600 141 | 390 142 | 561 143 | 231 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 0 152 | 0 153 | 1200 154 | 28 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | -------------------------------------------------------------------------------- /GUI/Basic-train/AdvanWin/WebPage/__pycache__/mainwindow.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/AdvanWin/WebPage/__pycache__/mainwindow.cpython-37.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/AdvanWin/WebPage/mainwindow.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'mainwindow.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.13.1 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | 10 | from PyQt5 import QtCore, QtGui, QtWidgets 11 | 12 | 13 | class Ui_MainWindow(object): 14 | def setupUi(self, MainWindow): 15 | MainWindow.setObjectName("MainWindow") 16 | MainWindow.resize(1202, 774) 17 | self.centralwidget = QtWidgets.QWidget(MainWindow) 18 | self.centralwidget.setObjectName("centralwidget") 19 | self.quit_btn = QtWidgets.QPushButton(self.centralwidget) 20 | self.quit_btn.setGeometry(QtCore.QRect(1100, 650, 91, 34)) 21 | font = QtGui.QFont() 22 | font.setFamily("苹方") 23 | font.setPointSize(14) 24 | self.quit_btn.setFont(font) 25 | self.quit_btn.setObjectName("quit_btn") 26 | self.label = QtWidgets.QLabel(self.centralwidget) 27 | self.label.setGeometry(QtCore.QRect(10, 20, 381, 51)) 28 | font = QtGui.QFont() 29 | font.setPointSize(16) 30 | font.setBold(True) 31 | font.setWeight(75) 32 | self.label.setFont(font) 33 | self.label.setLayoutDirection(QtCore.Qt.RightToLeft) 34 | self.label.setObjectName("label") 35 | self.quit_btn_2 = QtWidgets.QPushButton(self.centralwidget) 36 | self.quit_btn_2.setGeometry(QtCore.QRect(30, 80, 91, 34)) 37 | font = QtGui.QFont() 38 | font.setFamily("苹方") 39 | font.setPointSize(14) 40 | self.quit_btn_2.setFont(font) 41 | self.quit_btn_2.setObjectName("quit_btn_2") 42 | self.quit_btn_3 = QtWidgets.QPushButton(self.centralwidget) 43 | self.quit_btn_3.setGeometry(QtCore.QRect(170, 80, 91, 34)) 44 | font = QtGui.QFont() 45 | font.setFamily("苹方") 46 | font.setPointSize(14) 47 | self.quit_btn_3.setFont(font) 48 | self.quit_btn_3.setObjectName("quit_btn_3") 49 | self.quit_btn_4 = QtWidgets.QPushButton(self.centralwidget) 50 | self.quit_btn_4.setGeometry(QtCore.QRect(10, 140, 91, 34)) 51 | font = QtGui.QFont() 52 | font.setFamily("苹方") 53 | font.setPointSize(14) 54 | self.quit_btn_4.setFont(font) 55 | self.quit_btn_4.setObjectName("quit_btn_4") 56 | self.webEngineView = QtWebEngineWidgets.QWebEngineView(self.centralwidget) 57 | self.webEngineView.setGeometry(QtCore.QRect(0, 180, 1201, 531)) 58 | self.webEngineView.setUrl(QtCore.QUrl("about:blank")) 59 | self.webEngineView.setObjectName("webEngineView") 60 | MainWindow.setCentralWidget(self.centralwidget) 61 | self.menubar = QtWidgets.QMenuBar(MainWindow) 62 | self.menubar.setGeometry(QtCore.QRect(0, 0, 1202, 30)) 63 | self.menubar.setObjectName("menubar") 64 | MainWindow.setMenuBar(self.menubar) 65 | self.statusbar = QtWidgets.QStatusBar(MainWindow) 66 | self.statusbar.setObjectName("statusbar") 67 | MainWindow.setStatusBar(self.statusbar) 68 | 69 | self.retranslateUi(MainWindow) 70 | QtCore.QMetaObject.connectSlotsByName(MainWindow) 71 | 72 | def retranslateUi(self, MainWindow): 73 | _translate = QtCore.QCoreApplication.translate 74 | MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) 75 | self.quit_btn.setText(_translate("MainWindow", "退出")) 76 | self.label.setText(_translate("MainWindow", "显示时间")) 77 | self.quit_btn_2.setText(_translate("MainWindow", "开始")) 78 | self.quit_btn_3.setText(_translate("MainWindow", "结束")) 79 | self.quit_btn_4.setText(_translate("MainWindow", "加载界面")) 80 | from PyQt5 import QtWebEngineWidgets 81 | -------------------------------------------------------------------------------- /GUI/Basic-train/AdvanWin/WebPage/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 1202 10 | 774 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | 19 | 20 | 1100 21 | 650 22 | 91 23 | 34 24 | 25 | 26 | 27 | 28 | 苹方 29 | 14 30 | 31 | 32 | 33 | 退出 34 | 35 | 36 | 37 | 38 | 39 | 10 40 | 20 41 | 381 42 | 51 43 | 44 | 45 | 46 | 47 | 16 48 | 75 49 | true 50 | 51 | 52 | 53 | Qt::RightToLeft 54 | 55 | 56 | 显示时间 57 | 58 | 59 | 60 | 61 | 62 | 30 63 | 80 64 | 91 65 | 34 66 | 67 | 68 | 69 | 70 | 苹方 71 | 14 72 | 73 | 74 | 75 | 开始 76 | 77 | 78 | 79 | 80 | 81 | 170 82 | 80 83 | 91 84 | 34 85 | 86 | 87 | 88 | 89 | 苹方 90 | 14 91 | 92 | 93 | 94 | 结束 95 | 96 | 97 | 98 | 99 | 100 | 10 101 | 140 102 | 91 103 | 34 104 | 105 | 106 | 107 | 108 | 苹方 109 | 14 110 | 111 | 112 | 113 | 加载界面 114 | 115 | 116 | 117 | 118 | 119 | 10 120 | 170 121 | 1201 122 | 531 123 | 124 | 125 | 126 | 127 | about:blank 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 0 136 | 0 137 | 1202 138 | 28 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | QWebEngineView 147 | QWidget 148 |
QtWebEngineWidgets/QWebEngineView
149 |
150 |
151 | 152 | 153 |
154 | -------------------------------------------------------------------------------- /GUI/Basic-train/AdvanWin/WebPage/web.py: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # -*- coding: UTF-8 -*- 3 | import sys 4 | import time 5 | import PyQt5 6 | # 基本控件都在这里面 7 | from PyQt5.QtWidgets import (QApplication, QMainWindow, QDesktopWidget) 8 | from PyQt5.QtCore import QTimer, QDateTime, Qt, QUrl, QThread 9 | # from PyQt5.QtGui import QColor, QPalette 10 | from mainwindow import Ui_MainWindow 11 | 12 | # 继承主窗口 Qmainwindow 和 自己画的界面 Ui_MainWindow 13 | class MyMainWindow(QMainWindow, Ui_MainWindow): 14 | 15 | def __init__(self, parent = None): 16 | super(MyMainWindow, self).__init__(parent) 17 | self.setupUi(self) 18 | # self.resize(1200, 740) 19 | 20 | # 默认的状态栏 21 | self.status = self.statusBar() 22 | self.status.showMessage("你在主页面~") 23 | 24 | # 标题栏 25 | self.setWindowTitle("建模协会录入信息") 26 | 27 | # 窗口居中 28 | self.center() 29 | 30 | # 退出窗口 31 | self.quit_btn.clicked.connect(self.quit_act) 32 | 33 | # 定时器 34 | self.timer = QTimer() 35 | self.timer.timeout.connect(self.show_time) 36 | self.quit_btn_2.clicked.connect(self.start_time) 37 | self.quit_btn_3.clicked.connect(self.end_time) 38 | 39 | # 加载网络界面 40 | self.quit_btn_4.clicked.connect(self.show_page) # 加载外部的界面 41 | # 加载本地的页面 42 | # url = rE:/index.html' 43 | # self.webEngineView.load(Qurl(url)) 44 | 45 | # pyqt 与 JavaScript 可以相互调用 46 | 47 | def show_page(self): 48 | self.webEngineView.load(QUrl('https://muyuuuu.github.io/')) 49 | 50 | def start_time(self): 51 | self.timer.start() # 不设置间隔时间 52 | 53 | def end_time(self): 54 | self.timer.stop() 55 | 56 | def show_time(self): 57 | time = QDateTime.currentDateTime() 58 | time = time.toString("yyyy-MM-dd hh : mm : ss dddd") 59 | self.label.setText(time) 60 | 61 | def quit_act(self): 62 | # sender 是发送信号的对象 63 | sender = self.sender() 64 | print(sender.text() + '键被按下') 65 | qApp = QApplication.instance() 66 | qApp.quit() 67 | 68 | def center(self): 69 | ''' 70 | 获取桌面长宽 71 | 获取窗口长宽 72 | 移动 73 | ''' 74 | screen = QDesktopWidget().screenGeometry() 75 | size = self.geometry() 76 | self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2) 77 | 78 | 79 | if __name__ == "__main__": 80 | # 在shell中执行 81 | app = QApplication(sys.argv) 82 | mywin = MyMainWindow() 83 | mywin.show() 84 | # 开始主循环,直到退出 85 | sys.exit(app.exec()) -------------------------------------------------------------------------------- /GUI/Basic-train/BasicWin/__pycache__/mainwindow.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/BasicWin/__pycache__/mainwindow.cpython-37.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/BasicWin/a.py: -------------------------------------------------------------------------------- 1 | print("test") -------------------------------------------------------------------------------- /GUI/Basic-train/BasicWin/icon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/BasicWin/icon.jpg -------------------------------------------------------------------------------- /GUI/Basic-train/BasicWin/test.data: -------------------------------------------------------------------------------- 1 | asd -------------------------------------------------------------------------------- /GUI/Basic-train/DataBase/__pycache__/mainwidget.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/DataBase/__pycache__/mainwidget.cpython-37.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/DataBase/__pycache__/mainwindow.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/DataBase/__pycache__/mainwindow.cpython-37.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/DataBase/database.py: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # -*- coding: UTF-8 -*- 3 | import sys 4 | import time 5 | import PyQt5 6 | # 基本控件都在这里面 7 | from PyQt5.QtWidgets import (QApplication, QMainWindow, QDesktopWidget, QStyleFactory, QWidget, 8 | QMessageBox, QTableView) 9 | from PyQt5.QtGui import QPalette, QColor 10 | from PyQt5.QtCore import Qt 11 | # 导入数据库 12 | from PyQt5.QtSql import QSqlDatabase, QSqlQuery, QSqlTableModel 13 | from mainwidget import Ui_Form 14 | from mainwindow import Ui_MainWindow 15 | 16 | # 继承主窗口 Qmainwindow 和 自己画的界面 Ui_MainWindow 17 | class MyMainWidget(QWidget, Ui_Form): 18 | 19 | def __init__(self, parent = None): 20 | super(MyMainWidget, self).__init__(parent) 21 | self.setupUi(self) 22 | 23 | self.setLayout(self.gridLayout) 24 | 25 | # 退出窗口 26 | self.quit_btn.clicked.connect(self.quit_act) 27 | 28 | # 链接sql与查询 29 | self.db = QSqlDatabase.addDatabase("QSQLITE") 30 | self.db.setDatabaseName('table/test.db') 31 | self.db.open() 32 | if not self.db.open(): 33 | QMessageBox.critical(None, ("无法打开数据库"), ("SQlite支持"), QMessageBox.Cancel) 34 | return False 35 | 36 | self.model = QSqlTableModel() 37 | 38 | self.pushButton.clicked.connect(self.insert) 39 | self.pushButton_2.clicked.connect(self.query) 40 | self.pushButton_3.clicked.connect(self.insert_oneline) 41 | self.pushButton_4.clicked.connect(self.del_oneline) 42 | self.pushButton_5.clicked.connect(self.find_row) 43 | 44 | # 打印行列号 45 | def find_row(self): 46 | print(self.view.currentIndex().row() + 1, self.view.currentIndex().column() + 1) 47 | 48 | # 删除一行 49 | def del_oneline(self): 50 | self.model.removeRow(self.view.currentIndex().row()) 51 | self.model.setEditStrategy(QSqlTableModel.OnFieldChange) 52 | self.model.select() 53 | self.view.setModel(self.model) 54 | self.view.show() 55 | 56 | # 插入一行 57 | def insert_oneline(self): 58 | self.model.insertRows(self.model.rowCount(), 1) 59 | # print(str(ret)) 60 | 61 | def query(self): 62 | self.model.setTable("people") 63 | self.model.setEditStrategy(QSqlTableModel.OnFieldChange) 64 | # self.model.setFilter("id > 1") 65 | self.model.select() 66 | self.model.setHeaderData(0, Qt.Horizontal, "ID") 67 | self.model.setHeaderData(1, Qt.Horizontal, "Name") 68 | self.model.setHeaderData(2, Qt.Horizontal, "Address") 69 | self.view.setModel(self.model) 70 | self.view.show() 71 | 72 | def insert(self): 73 | query = QSqlQuery() 74 | # query.exec_("create table people(id int primary key, name varchar(20), address varchar(30))") 75 | # query.exec_("insert into people values(1, 'one', 'test1')") 76 | # query.exec_("insert into people values(2, 'two', 'test2')") 77 | # query.exec_("insert into people values(3, 'three', 'test3')") 78 | # query.exec_("insert into people values(4, 'four', 'test4')") 79 | for i in range (6, 100): 80 | query.exec_("insert into people values({}, 'test', 'test{}')".format(i, i)) 81 | 82 | def quit_act(self): 83 | # sender 是发送信号的对象 84 | sender = self.sender() 85 | print(sender.text() + '键被按下') 86 | qApp = QApplication.instance() 87 | self.db.close() 88 | qApp.quit() 89 | 90 | 91 | class MyMainWindow(QMainWindow, Ui_MainWindow): 92 | 93 | def __init__(self, parent = None): 94 | super(MyMainWindow, self).__init__(parent) 95 | self.setupUi(self) 96 | 97 | self.q = MyMainWidget() 98 | self.setCentralWidget(self.q) 99 | 100 | # 设置窗口透明 101 | self.setWindowOpacity(0.9) 102 | 103 | # self.resize(1000, 700) 104 | 105 | # 默认的状态栏 106 | # 可以设置其他按钮点击 参考多行文本显示 然而不行 107 | self.status = self.statusBar() 108 | self.status.showMessage("你在主页面~") 109 | 110 | # 标题栏 111 | self.setWindowTitle("建模协会录入信息") 112 | 113 | # 窗口居中 114 | self.center() 115 | 116 | def center(self): 117 | ''' 118 | 获取桌面长宽 119 | 获取窗口长宽 120 | 移动 121 | ''' 122 | screen = QDesktopWidget().screenGeometry() 123 | size = self.geometry() 124 | self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2) 125 | 126 | def closeEvent(self, e): 127 | self.q.db.close() 128 | 129 | 130 | if __name__ == "__main__": 131 | # 在shell中执行 132 | app = QApplication(sys.argv) 133 | mywin = MyMainWindow() 134 | mywin.show() 135 | # 开始主循环,直到退出 136 | sys.exit(app.exec()) 137 | -------------------------------------------------------------------------------- /GUI/Basic-train/DataBase/mainwidget.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'mainwidget.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.13.1 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | 10 | from PyQt5 import QtCore, QtGui, QtWidgets 11 | 12 | 13 | class Ui_Form(object): 14 | def setupUi(self, Form): 15 | Form.setObjectName("Form") 16 | Form.resize(976, 678) 17 | self.widget = QtWidgets.QWidget(Form) 18 | self.widget.setGeometry(QtCore.QRect(10, 150, 921, 274)) 19 | self.widget.setObjectName("widget") 20 | self.gridLayout = QtWidgets.QGridLayout(self.widget) 21 | self.gridLayout.setContentsMargins(0, 0, 0, 0) 22 | self.gridLayout.setObjectName("gridLayout") 23 | self.pushButton_2 = QtWidgets.QPushButton(self.widget) 24 | self.pushButton_2.setObjectName("pushButton_2") 25 | self.gridLayout.addWidget(self.pushButton_2, 2, 0, 1, 1) 26 | self.pushButton_3 = QtWidgets.QPushButton(self.widget) 27 | self.pushButton_3.setObjectName("pushButton_3") 28 | self.gridLayout.addWidget(self.pushButton_3, 1, 0, 1, 1) 29 | self.pushButton_4 = QtWidgets.QPushButton(self.widget) 30 | self.pushButton_4.setObjectName("pushButton_4") 31 | self.gridLayout.addWidget(self.pushButton_4, 0, 0, 1, 1) 32 | self.view = QtWidgets.QTableView(self.widget) 33 | self.view.setObjectName("view") 34 | self.gridLayout.addWidget(self.view, 0, 1, 7, 1) 35 | self.pushButton = QtWidgets.QPushButton(self.widget) 36 | self.pushButton.setObjectName("pushButton") 37 | self.gridLayout.addWidget(self.pushButton, 3, 0, 1, 1) 38 | self.quit_btn = QtWidgets.QPushButton(self.widget) 39 | self.quit_btn.setObjectName("quit_btn") 40 | self.gridLayout.addWidget(self.quit_btn, 4, 0, 1, 1) 41 | self.pushButton_5 = QtWidgets.QPushButton(self.widget) 42 | self.pushButton_5.setObjectName("pushButton_5") 43 | self.gridLayout.addWidget(self.pushButton_5, 5, 0, 1, 1) 44 | 45 | self.retranslateUi(Form) 46 | QtCore.QMetaObject.connectSlotsByName(Form) 47 | 48 | def retranslateUi(self, Form): 49 | _translate = QtCore.QCoreApplication.translate 50 | Form.setWindowTitle(_translate("Form", "Form")) 51 | self.pushButton_2.setText(_translate("Form", "查询")) 52 | self.pushButton_3.setText(_translate("Form", "插入一行")) 53 | self.pushButton_4.setText(_translate("Form", "删除一行")) 54 | self.pushButton.setText(_translate("Form", "插入")) 55 | self.quit_btn.setText(_translate("Form", "退出")) 56 | self.pushButton_5.setText(_translate("Form", "打印行号")) 57 | -------------------------------------------------------------------------------- /GUI/Basic-train/DataBase/mainwidget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Form 4 | 5 | 6 | 7 | 0 8 | 0 9 | 976 10 | 678 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 10 20 | 150 21 | 921 22 | 274 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 | -------------------------------------------------------------------------------- /GUI/Basic-train/DataBase/mainwindow.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'mainwindow.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.13.1 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | 10 | from PyQt5 import QtCore, QtGui, QtWidgets 11 | 12 | 13 | class Ui_MainWindow(object): 14 | def setupUi(self, MainWindow): 15 | MainWindow.setObjectName("MainWindow") 16 | MainWindow.resize(800, 717) 17 | self.centralwidget = QtWidgets.QWidget(MainWindow) 18 | self.centralwidget.setObjectName("centralwidget") 19 | self.pushButton = QtWidgets.QPushButton(self.centralwidget) 20 | self.pushButton.setGeometry(QtCore.QRect(120, 80, 110, 34)) 21 | self.pushButton.setObjectName("pushButton") 22 | MainWindow.setCentralWidget(self.centralwidget) 23 | self.menubar = QtWidgets.QMenuBar(MainWindow) 24 | self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 28)) 25 | self.menubar.setObjectName("menubar") 26 | self.menuLabel = QtWidgets.QMenu(self.menubar) 27 | self.menuLabel.setObjectName("menuLabel") 28 | MainWindow.setMenuBar(self.menubar) 29 | self.statusbar = QtWidgets.QStatusBar(MainWindow) 30 | self.statusbar.setObjectName("statusbar") 31 | MainWindow.setStatusBar(self.statusbar) 32 | self.menubar.addAction(self.menuLabel.menuAction()) 33 | 34 | self.retranslateUi(MainWindow) 35 | QtCore.QMetaObject.connectSlotsByName(MainWindow) 36 | 37 | def retranslateUi(self, MainWindow): 38 | _translate = QtCore.QCoreApplication.translate 39 | MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) 40 | self.pushButton.setText(_translate("MainWindow", "PushButton")) 41 | self.menuLabel.setTitle(_translate("MainWindow", "label")) 42 | -------------------------------------------------------------------------------- /GUI/Basic-train/DataBase/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 800 10 | 717 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | 19 | 20 | 0 21 | 0 22 | 800 23 | 28 24 | 25 | 26 | 27 | 28 | label 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /GUI/Basic-train/DataBase/table/test.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/DataBase/table/test.db -------------------------------------------------------------------------------- /GUI/Basic-train/DataBase/table/test1.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/DataBase/table/test1.db -------------------------------------------------------------------------------- /GUI/Basic-train/MVC/MVC-demo/UI/__pycache__/left_btn.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/MVC/MVC-demo/UI/__pycache__/left_btn.cpython-38.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/MVC/MVC-demo/UI/__pycache__/leftbtn_ui.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/MVC/MVC-demo/UI/__pycache__/leftbtn_ui.cpython-38.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/MVC/MVC-demo/UI/__pycache__/login.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/MVC/MVC-demo/UI/__pycache__/login.cpython-38.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/MVC/MVC-demo/UI/__pycache__/login_ui.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/MVC/MVC-demo/UI/__pycache__/login_ui.cpython-38.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/MVC/MVC-demo/UI/__pycache__/main_window.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/MVC/MVC-demo/UI/__pycache__/main_window.cpython-38.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/MVC/MVC-demo/UI/__pycache__/main_window_ui.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/MVC/MVC-demo/UI/__pycache__/main_window_ui.cpython-38.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/MVC/MVC-demo/UI/__pycache__/verify_ui.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/MVC/MVC-demo/UI/__pycache__/verify_ui.cpython-38.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/MVC/MVC-demo/UI/leftbtn_ui.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtWidgets import QPushButton, QVBoxLayout, QWidget 2 | from PyQt5 import QtCore 3 | 4 | 5 | class add_btn(QWidget): 6 | verify_signal = QtCore.pyqtSignal() 7 | login_signal = QtCore.pyqtSignal() 8 | 9 | def __init__(self, left_frame, right_layout): 10 | super(add_btn, self).__init__() 11 | 12 | self.right_layout = right_layout 13 | 14 | # 登录按钮 用于验证身份 15 | button_layout = QVBoxLayout(left_frame) 16 | self.verifyid_btn = QPushButton("确认身份") 17 | button_layout.addWidget(self.verifyid_btn) 18 | # 输入用户名 密码按钮 19 | # 因为在radiobutton中需要选择是否为管理员 20 | # 因此需要 确定某些按钮是否可用,所以,设置为self方便子函数的调用 21 | self.user_btn = QPushButton("登录") 22 | self.user_btn.setEnabled(False) 23 | button_layout.addWidget(self.user_btn) 24 | 25 | self.verifyid_btn.clicked.connect(self.verify_signal) 26 | self.user_btn.clicked.connect(self.login_signal) 27 | 28 | def show_verified_page(self): 29 | self.right_layout.setCurrentIndex(0) 30 | 31 | def show_login_page(self): 32 | self.right_layout.setCurrentIndex(1) -------------------------------------------------------------------------------- /GUI/Basic-train/MVC/MVC-demo/UI/login_ui.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtWidgets import QLineEdit, QVBoxLayout, QPushButton, QHBoxLayout, QWidget, QMessageBox 2 | from PyQt5 import QtCore 3 | 4 | 5 | class add_login(QWidget): 6 | login_signal = QtCore.pyqtSignal() 7 | def __init__(self, *args, **kwargs): 8 | super(add_login, self).__init__(*args, **kwargs) 9 | 10 | self.user_line = QLineEdit() 11 | self.user_line.setPlaceholderText("请输入账号:(游客可直接查询,请勿登录)") 12 | self.user_line.setFixedHeight(40) 13 | self.psd_line = QLineEdit() 14 | self.psd_line.setPlaceholderText("请输入密码:") 15 | self.psd_line.setEchoMode(QLineEdit.Password) 16 | self.psd_line.setFixedHeight(40) 17 | # 帐号密码的布局 18 | login_layout = QVBoxLayout() 19 | login_btn_layout = QHBoxLayout() 20 | login_btn_cancel = QPushButton("取消") 21 | self.login_btn_confirm = QPushButton("确认") 22 | # 按钮的布局 23 | login_btn_layout.addWidget(login_btn_cancel) 24 | login_btn_layout.addWidget(self.login_btn_confirm) 25 | # 添加全部元素的布局 26 | login_layout.addWidget(self.user_line) 27 | login_layout.addWidget(self.psd_line) 28 | login_layout.addLayout(login_btn_layout) 29 | self.login_widget = QWidget() 30 | self.login_widget.setLayout(login_layout) 31 | self.login_btn_confirm.clicked.connect(self.login) 32 | 33 | def login(self): 34 | self.login_signal.emit() 35 | 36 | def verify_ok(self): 37 | QMessageBox.about(self, "密码正确", "已经登录") 38 | 39 | def verify_no(self): 40 | QMessageBox.about(self, "你犯了一个粗误", "请重新检查输入") -------------------------------------------------------------------------------- /GUI/Basic-train/MVC/MVC-demo/UI/main_window_ui.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtWidgets import (QMainWindow, QDesktopWidget, QFrame, QStackedLayout, QSplitter, 2 | QGridLayout, QWidget) 3 | from PyQt5.QtCore import Qt 4 | import qdarkstyle 5 | from UI import leftbtn_ui, verify_ui, login_ui 6 | 7 | 8 | class MainWindow(QMainWindow): 9 | 10 | def __init__(self, *args, **kwargs): 11 | super(MainWindow, self).__init__(*args, **kwargs) 12 | 13 | # 设置窗口名称 14 | self.setWindowTitle("一个 MVC 实例") 15 | 16 | # 设置状态栏 17 | self.status = self.statusBar() 18 | self.status.showMessage("写着玩的~") 19 | 20 | # 设置初始化的窗口大小 21 | self.setFixedSize(600, 400) 22 | 23 | # 设置初始化的窗口位置 24 | self.center() 25 | 26 | # 设置整体布局 左右显示 27 | pagelayout = QGridLayout() 28 | 29 | """ 30 | 此处完成布局页面的基本功能 31 | 布局分为左侧和右侧,左侧为按钮,右侧为堆栈布局,完成鼠标点击的页面切换功能 32 | 最后两个布局部署在splitter中,完成页面内部拖拉界面可变大小 33 | """ 34 | 35 | # 创建左侧主窗口 36 | left_frame = QFrame(self) 37 | # 绘制矩形面板 38 | left_frame.setFrameShape(QFrame.StyledPanel) 39 | 40 | right_frame = QFrame(self) 41 | right_frame.setFrameShape(QFrame.StyledPanel) 42 | # 右边显示为stack布局 即点击按钮,右侧会加载不同的页面 43 | self.right_layout = QStackedLayout(right_frame) 44 | 45 | # 左侧按钮添加 46 | self.Btn = leftbtn_ui.add_btn(left_frame, self.right_layout) 47 | 48 | self.verify_page = verify_ui.add_verify() 49 | self.right_layout.addWidget(self.verify_page.radio_btn_widget) 50 | 51 | self.login_page = login_ui.add_login() 52 | self.right_layout.addWidget(self.login_page.login_widget) 53 | 54 | # 二分界面,可拖动 55 | self.splitter1 = QSplitter(Qt.Vertical) 56 | # left_frame.setFixedHeight(280) 57 | self.splitter1.addWidget(left_frame) 58 | self.splitter1.setMinimumWidth(150) 59 | self.splitter2 = QSplitter(Qt.Horizontal) 60 | self.splitter2.addWidget(self.splitter1) 61 | self.splitter2.setMinimumWidth(250) 62 | # 添加右侧的布局 63 | self.splitter2.addWidget(right_frame) 64 | 65 | # 窗口部件添加布局 66 | widget = QWidget() 67 | pagelayout.addWidget(self.splitter2) 68 | widget.setLayout(pagelayout) 69 | self.setCentralWidget(widget) 70 | self.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5()) 71 | 72 | def center(self): 73 | """ 74 | 获取桌面长宽 获取窗口长宽 计算位置 移动 75 | """ 76 | screen = QDesktopWidget().screenGeometry() 77 | size = self.geometry() 78 | self.move(int((screen.width() - size.width()) / 2), 79 | int((screen.height() - size.height()) / 2)) 80 | -------------------------------------------------------------------------------- /GUI/Basic-train/MVC/MVC-demo/UI/verify_ui.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtWidgets import QVBoxLayout, QWidget, QRadioButton 2 | from PyQt5 import QtCore 3 | 4 | 5 | class add_verify(QWidget): 6 | change_status = QtCore.pyqtSignal() 7 | 8 | def __init__(self, *args, **kwargs): 9 | super(add_verify, self).__init__(*args, **kwargs) 10 | # 确认身份 界面 11 | # 管理员身份 12 | self.radio_btn_admin = QRadioButton() 13 | self.radio_btn_admin.setText("我是管理员,来输入数据的") 14 | # 游客身份 二者只能选一个 15 | self.radio_btn_user = QRadioButton() 16 | self.radio_btn_user.setText("我是游客,就来看看") 17 | # 以垂直布局管理器管理 并设置为第一个界面 18 | radio_btn_layout = QVBoxLayout() 19 | self.radio_btn_widget = QWidget() 20 | radio_btn_layout.addWidget(self.radio_btn_admin) 21 | radio_btn_layout.addWidget(self.radio_btn_user) 22 | self.radio_btn_widget.setLayout(radio_btn_layout) 23 | 24 | 25 | self.radio_btn_user.toggled.connect(self.change_status) 26 | self.radio_btn_admin.toggled.connect(self.change_status) 27 | -------------------------------------------------------------------------------- /GUI/Basic-train/MVC/MVC-demo/control/__pycache__/controller.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/MVC/MVC-demo/control/__pycache__/controller.cpython-38.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/MVC/MVC-demo/control/__pycache__/left_btn_control.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/MVC/MVC-demo/control/__pycache__/left_btn_control.cpython-38.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/MVC/MVC-demo/control/__pycache__/leftbtn_control.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/MVC/MVC-demo/control/__pycache__/leftbtn_control.cpython-38.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/MVC/MVC-demo/control/__pycache__/login_control.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/MVC/MVC-demo/control/__pycache__/login_control.cpython-38.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/MVC/MVC-demo/control/__pycache__/verify_control.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/MVC/MVC-demo/control/__pycache__/verify_control.cpython-38.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/MVC/MVC-demo/control/__pycache__/verify_ui_control.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/MVC/MVC-demo/control/__pycache__/verify_ui_control.cpython-38.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/MVC/MVC-demo/control/controller.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5.QtWidgets import QApplication 3 | from model.model import Student 4 | from UI.main_window_ui import MainWindow 5 | from control import verify_control, leftbtn_control, login_control 6 | 7 | 8 | class Controll(object): 9 | 10 | def __init__(self): 11 | # 不需要从命令行输入参数 12 | # 初始换应用 13 | self._app = QApplication([]) 14 | # 初始化模型 15 | self._stu = Student() 16 | # 初始化试图 17 | self._view = MainWindow() 18 | self.init() 19 | 20 | # 各个子 controller 21 | def init(self): 22 | self.verify_ui_controller = verify_control.Controller(self._view.verify_page, self._view.Btn) 23 | self.left_btn_controller = leftbtn_control.Controller(self._view.Btn) 24 | self.login_controller = login_control.Controller(self._view.login_page, self._stu.name, self._stu.password) 25 | 26 | def run(self): 27 | self._view.show() 28 | # 事件循环,直到应用退出 29 | return self._app.exec() 30 | -------------------------------------------------------------------------------- /GUI/Basic-train/MVC/MVC-demo/control/leftbtn_control.py: -------------------------------------------------------------------------------- 1 | class Controller(object): 2 | def __init__(self, left_btn): 3 | self._left_btn = left_btn 4 | 5 | self._left_btn.verify_signal.connect(self._left_btn.show_verified_page) 6 | self._left_btn.login_signal.connect(self._left_btn.show_login_page) 7 | -------------------------------------------------------------------------------- /GUI/Basic-train/MVC/MVC-demo/control/login_control.py: -------------------------------------------------------------------------------- 1 | class Controller(object): 2 | def __init__(self, login_page, stu_id, stu_psd): 3 | self._login_page = login_page 4 | self._stu_id = stu_id 5 | self._stu_psd = stu_psd 6 | self._login_page.login_signal.connect(self.login) 7 | 8 | def login(self): 9 | id = self._login_page.user_line.text() 10 | psd = self._login_page.psd_line.text() 11 | 12 | if id == self._stu_id and psd == self._stu_psd: 13 | self._login_page.verify_ok() 14 | else: 15 | self._login_page.verify_no() 16 | -------------------------------------------------------------------------------- /GUI/Basic-train/MVC/MVC-demo/control/verify_control.py: -------------------------------------------------------------------------------- 1 | class Controller(object): 2 | def __init__(self, verify_page, left_btn): 3 | verify_page.change_status.connect(self.check_status) 4 | self._verify_page = verify_page 5 | self.left_btn = left_btn 6 | self.init() 7 | 8 | def init(self): 9 | self._verify_page.change_status.connect(self.check_status) 10 | 11 | def check_status(self): 12 | if self._verify_page.radio_btn_admin.isChecked(): 13 | self.left_btn.user_btn.setEnabled(True) 14 | else: 15 | self.left_btn.user_btn.setEnabled(False) -------------------------------------------------------------------------------- /GUI/Basic-train/MVC/MVC-demo/main.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from control.controller import Controll 3 | 4 | 5 | if __name__ == "__main__": 6 | controller = Controll() 7 | # 退出主程序 8 | sys.exit(controller.run()) -------------------------------------------------------------------------------- /GUI/Basic-train/MVC/MVC-demo/model/__pycache__/model.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/MVC/MVC-demo/model/__pycache__/model.cpython-38.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/MVC/MVC-demo/model/model.py: -------------------------------------------------------------------------------- 1 | class Student(object): 2 | 3 | def __init__(self): 4 | self.name = "aaa" 5 | self.password = "aaa" 6 | -------------------------------------------------------------------------------- /GUI/Basic-train/MVC/MVC-single-page/control/__pycache__/login_control.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/MVC/MVC-single-page/control/__pycache__/login_control.cpython-38.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/MVC/MVC-single-page/control/login_control.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import view.login as V 3 | import model.model as M 4 | from PyQt5.QtWidgets import QApplication 5 | 6 | 7 | class LoginControll(object): 8 | 9 | def __init__(self): 10 | # 不需要从命令行输入参数 11 | self._app = QApplication([]) 12 | self._model = M.Student() 13 | self._view = V.MainWindow() 14 | self.init() 15 | 16 | def init(self): 17 | self._view.verifySignal.connect(self.verify_user) 18 | 19 | def verify_user(self): 20 | id_ = self._view.id_line.text() 21 | psd_ = self._view.psd_line.text() 22 | 23 | if id_ == self._model.name and psd_ == self._model.password: 24 | self._view.verify_ok() 25 | else: 26 | self._view.verify_no() 27 | 28 | def run(self): 29 | self._view.show() 30 | # 事件循环,直到应用退出 31 | return self._app.exec_() 32 | -------------------------------------------------------------------------------- /GUI/Basic-train/MVC/MVC-single-page/main.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from control import login_control 3 | 4 | 5 | if __name__ == "__main__": 6 | login_control_ = login_control.LoginControll() 7 | # 退出主程序 8 | sys.exit(login_control_.run()) -------------------------------------------------------------------------------- /GUI/Basic-train/MVC/MVC-single-page/model/__pycache__/model.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/MVC/MVC-single-page/model/__pycache__/model.cpython-38.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/MVC/MVC-single-page/model/model.py: -------------------------------------------------------------------------------- 1 | class Student(object): 2 | 3 | def __init__(self): 4 | self.name = "aaa" 5 | self.password = "aaa" 6 | -------------------------------------------------------------------------------- /GUI/Basic-train/MVC/MVC-single-page/view/__pycache__/login.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/MVC/MVC-single-page/view/__pycache__/login.cpython-38.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/MVC/MVC-single-page/view/login.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtWidgets import QWidget, QHBoxLayout, QPushButton, QMessageBox, QLineEdit 2 | from PyQt5 import QtCore 3 | 4 | 5 | class MainWindow(QWidget): 6 | verifySignal = QtCore.pyqtSignal() 7 | 8 | def __init__(self, *args, **kwargs): 9 | super(MainWindow, self).__init__(*args, **kwargs) 10 | self.id_line = QLineEdit() 11 | self.id_line.setPlaceholderText("请输入账号") 12 | self.psd_line = QLineEdit() 13 | self.psd_line.setPlaceholderText("请输入密码") 14 | 15 | self.init() 16 | 17 | def init(self): 18 | 19 | layout = QHBoxLayout() 20 | self.setLayout(layout) 21 | 22 | self.button = QPushButton("登录") 23 | layout.addWidget(self.button) 24 | 25 | layout.addWidget(self.id_line) 26 | layout.addWidget(self.psd_line) 27 | 28 | # 连接定义的信号 29 | self.button.clicked.connect(self.verify_emit) 30 | 31 | def verify_emit(self): 32 | self.verifySignal.emit() 33 | 34 | def verify_ok(self): 35 | QMessageBox.about(self, "密码正确", "已经登录") 36 | 37 | def verify_no(self): 38 | QMessageBox.about(self, "你犯了一个粗误", "请重新检查输入") 39 | -------------------------------------------------------------------------------- /GUI/Basic-train/MatplotWidget/MatplotlibWidget.py: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # -*- coding: UTF-8 -*- 3 | import sys 4 | import numpy as np 5 | import PyQt5 6 | # 基本控件都在这里面 7 | from PyQt5.QtWidgets import (QApplication, QMainWindow, QDesktopWidget, QStyleFactory, QWidget, 8 | QSizePolicy, QPushButton, QGridLayout) 9 | from PyQt5.QtGui import QPalette, QColor 10 | from PyQt5.QtCore import Qt, QTimer 11 | from mainwidget import Ui_Form 12 | from mainwindow import Ui_MainWindow 13 | 14 | from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas 15 | from matplotlib.figure import Figure 16 | import matplotlib.pyplot as plt 17 | from matplotlib.backends.backend_qt5 import NavigationToolbar2QT as NavigationToolbar 18 | # 绘图的空白界面 19 | class MymplCanvas(FigureCanvas): 20 | 21 | def __init__(self, parent=None, width=5, height=4, dpi=100): 22 | self.fig = Figure(figsize=(width, height), dpi=dpi) 23 | self.axes = self.fig.add_subplot(111) # 多界面绘图 24 | FigureCanvas.__init__(self, self.fig) 25 | self.setParent(parent) 26 | FigureCanvas.setSizePolicy(self, 27 | QSizePolicy.Expanding, QSizePolicy.Expanding 28 | ) 29 | FigureCanvas.updateGeometry(self) 30 | 31 | def static_plot(self): 32 | self.axes.clear() 33 | self.fig.suptitle("static FIG") 34 | t = np.linspace(1, 10, 10) 35 | s = np.sin(np.pi * t) 36 | self.axes.plot(t, s) 37 | self.axes.grid(True) 38 | self.draw() 39 | 40 | # 为何要加参数 41 | def dynamic_plot(self, *args, **kwargs): 42 | timer = QTimer(self) 43 | timer.timeout.connect(self.update_fig) 44 | timer.start(1000) 45 | 46 | def update_fig(self): 47 | self.axes.clear() 48 | self.fig.suptitle("dynamic FIG") 49 | l = np.random.randint(1, 10, 4) 50 | self.axes.plot([0, 1, 2, 3], l, 'r') 51 | self.axes.grid(True) 52 | self.draw() 53 | 54 | # 实现绘图类 55 | class MatplotlibWidget(QWidget): 56 | def __init__(self, parent=None): 57 | super(MatplotlibWidget, self).__init__(parent) 58 | 59 | # 封装绘图类 60 | self.gridLayout = QGridLayout() 61 | self.mpl = MymplCanvas(self) 62 | self.mpl_tool = NavigationToolbar(self.mpl, self) 63 | # self.quit_btn_2 = QPushButton() 64 | # self.quit_btn_3 = QPushButton() 65 | # self.quit_btn_2.clicked.connect(self.static) 66 | # self.quit_btn_3.clicked.connect(self.dynamic) 67 | self.setLayout(self.gridLayout) 68 | self.gridLayout.addWidget(self.mpl) 69 | self.gridLayout.addWidget(self.mpl_tool) 70 | # self.gridLayout.addWidget(self.quit_btn_2) 71 | # self.gridLayout.addWidget(self.quit_btn_3) 72 | 73 | def static(self): 74 | self.mpl.static_plot() 75 | 76 | def dynamic(self): 77 | self.mpl.dynamic_plot() -------------------------------------------------------------------------------- /GUI/Basic-train/MatplotWidget/__pycache__/MatplotlibWidget.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/MatplotWidget/__pycache__/MatplotlibWidget.cpython-37.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/MatplotWidget/__pycache__/mainwidget.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/MatplotWidget/__pycache__/mainwidget.cpython-37.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/MatplotWidget/__pycache__/mainwindow.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/MatplotWidget/__pycache__/mainwindow.cpython-37.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/MatplotWidget/__pycache__/matplot.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/MatplotWidget/__pycache__/matplot.cpython-37.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/MatplotWidget/mainwidget.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'mainwidget.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.13.1 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | 10 | from PyQt5 import QtCore, QtGui, QtWidgets 11 | 12 | 13 | class Ui_Form(object): 14 | def setupUi(self, Form): 15 | Form.setObjectName("Form") 16 | Form.resize(903, 678) 17 | self.gridLayout = QtWidgets.QGridLayout(Form) 18 | self.gridLayout.setObjectName("gridLayout") 19 | self.pushButton_2 = QtWidgets.QPushButton(Form) 20 | self.pushButton_2.setObjectName("pushButton_2") 21 | self.gridLayout.addWidget(self.pushButton_2, 0, 0, 1, 1) 22 | self.verticalLayout = QtWidgets.QVBoxLayout() 23 | self.verticalLayout.setObjectName("verticalLayout") 24 | self.widget = MatplotlibWidget(Form) 25 | self.widget.setMinimumSize(QtCore.QSize(200, 200)) 26 | self.widget.setObjectName("widget") 27 | self.verticalLayout.addWidget(self.widget) 28 | self.widget_2 = MatplotlibWidget(Form) 29 | self.widget_2.setMinimumSize(QtCore.QSize(200, 200)) 30 | self.widget_2.setObjectName("widget_2") 31 | self.verticalLayout.addWidget(self.widget_2) 32 | self.gridLayout.addLayout(self.verticalLayout, 0, 1, 3, 1) 33 | self.pushButton = QtWidgets.QPushButton(Form) 34 | self.pushButton.setObjectName("pushButton") 35 | self.gridLayout.addWidget(self.pushButton, 1, 0, 1, 1) 36 | self.quit_btn = QtWidgets.QPushButton(Form) 37 | self.quit_btn.setObjectName("quit_btn") 38 | self.gridLayout.addWidget(self.quit_btn, 2, 0, 1, 1) 39 | self.widget.raise_() 40 | self.widget_2.raise_() 41 | self.widget_2.raise_() 42 | 43 | self.retranslateUi(Form) 44 | QtCore.QMetaObject.connectSlotsByName(Form) 45 | 46 | def retranslateUi(self, Form): 47 | _translate = QtCore.QCoreApplication.translate 48 | Form.setWindowTitle(_translate("Form", "Form")) 49 | self.pushButton_2.setText(_translate("Form", "静态绘图")) 50 | self.pushButton.setText(_translate("Form", "动态绘图")) 51 | self.quit_btn.setText(_translate("Form", "退出")) 52 | from MatplotlibWidget import MatplotlibWidget 53 | -------------------------------------------------------------------------------- /GUI/Basic-train/MatplotWidget/mainwidget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Form 4 | 5 | 6 | 7 | 0 8 | 0 9 | 903 10 | 678 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | 静态绘图 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 200 31 | 200 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 200 41 | 200 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 动态绘图 52 | 53 | 54 | 55 | 56 | 57 | 58 | 退出 59 | 60 | 61 | 62 | 63 | layoutWidget 64 | widget 65 | widget_2 66 | widget_3 67 | widget_2 68 | 69 | 70 | 71 | MatplotlibWidget 72 | QWidget 73 |
MatplotlibWidget
74 | 1 75 |
76 |
77 | 78 | 79 |
80 | -------------------------------------------------------------------------------- /GUI/Basic-train/MatplotWidget/mainwindow.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'mainwindow.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.13.1 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | 10 | from PyQt5 import QtCore, QtGui, QtWidgets 11 | 12 | 13 | class Ui_MainWindow(object): 14 | def setupUi(self, MainWindow): 15 | MainWindow.setObjectName("MainWindow") 16 | MainWindow.resize(800, 717) 17 | self.centralwidget = QtWidgets.QWidget(MainWindow) 18 | self.centralwidget.setObjectName("centralwidget") 19 | self.pushButton = QtWidgets.QPushButton(self.centralwidget) 20 | self.pushButton.setGeometry(QtCore.QRect(120, 80, 110, 34)) 21 | self.pushButton.setObjectName("pushButton") 22 | MainWindow.setCentralWidget(self.centralwidget) 23 | self.menubar = QtWidgets.QMenuBar(MainWindow) 24 | self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 28)) 25 | self.menubar.setObjectName("menubar") 26 | self.menuLabel = QtWidgets.QMenu(self.menubar) 27 | self.menuLabel.setObjectName("menuLabel") 28 | MainWindow.setMenuBar(self.menubar) 29 | self.statusbar = QtWidgets.QStatusBar(MainWindow) 30 | self.statusbar.setObjectName("statusbar") 31 | MainWindow.setStatusBar(self.statusbar) 32 | self.menubar.addAction(self.menuLabel.menuAction()) 33 | 34 | self.retranslateUi(MainWindow) 35 | QtCore.QMetaObject.connectSlotsByName(MainWindow) 36 | 37 | def retranslateUi(self, MainWindow): 38 | _translate = QtCore.QCoreApplication.translate 39 | MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) 40 | self.pushButton.setText(_translate("MainWindow", "PushButton")) 41 | self.menuLabel.setTitle(_translate("MainWindow", "label")) 42 | -------------------------------------------------------------------------------- /GUI/Basic-train/MatplotWidget/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 800 10 | 717 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | 19 | 20 | 0 21 | 0 22 | 800 23 | 28 24 | 25 | 26 | 27 | 28 | label 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /GUI/Basic-train/MatplotWidget/matplot.py: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # -*- coding: UTF-8 -*- 3 | import sys 4 | import numpy as np 5 | import PyQt5 6 | # 基本控件都在这里面 7 | from PyQt5.QtWidgets import (QApplication, QMainWindow, QDesktopWidget, QStyleFactory, QWidget, 8 | QSizePolicy, QPushButton, QGridLayout) 9 | from PyQt5.QtGui import QPalette, QColor 10 | from PyQt5.QtCore import Qt, QTimer 11 | from mainwidget import Ui_Form 12 | from mainwindow import Ui_MainWindow 13 | 14 | from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas 15 | from matplotlib.figure import Figure 16 | import matplotlib.pyplot as plt 17 | from matplotlib.backends.backend_qt5 import NavigationToolbar2QT as NavigationToolbar 18 | # 绘图的空白界面 19 | class MymplCanvas(FigureCanvas): 20 | 21 | def __init__(self, parent=None, width=5, height=4, dpi=100): 22 | self.fig = Figure(figsize=(width, height), dpi=dpi) 23 | self.axes = self.fig.add_subplot(111) # 多界面绘图 24 | FigureCanvas.__init__(self, self.fig) 25 | self.setParent(parent) 26 | FigureCanvas.setSizePolicy(self, 27 | QSizePolicy.Expanding, QSizePolicy.Expanding 28 | ) 29 | FigureCanvas.updateGeometry(self) 30 | 31 | def static_plot(self): 32 | self.axes.clear() 33 | self.fig.suptitle("static FIG") 34 | t = np.linspace(1, 10, 10) 35 | s = np.sin(np.pi * t) 36 | self.axes.plot(t, s) 37 | self.axes.grid(True) 38 | self.draw() 39 | 40 | # 为何要加参数 41 | def dynamic_plot(self, *args, **kwargs): 42 | timer = QTimer(self) 43 | timer.timeout.connect(self.update_fig) 44 | timer.start(1000) 45 | 46 | def update_fig(self): 47 | self.axes.clear() 48 | self.fig.suptitle("dynamic FIG") 49 | l = np.random.randint(1, 10, 4) 50 | self.axes.plot([0, 1, 2, 3], l, 'r') 51 | self.axes.grid(True) 52 | self.draw() 53 | 54 | # 实现绘图类 55 | class MatplotlibWidget(QWidget): 56 | def __init__(self, parent=None): 57 | super(MatplotlibWidget, self).__init__(parent) 58 | 59 | # 封装绘图类 60 | self.gridLayout = QGridLayout() 61 | self.mpl = MymplCanvas(self) 62 | # 添加matplotlib的工具栏 63 | self.mpl_tool = NavigationToolbar(self.mpl, self) 64 | # self.quit_btn_2 = QPushButton() 65 | # self.quit_btn_3 = QPushButton() 66 | # self.quit_btn_2.clicked.connect(self.static) 67 | # self.quit_btn_3.clicked.connect(self.dynamic) 68 | self.setLayout(self.gridLayout) 69 | self.gridLayout.addWidget(self.mpl) 70 | self.gridLayout.addWidget(self.mpl_tool) 71 | # self.gridLayout.addWidget(self.quit_btn_2) 72 | # self.gridLayout.addWidget(self.quit_btn_3) 73 | 74 | def static(self): 75 | self.mpl.static_plot() 76 | 77 | def dynamic(self): 78 | self.mpl.dynamic_plot() 79 | 80 | 81 | # 继承主窗口 Qmainwindow 和 自己画的界面 Ui_MainWindow 82 | class MyMainWidget(QWidget, Ui_Form): 83 | 84 | def __init__(self, parent = None): 85 | super(MyMainWidget, self).__init__(parent) 86 | self.setupUi(self) 87 | 88 | self.setLayout(self.gridLayout) 89 | 90 | # 退出窗口 91 | self.quit_btn.clicked.connect(self.quit_act) 92 | 93 | # 没有提升窗口控件 94 | # q = MatplotlibWidget() 95 | # self.gridLayout.addWidget(q) 96 | 97 | # 提升前 98 | # self.widget = MatplotlibWidget() 99 | self.widget.setVisible(False) 100 | # self.widget_2 = MatplotlibWidget() 101 | self.widget_2.setVisible(False) 102 | # print(type(self.widget_2)) 103 | 104 | # 提升后 105 | # self.gridLayout.addWidget(self.widget) 106 | # self.gridLayout.addWidget(self.widget_2) 107 | self.pushButton.clicked.connect(self.dynamic) 108 | self.pushButton_2.clicked.connect(self.static) 109 | 110 | def static(self): 111 | self.widget.setVisible(True) 112 | self.widget.mpl.static_plot() 113 | 114 | def dynamic(self): 115 | self.widget_2.setVisible(True) 116 | self.widget_2.mpl.dynamic_plot() 117 | 118 | def quit_act(self): 119 | # sender 是发送信号的对象 120 | sender = self.sender() 121 | print(sender.text() + '键被按下') 122 | qApp = QApplication.instance() 123 | qApp.quit() 124 | 125 | 126 | class MyMainWindow(QMainWindow, Ui_MainWindow): 127 | 128 | def __init__(self, parent = None): 129 | super(MyMainWindow, self).__init__(parent) 130 | self.setupUi(self) 131 | 132 | q = MyMainWidget() 133 | self.setCentralWidget(q) 134 | 135 | # 设置窗口透明 136 | self.setWindowOpacity(0.9) 137 | 138 | # self.resize(1000, 700) 139 | 140 | # 默认的状态栏 141 | # 可以设置其他按钮点击 参考多行文本显示 然而不行 142 | self.status = self.statusBar() 143 | self.status.showMessage("你在主页面~") 144 | 145 | # 标题栏 146 | self.setWindowTitle("建模协会录入信息") 147 | 148 | # 窗口居中 149 | self.center() 150 | 151 | def center(self): 152 | ''' 153 | 获取桌面长宽 154 | 获取窗口长宽 155 | 移动 156 | ''' 157 | screen = QDesktopWidget().screenGeometry() 158 | size = self.geometry() 159 | self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2) 160 | 161 | if __name__ == "__main__": 162 | # 在shell中执行 163 | app = QApplication(sys.argv) 164 | mywin = MyMainWindow() 165 | mywin.show() 166 | # 开始主循环,直到退出 167 | sys.exit(app.exec()) 168 | -------------------------------------------------------------------------------- /GUI/Basic-train/Multi-Thread/Error.py: -------------------------------------------------------------------------------- 1 | import sys, time 2 | from PyQt5.QtWidgets import (QApplication, QLabel, QMainWindow, QWidget, 3 | QHBoxLayout) 4 | from PyQt5.QtGui import QMovie 5 | from PyQt5.QtCore import Qt 6 | 7 | 8 | class MainWidget(QWidget): 9 | def __init__(self, parent=None): 10 | super(MainWidget, self).__init__(parent) 11 | self.setAttribute(Qt.WA_StyledBackground, True) 12 | self.setStyleSheet('background-color: white') 13 | 14 | self.label = QLabel() 15 | # 居中对齐 16 | self.label.setAlignment(Qt.AlignCenter | Qt.AlignVCenter) 17 | self.loading = QMovie("images/loading.gif") 18 | self.label.setMovie(self.loading) 19 | self.layout = QHBoxLayout() 20 | self.layout.addWidget(self.label) 21 | self.loading_start() 22 | self.setLayout(self.layout) 23 | 24 | def loading_start(self): 25 | self.loading.start() 26 | # self.loading.stop() 27 | time.sleep(2) 28 | self.loading.setPaused(True) 29 | # self.loading.stop() 30 | 31 | 32 | class MainWindow(QMainWindow): 33 | def __init__(self): 34 | super(MainWindow, self).__init__() 35 | 36 | W = MainWidget() 37 | self.setCentralWidget(W) 38 | 39 | 40 | if __name__ == '__main__': 41 | app = QApplication([]) 42 | window = MainWindow() 43 | window.show() 44 | sys.exit(app.exec()) -------------------------------------------------------------------------------- /GUI/Basic-train/Multi-Thread/MWE.py: -------------------------------------------------------------------------------- 1 | import sys, time 2 | from PyQt5.QtWidgets import QMainWindow, QWidget, QHBoxLayout, QApplication, QPushButton 3 | 4 | 5 | class mainwindow(QMainWindow): 6 | def __init__(self): 7 | super(mainwindow, self).__init__() 8 | 9 | layout = QHBoxLayout() 10 | w = QWidget() 11 | w.setLayout(layout) 12 | self.setCentralWidget(w) 13 | 14 | btn = QPushButton("点击") 15 | layout.addWidget(btn) 16 | btn.clicked.connect(self.count) 17 | 18 | def count(self): 19 | pass 20 | 21 | if __name__ == '__main__': 22 | app = QApplication([]) 23 | m = mainwindow() 24 | m.show() 25 | sys.exit(app.exec()) -------------------------------------------------------------------------------- /GUI/Basic-train/Multi-Thread/images/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/Multi-Thread/images/loading.gif -------------------------------------------------------------------------------- /GUI/Basic-train/Multi-Thread/qthread.py: -------------------------------------------------------------------------------- 1 | ''' 2 | File: th.py 3 | Project: demo 4 | File Created: Friday, 5th February 2021 6:13:30 pm 5 | Author: lanling (https://github.com/muyuuuu) 6 | ----------- 7 | Last Modified: Friday, 5th February 2021 6:21:55 pm 8 | Modified By: lanling (https://github.com/muyuuuu) 9 | Copyright 2020 - 2021 XDU, XDU 10 | ----------- 11 | Description: 模拟 IO 12 | ''' 13 | import sys, time 14 | from PyQt5.QtWidgets import (QMainWindow, QTextEdit, QWidget, QApplication, 15 | QHBoxLayout) 16 | from PyQt5.QtCore import QThread, pyqtSignal 17 | 18 | 19 | class Worker(QThread): 20 | # 自定义信号 21 | signal_out = pyqtSignal(str) 22 | def __init__(self, working): 23 | super(Worker, self).__init__() 24 | self.working = working 25 | self.num = 0 26 | # 结束信号的触发 27 | self.finished.connect(self.finish) 28 | 29 | def finish(self): 30 | print('finish') 31 | 32 | def run(self): 33 | # while 持续发送 34 | while self.working == True: 35 | string = "Index " + str(self.num) 36 | self.num += 1 37 | self.signal_out.emit(string) 38 | self.sleep(1) 39 | if self.num != 0 and self.num % 2 == 0: 40 | self.signal_out.emit("stop") 41 | 42 | 43 | class MainWindow(QMainWindow): 44 | def __init__(self): 45 | super(MainWindow, self).__init__() 46 | self.text = QTextEdit() 47 | layout = QHBoxLayout() 48 | layout.addWidget(self.text) 49 | w = QWidget() 50 | w.setLayout(layout) 51 | self.setCentralWidget(w) 52 | self.worker = Worker(working=True) 53 | self.start() 54 | self.worker.signal_out.connect(self.display) 55 | 56 | def display(self, string): 57 | if string == 'stop': 58 | self.text.clear() 59 | # 线程结束后,被这个线程阻塞的线程都会被唤醒 60 | self.worker.working = False 61 | self.worker.quit() 62 | # 强制结束进程的执行,但不推荐 63 | # self.worker.terminate() 64 | else: 65 | QApplication.processEvents() 66 | self.text.append(string) 67 | 68 | def start(self): 69 | # 启动线程 70 | # 自动调用类内的 run 方法 71 | self.worker.start() 72 | 73 | if __name__ == "__main__": 74 | q = QApplication([]) 75 | m = MainWindow() 76 | m.show() 77 | sys.exit(q.exec()) 78 | -------------------------------------------------------------------------------- /GUI/Basic-train/Multi-Thread/timer.py: -------------------------------------------------------------------------------- 1 | import sys, time 2 | from PyQt5.QtWidgets import (QApplication, QLabel, QMainWindow, QWidget, 3 | QHBoxLayout) 4 | from PyQt5.QtGui import QMovie 5 | from PyQt5.QtCore import Qt, QTimer 6 | 7 | 8 | class MainWidget(QWidget): 9 | def __init__(self, parent=None): 10 | super(MainWidget, self).__init__(parent) 11 | self.setAttribute(Qt.WA_StyledBackground, True) 12 | self.setStyleSheet('background-color: white') 13 | 14 | self.label = QLabel() 15 | # 居中对齐 16 | self.label.setAlignment(Qt.AlignCenter | Qt.AlignVCenter) 17 | self.loading = QMovie("images/loading.gif") 18 | self.label.setMovie(self.loading) 19 | self.layout = QHBoxLayout() 20 | self.layout.addWidget(self.label) 21 | self.loading_start() 22 | self.setLayout(self.layout) 23 | 24 | # 定时器 25 | self.t = QTimer() 26 | self.t.start(8000) 27 | self.t.timeout.connect(self.loading_end) 28 | 29 | def loading_end(self): 30 | self.t.stop() 31 | self.loading.stop() 32 | time.sleep(0.2) 33 | self.label.clear() 34 | 35 | def loading_start(self): 36 | self.loading.start() 37 | # self.loading.stop() 38 | 39 | 40 | class MainWindow(QMainWindow): 41 | def __init__(self): 42 | super(MainWindow, self).__init__() 43 | 44 | W = MainWidget() 45 | self.setCentralWidget(W) 46 | 47 | 48 | if __name__ == '__main__': 49 | app = QApplication([]) 50 | window = MainWindow() 51 | window.show() 52 | sys.exit(app.exec()) -------------------------------------------------------------------------------- /GUI/Basic-train/Multi-Thread/wait.py: -------------------------------------------------------------------------------- 1 | ''' 2 | File: th.py 3 | Project: demo 4 | File Created: Friday, 5th February 2021 6:13:30 pm 5 | Author: lanling (https://github.com/muyuuuu) 6 | ----------- 7 | Last Modified: Friday, 5th February 2021 6:21:55 pm 8 | Modified By: lanling (https://github.com/muyuuuu) 9 | Copyright 2020 - 2021 XDU, XDU 10 | ----------- 11 | Description: 模拟 IO 12 | ''' 13 | import sys, time 14 | from PyQt5.QtWidgets import (QMainWindow, QTextEdit, QWidget, QApplication, 15 | QVBoxLayout, QPushButton) 16 | from PyQt5.QtCore import QThread, pyqtSignal, QDeadlineTimer 17 | 18 | 19 | class Worker(QThread): 20 | # 自定义信号 21 | signal_out = pyqtSignal(str) 22 | def __init__(self, working): 23 | super(Worker, self).__init__() 24 | self.working = working 25 | self.num = 0 26 | # 结束信号的触发 27 | self.finished.connect(self.finish) 28 | 29 | def finish(self): 30 | print('begin finishing ', time.time()) 31 | print('finish') 32 | 33 | def run(self): 34 | # while 持续发送 35 | while self.working == True: 36 | self.num += 1 37 | string = "Index " + str(self.num) 38 | self.sleep(1) 39 | self.signal_out.emit(string) 40 | if self.num != 0 and self.num % 2 == 0: 41 | self.signal_out.emit("stop") 42 | 43 | 44 | class MainWindow(QMainWindow): 45 | def __init__(self): 46 | super(MainWindow, self).__init__() 47 | self.text = QTextEdit() 48 | layout = QVBoxLayout() 49 | layout.addWidget(self.text) 50 | w = QWidget() 51 | w.setLayout(layout) 52 | self.setCentralWidget(w) 53 | self.worker = Worker(working=True) 54 | self.start() 55 | self.worker.signal_out.connect(self.display) 56 | 57 | btn = QPushButton("点击") 58 | layout.addWidget(btn) 59 | btn.clicked.connect(self.restart) 60 | 61 | self.time_out = QDeadlineTimer(3); 62 | 63 | def restart(self): 64 | if self.worker.isFinished(): 65 | self.worker.working = True 66 | self.worker.num = 0 67 | self.worker.start() 68 | 69 | def display(self, string): 70 | if string == 'stop': 71 | # self.text.clear() 72 | # 线程结束后,被这个线程阻塞的线程都会被唤醒 73 | self.worker.working = False 74 | print('begin waitting', time.time()) 75 | QApplication.processEvents() 76 | self.worker.wait() 77 | # self.worker.quit() 78 | # 强制结束进程的执行,但不推荐 79 | # self.worker.terminate() 80 | else: 81 | self.text.append(string) 82 | 83 | def start(self): 84 | # 启动线程 85 | # 自动调用类内的 run 方法 86 | self.worker.start() 87 | 88 | if __name__ == "__main__": 89 | q = QApplication([]) 90 | m = MainWindow() 91 | m.show() 92 | sys.exit(q.exec()) 93 | -------------------------------------------------------------------------------- /GUI/Basic-train/PyQtGraph/__pycache__/mainwidget.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/PyQtGraph/__pycache__/mainwidget.cpython-37.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/PyQtGraph/__pycache__/mainwindow.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/PyQtGraph/__pycache__/mainwindow.cpython-37.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/PyQtGraph/__pycache__/pyqtgraph.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/PyQtGraph/__pycache__/pyqtgraph.cpython-37.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/PyQtGraph/graph.py: -------------------------------------------------------------------------------- 1 | # import pyqtgraph.examples 2 | # pyqtgraph.examples.run() 3 | 4 | #!/bin/bash 5 | # -*- coding: UTF-8 -*- 6 | import pyqtgraph as pg 7 | import sys 8 | import numpy as np 9 | import PyQt5 10 | # 基本控件都在这里面 11 | from PyQt5.QtWidgets import QApplication, QMainWindow, QDesktopWidget, QStyleFactory, QWidget 12 | from PyQt5.QtGui import QPalette, QColor 13 | from PyQt5.QtCore import Qt 14 | from mainwidget import Ui_Form 15 | from mainwindow import Ui_MainWindow 16 | 17 | # 继承主窗口 Qmainwindow 和 自己画的界面 Ui_MainWindow 18 | class MyMainWidget(QWidget, Ui_Form): 19 | 20 | def __init__(self, parent = None): 21 | 22 | super(MyMainWidget, self).__init__(parent) 23 | 24 | pg.setConfigOption('background', '#f0f0f0') 25 | pg.setConfigOption('foreground', 'd') 26 | pg.setConfigOptions(antialias = True) 27 | 28 | self.setupUi(self) 29 | self.setLayout(self.gridLayout) 30 | 31 | # 退出窗口 32 | self.quit_btn.clicked.connect(self.quit_act) 33 | 34 | # 绘图 35 | self.pushButton.clicked.connect(self.graph_plot) 36 | self.pushButton_2.clicked.connect(self.graph_plot1) 37 | 38 | def graph_plot1(self): 39 | self.pyqtgraph2.clear() 40 | plt = self.pyqtgraph2.addPlot(title="test") 41 | x = np.random.normal(size=20) 42 | y1 = np.sin(x) 43 | y2 = 1.1 * np.sin(x + 1) 44 | bg1 = pg.BarGraphItem(x = x, height = y1, width = 2, brush = 'r') 45 | bg2 = pg.BarGraphItem(x = x, height = y2, width = 2, brush = 'b') 46 | plt.addItem(bg1) 47 | plt.addItem(bg2) 48 | # self.pyqtgraph2.nextColumn() 49 | self.pyqtgraph2.nextRow() 50 | plt2 = self.pyqtgraph2.addPlot(title="test1") 51 | x = np.linspace(1, 20, 20) 52 | y3 = np.random.normal(size=20) 53 | plt2.plot(x, y3, pen = pg.mkPen(width = 2, color = 'd')) 54 | plt2.showGrid(x=True, y=True) 55 | 56 | 57 | def graph_plot(self): 58 | self.pyqtgraph.clear() 59 | # 两种绘图方式 60 | # self.pyqtgraph.addPlot(y = np.random.normal(size=100), 61 | # pen = pg.mkPen(color='b', width=2)) 62 | plt2 = self.pyqtgraph.addPlot(title="multi rules") 63 | plt2.plot(np.random.normal(size=150), 64 | pen = pg.mkPen(color='r', width=2)) 65 | plt2.plot(np.random.normal(size=150) + 5, 66 | pen = pg.mkPen(color='b', width=2)) 67 | 68 | 69 | def quit_act(self): 70 | # sender 是发送信号的对象 71 | sender = self.sender() 72 | print(sender.text() + '键被按下') 73 | qApp = QApplication.instance() 74 | qApp.quit() 75 | 76 | 77 | class MyMainWindow(QMainWindow, Ui_MainWindow): 78 | 79 | def __init__(self, parent = None): 80 | super(MyMainWindow, self).__init__(parent) 81 | self.setupUi(self) 82 | 83 | q = MyMainWidget() 84 | self.setCentralWidget(q) 85 | 86 | # 设置窗口透明 87 | self.setWindowOpacity(0.9) 88 | 89 | # self.resize(1000, 700) 90 | 91 | # 默认的状态栏 92 | # 可以设置其他按钮点击 参考多行文本显示 然而不行 93 | self.status = self.statusBar() 94 | self.status.showMessage("你在主页面~") 95 | 96 | # 标题栏 97 | self.setWindowTitle("建模协会录入信息") 98 | 99 | # 窗口居中 100 | self.center() 101 | 102 | def center(self): 103 | ''' 104 | 获取桌面长宽 105 | 获取窗口长宽 106 | 移动 107 | ''' 108 | screen = QDesktopWidget().screenGeometry() 109 | size = self.geometry() 110 | self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2) 111 | 112 | if __name__ == "__main__": 113 | # 在shell中执行 114 | app = QApplication(sys.argv) 115 | mywin = MyMainWindow() 116 | mywin.show() 117 | # 开始主循环,直到退出 118 | sys.exit(app.exec()) 119 | -------------------------------------------------------------------------------- /GUI/Basic-train/PyQtGraph/mainwidget.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'mainwidget.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.13.1 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | 10 | from PyQt5 import QtCore, QtGui, QtWidgets 11 | 12 | 13 | class Ui_Form(object): 14 | def setupUi(self, Form): 15 | Form.setObjectName("Form") 16 | Form.resize(903, 678) 17 | self.widget = QtWidgets.QWidget(Form) 18 | self.widget.setGeometry(QtCore.QRect(60, 100, 731, 451)) 19 | self.widget.setObjectName("widget") 20 | self.gridLayout = QtWidgets.QGridLayout(self.widget) 21 | self.gridLayout.setContentsMargins(0, 0, 0, 0) 22 | self.gridLayout.setObjectName("gridLayout") 23 | self.horizontalLayout = QtWidgets.QHBoxLayout() 24 | self.horizontalLayout.setObjectName("horizontalLayout") 25 | self.pyqtgraph = GraphicsLayoutWidget(self.widget) 26 | self.pyqtgraph.setMinimumSize(QtCore.QSize(100, 50)) 27 | self.pyqtgraph.setObjectName("pyqtgraph") 28 | self.horizontalLayout.addWidget(self.pyqtgraph) 29 | self.pyqtgraph2 = GraphicsLayoutWidget(self.widget) 30 | self.pyqtgraph2.setMinimumSize(QtCore.QSize(100, 50)) 31 | self.pyqtgraph2.setObjectName("pyqtgraph2") 32 | self.horizontalLayout.addWidget(self.pyqtgraph2) 33 | self.gridLayout.addLayout(self.horizontalLayout, 0, 0, 1, 3) 34 | self.pushButton = QtWidgets.QPushButton(self.widget) 35 | self.pushButton.setObjectName("pushButton") 36 | self.gridLayout.addWidget(self.pushButton, 1, 0, 1, 1) 37 | self.pushButton_2 = QtWidgets.QPushButton(self.widget) 38 | self.pushButton_2.setObjectName("pushButton_2") 39 | self.gridLayout.addWidget(self.pushButton_2, 1, 1, 1, 1) 40 | self.quit_btn = QtWidgets.QPushButton(self.widget) 41 | self.quit_btn.setObjectName("quit_btn") 42 | self.gridLayout.addWidget(self.quit_btn, 1, 2, 1, 1) 43 | 44 | self.retranslateUi(Form) 45 | QtCore.QMetaObject.connectSlotsByName(Form) 46 | 47 | def retranslateUi(self, Form): 48 | _translate = QtCore.QCoreApplication.translate 49 | Form.setWindowTitle(_translate("Form", "Form")) 50 | self.pushButton.setText(_translate("Form", "单条线绘图")) 51 | self.pushButton_2.setText(_translate("Form", "多条线绘图")) 52 | self.quit_btn.setText(_translate("Form", "退出")) 53 | from pyqtgraph import GraphicsLayoutWidget 54 | -------------------------------------------------------------------------------- /GUI/Basic-train/PyQtGraph/mainwidget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Form 4 | 5 | 6 | 7 | 0 8 | 0 9 | 903 10 | 678 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 60 20 | 100 21 | 731 22 | 451 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 | 100 54 | 50 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 100 64 | 50 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | GraphicsLayoutWidget 77 | QWidget 78 |
pyqtgraph
79 | 1 80 |
81 |
82 | 83 | 84 |
85 | -------------------------------------------------------------------------------- /GUI/Basic-train/PyQtGraph/mainwindow.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'mainwindow.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.13.1 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | 10 | from PyQt5 import QtCore, QtGui, QtWidgets 11 | 12 | 13 | class Ui_MainWindow(object): 14 | def setupUi(self, MainWindow): 15 | MainWindow.setObjectName("MainWindow") 16 | MainWindow.resize(800, 717) 17 | self.centralwidget = QtWidgets.QWidget(MainWindow) 18 | self.centralwidget.setObjectName("centralwidget") 19 | self.pushButton = QtWidgets.QPushButton(self.centralwidget) 20 | self.pushButton.setGeometry(QtCore.QRect(120, 80, 110, 34)) 21 | self.pushButton.setObjectName("pushButton") 22 | MainWindow.setCentralWidget(self.centralwidget) 23 | self.menubar = QtWidgets.QMenuBar(MainWindow) 24 | self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 28)) 25 | self.menubar.setObjectName("menubar") 26 | self.menuLabel = QtWidgets.QMenu(self.menubar) 27 | self.menuLabel.setObjectName("menuLabel") 28 | MainWindow.setMenuBar(self.menubar) 29 | self.statusbar = QtWidgets.QStatusBar(MainWindow) 30 | self.statusbar.setObjectName("statusbar") 31 | MainWindow.setStatusBar(self.statusbar) 32 | self.menubar.addAction(self.menuLabel.menuAction()) 33 | 34 | self.retranslateUi(MainWindow) 35 | QtCore.QMetaObject.connectSlotsByName(MainWindow) 36 | 37 | def retranslateUi(self, MainWindow): 38 | _translate = QtCore.QCoreApplication.translate 39 | MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) 40 | self.pushButton.setText(_translate("MainWindow", "PushButton")) 41 | self.menuLabel.setTitle(_translate("MainWindow", "label")) 42 | -------------------------------------------------------------------------------- /GUI/Basic-train/PyQtGraph/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 800 10 | 717 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | 19 | 20 | 0 21 | 0 22 | 800 23 | 28 24 | 25 | 26 | 27 | 28 | label 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /GUI/Basic-train/Pyecharts/.ipynb_checkpoints/html-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 2, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "ename": "ImportError", 10 | "evalue": "cannot import name 'Bar' from 'pyecharts' (/home/lanling/.local/lib/python3.7/site-packages/pyecharts/__init__.py)", 11 | "output_type": "error", 12 | "traceback": [ 13 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", 14 | "\u001b[0;31mImportError\u001b[0m Traceback (most recent call last)", 15 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mpyecharts\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mBar\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", 16 | "\u001b[0;31mImportError\u001b[0m: cannot import name 'Bar' from 'pyecharts' (/home/lanling/.local/lib/python3.7/site-packages/pyecharts/__init__.py)" 17 | ] 18 | } 19 | ], 20 | "source": [ 21 | "from pyecharts import Bar" 22 | ] 23 | }, 24 | { 25 | "cell_type": "code", 26 | "execution_count": null, 27 | "metadata": {}, 28 | "outputs": [], 29 | "source": [ 30 | "bar = Bar(\"我的第一个图表\", \"这里是副标题\")\n", 31 | "bar.add(\"服装\", [\"衬衫\", \"羊毛衫\", \"雪纺衫\", \"裤子\", \"高跟鞋\", \"袜子\"], [5, 20, 36, 10, 75, 90])\n", 32 | "# bar.print_echarts_options() # 该行只为了打印配置项,方便调试时使用\n", 33 | "bar.render() # 生成本地 HTML 文件" 34 | ] 35 | } 36 | ], 37 | "metadata": { 38 | "kernelspec": { 39 | "display_name": "Python 3", 40 | "language": "python", 41 | "name": "python3" 42 | }, 43 | "language_info": { 44 | "codemirror_mode": { 45 | "name": "ipython", 46 | "version": 3 47 | }, 48 | "file_extension": ".py", 49 | "mimetype": "text/x-python", 50 | "name": "python", 51 | "nbconvert_exporter": "python", 52 | "pygments_lexer": "ipython3", 53 | "version": "3.7.4" 54 | } 55 | }, 56 | "nbformat": 4, 57 | "nbformat_minor": 4 58 | } 59 | -------------------------------------------------------------------------------- /GUI/Basic-train/Pyecharts/.ipynb_checkpoints/html_plot-checkpoint.py: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # -*- coding: UTF-8 -*- 3 | import sys 4 | import PyQt5 5 | # 基本控件都在这里面 6 | from PyQt5.QtWidgets import QApplication, QMainWindow, QDesktopWidget, QStyleFactory, QWidget 7 | from PyQt5.QtGui import QPalette, QColor 8 | from PyQt5.QtCore import Qt, QUrl 9 | # from PyQt5.QtWebEngineWidgets import QWebEngineView 10 | from mainwidget import Ui_Form 11 | from mainwindow import Ui_MainWindow 12 | 13 | # 继承主窗口 Qmainwindow 和 自己画的界面 Ui_MainWindow 14 | class MyMainWidget(QWidget, Ui_Form): 15 | 16 | def __init__(self, parent = None): 17 | super(MyMainWidget, self).__init__(parent) 18 | self.setupUi(self) 19 | 20 | self.setLayout(self.gridLayout) 21 | 22 | # 退出窗口 23 | self.quit_btn.clicked.connect(self.quit_act) 24 | 25 | # html 绘图 26 | self.quit_btn_2.clicked.connect(self.html_plot) 27 | 28 | def html_plot(self): 29 | url = r'test.html' 30 | self.web_view.load(QUrl(url)) 31 | 32 | def quit_act(self): 33 | # sender 是发送信号的对象 34 | sender = self.sender() 35 | print(sender.text() + '键被按下') 36 | qApp = QApplication.instance() 37 | qApp.quit() 38 | 39 | 40 | class MyMainWindow(QMainWindow, Ui_MainWindow): 41 | 42 | def __init__(self, parent = None): 43 | super(MyMainWindow, self).__init__(parent) 44 | self.setupUi(self) 45 | 46 | q = MyMainWidget() 47 | self.setCentralWidget(q) 48 | 49 | # 设置窗口透明 50 | self.setWindowOpacity(0.9) 51 | 52 | # self.resize(1000, 700) 53 | 54 | # 默认的状态栏 55 | # 可以设置其他按钮点击 参考多行文本显示 然而不行 56 | self.status = self.statusBar() 57 | self.status.showMessage("你在主页面~") 58 | 59 | # 标题栏 60 | self.setWindowTitle("建模协会录入信息") 61 | 62 | # 窗口居中 63 | self.center() 64 | 65 | def center(self): 66 | ''' 67 | 获取桌面长宽 68 | 获取窗口长宽 69 | 移动 70 | ''' 71 | screen = QDesktopWidget().screenGeometry() 72 | size = self.geometry() 73 | self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2) 74 | 75 | if __name__ == "__main__": 76 | # 在shell中执行 77 | app = QApplication(sys.argv) 78 | mywin = MyMainWindow() 79 | mywin.show() 80 | # 开始主循环,直到退出 81 | sys.exit(app.exec()) 82 | -------------------------------------------------------------------------------- /GUI/Basic-train/Pyecharts/__pycache__/mainwidget.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/Pyecharts/__pycache__/mainwidget.cpython-37.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/Pyecharts/__pycache__/mainwindow.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/Pyecharts/__pycache__/mainwindow.cpython-37.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/Pyecharts/html.ipynb: -------------------------------------------------------------------------------- 1 | {"cells":[{"cell_type":"code","execution_count":1,"metadata":{},"outputs":[],"source":"from pyecharts.charts import Bar"},{"cell_type":"code","execution_count":2,"metadata":{},"outputs":[{"data":{"text/plain":"'/home/lanling/Srcode/python/tools/GUI/practice/render.html'"},"execution_count":2,"metadata":{},"output_type":"execute_result"}],"source":"import random\n\nfrom pyecharts import options as opts\nfrom pyecharts.charts import Bar3D, Page\nfrom pyecharts.faker import Collector, Faker\n\nC = Collector()\n\n\n@C.funcs\ndef bar3d_base() -> Bar3D:\n data = [(i, j, random.randint(0, 12)) for i in range(6) for j in range(24)]\n c = (\n Bar3D()\n .add(\n \"\",\n [[d[1], d[0], d[2]] for d in data],\n xaxis3d_opts=opts.Axis3DOpts(Faker.clock, type_=\"category\"),\n yaxis3d_opts=opts.Axis3DOpts(Faker.week_en, type_=\"category\"),\n zaxis3d_opts=opts.Axis3DOpts(type_=\"value\"),\n )\n .set_global_opts(\n visualmap_opts=opts.VisualMapOpts(max_=20),\n title_opts=opts.TitleOpts(title=\"Bar3D-基本示例\"),\n )\n )\n return c\n\n\nPage().add(*[fn() for fn, _ in C.charts]).render()"},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":""}],"nbformat":4,"nbformat_minor":2,"metadata":{"language_info":{"name":"python","codemirror_mode":{"name":"ipython","version":3}},"orig_nbformat":2,"file_extension":".py","mimetype":"text/x-python","name":"python","npconvert_exporter":"python","pygments_lexer":"ipython3","version":3}} -------------------------------------------------------------------------------- /GUI/Basic-train/Pyecharts/html_plot.py: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # -*- coding: UTF-8 -*- 3 | import sys 4 | import PyQt5 5 | # 基本控件都在这里面 6 | from PyQt5.QtWidgets import QApplication, QMainWindow, QDesktopWidget, QStyleFactory, QWidget 7 | from PyQt5.QtGui import QPalette, QColor 8 | from PyQt5.QtCore import Qt, QUrl, QRect 9 | # from PyQt5.QtWebEngineWidgets import QWebEngineView 10 | from mainwidget import Ui_Form 11 | from mainwindow import Ui_MainWindow 12 | 13 | import plotly.offline as pyof 14 | import plotly.graph_objs as go 15 | 16 | # 继承主窗口 Qmainwindow 和 自己画的界面 Ui_MainWindow 17 | class MyMainWidget(QWidget, Ui_Form): 18 | 19 | def __init__(self, parent = None): 20 | super(MyMainWidget, self).__init__(parent) 21 | self.setupUi(self) 22 | 23 | self.setLayout(self.gridLayout) 24 | 25 | # 退出窗口 26 | self.quit_btn.clicked.connect(self.quit_act) 27 | 28 | # html 绘图 29 | self.quit_btn_2.clicked.connect(self.html_plot) 30 | 31 | def html_plot(self): 32 | # 必须用绝对路径 33 | url = "/home/lanling/Srcode/python/tools/GUI/practice/Pyecharts/render.html" 34 | self.web_view.load(QUrl.fromLocalFile(url)) 35 | 36 | def quit_act(self): 37 | # sender 是发送信号的对象 38 | sender = self.sender() 39 | print(sender.text() + '键被按下') 40 | qApp = QApplication.instance() 41 | qApp.quit() 42 | 43 | 44 | class MyMainWindow(QMainWindow, Ui_MainWindow): 45 | 46 | def __init__(self, parent = None): 47 | super(MyMainWindow, self).__init__(parent) 48 | self.setupUi(self) 49 | 50 | q = MyMainWidget() 51 | self.setCentralWidget(q) 52 | 53 | # 设置窗口透明 54 | self.setWindowOpacity(0.9) 55 | 56 | # self.resize(1000, 700) 57 | 58 | # 默认的状态栏 59 | # 可以设置其他按钮点击 参考多行文本显示 然而不行 60 | self.status = self.statusBar() 61 | self.status.showMessage("你在主页面~") 62 | 63 | # 标题栏 64 | self.setWindowTitle("建模协会录入信息") 65 | 66 | # 窗口居中 67 | self.center() 68 | 69 | def center(self): 70 | ''' 71 | 获取桌面长宽 72 | 获取窗口长宽 73 | 移动 74 | ''' 75 | screen = QDesktopWidget().screenGeometry() 76 | size = self.geometry() 77 | self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2) 78 | 79 | if __name__ == "__main__": 80 | # 在shell中执行 81 | app = QApplication(sys.argv) 82 | mywin = MyMainWindow() 83 | mywin.show() 84 | # 开始主循环,直到退出 85 | sys.exit(app.exec()) 86 | -------------------------------------------------------------------------------- /GUI/Basic-train/Pyecharts/mainwidget.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'mainwidget.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.13.1 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | 10 | from PyQt5 import QtCore, QtGui, QtWidgets 11 | 12 | 13 | class Ui_Form(object): 14 | def setupUi(self, Form): 15 | Form.setObjectName("Form") 16 | Form.resize(903, 678) 17 | self.horizontalLayout = QtWidgets.QHBoxLayout(Form) 18 | self.horizontalLayout.setObjectName("horizontalLayout") 19 | self.gridLayout = QtWidgets.QGridLayout() 20 | self.gridLayout.setObjectName("gridLayout") 21 | self.quit_btn = QtWidgets.QPushButton(Form) 22 | self.quit_btn.setObjectName("quit_btn") 23 | self.gridLayout.addWidget(self.quit_btn, 2, 1, 1, 1) 24 | self.quit_btn_2 = QtWidgets.QPushButton(Form) 25 | self.quit_btn_2.setObjectName("quit_btn_2") 26 | self.gridLayout.addWidget(self.quit_btn_2, 2, 0, 1, 1) 27 | self.web_view = QtWebEngineWidgets.QWebEngineView(Form) 28 | sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding) 29 | sizePolicy.setHorizontalStretch(0) 30 | sizePolicy.setVerticalStretch(0) 31 | sizePolicy.setHeightForWidth(self.web_view.sizePolicy().hasHeightForWidth()) 32 | self.web_view.setSizePolicy(sizePolicy) 33 | self.web_view.setMinimumSize(QtCore.QSize(300, 100)) 34 | self.web_view.setObjectName("web_view") 35 | self.gridLayout.addWidget(self.web_view, 1, 0, 1, 2) 36 | self.horizontalLayout.addLayout(self.gridLayout) 37 | 38 | self.retranslateUi(Form) 39 | QtCore.QMetaObject.connectSlotsByName(Form) 40 | 41 | def retranslateUi(self, Form): 42 | _translate = QtCore.QCoreApplication.translate 43 | Form.setWindowTitle(_translate("Form", "Form")) 44 | self.quit_btn.setText(_translate("Form", "退出")) 45 | self.quit_btn_2.setText(_translate("Form", "动态绘图")) 46 | from PyQt5 import QtWebEngineWidgets 47 | -------------------------------------------------------------------------------- /GUI/Basic-train/Pyecharts/mainwidget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Form 4 | 5 | 6 | 7 | 0 8 | 0 9 | 903 10 | 678 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 退出 23 | 24 | 25 | 26 | 27 | 28 | 29 | 动态绘图 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 0 38 | 0 39 | 40 | 41 | 42 | 43 | 300 44 | 100 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | QWebEngineView 56 | QWidget 57 |
PyQt5.QtWebEngineWidgets
58 | 1 59 |
60 |
61 | 62 | 63 |
64 | -------------------------------------------------------------------------------- /GUI/Basic-train/Pyecharts/mainwindow.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'mainwindow.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.13.1 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | 10 | from PyQt5 import QtCore, QtGui, QtWidgets 11 | 12 | 13 | class Ui_MainWindow(object): 14 | def setupUi(self, MainWindow): 15 | MainWindow.setObjectName("MainWindow") 16 | MainWindow.resize(800, 717) 17 | self.centralwidget = QtWidgets.QWidget(MainWindow) 18 | self.centralwidget.setObjectName("centralwidget") 19 | self.pushButton = QtWidgets.QPushButton(self.centralwidget) 20 | self.pushButton.setGeometry(QtCore.QRect(120, 80, 110, 34)) 21 | self.pushButton.setObjectName("pushButton") 22 | MainWindow.setCentralWidget(self.centralwidget) 23 | self.menubar = QtWidgets.QMenuBar(MainWindow) 24 | self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 28)) 25 | self.menubar.setObjectName("menubar") 26 | self.menuLabel = QtWidgets.QMenu(self.menubar) 27 | self.menuLabel.setObjectName("menuLabel") 28 | MainWindow.setMenuBar(self.menubar) 29 | self.statusbar = QtWidgets.QStatusBar(MainWindow) 30 | self.statusbar.setObjectName("statusbar") 31 | MainWindow.setStatusBar(self.statusbar) 32 | self.menubar.addAction(self.menuLabel.menuAction()) 33 | 34 | self.retranslateUi(MainWindow) 35 | QtCore.QMetaObject.connectSlotsByName(MainWindow) 36 | 37 | def retranslateUi(self, MainWindow): 38 | _translate = QtCore.QCoreApplication.translate 39 | MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) 40 | self.pushButton.setText(_translate("MainWindow", "PushButton")) 41 | self.menuLabel.setTitle(_translate("MainWindow", "label")) 42 | -------------------------------------------------------------------------------- /GUI/Basic-train/Pyecharts/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 800 10 | 717 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | 19 | 20 | 0 21 | 0 22 | 800 23 | 28 24 | 25 | 26 | 27 | 28 | label 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /GUI/Basic-train/Pyecharts/test.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/Pyecharts/test.html -------------------------------------------------------------------------------- /GUI/Basic-train/QSS/QSS.py: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # -*- coding: UTF-8 -*- 3 | import sys 4 | import time 5 | import PyQt5 6 | # 基本控件都在这里面 7 | from PyQt5.QtWidgets import QApplication, QMainWindow, QDesktopWidget, QStyleFactory, QWidget 8 | from PyQt5.QtGui import QPalette, QColor 9 | from PyQt5.QtCore import Qt 10 | # 导入样式 11 | import qdarkstyle 12 | from mainwidget import Ui_Form 13 | from mainwindow import Ui_MainWindow 14 | 15 | # 样式的类 16 | class StyleFile: 17 | def __init__(self): 18 | pass 19 | # @staticmethod 20 | def readQSS(style): 21 | with open (style, 'r') as f: 22 | return f.read() 23 | 24 | # 继承主窗口 Qmainwindow 和 自己画的界面 Ui_MainWindow 25 | class MyMainWidget(QWidget, Ui_Form): 26 | 27 | def __init__(self, parent = None): 28 | super(MyMainWidget, self).__init__(parent) 29 | self.setupUi(self) 30 | # self.resize(1000, 700) 31 | 32 | # 默认的状态栏 33 | # 可以设置其他按钮点击 参考多行文本显示 然而不行 34 | # self.status = self.statusBar() 35 | # self.status.showMessage("你在主页面~") 36 | 37 | # 标题栏 38 | self.setWindowTitle("建模协会录入信息") 39 | 40 | # 窗口居中 41 | self.center() 42 | 43 | # 退出窗口 44 | self.quit_btn.clicked.connect(self.quit_act) 45 | 46 | # 无边框程序 47 | # self.setWindowFlags(Qt.FramelessWindowHint) 48 | 49 | # 设置为桌面尺寸 50 | desktop = QApplication.desktop() # 得到桌面控件 51 | # print(desktop.height(), desktop.width()) # 输出桌面的宽高 52 | rect = desktop.availableGeometry() 53 | self.setGeometry(rect) 54 | 55 | # 载入自定义 QSS 56 | self.quit_btn_3.clicked.connect(self.style_change) 57 | 58 | self.quit_btn_4.clicked.connect(self.style_change1) 59 | 60 | # 换默认主题 61 | self.quit_btn_5.clicked.connect(self.style_change2) 62 | 63 | # QMainWindow 有自己的布局,所以下列语句无效 64 | # 只有设置布局,风格切换才有效 65 | self.setLayout(self.gridLayout) 66 | 67 | # self.setCentralWidget(self) 68 | 69 | def style_change2(self): 70 | self.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5()) 71 | 72 | def style_change1(self): 73 | style_file = 'white.qss' 74 | self.style = StyleFile.readQSS(style_file) 75 | self.setStyleSheet(self.style) 76 | palette = QPalette() 77 | c = QColor(192,253,123) 78 | palette.setColor(QPalette.Background, c) 79 | q = MyMainWindow() 80 | q.setPalette(palette) 81 | 82 | 83 | def style_change(self): 84 | style_file = 'black.qss' 85 | self.style = StyleFile.readQSS(style_file) 86 | self.setStyleSheet(self.style) 87 | 88 | def quit_act(self): 89 | # sender 是发送信号的对象 90 | sender = self.sender() 91 | print(sender.text() + '键被按下') 92 | qApp = QApplication.instance() 93 | qApp.quit() 94 | 95 | def center(self): 96 | ''' 97 | 获取桌面长宽 98 | 获取窗口长宽 99 | 移动 100 | ''' 101 | screen = QDesktopWidget().screenGeometry() 102 | size = self.geometry() 103 | self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2) 104 | 105 | class MyMainWindow(QMainWindow, Ui_MainWindow): 106 | 107 | def __init__(self, parent = None): 108 | super(MyMainWindow, self).__init__(parent) 109 | self.setupUi(self) 110 | 111 | q = MyMainWidget() 112 | self.setCentralWidget(q) 113 | 114 | # 设置窗口透明 115 | self.setWindowOpacity(0.9) 116 | 117 | 118 | if __name__ == "__main__": 119 | # 在shell中执行 120 | app = QApplication(sys.argv) 121 | mywin = MyMainWindow() 122 | mywin.show() 123 | # 开始主循环,直到退出 124 | sys.exit(app.exec()) 125 | -------------------------------------------------------------------------------- /GUI/Basic-train/QSS/__pycache__/mainwidget.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QSS/__pycache__/mainwidget.cpython-37.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/QSS/__pycache__/mainwindow.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QSS/__pycache__/mainwindow.cpython-37.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/QSS/mainwidget.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'untitled.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.13.1 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | 10 | from PyQt5 import QtCore, QtGui, QtWidgets 11 | 12 | 13 | class Ui_Form(object): 14 | def setupUi(self, Form): 15 | Form.setObjectName("Form") 16 | Form.resize(903, 678) 17 | self.widget = QtWidgets.QWidget(Form) 18 | self.widget.setGeometry(QtCore.QRect(-20, -10, 971, 741)) 19 | self.widget.setObjectName("widget") 20 | self.gridLayout = QtWidgets.QGridLayout(self.widget) 21 | self.gridLayout.setContentsMargins(0, 0, 0, 0) 22 | self.gridLayout.setObjectName("gridLayout") 23 | self.quit_btn_3 = QtWidgets.QPushButton(self.widget) 24 | sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Fixed) 25 | sizePolicy.setHorizontalStretch(0) 26 | sizePolicy.setVerticalStretch(0) 27 | sizePolicy.setHeightForWidth(self.quit_btn_3.sizePolicy().hasHeightForWidth()) 28 | self.quit_btn_3.setSizePolicy(sizePolicy) 29 | self.quit_btn_3.setObjectName("quit_btn_3") 30 | self.gridLayout.addWidget(self.quit_btn_3, 0, 0, 1, 1) 31 | self.quit_btn_5 = QtWidgets.QPushButton(self.widget) 32 | self.quit_btn_5.setObjectName("quit_btn_5") 33 | self.gridLayout.addWidget(self.quit_btn_5, 1, 0, 1, 1) 34 | self.quit_btn_4 = QtWidgets.QPushButton(self.widget) 35 | self.quit_btn_4.setObjectName("quit_btn_4") 36 | self.gridLayout.addWidget(self.quit_btn_4, 2, 0, 1, 1) 37 | self.quit_btn = QtWidgets.QPushButton(self.widget) 38 | self.quit_btn.setObjectName("quit_btn") 39 | self.gridLayout.addWidget(self.quit_btn, 3, 0, 1, 1) 40 | 41 | self.retranslateUi(Form) 42 | QtCore.QMetaObject.connectSlotsByName(Form) 43 | 44 | def retranslateUi(self, Form): 45 | _translate = QtCore.QCoreApplication.translate 46 | Form.setWindowTitle(_translate("Form", "Form")) 47 | self.quit_btn_3.setText(_translate("Form", "黑色主题")) 48 | self.quit_btn_5.setText(_translate("Form", "默认主题")) 49 | self.quit_btn_4.setText(_translate("Form", "白色主题")) 50 | self.quit_btn.setText(_translate("Form", "退出")) 51 | -------------------------------------------------------------------------------- /GUI/Basic-train/QSS/mainwidget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Form 4 | 5 | 6 | 7 | 0 8 | 0 9 | 903 10 | 678 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | -20 20 | -10 21 | 971 22 | 741 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 0 31 | 0 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 | -------------------------------------------------------------------------------- /GUI/Basic-train/QSS/mainwindow.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'mainwindow.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.13.1 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | 10 | from PyQt5 import QtCore, QtGui, QtWidgets 11 | 12 | 13 | class Ui_MainWindow(object): 14 | def setupUi(self, MainWindow): 15 | MainWindow.setObjectName("MainWindow") 16 | MainWindow.resize(800, 717) 17 | self.centralwidget = QtWidgets.QWidget(MainWindow) 18 | self.centralwidget.setObjectName("centralwidget") 19 | self.pushButton = QtWidgets.QPushButton(self.centralwidget) 20 | self.pushButton.setGeometry(QtCore.QRect(120, 80, 110, 34)) 21 | self.pushButton.setObjectName("pushButton") 22 | MainWindow.setCentralWidget(self.centralwidget) 23 | self.menubar = QtWidgets.QMenuBar(MainWindow) 24 | self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 28)) 25 | self.menubar.setObjectName("menubar") 26 | self.menuLabel = QtWidgets.QMenu(self.menubar) 27 | self.menuLabel.setObjectName("menuLabel") 28 | MainWindow.setMenuBar(self.menubar) 29 | self.statusbar = QtWidgets.QStatusBar(MainWindow) 30 | self.statusbar.setObjectName("statusbar") 31 | MainWindow.setStatusBar(self.statusbar) 32 | self.menubar.addAction(self.menuLabel.menuAction()) 33 | 34 | self.retranslateUi(MainWindow) 35 | QtCore.QMetaObject.connectSlotsByName(MainWindow) 36 | 37 | def retranslateUi(self, MainWindow): 38 | _translate = QtCore.QCoreApplication.translate 39 | MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) 40 | self.pushButton.setText(_translate("MainWindow", "PushButton")) 41 | self.menuLabel.setTitle(_translate("MainWindow", "label")) 42 | -------------------------------------------------------------------------------- /GUI/Basic-train/QSS/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 800 10 | 717 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | 19 | 20 | 140 21 | 130 22 | 160 23 | 80 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 0 33 | 0 34 | 800 35 | 28 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 | -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/__pycache__/mainwidget.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/__pycache__/mainwidget.cpython-37.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/__pycache__/mainwindow.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/__pycache__/mainwindow.cpython-37.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/__pycache__/qtpandas.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/__pycache__/qtpandas.cpython-37.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/data.csv: -------------------------------------------------------------------------------- 1 | ,A,B,C 2 | 0,10,12,a 3 | 1,11,11,b 4 | 2,12,10,c 5 | -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/mainwidget.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'mainwidget.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.13.1 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | 10 | from PyQt5 import QtCore, QtGui, QtWidgets 11 | 12 | 13 | class Ui_Form(object): 14 | def setupUi(self, Form): 15 | Form.setObjectName("Form") 16 | Form.resize(903, 678) 17 | self.layoutWidget = QtWidgets.QWidget(Form) 18 | self.layoutWidget.setGeometry(QtCore.QRect(20, 40, 761, 541)) 19 | self.layoutWidget.setObjectName("layoutWidget") 20 | self.gridLayout = QtWidgets.QGridLayout(self.layoutWidget) 21 | self.gridLayout.setContentsMargins(0, 0, 0, 0) 22 | self.gridLayout.setObjectName("gridLayout") 23 | self.quit_btn_7 = QtWidgets.QPushButton(self.layoutWidget) 24 | self.quit_btn_7.setObjectName("quit_btn_7") 25 | self.gridLayout.addWidget(self.quit_btn_7, 0, 1, 1, 1) 26 | self.quit_btn = QtWidgets.QPushButton(self.layoutWidget) 27 | self.quit_btn.setObjectName("quit_btn") 28 | self.gridLayout.addWidget(self.quit_btn, 0, 2, 1, 1) 29 | self.widget_2 = DataTableWidget(self.layoutWidget) 30 | self.widget_2.setObjectName("widget_2") 31 | self.gridLayout.addWidget(self.widget_2, 2, 0, 2, 3) 32 | self.quit_btn_5 = QtWidgets.QPushButton(self.layoutWidget) 33 | self.quit_btn_5.setObjectName("quit_btn_5") 34 | self.gridLayout.addWidget(self.quit_btn_5, 0, 0, 1, 1) 35 | 36 | self.retranslateUi(Form) 37 | QtCore.QMetaObject.connectSlotsByName(Form) 38 | 39 | def retranslateUi(self, Form): 40 | _translate = QtCore.QCoreApplication.translate 41 | Form.setWindowTitle(_translate("Form", "Form")) 42 | self.quit_btn_7.setText(_translate("Form", "保存数据")) 43 | self.quit_btn.setText(_translate("Form", "退出")) 44 | self.quit_btn_5.setText(_translate("Form", "导入数据")) 45 | from qtpandas.views.DataTableView import DataTableWidget 46 | -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/mainwidget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Form 4 | 5 | 6 | 7 | 0 8 | 0 9 | 903 10 | 678 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 20 | 40 21 | 761 22 | 541 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 | DataTableWidget 56 | QWidget 57 |
qtpandas.views.DataTableView
58 | 1 59 |
60 |
61 | 62 | 63 |
64 | -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/mainwindow.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'mainwindow.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.13.1 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | 10 | from PyQt5 import QtCore, QtGui, QtWidgets 11 | 12 | 13 | class Ui_MainWindow(object): 14 | def setupUi(self, MainWindow): 15 | MainWindow.setObjectName("MainWindow") 16 | MainWindow.resize(800, 717) 17 | self.centralwidget = QtWidgets.QWidget(MainWindow) 18 | self.centralwidget.setObjectName("centralwidget") 19 | self.pushButton = QtWidgets.QPushButton(self.centralwidget) 20 | self.pushButton.setGeometry(QtCore.QRect(120, 80, 110, 34)) 21 | self.pushButton.setObjectName("pushButton") 22 | MainWindow.setCentralWidget(self.centralwidget) 23 | self.menubar = QtWidgets.QMenuBar(MainWindow) 24 | self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 28)) 25 | self.menubar.setObjectName("menubar") 26 | self.menuLabel = QtWidgets.QMenu(self.menubar) 27 | self.menuLabel.setObjectName("menuLabel") 28 | MainWindow.setMenuBar(self.menubar) 29 | self.statusbar = QtWidgets.QStatusBar(MainWindow) 30 | self.statusbar.setObjectName("statusbar") 31 | MainWindow.setStatusBar(self.statusbar) 32 | self.menubar.addAction(self.menuLabel.menuAction()) 33 | 34 | self.retranslateUi(MainWindow) 35 | QtCore.QMetaObject.connectSlotsByName(MainWindow) 36 | 37 | def retranslateUi(self, MainWindow): 38 | _translate = QtCore.QCoreApplication.translate 39 | MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) 40 | self.pushButton.setText(_translate("MainWindow", "PushButton")) 41 | self.menuLabel.setTitle(_translate("MainWindow", "label")) 42 | -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 800 10 | 717 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | 19 | 20 | 0 21 | 0 22 | 800 23 | 28 24 | 25 | 26 | 27 | 28 | label 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | toolBar 37 | 38 | 39 | TopToolBarArea 40 | 41 | 42 | false 43 | 44 | 45 | 46 | 47 | toolBar_2 48 | 49 | 50 | TopToolBarArea 51 | 52 | 53 | false 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas.py: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # -*- coding: UTF-8 -*- 3 | import sys, pandas 4 | import PyQt5 5 | import numpy as np 6 | # 基本控件都在这里面 7 | from PyQt5.QtWidgets import QApplication, QMainWindow, QDesktopWidget, QStyleFactory, QWidget 8 | from PyQt5.QtGui import QPalette, QColor 9 | from PyQt5.QtCore import Qt 10 | from mainwidget import Ui_Form 11 | from mainwindow import Ui_MainWindow 12 | 13 | from qtpandas.views.DataTableView import DataTableWidget 14 | from qtpandas.models.DataFrameModel import DataFrameModel 15 | # 继承主窗口 Qmainwindow 和 自己画的界面 Ui_MainWindow 16 | class MyMainWidget(QWidget, Ui_Form): 17 | 18 | def __init__(self, parent = None): 19 | super(MyMainWidget, self).__init__(parent) 20 | self.setupUi(self) 21 | 22 | self.setLayout(self.gridLayout) 23 | 24 | # 退出窗口 25 | self.quit_btn.clicked.connect(self.quit_act) 26 | 27 | # qtpandas 28 | model = DataFrameModel() # 空模型那个用于存储和处理数据 29 | # print(type(self.widget_2)) 30 | self.widget_2.setViewModel(model) 31 | data = { 32 | 'A': [10, 11, 12], 33 | 'B': [12, 11, 10], 34 | 'C': ['a', 'b', 'c'] 35 | } 36 | self.df = pandas.DataFrame(data) 37 | self.df['A'] = self.df['A'].astype(np.int8) # 委托,规定某一列的类型 38 | model.setDataFrame(self.df) 39 | 40 | # 保存数据 41 | self.quit_btn_7.clicked.connect(self.save_data) 42 | 43 | def save_data(self): 44 | self.df.to_csv('data.csv') 45 | 46 | def quit_act(self): 47 | # sender 是发送信号的对象 48 | sender = self.sender() 49 | print(sender.text() + '键被按下') 50 | qApp = QApplication.instance() 51 | qApp.quit() 52 | 53 | 54 | class MyMainWindow(QMainWindow, Ui_MainWindow): 55 | 56 | def __init__(self, parent = None): 57 | super(MyMainWindow, self).__init__(parent) 58 | self.setupUi(self) 59 | 60 | q = MyMainWidget() 61 | self.setCentralWidget(q) 62 | 63 | # 设置窗口透明 64 | self.setWindowOpacity(0.9) 65 | 66 | # self.resize(1000, 700) 67 | 68 | # 默认的状态栏 69 | # 可以设置其他按钮点击 参考多行文本显示 然而不行 70 | self.status = self.statusBar() 71 | self.status.showMessage("你在主页面~") 72 | 73 | # 标题栏 74 | self.setWindowTitle("建模协会录入信息") 75 | 76 | # 窗口居中 77 | self.center() 78 | 79 | def center(self): 80 | ''' 81 | 获取桌面长宽 82 | 获取窗口长宽 83 | 移动 84 | ''' 85 | screen = QDesktopWidget().screenGeometry() 86 | size = self.geometry() 87 | self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2) 88 | 89 | if __name__ == "__main__": 90 | # 在shell中执行 91 | app = QApplication(sys.argv) 92 | mywin = MyMainWindow() 93 | mywin.show() 94 | # 开始主循环,直到退出 95 | sys.exit(app.exec()) 96 | -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from __future__ import unicode_literals 4 | from __future__ import print_function 5 | from __future__ import division 6 | from __future__ import absolute_import 7 | from future import standard_library 8 | standard_library.install_aliases() 9 | from qtpandas.models.DataFrameModel import (DataFrameModel, 10 | read_file, 11 | read_sql) 12 | 13 | from qtpandas.models.ColumnDtypeModel import ColumnDtypeModel 14 | 15 | from qtpandas.models.DataSearch import DataSearch 16 | 17 | from qtpandas.views.CSVDialogs import (CSVExportDialog, 18 | CSVImportDialog) 19 | 20 | from qtpandas.views.EditDialogs import (AddAttributesDialog, 21 | RemoveAttributesDialog) 22 | 23 | # __import__('pkg_resources').declare_namespace(__name__) 24 | 25 | __version__ = '1.0.4' 26 | -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/qtpandas/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/__pycache__/compat.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/qtpandas/__pycache__/compat.cpython-37.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/__pycache__/utils.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/qtpandas/__pycache__/utils.cpython-37.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/_lib/magic/db/magic.mgc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/qtpandas/_lib/magic/db/magic.mgc -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/_lib/magic/libgcc_s_dw2-1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/qtpandas/_lib/magic/libgcc_s_dw2-1.dll -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/_lib/magic/libmagic-1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/qtpandas/_lib/magic/libmagic-1.dll -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/_lib/magic/libregex-1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/qtpandas/_lib/magic/libregex-1.dll -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/_lib/magic/magic1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/qtpandas/_lib/magic/magic1.dll -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/_lib/magic/zlib1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/qtpandas/_lib/magic/zlib1.dll -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/compat.py: -------------------------------------------------------------------------------- 1 | """Systematically imports tools needed from PyQt4, PyQt5 and or Pyside as well 2 | as attempts to set sip API values if sip is installed. 3 | 4 | @author: qtpandas contributors 5 | """ 6 | from __future__ import unicode_literals 7 | from __future__ import print_function 8 | from __future__ import division 9 | from __future__ import absolute_import 10 | from future import standard_library 11 | standard_library.install_aliases() 12 | import qtpy.QtGui as _QtGui 13 | import qtpy.QtWidgets as _QtWidgets 14 | import qtpy.QtCore as _QtCore 15 | from qtpy.QtCore import (Signal, Slot, Qt) 16 | QtGui = _QtGui 17 | QtCore = _QtCore 18 | # QtGui compatility 19 | for sub_mod in dir(_QtWidgets): 20 | QtGui.__dict__[sub_mod] = _QtWidgets.__dict__[sub_mod] 21 | 22 | 23 | __all__ = ['QtCore', 'QtGui', 'Qt', 'Signal', 'Slot'] 24 | -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/encoding.py: -------------------------------------------------------------------------------- 1 | from __future__ import unicode_literals 2 | from __future__ import print_function 3 | from __future__ import division 4 | from __future__ import absolute_import 5 | from future import standard_library 6 | standard_library.install_aliases() 7 | import sys 8 | import os 9 | import warnings 10 | BASEDIR = os.path.dirname(os.path.abspath(__file__)) 11 | 12 | if sys.platform == 'win32': 13 | # add local folder to path 14 | lib = os.path.join(BASEDIR, '_lib', 'magic') 15 | envpath = os.environ['PATH'] 16 | os.environ['PATH'] = ';'.join([lib, envpath]) 17 | -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/excepthook.py: -------------------------------------------------------------------------------- 1 | from __future__ import unicode_literals 2 | from __future__ import print_function 3 | from __future__ import division 4 | from __future__ import absolute_import 5 | # copied and modified from Eric IDE ( credits goes to author ) 6 | 7 | from builtins import str 8 | from future import standard_library 9 | standard_library.install_aliases() 10 | import time 11 | import io 12 | import traceback 13 | from qtpandas.compat import QtGui 14 | import codecs 15 | import os 16 | import tempfile 17 | import sys 18 | # fallback solution to show a OS independent messagebox 19 | from easygui.boxes.derived_boxes import msgbox 20 | 21 | # Load python version, an int with value 2 or 3. 22 | python_version = sys.version_info[0] 23 | 24 | 25 | def excepthook(excType, excValue, tracebackobj): 26 | """ 27 | Global function to catch unhandled exceptions. 28 | 29 | @param excType exception type 30 | @param excValue exception value 31 | @param tracebackobj traceback object 32 | """ 33 | separator = '-' * 80 34 | 35 | logFile = os.path.join(tempfile.gettempdir(), "error.log") 36 | 37 | notice = "An unhandled exception occurred. Please report the problem.\n" 38 | 39 | notice += """A log has been written to "{}".\n\nError information:""".format(logFile) 40 | 41 | timeString = time.strftime("%Y-%m-%d, %H:%M:%S") 42 | 43 | tbinfofile = io.StringIO() 44 | traceback.print_tb(tracebackobj, None, tbinfofile) 45 | tbinfofile.seek(0) 46 | tbinfo = tbinfofile.read() 47 | if python_version < 3: 48 | # Python3 has no str().decode() 49 | tbinfo = tbinfo.decode('utf-8') 50 | else: 51 | pass 52 | 53 | try: 54 | if python_version < 3: 55 | # Python3 has no str().decode() 56 | excValueStr = str(excValue).decode('utf-8') 57 | else: 58 | excValueStr = str(excValue) 59 | 60 | except UnicodeEncodeError: 61 | excValueStr = str(excValue) 62 | 63 | errmsg = '{0}: \n{1}'.format(excType, excValueStr) 64 | 65 | sections = ['\n', separator, timeString, separator, 66 | errmsg, separator, tbinfo] 67 | try: 68 | msg = '\n'.join(sections) 69 | 70 | except TypeError: 71 | # Remove all things not string. 72 | sections = [item for item in sections if type(item) == str] 73 | msg = '\n'.join(sections) 74 | 75 | try: 76 | f = codecs.open(logFile, "a+", encoding='utf-8') 77 | f.write(msg) 78 | f.close() 79 | except IOError: 80 | msgbox("unable to write to {0}".format(logFile), "Writing error") 81 | 82 | # always show an error message 83 | try: 84 | if not _isQAppRunning(): 85 | app = QtGui.QApplication([]) 86 | _showMessageBox(str(notice) + str(msg)) 87 | except Exception: 88 | msgbox(str(notice) + str(msg), "Error") 89 | 90 | 91 | def _isQAppRunning(): 92 | if QtGui.QApplication.instance() is None: 93 | return False 94 | else: 95 | return True 96 | 97 | 98 | def _showMessageBox(text): 99 | errorbox = QtGui.QMessageBox() 100 | errorbox.setText(text) 101 | errorbox.exec_() 102 | -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/models/ProgressThread.py: -------------------------------------------------------------------------------- 1 | from __future__ import unicode_literals 2 | from __future__ import print_function 3 | from __future__ import division 4 | from __future__ import absolute_import 5 | from builtins import super 6 | from future import standard_library 7 | standard_library.install_aliases() 8 | from qtpandas.compat import QtCore, QtGui, Qt, Signal, Slot 9 | 10 | 11 | class ProgressWorker(QtCore.QObject): 12 | 13 | progressChanged = Signal(int) # set value of OverlayProgressView 14 | finished = Signal() 15 | 16 | def __init__(self, name): 17 | """Worker object that will be passed to the thread. 18 | 19 | Args: 20 | name (str): name shown in progress ui. 21 | 22 | """ 23 | super(ProgressWorker, self).__init__() 24 | self.name = name 25 | 26 | @Slot() 27 | def doWork(self): 28 | """start the thread""" 29 | self.run() 30 | # emit the result of the operation? 31 | self.finished.emit() 32 | 33 | def run(self): 34 | """Implement your job here. This is what the thread will do. 35 | 36 | """ 37 | raise NotImplementedError 38 | 39 | 40 | 41 | def createThread(parent, worker, deleteWorkerLater=False): 42 | """Create a new thread for given worker. 43 | 44 | Args: 45 | parent (QObject): parent of thread and worker. 46 | worker (ProgressWorker): worker to use in thread. 47 | deleteWorkerLater (bool, optional): delete the worker if thread finishes. 48 | 49 | Returns: 50 | QThread 51 | 52 | """ 53 | thread = QtCore.QThread(parent) 54 | thread.started.connect(worker.doWork) 55 | worker.finished.connect(thread.quit) 56 | if deleteWorkerLater: 57 | thread.finished.connect(worker.deleteLater) 58 | 59 | worker.moveToThread(thread) 60 | worker.setParent(parent) 61 | return thread 62 | -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/models/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/qtpandas/models/__init__.py -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/models/__pycache__/ColumnDtypeModel.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/qtpandas/models/__pycache__/ColumnDtypeModel.cpython-37.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/models/__pycache__/DataFrameModel.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/qtpandas/models/__pycache__/DataFrameModel.cpython-37.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/models/__pycache__/DataSearch.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/qtpandas/models/__pycache__/DataSearch.cpython-37.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/models/__pycache__/SupportedDtypes.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/qtpandas/models/__pycache__/SupportedDtypes.cpython-37.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/models/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/qtpandas/models/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/models/__pycache__/mime.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/qtpandas/models/__pycache__/mime.cpython-37.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/models/mime.py: -------------------------------------------------------------------------------- 1 | from __future__ import unicode_literals 2 | from __future__ import print_function 3 | from __future__ import division 4 | from __future__ import absolute_import 5 | from builtins import super 6 | from future import standard_library 7 | standard_library.install_aliases() 8 | import pickle as pickle 9 | from qtpandas.models.SupportedDtypes import SupportedDtypes 10 | from qtpandas.compat import QtCore 11 | 12 | PandasCellMimeType = "application/pandas-cell" # comparable to a QModelIndex for DataFrames 13 | 14 | class MimeData(QtCore.QMimeData): 15 | 16 | def __init__(self, mimeType=PandasCellMimeType): 17 | """create a new MimeData object. 18 | 19 | Args: 20 | mimeType (str): the mime type. 21 | """ 22 | super(MimeData, self).__init__() 23 | self._mimeType = mimeType 24 | 25 | def mimeType(self): 26 | """return mimeType 27 | 28 | Returns: 29 | str 30 | """ 31 | return self._mimeType 32 | 33 | def setData(self, data): 34 | """Add some data. 35 | 36 | Args: 37 | data (object): Object to add as data. This object has to be pickable. 38 | Qt objects don't work! 39 | 40 | Raises: 41 | TypeError if data is not pickable 42 | """ 43 | try: 44 | bytestream = pickle.dumps(data) 45 | super(MimeData, self).setData(self._mimeType, bytestream) 46 | except TypeError: 47 | raise TypeError(self.tr("can not pickle added data")) 48 | except: 49 | raise 50 | 51 | def data(self): 52 | """return stored data 53 | 54 | Returns: 55 | unpickled data 56 | """ 57 | try: 58 | bytestream = super(MimeData, self).data(self._mimeType).data() 59 | return pickle.loads(bytestream) 60 | except: 61 | raise 62 | 63 | class MimeDataPayload(object): 64 | 65 | def __init__(self): 66 | """base class for your own payload""" 67 | super(MimeDataPayload, self).__init__() 68 | 69 | def isValid(self): 70 | """Will be checked in the dragEnterEvent to check if our payload can be accepted. 71 | e.x. data is a filepath its valid if the file exists. 72 | 73 | Hint: 74 | Implement your own validation criterias. 75 | 76 | Returns: 77 | True if valid 78 | False if invalid 79 | """ 80 | return False 81 | 82 | class PandasCellPayload(MimeDataPayload): 83 | 84 | _allowedDtypes = SupportedDtypes.allTypes() 85 | 86 | def __init__(self, dfindex, column, value, dtype, parentId): 87 | """store dataframe information in a pickable object 88 | 89 | Args: 90 | dfindex (pandas.index): index of the dragged data. 91 | column (str): name of column to be dragged. 92 | value (object): value on according position. 93 | dtype (pandas dtype): data type of column. 94 | parentId (str): hex(id(...)) of according DataFrameModel. 95 | 96 | """ 97 | super(PandasCellPayload, self).__init__() 98 | self.dfindex = dfindex 99 | self.column = column 100 | self.value = value 101 | self.dtype = dtype 102 | self.parentId = parentId 103 | 104 | def setAllowedDtypes(self, dtypes): 105 | """set the allowed dtypes used by the dropped widget to determin if we accept or decline the data. 106 | Defaults to allTypes. 107 | 108 | Args: 109 | dtypes(SupportedDtypes type): combination of SupportedDtypes types. 110 | e.x. SupportedDtypes.intTypes() + SupportedDtypes.floatTypes() 111 | 112 | """ 113 | self._allowedDtypes = dtypes 114 | 115 | def allowedDtypes(self): 116 | """return allowedDtypes""" 117 | return self._allowedDtypes 118 | 119 | def isValid(self): 120 | """check if the dtype is in allowedDtypes. Used to accept or decline a drop in the view.""" 121 | if self.dtype in self._allowedDtypes: 122 | return True 123 | else: 124 | return False -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/ui/AddAttributesDialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Dialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 264 10 | 157 11 | 12 | 13 | 14 | Add Attribute 15 | 16 | 17 | 18 | 19 | 50 20 | 120 21 | 201 22 | 32 23 | 24 | 25 | 26 | Qt::Horizontal 27 | 28 | 29 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 30 | 31 | 32 | 33 | 34 | 35 | 40 36 | 10 37 | 178 38 | 13 39 | 40 | 41 | 42 | Add a new Attribute to the data 43 | 44 | 45 | 46 | 47 | 48 | 10 49 | 30 50 | 241 51 | 84 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 0 60 | 0 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | Type 69 | 70 | 71 | dataTypeComboBox 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | Name 82 | 83 | 84 | columnNameLineEdit 85 | 86 | 87 | 88 | 89 | 90 | 91 | Inital Value 92 | 93 | 94 | defaultValueLineEdit 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | buttonBox 108 | accepted() 109 | Dialog 110 | accept() 111 | 112 | 113 | 250 114 | 134 115 | 116 | 117 | 157 118 | 156 119 | 120 | 121 | 122 | 123 | buttonBox 124 | rejected() 125 | Dialog 126 | reject() 127 | 128 | 129 | 250 130 | 140 131 | 132 | 133 | 263 134 | 156 135 | 136 | 137 | 138 | 139 | 140 | -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/ui/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/ui/fallback/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/ui/fallback/easygui/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Hello from easygui/__init__.py 3 | 4 | """ 5 | from __future__ import unicode_literals 6 | from __future__ import print_function 7 | from __future__ import division 8 | from __future__ import absolute_import 9 | 10 | # __all__ must be defined in order for Sphinx to generate the API automatically. 11 | from future import standard_library 12 | standard_library.install_aliases() 13 | __all__ = ['buttonbox', 14 | 'diropenbox', 15 | 'fileopenbox', 16 | 'filesavebox', 17 | 'textbox', 18 | 'ynbox', 19 | 'ccbox', 20 | 'boolbox', 21 | 'indexbox', 22 | 'msgbox', 23 | 'integerbox', 24 | 'multenterbox', 25 | 'enterbox', 26 | 'exceptionbox', 27 | 'choicebox', 28 | 'codebox', 29 | 'passwordbox', 30 | 'multpasswordbox', 31 | 'multchoicebox', 32 | 'EgStore', 33 | 'eg_version', 34 | 'egversion', 35 | 'abouteasygui', 36 | ] 37 | 38 | # Import all functions that form the API 39 | from .boxes.base_boxes import buttonbox 40 | from .boxes.base_boxes import diropenbox 41 | from .boxes.base_boxes import fileopenbox 42 | from .boxes.base_boxes import filesavebox 43 | 44 | from .boxes.text_box import textbox 45 | 46 | from .boxes.derived_boxes import ynbox 47 | from .boxes.derived_boxes import ccbox 48 | from .boxes.derived_boxes import boolbox 49 | from .boxes.derived_boxes import indexbox 50 | from .boxes.derived_boxes import msgbox 51 | from .boxes.derived_boxes import integerbox 52 | from .boxes.derived_boxes import multenterbox 53 | from .boxes.derived_boxes import enterbox 54 | from .boxes.derived_boxes import exceptionbox 55 | from .boxes.derived_boxes import choicebox 56 | from .boxes.derived_boxes import codebox 57 | from .boxes.derived_boxes import passwordbox 58 | from .boxes.derived_boxes import multpasswordbox 59 | from .boxes.derived_boxes import multchoicebox 60 | from .boxes.egstore import EgStore 61 | from .boxes.about import eg_version, egversion, abouteasygui -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/ui/fallback/easygui/boxes/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/qtpandas/ui/fallback/easygui/boxes/__init__.py -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/ui/fallback/easygui/boxes/egstore.py: -------------------------------------------------------------------------------- 1 | """ 2 | 3 | .. moduleauthor:: Stephen Raymond Ferg and Robert Lugg (active) 4 | .. default-domain:: py 5 | .. highlight:: python 6 | 7 | Version |release| 8 | """ 9 | from __future__ import unicode_literals 10 | from __future__ import print_function 11 | from __future__ import division 12 | from __future__ import absolute_import 13 | 14 | 15 | from builtins import open 16 | from future import standard_library 17 | standard_library.install_aliases() 18 | from builtins import object 19 | import os 20 | import pickle 21 | 22 | 23 | # ----------------------------------------------------------------------- 24 | # 25 | # class EgStore 26 | # 27 | # ----------------------------------------------------------------------- 28 | class EgStore(object): 29 | 30 | r""" 31 | A class to support persistent storage. 32 | 33 | You can use EgStore to support the storage and retrieval 34 | of user settings for an EasyGui application. 35 | 36 | **Example A: define a class named Settings as a subclass of EgStore** 37 | :: 38 | 39 | class Settings(EgStore): 40 | def __init__(self, filename): # filename is required 41 | #------------------------------------------------- 42 | # Specify default/initial values for variables that 43 | # this particular application wants to remember. 44 | #------------------------------------------------- 45 | self.userId = "" 46 | self.targetServer = "" 47 | 48 | #------------------------------------------------- 49 | # For subclasses of EgStore, these must be 50 | # the last two statements in __init__ 51 | #------------------------------------------------- 52 | self.filename = filename # this is required 53 | self.restore() # restore values from the storage file if possible 54 | 55 | **Example B: create settings, a persistent Settings object** 56 | :: 57 | 58 | settingsFile = "myApp_settings.txt" 59 | settings = Settings(settingsFile) 60 | 61 | user = "obama_barak" 62 | server = "whitehouse1" 63 | settings.userId = user 64 | settings.targetServer = server 65 | settings.store() # persist the settings 66 | 67 | # run code that gets a new value for userId, and persist the settings 68 | user = "biden_joe" 69 | settings.userId = user 70 | settings.store() 71 | 72 | **Example C: recover the Settings instance, change an attribute, and store it again.** 73 | :: 74 | 75 | settings = Settings(settingsFile) 76 | settings.userId = "vanrossum_g" 77 | settings.store() 78 | 79 | """ 80 | 81 | def __init__(self, filename): # obtaining filename is required 82 | self.filename = None 83 | raise NotImplementedError() 84 | 85 | def restore(self): 86 | """ 87 | Set the values of whatever attributes are recoverable 88 | from the pickle file. 89 | 90 | Populate the attributes (the __dict__) of the EgStore object 91 | from the attributes (the __dict__) of the pickled object. 92 | 93 | If the pickled object has attributes that have been initialized 94 | in the EgStore object, then those attributes of the EgStore object 95 | will be replaced by the values of the corresponding attributes 96 | in the pickled object. 97 | 98 | If the pickled object is missing some attributes that have 99 | been initialized in the EgStore object, then those attributes 100 | of the EgStore object will retain the values that they were 101 | initialized with. 102 | 103 | If the pickled object has some attributes that were not 104 | initialized in the EgStore object, then those attributes 105 | will be ignored. 106 | 107 | IN SUMMARY: 108 | 109 | After the recover() operation, the EgStore object will have all, 110 | and only, the attributes that it had when it was initialized. 111 | 112 | Where possible, those attributes will have values recovered 113 | from the pickled object. 114 | """ 115 | if not os.path.exists(self.filename): 116 | return self 117 | if not os.path.isfile(self.filename): 118 | return self 119 | 120 | try: 121 | with open(self.filename, "rb") as f: 122 | unpickledObject = pickle.load(f) 123 | 124 | for key in list(self.__dict__.keys()): 125 | default = self.__dict__[key] 126 | self.__dict__[key] = unpickledObject.__dict__.get(key, default) 127 | except: 128 | pass 129 | 130 | return self 131 | 132 | def store(self): 133 | """ 134 | Save the attributes of the EgStore object to a pickle file. 135 | Note that if the directory for the pickle file does not already exist, 136 | the store operation will fail. 137 | """ 138 | with open(self.filename, "wb") as f: 139 | pickle.dump(self, f) 140 | 141 | def kill(self): 142 | """ 143 | Delete my persistent file (i.e. pickle file), if it exists. 144 | """ 145 | if os.path.isfile(self.filename): 146 | os.remove(self.filename) 147 | return 148 | 149 | def __str__(self): 150 | """ 151 | return my contents as a string in an easy-to-read format. 152 | """ 153 | # find the length of the longest attribute name 154 | longest_key_length = 0 155 | keys = list() 156 | for key in list(self.__dict__.keys()): 157 | keys.append(key) 158 | longest_key_length = max(longest_key_length, len(key)) 159 | 160 | keys.sort() # sort the attribute names 161 | lines = list() 162 | for key in keys: 163 | value = self.__dict__[key] 164 | key = key.ljust(longest_key_length) 165 | lines.append("%s : %s\n" % (key, repr(value))) 166 | return "".join(lines) # return a string showing the attributes 167 | -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/ui/fallback/easygui/boxes/state.py: -------------------------------------------------------------------------------- 1 | """ 2 | 3 | .. moduleauthor:: Stephen Raymond Ferg and Robert Lugg (active) 4 | .. default-domain:: py 5 | .. highlight:: python 6 | 7 | Version |release| 8 | """ 9 | from __future__ import unicode_literals 10 | from __future__ import print_function 11 | from __future__ import division 12 | from __future__ import absolute_import 13 | 14 | # Starting and global variables 15 | 16 | from future import standard_library 17 | standard_library.install_aliases() 18 | rootWindowPosition = "+300+200" 19 | 20 | PROPORTIONAL_FONT_FAMILY = ("MS", "Sans", "Serif") 21 | MONOSPACE_FONT_FAMILY = "Courier" 22 | 23 | PROPORTIONAL_FONT_SIZE = 10 24 | # a little smaller, because it is more legible at a smaller size 25 | MONOSPACE_FONT_SIZE = 9 26 | TEXT_ENTRY_FONT_SIZE = 12 # a little larger makes it easier to see 27 | 28 | 29 | STANDARD_SELECTION_EVENTS = ["Return", "Button-1", "space"] 30 | -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/ui/fallback/easygui/easygui.py: -------------------------------------------------------------------------------- 1 | """ 2 | 3 | .. moduleauthor:: Stephen Raymond Ferg and Robert Lugg (active) 4 | .. default-domain:: py 5 | .. highlight:: python 6 | 7 | Version |release| 8 | 9 | ABOUT EASYGUI 10 | ============= 11 | 12 | EasyGui provides an easy-to-use interface for simple GUI interaction 13 | with a user. It does not require the programmer to know anything about 14 | tkinter, frames, widgets, callbacks or lambda. All GUI interactions are 15 | invoked by simple function calls that return results. 16 | 17 | .. warning:: Using EasyGui with IDLE 18 | 19 | You may encounter problems using IDLE to run programs that use EasyGui. Try it 20 | and find out. EasyGui is a collection of Tkinter routines that run their own 21 | event loops. IDLE is also a Tkinter application, with its own event loop. The 22 | two may conflict, with unpredictable results. If you find that you have 23 | problems, try running your EasyGui program outside of IDLE. 24 | 25 | .. note:: EasyGui requires Tk release 8.0 or greater. 26 | 27 | LICENSE INFORMATION 28 | =================== 29 | EasyGui version |version| 30 | 31 | Copyright (c) 2014, Stephen Raymond Ferg 32 | 33 | All rights reserved. 34 | 35 | Redistribution and use in source and binary forms, with or without modification, 36 | are permitted provided that the following conditions are met: 37 | 38 | 1. Redistributions of source code must retain the above copyright notice, 39 | this list of conditions and the following disclaimer. 40 | 41 | 2. Redistributions in binary form must reproduce the above copyright notice, 42 | this list of conditions and the following disclaimer in the documentation and/or 43 | other materials provided with the distribution. 44 | 45 | 3. The name of the author may not be used to endorse or promote products derived 46 | from this software without specific prior written permission. 47 | 48 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" 49 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 50 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 51 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 52 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 53 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 54 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 55 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 56 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 57 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 58 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 59 | 60 | 61 | ABOUT THE EASYGUI LICENSE 62 | ------------------------- 63 | | This license is what is generally known as the "modified BSD license", 64 | | aka "revised BSD", "new BSD", "3-clause BSD". 65 | | See http://www.opensource.org/licenses/bsd-license.php 66 | | 67 | | This license is GPL-compatible. 68 | | See ``_ 69 | | See http://www.gnu.org/licenses/license-list.html#GPLCompatibleLicenses 70 | | 71 | | The BSD License is less restrictive than GPL. 72 | | It allows software released under the license to be incorporated into proprietary products. 73 | | Works based on the software may be released under a proprietary license or as closed source software. 74 | | ``_ 75 | 76 | API 77 | === 78 | """ 79 | from __future__ import unicode_literals 80 | from __future__ import print_function 81 | from __future__ import division 82 | from __future__ import absolute_import 83 | 84 | 85 | from future import standard_library 86 | standard_library.install_aliases() -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/views/BigIntSpinbox.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """Custom spinbox for very big integers (like numpy.int64 and uint64) 3 | 4 | @author: Matthias Ludwig - Datalyze Solutions 5 | """ 6 | from __future__ import unicode_literals 7 | from __future__ import print_function 8 | from __future__ import division 9 | from __future__ import absolute_import 10 | 11 | from builtins import super 12 | from builtins import int 13 | from builtins import str 14 | from future import standard_library 15 | standard_library.install_aliases() 16 | from qtpandas.compat import Qt, QtCore, QtGui 17 | 18 | class BigIntSpinbox(QtGui.QAbstractSpinBox): 19 | """Custom spinbox for very big integers (like numpy.int64 and uint64) 20 | 21 | Attributes: 22 | 23 | """ 24 | 25 | def __init__(self, parent=None): 26 | """the __init__ method. 27 | 28 | Args: 29 | parent (QObject): defaults to None. If parent is 0, the new widget becomes a window. 30 | If parent is another widget, this widget becomes a child window inside parent. 31 | The new widget is deleted when its parent is deleted. 32 | 33 | """ 34 | super(BigIntSpinbox, self).__init__(parent) 35 | 36 | self._singleStep = 1 37 | self._minimum = -18446744073709551616 38 | self._maximum = 18446744073709551615 39 | 40 | rx = QtCore.QRegExp("[0-9]\\d{0,20}") 41 | validator = QtGui.QRegExpValidator(rx, self) 42 | 43 | self._lineEdit = QtGui.QLineEdit(self) 44 | self._lineEdit.setText('0') 45 | self._lineEdit.setValidator(validator) 46 | self.setLineEdit(self._lineEdit) 47 | 48 | def value(self): 49 | """ 50 | Getter function to _lineEdit.text. Returns 0 in case of exception. 51 | """ 52 | try: 53 | return int(self._lineEdit.text()) 54 | except Exception: 55 | return 0 56 | 57 | def setValue(self, value): 58 | """setter function to _lineEdit.text. Sets minimum/maximum as new value if value is out of bounds. 59 | 60 | Args: 61 | value (int/long): new value to set. 62 | 63 | Returns 64 | True if all went fine. 65 | """ 66 | if value >= self.minimum() and value <= self.maximum(): 67 | self._lineEdit.setText(str(value)) 68 | elif value < self.minimum(): 69 | self._lineEdit.setText(str(self.minimum())) 70 | elif value > self.maximum(): 71 | self._lineEdit.setText(str(self.maximum())) 72 | return True 73 | 74 | def stepBy(self, steps): 75 | """steps value up/down by a single step. Single step is defined in singleStep(). 76 | 77 | Args: 78 | steps (int): positiv int steps up, negativ steps down 79 | """ 80 | self.setValue(self.value() + steps*self.singleStep()) 81 | 82 | def stepEnabled(self): 83 | """Virtual function that determines whether stepping up and down is legal at any given time. 84 | 85 | Returns: 86 | ored combination of StepUpEnabled | StepDownEnabled 87 | """ 88 | if self.value() > self.minimum() and self.value() < self.maximum(): 89 | return self.StepUpEnabled | self.StepDownEnabled 90 | elif self.value() <= self.minimum(): 91 | return self.StepUpEnabled 92 | elif self.value() >= self.maximum(): 93 | return self.StepDownEnabled 94 | 95 | def singleStep(self): 96 | """getter to _singleStep. determines the value to add if stepBy() is done.""" 97 | return self._singleStep 98 | 99 | def setSingleStep(self, singleStep): 100 | """setter to _singleStep. converts negativ values to positiv ones. 101 | 102 | Args: 103 | singleStep (int): new _singleStep value. converts negativ values to positiv ones. 104 | 105 | Raises: 106 | TypeError: If the given argument is not an integer. 107 | 108 | Returns: 109 | int or long: the absolute value of the given argument. 110 | """ 111 | if not isinstance(singleStep, int): 112 | raise TypeError("Argument is not of type int") 113 | # don't use negative values 114 | self._singleStep = abs(singleStep) 115 | return self._singleStep 116 | 117 | def minimum(self): 118 | """getter to _minimum. lowest possible number""" 119 | return self._minimum 120 | 121 | def setMinimum(self, minimum): 122 | """setter to _minimum. 123 | 124 | Args: 125 | minimum (int or long): new _minimum value. 126 | 127 | Raises: 128 | TypeError: If the given argument is not an integer. 129 | """ 130 | if not isinstance(minimum, int): 131 | raise TypeError("Argument is not of type int or long") 132 | self._minimum = minimum 133 | 134 | def maximum(self): 135 | """getter to _maximum. biggest possible number""" 136 | return self._maximum 137 | 138 | def setMaximum(self, maximum): 139 | """setter to _maximum. 140 | 141 | Args: 142 | maximum (int or long): new _maximum value 143 | """ 144 | if not isinstance(maximum, int): 145 | raise TypeError("Argument is not of type int or long") 146 | self._maximum = maximum 147 | -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/views/MultiFileDialogs.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | from __future__ import unicode_literals 3 | from __future__ import division 4 | from __future__ import absolute_import 5 | from builtins import str 6 | from future import standard_library 7 | standard_library.install_aliases() 8 | import os 9 | from qtpandas.compat import QtCore 10 | from qtpandas.views.CSVDialogs import (CSVExportDialog, CSVImportDialog, 11 | _calculateEncodingKey, Slot, 12 | DataFrameModel) 13 | 14 | 15 | 16 | class DataFrameExportDialog(CSVExportDialog): 17 | """ 18 | Extends the CSVExportDialog with support for 19 | exporting to .txt and .xlsx 20 | """ 21 | signalExportFilenames = QtCore.Signal(str, str) 22 | signalModelChanged = QtCore.Signal(DataFrameModel) 23 | 24 | def __init__(self, model=None, parent=None): 25 | CSVExportDialog.__init__(self, model=None, parent=None) 26 | if model is not None: 27 | self._filename = model.filePath 28 | else: 29 | self._filename = None 30 | self._windowTitle = "Export Data" 31 | self.setWindowTitle(self._windowTitle) 32 | 33 | @Slot(DataFrameModel) 34 | def swapModel(self, model): 35 | good = self.setExportModel(model) 36 | if good: 37 | self.signalModelChanged.emit(model) 38 | 39 | @Slot() 40 | def accepted(self): 41 | """Successfully close the widget and emit an export signal. 42 | 43 | This method is also a `SLOT`. 44 | The dialog will be closed, when the `Export Data` button is 45 | pressed. If errors occur during the export, the status bar 46 | will show the error message and the dialog will not be closed. 47 | 48 | """ 49 | #return super(DataFrameExportDialog, self).accepted 50 | try: 51 | self._saveModel() 52 | except Exception as err: 53 | self._statusBar.showMessage(str(err)) 54 | raise 55 | else: 56 | self._resetWidgets() 57 | self.exported.emit(True) 58 | self.accept() 59 | 60 | @Slot() 61 | def rejected(self): 62 | """Close the widget and reset its inital state. 63 | 64 | This method is also a `SLOT`. 65 | The dialog will be closed and all changes reverted, when the 66 | `cancel` button is pressed. 67 | 68 | """ 69 | self._resetWidgets() 70 | self.exported.emit(False) 71 | self.reject() 72 | 73 | def _saveModel(self): 74 | """ 75 | Reimplements _saveModel to utilize all of the 76 | Pandas export options based on file extension. 77 | :return: None 78 | """ 79 | delimiter = self._delimiterBox.currentSelected() 80 | header = self._headerCheckBox.isChecked() # column labels 81 | if self._filename is None: 82 | filename = self._filenameLineEdit.text() 83 | else: 84 | filename = self._filename 85 | ext = os.path.splitext(filename)[1].lower() 86 | index = False # row labels 87 | 88 | encodingIndex = self._encodingComboBox.currentIndex() 89 | encoding = self._encodingComboBox.itemText(encodingIndex) 90 | encoding = _calculateEncodingKey(encoding.lower()) 91 | 92 | try: 93 | dataFrame = self._model.dataFrame() 94 | except AttributeError as err: 95 | raise AttributeError('No data loaded to export.') 96 | else: 97 | print("Identifying export type for {}".format(filename)) 98 | try: 99 | if ext in ['.txt','.csv']: 100 | dataFrame.to_csv(filename, encoding=encoding, header=header, index=index, sep=delimiter) 101 | elif ext == '.tsv': 102 | sep = '\t' 103 | dataFrame.to_csv(filename, encoding=encoding, header=header, index=index, sep=delimiter) 104 | elif ext in ['.xlsx','.xls']: 105 | dataFrame.to_excel(filename, encoding=encoding, header=header, index=index, sep=delimiter) 106 | except IOError as err: 107 | raise IOError('No filename given') 108 | except UnicodeError as err: 109 | raise UnicodeError('Could not encode all data. Choose a different encoding') 110 | except Exception: 111 | raise 112 | self.signalExportFilenames.emit(self._model._filePath, filename) 113 | -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/views/OverlayProgressView.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | from __future__ import division 3 | from __future__ import unicode_literals 4 | from __future__ import absolute_import 5 | from builtins import super 6 | from future import standard_library 7 | standard_library.install_aliases() 8 | from qtpandas.compat import QtCore, QtGui, Qt, Signal, Slot 9 | 10 | class OverlayProgressWidget(QtGui.QFrame): 11 | def __init__(self, parent, workers=None, debug=True, margin=0): 12 | workers = workers or [] 13 | super(OverlayProgressWidget, self).__init__(parent) 14 | self._debug = debug 15 | self._workers = workers 16 | self._detailProgressBars = [] 17 | self._addedBars = 0 18 | self._minHeight = 50 19 | self._width = parent.width() * 0.38 20 | self._margin = margin 21 | self._totalProgress = 0 22 | 23 | self.initUi() 24 | 25 | for worker in workers: 26 | self._addProgressBar(worker) 27 | 28 | 29 | def initUi(self): 30 | self.sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Expanding) 31 | 32 | self._pbHeight = 30 33 | 34 | self.setMinimumWidth(self._width) 35 | #self.setMaximumWidth(self._width) 36 | self.setMinimumHeight(self._minHeight) 37 | 38 | self.glayout = QtGui.QGridLayout(self) 39 | 40 | self.totalProgressBar = QtGui.QProgressBar(self) 41 | self.totalProgressBar.setMinimumHeight(self._pbHeight) 42 | self.totalProgressBar.setMaximumHeight(self._pbHeight) 43 | 44 | self.toggleButton = QtGui.QPushButton('Details', self) 45 | self.toggleButton.setCheckable(True) 46 | self.toggleButton.toggled.connect(self.showDetails) 47 | self.glayout.addWidget(self.totalProgressBar, 0, 0, 1, 1) 48 | self.glayout.addWidget(self.toggleButton, 0, 1, 1, 1) 49 | 50 | #styleSheet = """.QProgressBar { 51 | #border: none; 52 | #border-radius: 3px; 53 | #text-align: center; 54 | #background-color: rgba(37, 37, 37, 50%); 55 | #color: white; 56 | #margin: 1px; 57 | #border-bottom-left-radius:5px; 58 | #border-top-left-radius:5px; 59 | #} 60 | 61 | #.QProgressBar::chunk { 62 | #background-color: #05B8CC; 63 | #border-radius: 3px; 64 | #} 65 | 66 | #.OverlayProgressWidget { 67 | #background-color: white; 68 | #} 69 | 70 | #""" 71 | ## set stylesheet for all progressbars in this widget 72 | #self.setStyleSheet(styleSheet) 73 | 74 | parent = self.parent() 75 | xAnchor = parent.width() - self._width - self._margin 76 | yAnchor = self._margin 77 | self.setGeometry(xAnchor, yAnchor, self._width, self._minHeight) 78 | 79 | @Slot(bool) 80 | def showDetails(self, toggled): 81 | for (progressBar, label) in self._detailProgressBars: 82 | progressBar.setVisible(toggled) 83 | label.setVisible(toggled) 84 | self.resizeFrame() 85 | 86 | 87 | def _addProgressBar(self, worker): 88 | progressBar = QtGui.QProgressBar(self) 89 | progressBar.setMinimumHeight(self._pbHeight - 5) 90 | progressBar.setMaximumHeight(self._pbHeight - 5) 91 | label = QtGui.QLabel(worker.name, self) 92 | if not self.toggleButton.isChecked(): 93 | progressBar.hide() 94 | label.hide() 95 | row = self._addedBars + 1 96 | self.glayout.addWidget(progressBar, row, 0, 1, 1) 97 | self.glayout.addWidget(label, row, 1, 1, 1) 98 | self._addedBars += 1 99 | self._detailProgressBars.append((progressBar, label)) 100 | worker.progressChanged.connect(progressBar.setValue) 101 | worker.progressChanged.connect(self.calculateTotalProgress) 102 | 103 | worker.progressChanged.connect(self.debugProgressChanged) 104 | 105 | def debugProgressChanged(self, value): 106 | print(("debugProgressChanged", value)) 107 | 108 | def addWorker(self, worker): 109 | self._workers.append(worker) 110 | self._addProgressBar(worker) 111 | self.resizeFrame() 112 | 113 | def resizeFrame(self): 114 | size = self.glayout.sizeHint() 115 | self.resize(size.width(), size.height()) 116 | 117 | @Slot() 118 | def calculateTotalProgress(self): 119 | bars = len(self._detailProgressBars) 120 | if bars: 121 | progress = 0 122 | for (progressBar, label) in self._detailProgressBars: 123 | value = progressBar.value() 124 | progress += value 125 | progress = progress / bars 126 | else: 127 | progress = 100 128 | 129 | self.totalProgressBar.setValue(progress) 130 | -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/views/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/qtpandas/views/__init__.py -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/views/__pycache__/BigIntSpinbox.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/qtpandas/views/__pycache__/BigIntSpinbox.cpython-37.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/views/__pycache__/CSVDialogs.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/qtpandas/views/__pycache__/CSVDialogs.cpython-37.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/views/__pycache__/CustomDelegates.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/qtpandas/views/__pycache__/CustomDelegates.cpython-37.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/views/__pycache__/DataTableView.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/qtpandas/views/__pycache__/DataTableView.cpython-37.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/views/__pycache__/EditDialogs.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/qtpandas/views/__pycache__/EditDialogs.cpython-37.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/views/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/qtpandas/views/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/views/_ui/AddAttributesDialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Dialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 303 10 | 168 11 | 12 | 13 | 14 | 15 | 0 16 | 0 17 | 18 | 19 | 20 | 21 | 303 22 | 168 23 | 24 | 25 | 26 | Add Attribute 27 | 28 | 29 | 30 | 31 | 32 | 33 | 279 34 | 12 35 | 36 | 37 | 38 | 39 | 279 40 | 12 41 | 42 | 43 | 44 | Add a new Attribute to the data 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 0 55 | 0 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | Type 64 | 65 | 66 | dataTypeComboBox 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | Inital Value 80 | 81 | 82 | defaultValueLineEdit 83 | 84 | 85 | 86 | 87 | 88 | 89 | Name 90 | 91 | 92 | columnNameLineEdit 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 291 103 | 32 104 | 105 | 106 | 107 | 108 | 291 109 | 32 110 | 111 | 112 | 113 | Qt::Horizontal 114 | 115 | 116 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | buttonBox 126 | accepted() 127 | Dialog 128 | accept() 129 | 130 | 131 | 250 132 | 134 133 | 134 | 135 | 157 136 | 156 137 | 138 | 139 | 140 | 141 | buttonBox 142 | rejected() 143 | Dialog 144 | reject() 145 | 146 | 147 | 250 148 | 140 149 | 150 | 151 | 263 152 | 156 153 | 154 | 155 | 156 | 157 | 158 | -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/views/_ui/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/views/_ui/icons.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | icons/dialog-cancel.png 4 | icons/dialog-ok-apply.png 5 | icons/document-open.png 6 | icons/view-refresh.png 7 | icons/document-save-as.png 8 | icons/document-edit.png 9 | icons/edit-table-delete-column.png 10 | icons/edit-table-delete-row.png 11 | icons/edit-table-insert-column-right.png 12 | icons/edit-table-insert-row-below.png 13 | 14 | 15 | -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/views/_ui/icons/dialog-cancel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/qtpandas/views/_ui/icons/dialog-cancel.png -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/views/_ui/icons/dialog-ok-apply.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/qtpandas/views/_ui/icons/dialog-ok-apply.png -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/views/_ui/icons/document-edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/qtpandas/views/_ui/icons/document-edit.png -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/views/_ui/icons/document-open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/qtpandas/views/_ui/icons/document-open.png -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/views/_ui/icons/document-save-as.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/qtpandas/views/_ui/icons/document-save-as.png -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/views/_ui/icons/edit-table-delete-column.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/qtpandas/views/_ui/icons/edit-table-delete-column.png -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/views/_ui/icons/edit-table-delete-row.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/qtpandas/views/_ui/icons/edit-table-delete-row.png -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/views/_ui/icons/edit-table-insert-column-right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/qtpandas/views/_ui/icons/edit-table-insert-column-right.png -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/views/_ui/icons/edit-table-insert-row-below.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/qtpandas/views/_ui/icons/edit-table-insert-row-below.png -------------------------------------------------------------------------------- /GUI/Basic-train/QtPandas/qtpandas/views/_ui/icons/view-refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muyuuuu/PyQt5-learn/a9134566505c88ae9d46ae23480b140c8c911c33/GUI/Basic-train/QtPandas/qtpandas/views/_ui/icons/view-refresh.png -------------------------------------------------------------------------------- /GUI/Basic-train/SiganlSlot/demo1.py: -------------------------------------------------------------------------------- 1 | ''' 2 | File: a.py 3 | Project: test 4 | File Created: Wednesday, 3rd February 2021 5:03:21 pm 5 | Author: lanling (https://github.com/muyuuuu) 6 | ----------- 7 | Last Modified: Wednesday, 3rd February 2021 5:21:28 pm 8 | Modified By: lanling (https://github.com/muyuuuu) 9 | Copyright 2020 - 2021 XDU, XDU 10 | ----------- 11 | Description: 内置信号绑定自定义槽函数 12 | ''' 13 | import sys 14 | from functools import partial 15 | from PyQt5.QtCore import pyqtSignal 16 | from PyQt5.QtWidgets import QMainWindow, QApplication, QPushButton, QWidget, QHBoxLayout 17 | 18 | 19 | class MainWindow(QMainWindow): 20 | btn_signal = pyqtSignal() 21 | def __init__(self): 22 | super(MainWindow, self).__init__() 23 | 24 | a = QPushButton("退出") 25 | a.clicked.connect(partial(self.btn_clicked, 1)) 26 | self.btn_signal.connect(self.close) 27 | 28 | self.setWindowTitle("演示") 29 | 30 | main_widget = QWidget() 31 | layout = QHBoxLayout() 32 | layout.addWidget(a) 33 | main_widget.setLayout(layout) 34 | # QMainWindow 不能设置布局 35 | self.setCentralWidget(main_widget) 36 | 37 | def btn_clicked(self, n): 38 | print(n) 39 | self.btn_signal.emit() 40 | 41 | def close(self): 42 | app = QApplication.instance() 43 | app.quit() 44 | 45 | 46 | if __name__ == "__main__": 47 | # 在shell中执行 48 | app = QApplication(sys.argv) 49 | mywin = MainWindow() 50 | mywin.show() 51 | # 开始主循环,直到退出 52 | sys.exit(app.exec()) -------------------------------------------------------------------------------- /GUI/Basic-train/SiganlSlot/demo2.py: -------------------------------------------------------------------------------- 1 | ''' 2 | File: test.py 3 | Project: test 4 | File Created: Wednesday, 3rd February 2021 4:52:53 pm 5 | Author: lanling (https://github.com/muyuuuu) 6 | ----------- 7 | Last Modified: Wednesday, 3rd February 2021 5:22:11 pm 8 | Modified By: lanling (https://github.com/muyuuuu) 9 | Copyright 2020 - 2021 XDU, XDU 10 | ----------- 11 | Description: 自定义信号与自定义槽函数演示 12 | ''' 13 | 14 | from PyQt5.QtCore import QObject, pyqtSignal 15 | 16 | # 信号对象 17 | class QSignal(QObject): 18 | # 定义信号 19 | # 在类创建时定义,不能在类创建后作为类的属性而添加 20 | # 指定信号传递参数的数量,类型等 21 | send_msg = pyqtSignal(str, str) 22 | 23 | def __init__(self): 24 | super(QSignal, self).__init__() 25 | 26 | def run(self): 27 | # 信号发射 28 | self.send_msg.emit('First arg', 'Second arg') 29 | 30 | # 槽对象 31 | class QSlot(QObject): 32 | def __init__(self): 33 | super(QSlot, self).__init__() 34 | 35 | def get(self, *args): 36 | # 信号接收 37 | print("Get message =>" + args[0], args[1], sep=', ') 38 | 39 | if __name__ == '__main__': 40 | send = QSignal() 41 | slot = QSlot() 42 | 43 | # 将信号与槽函数绑定 44 | send.send_msg.connect(slot.get) 45 | # 外部调用 发射信号 46 | send.run() 47 | # 信号与槽解除关联 48 | send.send_msg.disconnect(slot.get) 49 | send.run() -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | - The Basic-train floder 4 | - AdvanWin 5 | - Container: QStackedWidget, QTabWidget, QDockWidget, verticalScrollBar. 6 | - ViewWidget: tableview, listview, tableWidget, combox, treeWidget. 7 | - WebPage: webEngineView(It is recommended to call the system browser to open the webpage instead of the software.) 8 | - BasicWin 9 | - DataBase 10 | - MatplotWidget 11 | - Pyecharts 12 | - PyQtGraph 13 | - QSS 14 | - QtPandas 15 | 16 | # Basic-train floder 17 | 18 | - QtPandas: Using pyqt5's window to view and edit data with pandas. (Attention: pandas version 0.23 will be needed not the latest version) 19 | 20 | ![](3.png) 21 | 22 | - QSS: Using Qt style sheet to beautify the interface. (Suggestion: Using qss written by others, such as qdarkstyle) 23 | - PyQtGraph: A simple and fast way to draw in a window. 24 | 25 | ![](3.gif) 26 | 27 | - Pyecahrts: Integrating web page drawing in the window. 28 | 29 | ![](4.gif) 30 | 31 | - MatplotWidget: Integrating Matplotlib to draw in the window.(more powerful) 32 | 33 | ![](5.gif) 34 | 35 | - DataBase: Connecting database by pyqt. (Not recommended, it is recommended to connect to the database directly with python) 36 | - BasicWin: Contains basic controls such as buttons, calendars, input boxes, comboBox, label, etc.(recommending learn it carefully) 37 | 38 | ![](4.png) 39 | 40 | - AdvanWin: 41 | - Container: tabwidget, listwidget to hold control 42 | - ViewWidget: To view and edit table conveniently, also can show result which from query of database. 43 | - WebPage: To load and show web page in a window. 44 | 45 | # Attention 46 | 47 | Some `.py` file based on `.ui` file, the software qtdesigner can open and edit `.ui` file and generate the same name `.py` file correspondingly. 48 | 49 | So, don't change `.ui` file unless you know what you are doing. 50 | 51 | # More detailed description: 52 | 53 | If you know chinese, the following website is a good choice. 54 | 55 | About basic and advanced control(tabwidget and button, etc.): https://muyuuuu.github.io/2019/10/06/pyqt5-basic/ 56 | 57 | Matplotlib, qtpandas, database, etc: https://muyuuuu.github.io/2019/10/11/pyqt-pit/ 58 | 59 | Layout and beautify window: https://muyuuuu.github.io/2019/10/19/pyqt-layout/ 60 | 61 | A beautiful and applicable interface: https://github.com/muyuuuu/A-Beautiful-PyQt5-Interface 62 | 63 | ![](1.gif) --------------------------------------------------------------------------------