-
Notifications
You must be signed in to change notification settings - Fork 219
/
01-QFileDialog-静态方法-弹出文件操作对话框.py
38 lines (30 loc) · 1.26 KB
/
01-QFileDialog-静态方法-弹出文件操作对话框.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import sys
from PyQt5.Qt import *
class Window(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle("QFileDialog")
self.resize(500, 500)
self.move(400, 250)
self.setup_ui()
def setup_ui(self):
# result = QFileDialog.getOpenFileName(self, "选择一个py文件", "../",
# "ALL(*, *);;Images(*.png *.jpg);;Python文件(*.py)",
# "Python文件(*.py)")
# result = QFileDialog.getOpenFileNames(self, "选择一个py文件", "../",
# "ALL(*, *);;Images(*.png *.jpg);;Python文件(*.py)",
# "Python文件(*.py)")
# result = QFileDialog.getOpenFileUrl(self, '选择一个py文件', '../', '所有文件(*.*);;Python文件(*.py);;图片(*.png *.jpg)')
result = QFileDialog.getSaveFileName(
self,
"保存为py文件",
"../",
"ALL(*, *);;Images(*.png *.jpg);;Python文件(*.py)",
"Python文件(*.py)",
)
print(result)
if __name__ == "__main__":
app = QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec_())