1 |
# Copyright (c) 2001 by Intevation GmbH |
# Copyright (c) 2001, 2002 by Intevation GmbH |
2 |
# Authors: |
# Authors: |
3 |
# Bernhard Herzog <[email protected]> |
# Bernhard Herzog <[email protected]> |
4 |
# |
# |
10 |
from wxPython.wx import * |
from wxPython.wx import * |
11 |
from wxPython.grid import * |
from wxPython.grid import * |
12 |
|
|
13 |
|
from Thuban import _ |
14 |
|
|
15 |
import view |
import view |
16 |
from dialogs import NonModalDialog |
from dialogs import NonModalDialog |
17 |
|
from controls import RecordListCtrl, RecordGridCtrl |
18 |
from messages import SELECTED_SHAPE |
from messages import SELECTED_SHAPE |
19 |
|
|
20 |
class IdentifyListCtrl(wxListCtrl): |
class IdentifyListCtrl(RecordListCtrl): |
|
|
|
|
def __init__(self, parent, id): |
|
|
wxListCtrl.__init__(self, parent, id, style = wxLC_REPORT) |
|
|
|
|
|
self.InsertColumn(0, "Field") |
|
|
self.SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER) |
|
|
self.InsertColumn(1, "Value") |
|
|
self.SetColumnWidth(1, wxLIST_AUTOSIZE_USEHEADER) |
|
|
|
|
|
def fill_list(self, layer, shape): |
|
|
self.DeleteAllItems() |
|
21 |
|
|
22 |
if shape is not None: |
def selected_shape(self, layer, shape): |
23 |
|
if layer is not None: |
24 |
table = layer.shapetable |
table = layer.shapetable |
25 |
num_cols = table.field_count() |
else: |
26 |
num_rows = table.record_count() |
table = None |
27 |
|
self.fill_list(table, shape) |
|
names = [] |
|
|
for i in range(num_cols): |
|
|
type, name, length, decc = table.field_info(i) |
|
|
names.append(name) |
|
|
record = table.read_record(shape) |
|
|
i = 0 |
|
|
for name in names: |
|
|
value = record[name] |
|
|
i = self.InsertStringItem(i, name) |
|
|
self.SetStringItem(i, 1, str(value)) |
|
28 |
|
|
29 |
def selected_shape(self, layer, shape): |
class IdentifyGridCtrl(RecordGridCtrl): |
|
self.fill_list(layer, shape) |
|
|
|
|
30 |
|
|
31 |
|
def selected_shape(self, layer, shape): |
32 |
|
if layer is not None: |
33 |
|
table = layer.shapetable |
34 |
|
else: |
35 |
|
table = None |
36 |
|
self.SetTableRecord(table, shape) |
37 |
|
|
38 |
class IdentifyView(NonModalDialog): |
class IdentifyView(NonModalDialog): |
39 |
|
|
40 |
def __init__(self, parent, interactor, name): |
def __init__(self, parent, interactor, name): |
41 |
NonModalDialog.__init__(self, parent, interactor, name, |
NonModalDialog.__init__(self, parent, interactor, name, |
42 |
"Identify Shape") |
_("Identify Shape")) |
43 |
self.interactor.Subscribe(SELECTED_SHAPE, self.selected_shape) |
self.interactor.Subscribe(SELECTED_SHAPE, self.selected_shape) |
44 |
|
|
45 |
panel = wxPanel(self, -1, style = wxWANTS_CHARS) |
panel = wxPanel(self, -1, style = wxWANTS_CHARS) |
46 |
self.list = IdentifyListCtrl(panel, -1) |
#self.list = IdentifyListCtrl(panel, -1) |
47 |
|
self.list = IdentifyGridCtrl(panel) |
48 |
|
|
49 |
sizer = wxBoxSizer(wxVERTICAL) |
sizer = wxBoxSizer(wxVERTICAL) |
50 |
sizer.Add(self.list, 1, wx.wxEXPAND| wx.wxALL, 0) |
sizer.Add(self.list, 1, wx.wxEXPAND| wx.wxALL, 0) |