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