12 |
|
|
13 |
import view |
import view |
14 |
from dialogs import NonModalDialog |
from dialogs import NonModalDialog |
15 |
|
from controls import RecordListCtrl |
16 |
from messages import SELECTED_SHAPE |
from messages import SELECTED_SHAPE |
17 |
|
|
18 |
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() |
|
|
|
|
|
if shape is not None: |
|
|
table = layer.shapetable |
|
|
num_cols = table.field_count() |
|
|
num_rows = table.record_count() |
|
|
|
|
|
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)) |
|
19 |
|
|
20 |
def selected_shape(self, layer, shape): |
def selected_shape(self, layer, shape): |
21 |
self.fill_list(layer, shape) |
self.fill_list(layer.shapetable, shape) |
|
|
|
22 |
|
|
23 |
|
|
24 |
class IdentifyView(NonModalDialog): |
class IdentifyView(NonModalDialog): |