2023/1/5 update-窗口5

这个链接-槽好抽象,明天再研究了
This commit is contained in:
bgArray 2023-01-05 23:02:15 +08:00
parent 082934d918
commit ab3c55e7b7
3 changed files with 255 additions and 0 deletions

153
mid_analyse.py Normal file
View File

@ -0,0 +1,153 @@
# -*- coding: utf-8 -*-
##########################################################################
# Form generated from reading UI file 'mid_analyse.ui'
##
# Created by: Qt User Interface Compiler version 6.4.1
##
# WARNING! All changes made in this file will be lost when recompiling UI file!
##########################################################################
# from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
# QMetaObject, QObject, QPoint, QRect,
# QSize, QTime, QUrl, Qt)
# from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
# QFont, QFontDatabase, QGradient, QIcon,
# QImage, QKeySequence, QLinearGradient, QPainter,
# QPalette, QPixmap, QRadialGradient, QTransform)
# from PySide6.QtWidgets import (QApplication, QGroupBox, QHBoxLayout, QLabel,
# QLineEdit, QPushButton, QSizePolicy, QWidget)
import sys
from PySide6.QtWidgets import QApplication, QWidget, QGroupBox, QPushButton, \
QLabel, QLineEdit, QHBoxLayout, QFileDialog
from PySide6.QtCore import QRect, QMetaObject, Slot
class Ui_Form(QWidget):
def __init__(self):
super().__init__()
self.groupBox = None
self.horizontalLayout = None
self.horizontalLayoutWidget = None
self.close_button = None
self.fileChoseButton = None
self.input_button = None
self.note_count_label = None
self.note_count_shower = None
self.output_button = None
def setupUi(self, Form):
if not Form.objectName():
Form.setObjectName(u"Form")
Form.resize(582, 355)
self.groupBox = QGroupBox(Form)
self.groupBox.setObjectName(u"groupBox")
self.groupBox.setGeometry(QRect(10, 0, 561, 311))
self.fileChoseButton = QPushButton(self.groupBox)
self.fileChoseButton.setObjectName(u"file_chose_button")
self.fileChoseButton.setGeometry(QRect(10, 20, 75, 24))
self.note_count_label = QLabel(self.groupBox)
self.note_count_label.setObjectName(u"note_count_label")
self.note_count_label.setGeometry(QRect(20, 50, 54, 16))
self.note_count_shower = QLineEdit(self.groupBox)
self.note_count_shower.setObjectName(u"note_count_shower")
self.note_count_shower.setGeometry(QRect(70, 50, 113, 20))
self.horizontalLayoutWidget = QWidget(Form)
self.horizontalLayoutWidget.setObjectName(u"horizontalLayoutWidget")
self.horizontalLayoutWidget.setGeometry(QRect(10, 310, 561, 41))
self.horizontalLayout = QHBoxLayout(self.horizontalLayoutWidget)
self.horizontalLayout.setObjectName(u"horizontalLayout")
self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
self.input_button = QPushButton(self.horizontalLayoutWidget)
self.input_button.setObjectName(u"input_button")
self.horizontalLayout.addWidget(self.input_button)
self.output_button = QPushButton(self.horizontalLayoutWidget)
self.output_button.setObjectName(u"output_button")
self.horizontalLayout.addWidget(self.output_button)
self.close_button = QPushButton(self.horizontalLayoutWidget)
self.close_button.setObjectName(u"close_button")
self.horizontalLayout.addWidget(self.close_button)
Form.setWindowTitle("Mid解析器")
self.groupBox.setTitle("mid信息")
self.fileChoseButton.setText("选择文件")
self.note_count_label.setText("音符数")
self.input_button.setText("导入")
self.output_button.setText("导出分析")
self.close_button.setText("关闭")
QMetaObject.connectSlotsByName(Form)
# self.ui.btnCalculate.clicked.connect(self.fileLoading)
def fileLoading(self):
filePath, _ = QFileDialog.getOpenFileName(
self.groupBox, # 父窗口对象
"选择文件", # 标题
r"./", # 起始目录
"mid类型 (*.mid *.midi)" # 选择类型过滤项,过滤内容在括号中
)
print(filePath)
@Slot()
def on_fileChoseButton_clicked(self):
filePath, _ = QFileDialog.getOpenFileName(
self.groupBox, # 父窗口对象
"选择文件", # 标题
r"./", # 起始目录
"mid类型 (*.mid *.midi)" # 选择类型过滤项,过滤内容在括号中
)
print(filePath)
class MidAnalyseGui(QWidget):
def __init__(self, parent=None):
super().__init__(parent)
self.ui = Ui_Form()
self.ui.setupUi(self)
self.ui.fileChoseButton.clicked.connect(self.fileLoading)
def fileLoading(self):
filePath, _ = QFileDialog.getOpenFileName(
self.ui.groupBox, # 父窗口对象
"选择文件", # 标题
r"./", # 起始目录
"mid类型 (*.mid *.midi)" # 选择类型过滤项,过滤内容在括号中
)
print(filePath)
@Slot()
def on_fileChoseButton_clicked(self):
filePath, _ = QFileDialog.getOpenFileName(
self.ui.groupBox, # 父窗口对象
"选择文件", # 标题
r"./", # 起始目录
"mid类型 (*.mid *.midi)" # 选择类型过滤项,过滤内容在括号中
)
print(filePath)
if __name__ == "__main__":
app = QApplication(sys.argv) # 创建一个QApplication也就是你要开发的软件app
# MainWindow = QMainWindow() # 创建一个QMainWindow用来装载你需要的各种组件、控件
# MainWindow = QWidget() # 创建一个QMainWindow用来装载你需要的各种组件、控件
ui = MidAnalyseGui() # ui是你创建的ui类的实例化对象
# ui.setupUi(MainWindow) # 执行类中的setupUi方法方法的参数是第二步中创建的QMainWindow
ui.show() # 执行QMainWindow的show()方法显示这个QMainWindow
sys.exit(app.exec()) # 使用exit()或者点击关闭按钮退出QApplication
if __name__ == '__main__':
app = QApplication(sys.argv)
MainWindow = QWidget()
ui = Ui_Form()
ui.setupUi(MainWindow)
ui.show()
sys.exit(app.exec())

101
mid_analyse.ui Normal file
View File

@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>582</width>
<height>355</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>10</x>
<y>0</y>
<width>561</width>
<height>311</height>
</rect>
</property>
<property name="title">
<string>mid信息</string>
</property>
<widget class="QPushButton" name="file_chose_button">
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>75</width>
<height>24</height>
</rect>
</property>
<property name="text">
<string>选择文件</string>
</property>
</widget>
<widget class="QLabel" name="note_count_label">
<property name="geometry">
<rect>
<x>20</x>
<y>50</y>
<width>54</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>音符数</string>
</property>
</widget>
<widget class="QLineEdit" name="note_count_shower">
<property name="geometry">
<rect>
<x>70</x>
<y>50</y>
<width>113</width>
<height>20</height>
</rect>
</property>
</widget>
</widget>
<widget class="QWidget" name="horizontalLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>310</y>
<width>561</width>
<height>41</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="input_button">
<property name="text">
<string>导入</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="output_button">
<property name="text">
<string>导出分析</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="close_button">
<property name="text">
<string>关闭</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>

1
trans_mid_analyse.bat Normal file
View File

@ -0,0 +1 @@
pyside6-uic mid_analyse.ui -o mid_analyse.py