-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDialogs.py
More file actions
executable file
·55 lines (51 loc) · 2.52 KB
/
Dialogs.py
File metadata and controls
executable file
·55 lines (51 loc) · 2.52 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from Tkinter import *
import Tkinter
import tkMessageBox
# dialog to select one layer
class LayerDialog:
def __init__(self, root, layers):
self.top = Tkinter.Toplevel(root)
self.layers = layers
self.var = IntVar()
i = 0
for layer in self.layers:
Radiobutton(self.top, text=layer.getFileName(), variable=self.var, value=i).pack(anchor=W)
i+=1
button = Tkinter.Button(self.top, text='Ok', command=self.Ok)
button.pack()
self.ok = False
self.selectLayer = None
def Ok(self):
# destroy the diallog and set ok to True if click button ok
self.top.destroy()
self.ok = True
def get(self):
return self.layers[self.var.get()]
# dialog to select two polyline layers
class PolylineLayerDialog:
def __init__(self, root, layers):
self.top = Tkinter.Toplevel(root)
# polyline layers list in the dialog
self.polylineLayers = []
# layers selected
self.selectedPolylineLayers = []
# each checkbutton has a IntVar
self.vs = []
for layer in layers:
if layer.shapeType == 3:
v = IntVar()
self.polylineLayers.append(layer)
Checkbutton(self.top, text=layer.getFileName(), variable=v).pack(anchor=W)
self.vs.append(v)
button = Tkinter.Button(self.top, text='Ok', command=self.Ok)
button.pack()
self.ok = False
def Ok(self):
self.top.destroy()
self.ok = True
for i in range(len(self.vs)):
if self.vs[i].get():
print self.polylineLayers[i].getFileName()
self.selectedPolylineLayers.append(self.polylineLayers[i])
def get(self):
return self.selectedPolylineLayers