2 |
|
|
3 |
from wxPython.wx import * |
from wxPython.wx import * |
4 |
from wxPython.stc import * |
from wxPython.stc import * |
5 |
|
import FraggleItemFrame |
6 |
|
|
7 |
def create(parent): |
def create(parent): |
8 |
return FraggleListFrame(parent) |
return FraggleListFrame(parent) |
33 |
self.listViewMain = wxListView(id=wxID_FRAGGLELISTFRAMELISTVIEWMAIN, |
self.listViewMain = wxListView(id=wxID_FRAGGLELISTFRAMELISTVIEWMAIN, |
34 |
name=u'listViewMain', parent=self.panel1, pos=wxPoint(8, 40), |
name=u'listViewMain', parent=self.panel1, pos=wxPoint(8, 40), |
35 |
size=wxSize(376, 168), style=wxLC_REPORT) |
size=wxSize(376, 168), style=wxLC_REPORT) |
36 |
|
EVT_LEFT_DCLICK(self.listViewMain, self.OnListViewMainLeftDclick) |
37 |
|
|
38 |
def __init__(self, parent): |
def __init__(self, parent): |
39 |
|
self.parent = parent |
40 |
self._init_ctrls(parent) |
self._init_ctrls(parent) |
41 |
# get engine-instance (singleton) |
# get engine-instance (singleton) |
42 |
import __main__ |
import __main__ |
48 |
event.Skip() |
event.Skip() |
49 |
|
|
50 |
def load_content(self): |
def load_content(self): |
51 |
topicid = int(self.GetName()) |
self.topicid = int(self.GetName()) |
52 |
topicdata = self.engine.query_remote(topicid) |
self.topicmeta = self.engine.getTopicById(self.topicid) |
53 |
|
self.payload = self.engine.query_remote(self.topicmeta) |
54 |
|
|
55 |
if topicdata: |
if self.payload: |
56 |
|
|
57 |
# 1. generate columns |
# 1. generate columns |
58 |
row0 = topicdata[0] |
row0 = self.payload[0] |
59 |
colid = 0 |
colid = 0 |
60 |
for column in row0.keys(): |
for column in row0.keys(): |
61 |
self.listViewMain.InsertColumn( |
self.listViewMain.InsertColumn( |
68 |
|
|
69 |
# 2. fill entries |
# 2. fill entries |
70 |
itemid = 0 |
itemid = 0 |
71 |
for entry in topicdata: |
for entry in self.payload: |
72 |
self.listViewMain.InsertStringItem(itemid, entry.keys()[0]) |
self.listViewMain.InsertStringItem(itemid, entry.keys()[0]) |
73 |
colid = 0 |
colid = 0 |
74 |
columnlist = entry.keys() |
columnlist = entry.keys() |
75 |
columnlist.pop() |
columnlist.pop() |
76 |
for column in columnlist: |
for column in columnlist: |
|
#print column |
|
|
#item = wxListItem() |
|
|
#item.SetText(entry[column]) |
|
|
#item.SetId(itemid) |
|
|
#item.SetColumn(colid) |
|
|
|
|
|
#item.se |
|
|
#self.listViewTopics.SetItem(item) |
|
|
#self.listViewTopics.InsertItem(item) |
|
77 |
self.listViewMain.SetStringItem(itemid, colid, entry[column]) |
self.listViewMain.SetStringItem(itemid, colid, entry[column]) |
78 |
colid += 1 |
colid += 1 |
|
itemid += 1 |
|
79 |
|
|
80 |
|
# set custom data |
81 |
|
self.listViewMain.SetItemData(itemid, itemid) |
82 |
|
|
83 |
|
itemid += 1 |
84 |
|
|
85 |
|
def OnListViewMainLeftDclick(self, event): |
86 |
|
#event.Skip() |
87 |
|
list_selection = self.listViewMain.GetFocusedItem() |
88 |
|
list_item = self.listViewMain.GetItem(list_selection) |
89 |
|
#wxMessageBox(str(item.GetData())) |
90 |
|
idx = list_item.GetData() |
91 |
|
item = self.payload[idx] |
92 |
|
|
93 |
|
# create new MDI frame |
94 |
|
frame = FraggleItemFrame.create(self.parent) |
95 |
|
frame.SetName(str(idx)) |
96 |
|
frame.SetTitle(item['keyname']) |
97 |
|
|
98 |
|
# calculate new position (right lower offset of 15px to us) |
99 |
|
pos = self.GetPosition() + wxPoint(25, 25) |
100 |
|
frame.Move(pos) |
101 |
|
self.parent.Fit() |
102 |
|
|
103 |
|
# patch topic metadata to point to an item instead of a list |
104 |
|
# use keyname as query argument |
105 |
|
topicmeta = self.topicmeta |
106 |
|
topicmeta['result'] = 'item' |
107 |
|
topicmeta['target']['arguments'] = item['keyname'] |
108 |
|
frame.load_content(topicmeta) |