forked from moluwole/face
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gui.py
44 lines (32 loc) · 1.06 KB
/
gui.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
39
40
41
42
43
44
import sys
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
class MyDialog(QWidget):
def __init__(self, parent=None):
super(MyDialog, self).__init__(parent)
layout = QVBoxLayout()
self.btn = QPushButton("QFileDialog static method demo")
self.btn.clicked.connect(self.getfile)
layout.addWidget(self.btn)
self.le = QLabel("Hello")
# # layout.addWidget(self.le)
# # self.btn1 = QPushButton("QFileDialog object")
# # self.btn1.clicked.connect(self.getfiles)
# # layout.addWidget(self.btn1)
#
# self.contents = QTextEdit()
# layout.addWidget(self.contents)
self.setLayout(layout)
self.setWindowTitle("File Dialog demo")
def getfile(self):
fname = QFileDialog.getOpenFileName(self, 'Open file')
filename = fname[0]
print filename
self.le.setPixmap(QPixmap(filename))
def main():
app = QApplication(sys.argv)
ex = MyDialog()
ex.show()
sys.exit(app.exec_())
if __name__ == '__main__':
main()