-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
40 lines (29 loc) · 1.12 KB
/
Copy pathmain.py
File metadata and controls
40 lines (29 loc) · 1.12 KB
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
from PyQt5.QtCore import Qt, pyqtSlot
from PyQt5.QtWidgets import QApplication, QMainWindow, QGridLayout, QWidget, QPushButton, QFileDialog
from PyQt5.QtWidgets import QGraphicsView
import sys
class MainWindow(QMainWindow):
def __init__(self, *args, **kwargs):
super(MainWindow, self).__init__(*args, **kwargs)
self.setWindowTitle("MapViewer")
self.fdir_ = ''
layout = QGridLayout()
openButton = QPushButton()
openButton.setText("Open File")
openButton.clicked.connect(self.on_click)
layout.addWidget(openButton, 0, 0,)
graphicsView = QGraphicsView()
graphicsView.setAlignment(Qt.AlignCenter)
graphicsView.setFixedSize(1200, 800)
layout.addWidget(graphicsView, 1, 0, 1, 8)
widget = QWidget()
widget.setLayout(layout)
self.setCentralWidget(widget)
@pyqtSlot()
def on_click(self):
self.fdir_ = QFileDialog.getExistingDirectory(None, 'Select a folder:', 'C:\\', QFileDialog.ShowDirsOnly)
print(bool(self.fdir_))
app = QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec_()