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,contentkey): |
51 |
topicid = int(self.GetName()) |
self.payload = self.engine.listItems(contentkey) |
52 |
topicdata = self.engine.query_remote(topicid) |
self.columns = self.payload['2'] |
53 |
|
if self.payload: |
54 |
if topicdata: |
load3 = self.columns |
55 |
|
colid = 0 |
56 |
|
for i in load3: |
57 |
|
self.listViewMain.InsertColumn( |
58 |
|
col=colid, |
59 |
|
format=wxLIST_FORMAT_LEFT, |
60 |
|
heading=load3[i], |
61 |
|
width=-1 |
62 |
|
) |
63 |
|
colid += 1 |
64 |
|
#print self.payload |
65 |
|
|
66 |
|
entries = self.payload['1'] |
67 |
|
|
|
# 1. generate columns |
|
|
row0 = topicdata[0] |
|
|
colid = 0 |
|
|
for column in row0.keys(): |
|
|
self.listViewMain.InsertColumn( |
|
|
col=colid, |
|
|
format=wxLIST_FORMAT_LEFT, |
|
|
heading=column, |
|
|
width=-1 |
|
|
) |
|
|
colid += 1 |
|
|
|
|
|
# 2. fill entries |
|
68 |
itemid = 0 |
itemid = 0 |
69 |
for entry in topicdata: |
|
70 |
self.listViewMain.InsertStringItem(itemid, entry.keys()[0]) |
columnlist = self.columns |
71 |
|
|
72 |
|
for entry in entries: |
73 |
colid = 0 |
colid = 0 |
74 |
columnlist = entry.keys() |
#print columnlist |
75 |
columnlist.pop() |
#columnlist.pop() |
76 |
for column in columnlist: |
for column in columnlist: |
77 |
#print column |
if column == '1' and entries[entry][column] == '1': |
78 |
#item = wxListItem() |
self.listViewMain.InsertStringItem(itemid, 'English') |
79 |
#item.SetText(entry[column]) |
elif column == '1' and entries[entry][column] == '2': |
80 |
#item.SetId(itemid) |
self.listViewMain.InsertStringItem(itemid, 'Deutsch') |
81 |
#item.SetColumn(colid) |
#print entries[entry][column] |
82 |
|
#print "column: "+column |
83 |
#item.se |
if column != '1': |
84 |
#self.listViewTopics.SetItem(item) |
self.listViewMain.SetStringItem(itemid, colid, entries[entry][column]) |
85 |
#self.listViewTopics.InsertItem(item) |
print "colid: "+str(colid) |
|
self.listViewMain.SetStringItem(itemid, colid, entry[column]) |
|
86 |
colid += 1 |
colid += 1 |
87 |
|
|
88 |
|
#set custom data |
89 |
|
self.listViewMain.SetItemData(itemid, itemid) |
90 |
itemid += 1 |
itemid += 1 |
91 |
|
|
92 |
|
|
93 |
|
#def load_content(self): |
94 |
|
# self.topicid = int(self.GetName()) |
95 |
|
# self.topicmeta = self.engine.getTopicById(self.topicid) |
96 |
|
# self.payload = self.engine.query_remote(self.topicmeta) |
97 |
|
|
98 |
|
# if self.payload: |
99 |
|
|
100 |
|
# 1. generate columns |
101 |
|
# row0 = self.payload[0] |
102 |
|
# colid = 0 |
103 |
|
# for column in row0.keys(): |
104 |
|
# self.listViewMain.InsertColumn( |
105 |
|
# col=colid, |
106 |
|
# format=wxLIST_FORMAT_LEFT, |
107 |
|
# heading=column, |
108 |
|
# width=-1 |
109 |
|
# ) |
110 |
|
# colid += 1 |
111 |
|
|
112 |
|
# 2. fill entries |
113 |
|
#itemid = 0 |
114 |
|
#for entry in self.payload: |
115 |
|
# self.listViewMain.InsertStringItem(itemid, entry.keys()[0]) |
116 |
|
# colid = 0 |
117 |
|
# columnlist = entry.keys() |
118 |
|
# columnlist.pop() |
119 |
|
# for column in columnlist: |
120 |
|
# self.listViewMain.SetStringItem(itemid, colid, entry[column]) |
121 |
|
# colid += 1 |
122 |
|
|
123 |
|
# set custom data |
124 |
|
#self.listViewMain.SetItemData(itemid, itemid) |
125 |
|
|
126 |
|
#itemid += 1 |
127 |
|
|
128 |
|
def OnListViewMainLeftDclick(self, event): |
129 |
|
#event.Skip() |
130 |
|
list_selection = self.listViewMain.GetFocusedItem() |
131 |
|
list_item = self.listViewMain.GetItem(list_selection) |
132 |
|
#wxMessageBox(str(item.GetData())) |
133 |
|
idx = list_item.GetData() |
134 |
|
item = self.payload[idx] |
135 |
|
|
136 |
|
# create new MDI frame |
137 |
|
frame = FraggleItemFrame.create(self.parent) |
138 |
|
frame.SetName(str(idx)) |
139 |
|
frame.SetTitle(item['keyname']) |
140 |
|
|
141 |
|
# calculate new position (right lower offset of 15px to us) |
142 |
|
pos = self.GetPosition() + wxPoint(25, 25) |
143 |
|
frame.Move(pos) |
144 |
|
self.parent.Fit() |
145 |
|
|
146 |
|
# patch topic metadata to point to an item instead of a list |
147 |
|
# use keyname as query argument |
148 |
|
topicmeta = self.topicmeta |
149 |
|
topicmeta['result'] = 'item' |
150 |
|
topicmeta['target']['arguments'] = item['keyname'] |
151 |
|
frame.load_content(topicmeta) |