-
Notifications
You must be signed in to change notification settings - Fork 0
/
gui.py
61 lines (43 loc) · 1.48 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import maps
class MainWindow(QWidget):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
superlayout = QHBoxLayout()
layout = QFormLayout()
self.label = QLabel()
pixmap = QPixmap('image\\mainmap-resized.png')
self.label.setPixmap(pixmap)
superlayout.addWidget(self.label)
superlayout.addStretch()
self.s_cb = QComboBox()
self.t_cb = QComboBox()
self.btn = QPushButton("시작")
self.route = QLabel()
bldlist = sorted(list(maps.building_number.keys()))
self.s_cb.addItems(bldlist)
self.t_cb.addItems(bldlist)
self.btn.clicked.connect(self.navigate)
layout.addRow("출발", self.s_cb)
layout.addRow("도착", self.t_cb)
layout.addRow(self.btn)
layout.addRow(self.route)
superlayout.addLayout(layout)
self.setLayout(superlayout)
self.setWindowTitle("Hanyang University Navigator")
def navigate(self):
src = maps.building_number[self.s_cb.currentText()]
tgt = maps.building_number[self.t_cb.currentText()]
rtn = maps.path_search(src, tgt)
for i in range(len(rtn)): rtn[i] = str(rtn[i])
way = " > ".join(rtn)
self.route.setText(way)
def main():
app = QApplication(sys.argv)
ex = MainWindow()
ex.show()
sys.exit(app.exec_())
if __name__=='__main__':
main()