46 |
def OnButtoncloseButton(self, event): |
def OnButtoncloseButton(self, event): |
47 |
self.Destroy() |
self.Destroy() |
48 |
event.Skip() |
event.Skip() |
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
#def load_content(self): |
54 |
|
# self.topicid = int(self.GetName()) |
55 |
|
# self.topicmeta = self.engine.getTopicById(self.topicid) |
56 |
|
# self.payload = self.engine.query_remote(self.topicmeta) |
57 |
|
|
58 |
def load_content(self): |
# if self.payload: |
|
self.topicid = int(self.GetName()) |
|
|
self.topicmeta = self.engine.getTopicById(self.topicid) |
|
|
self.payload = self.engine.query_remote(self.topicmeta) |
|
|
|
|
|
if self.payload: |
|
59 |
|
|
60 |
# 1. generate columns |
# 1. generate columns |
61 |
row0 = self.payload[0] |
# row0 = self.payload[0] |
62 |
colid = 0 |
# colid = 0 |
63 |
for column in row0.keys(): |
# for column in row0.keys(): |
64 |
self.listViewMain.InsertColumn( |
# self.listViewMain.InsertColumn( |
65 |
col=colid, |
# col=colid, |
66 |
format=wxLIST_FORMAT_LEFT, |
# format=wxLIST_FORMAT_LEFT, |
67 |
heading=column, |
# heading=column, |
68 |
width=-1 |
# width=-1 |
69 |
) |
# ) |
70 |
colid += 1 |
# colid += 1 |
71 |
|
|
72 |
# 2. fill entries |
# 2. fill entries |
73 |
itemid = 0 |
#itemid = 0 |
74 |
for entry in self.payload: |
#for entry in self.payload: |
75 |
self.listViewMain.InsertStringItem(itemid, entry.keys()[0]) |
# self.listViewMain.InsertStringItem(itemid, entry.keys()[0]) |
76 |
colid = 0 |
# colid = 0 |
77 |
columnlist = entry.keys() |
# columnlist = entry.keys() |
78 |
columnlist.pop() |
# columnlist.pop() |
79 |
for column in columnlist: |
# for column in columnlist: |
80 |
self.listViewMain.SetStringItem(itemid, colid, entry[column]) |
# self.listViewMain.SetStringItem(itemid, colid, entry[column]) |
81 |
colid += 1 |
# colid += 1 |
82 |
|
|
83 |
# set custom data |
# set custom data |
84 |
self.listViewMain.SetItemData(itemid, itemid) |
#self.listViewMain.SetItemData(itemid, itemid) |
85 |
|
|
86 |
itemid += 1 |
#itemid += 1 |
87 |
|
|
88 |
def OnListViewMainLeftDclick(self, event): |
def OnListViewMainLeftDclick(self, event): |
89 |
#event.Skip() |
#event.Skip() |
91 |
list_item = self.listViewMain.GetItem(list_selection) |
list_item = self.listViewMain.GetItem(list_selection) |
92 |
#wxMessageBox(str(item.GetData())) |
#wxMessageBox(str(item.GetData())) |
93 |
idx = list_item.GetData() |
idx = list_item.GetData() |
94 |
item = self.payload[idx] |
entries = self.payload['1'] |
95 |
|
|
96 |
|
item = entries[str(idx)] |
97 |
|
|
98 |
# create new MDI frame |
# create new MDI frame |
99 |
frame = FraggleItemFrame.create(self.parent) |
frame = FraggleItemFrame.create(self.parent) |
100 |
frame.SetName(str(idx)) |
frame.SetName(str(idx)) |
101 |
frame.SetTitle(item['keyname']) |
frame.SetTitle(str("Item No."+item['id'])) |
102 |
|
|
103 |
# calculate new position (right lower offset of 15px to us) |
# calculate new position (right lower offset of 15px to us) |
104 |
pos = self.GetPosition() + wxPoint(25, 25) |
pos = self.GetPosition() + wxPoint(25, 25) |
107 |
|
|
108 |
# patch topic metadata to point to an item instead of a list |
# patch topic metadata to point to an item instead of a list |
109 |
# use keyname as query argument |
# use keyname as query argument |
110 |
topicmeta = self.topicmeta |
#topicmeta = self.topicmeta |
111 |
topicmeta['result'] = 'item' |
#topicmeta['result'] = 'item' |
112 |
topicmeta['target']['arguments'] = item['keyname'] |
#topicmeta['target']['arguments'] = item['keyname'] |
113 |
frame.load_content(topicmeta) |
#frame.load_content(topicmeta) |