-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcoord_dialog.py
60 lines (52 loc) · 1.82 KB
/
coord_dialog.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
# -*- coding: utf-8 -*-
"""
.. module:: coord_dialog
:platform: Linux, Windows
:synopsis: GUI for area division
.. moduleauthor: Zoltan Siki <[email protected]>
"""
from PyQt4.QtGui import QDialog, QMessageBox
from coords import Ui_CoordDialog
from base_classes import tr
class CoordDialog(QDialog):
""" Class for coords of division line dialog
"""
def __init__(self, point1, point2):
""" Initialize dialog data and event handlers
:param log: log instance for log messages
"""
super(CoordDialog, self).__init__()
self.point1 = point1
self.point2 = point2
self.ui = Ui_CoordDialog()
self.ui.setupUi(self)
self.ui.CancelButton.clicked.connect(self.onCancelButton)
self.ui.ContinueButton.clicked.connect(self.onContinueButton)
def showEvent(self, event):
""" Set up initial state of dialog widgets
:param event: NOT USED
"""
self.reset()
def reset(self):
""" Reset dialog to initial state
"""
self.ui.StartEast.setText('{0:.2f}'.format(self.point1.x()))
self.ui.StartNorth.setText('{0:.2f}'.format(self.point1.y()))
self.ui.EndEast.setText('{0:.2f}'.format(self.point2.x()))
self.ui.EndNorth.setText('{0:.2f}'.format(self.point2.y()))
def onContinueButton(self):
""" Check input and accept dialog
"""
try:
w = float(self.ui.StartEast.text())
w = float(self.ui.StartNorth.text())
w = float(self.ui.EndEast.text())
w = float(self.ui.EndNorth.text())
except ValueError:
QMessageBox.warning(self, tr("Warning"), tr("Invalid coordinate value"))
return
self.accept()
def onCancelButton(self):
""" Reject dialog
"""
self.reject()