2022-06-24 09:02:09【CSDN Q & A】
Attach completed untiled.py Code
# -*- coding: utf-8 -*-# Form implementation generated from reading ui file 'untitled.ui'## Created by: PyQt5 UI code generator 5.13.0## WARNING! All changes made in this file will be lost!import osfrom PyQt5 import QtCore, QtGui, QtWidgetsimport sysfrom PyQt5.QtWidgets import QApplication, QMainWindow, QFileDialogclass Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(800, 600) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.pushButton = QtWidgets.QPushButton(self.centralwidget) self.pushButton.setGeometry(QtCore.QRect(340, 220, 93, 28)) self.pushButton.setObjectName("pushButton") self.pushButton2 = QtWidgets.QPushButton(self.centralwidget) self.pushButton2.setGeometry(QtCore.QRect(340, 250, 93, 28)) self.pushButton2.setObjectName("pushButton2") MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtWidgets.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 26)) self.menubar.setObjectName("menubar") MainWindow.setMenuBar(self.menubar) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) self.pushButton.clicked.connect(self.pbClicked) self.pushButton2.clicked.connect(self.pbClicked2) def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) self.pushButton.setText(_translate("MainWindow", "PushButton")) self.pushButton2.setText(_translate("MainWindow", "PushButton2")) def pbClicked(self): self.fileName = QFileDialog.getOpenFileNames(None, " Please select the file to add ", "E:\Program Files (x86)\PycharmProjects\nn\wangyiyun", "Text Files (*.xls);;All Files (*)") return self.fileName def pbClicked2(self): os.system('python test2.py')if __name__=='__main__': app=QApplication(sys.argv) mainWindow=QMainWindow() ui=Ui_MainWindow() # You need to change your name ui.setupUi(mainWindow) mainWindow.show() sys.exit(app.exec_())
def pbClicked(self): self.fileName = QFileDialog.getOpenFileNames(None, " Please select the file to add ", "E:\Program Files (x86)\PycharmProjects\nn\wangyiyun", "Text Files (*.xls);;All Files (*)") return self.fileName
I was thinking about this filename This variable can be passed to another py In the document , And can output
def pbClicked(self): self.fileName = QFileDialog.getOpenFileNames(None, " Please select the file to add ", "E:\Program Files (x86)\PycharmProjects\nn\wangyiyun", "Text Files (*.xls);;All Files (*)") return self.fileNamedef pbClicked2(self): os.system('python test2.py')
Just click the second button , And then run test2.py file , And then in test2.py In the file, you can get the file path returned by the first button to open the file
Here is test2.py
import Qtdesigner.untitled as tsfrom Qtdesigner.untitled import Ui_MainWindowfilename = Ui_MainWindow.pbClicked()print(filename)
But this Ui_MainWindow.pbClicked(), Report errors Parameter 'self' unfilled
author[CSDN Q & A],Please bring the original link to reprint, thank you.
The sidebar is recommended
- Learn from your experience. PHP programming, especially urgent for beginners before 1:30
- The child container changes with the height of the parent container
- Prove the correctness of Dijkstra algorithm and analyze the time complexity
- How to sort the fields of TP withattr
- Why should numbers be underlined?
- Maximum coverage problem and location problem matlab
- Is there anyone who can help to simplify the procedure? It has been completed. Make it easier to understand?
- How to solve the database connection failure of Java eclipse
- Interface related problems of Java
- When HTML accesses the parent directory, the file content cannot be displayed normally in the browser after reading
guess what you like
Page Jump and database connection of student management system
VB listview does not display children
Mockito test case
The scrapy framework only gets a set of results. I don't know why (Language Python)
After the win10 computer turns on the hotspot, the mobile phone can access the Internet, but the computer can't.
How to embed tabelau in the front page of react
Code problems in Python
No pointer, structure, linked list to write student achievement management system
Linux CentOS process text management
Vue component communication data does not update rendering
- Python automation framework
- If you change K to *p in the fiind function, there will be no output. Why
- How to create a DLL.; '
- Program error, I don't know how to change it
- After setting the exchange mailbox in outlook2021, you can send and receive emails normally, but you often pop up to log in to Microsoft
- _ What are the application scenarios in Python
- Springcloud has problems using ribbon
- Excel VBA: how to save multiple worksheets to the same workbook
- Is the pre here a global variable?
- I'd like to ask you to look at the fault and how to return to normal.
- On object injection by spring5 framework
- About creating text files in the root directory
- Yolov5-5.0/6.0 how to change the video detection frame rate?
- Matlab encountered an infinite or non numeric value
- Automatic shutdown after Tomcat startup
- C language, about the macro parameter conversion of ＃ operator, a C language exercise
- Why is this problem caused by the bubbling method written in function? It can be run without function writing
- Python writing yaml file
- Please write down the following introduction to the router configuration interface and its implementation purpose: (this question needs to describe 3 screenshots) answer:
- Go operation SQLite code error
- What is the usage of:... In testcase() of unittest? What does any mean?
- main. c: (.Text+0xee): undefined reference to 'pop' collect2: error: LD returned 1 exit status
- C language! The run page will flash out when running!! Let's have a look!
- How to solve the problem of white screen flickering? Even if the transparent background is set
- What do the exponential forms E and e here mean
- Solving integral equations with variables
- What should I do if yanzhao.com can't get the link to the school website?
- A c++ question (multi school joint examination)
- How does the structure of Android project package into app?
- How does webstorm set the bootstrap auto prompt
- Why can't Kali start the machine
- missing operate system
- Luogu p1098 solution, sample can pass
- Although object f is an object created by the parent class, it is a constant and does not use the parent class to reference the child class object. Why can the override method value of the child class be output
- Wechat applet development error: do not use empty rulesets
- About C language: if an error occurs after deleting ch=getchar() in the first for loop
- How to solve the problem of Java?
- Why the 8-core 8g win7 32 virtual machine fails to recognize 4G memory after connecting to the virtual machine?
- Uni app calling interface click login operation does not take effect on the mobile terminal
- How to solve the problem of error 5321 in the mixed programming call of C ＃ and Halcon?