如题所示 PyQt5.QtWidgets打包的py文件如何运行(窗口类型-Dialog)
ui文件:
"1.0" encoding="UTF-8"?>
"4.0">
<class>Dialogclass>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0x>
<y>0y>
<width>400width>
<height>130height>
rect>
property>
<property name="windowTitle">
<string>Dialogstring>
property>
<layout class="QGridLayout" name="gridLayout">
<item row="4" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontalenum>
property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Okset>
property>
widget>
item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBox">
<item>
<property name="text">
<string>文件名查找string>
property>
item>
<item>
<property name="text">
<string>文件内容查找string>
property>
item>
widget>
item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>请选择文件查找模式string>
property>
<property name="buddy">
<cstring>comboBoxcstring>
property>
widget>
item>
layout>
widget>
<resources/>
<connections>
<connection>
<sender>buttonBoxsender>
<signal>accepted()signal>
<receiver>Dialogreceiver>
<slot>accept()slot>
<hints>
<hint type="sourcelabel">
<x>248x>
<y>254y>
hint>
<hint type="destinationlabel">
<x>157x>
<y>274y>
hint>
hints>
connection>
<connection>
<sender>buttonBoxsender>
<signal>rejected()signal>
<receiver>Dialogreceiver>
<slot>reject()slot>
<hints>
<hint type="sourcelabel">
<x>316x>
<y>260y>
hint>
<hint type="destinationlabel">
<x>286x>
<y>274y>
hint>
hints>
connection>
connections>
ui>
py文件:(做过修改,已经尽量恢复)
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'D:\Desktop\untitled.ui'
#
# Created by: PyQt5 UI code generator 5.15.4
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
import sys
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QMainWindow, QWidget, QApplication
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(400, 130)
self.gridLayout = QtWidgets.QGridLayout(Dialog)
self.gridLayout.setObjectName("gridLayout")
self.buttonBox = QtWidgets.QDialogButtonBox(Dialog)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
self.buttonBox.setObjectName("buttonBox")
self.gridLayout.addWidget(self.buttonBox, 4, 0, 1, 2)
self.comboBox = QtWidgets.QComboBox(Dialog)
self.comboBox.setObjectName("comboBox")
self.comboBox.addItem("")
self.comboBox.addItem("")
self.gridLayout.addWidget(self.comboBox, 0, 1, 1, 1)
self.label = QtWidgets.QLabel(Dialog)
self.label.setObjectName("label")
self.gridLayout.addWidget(self.label, 0, 0, 1, 1)
self.label.setBuddy(self.comboBox)
self.retranslateUi(Dialog)
self.buttonBox.accepted.connect(Dialog.accept)
self.buttonBox.rejected.connect(Dialog.reject)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.comboBox.setItemText(0, _translate("Dialog", "文件名查找"))
self.comboBox.setItemText(1, _translate("Dialog", "文件内容查找"))
self.label.setText(_translate("Dialog", "请选择文件查找模式"))
总结:
窗口类型为Dialog的ui文件转换的py文件如何运行
找个QT例子学学