1 |
#Boa:MDIChild:FraggleListFrame |
2 |
|
3 |
from wxPython.wx import * |
4 |
from wxPython.stc import * |
5 |
|
6 |
def create(parent): |
7 |
return FraggleListFrame(parent) |
8 |
|
9 |
[wxID_FRAGGLELISTFRAME, wxID_FRAGGLELISTFRAMEBUTTONCLOSE, |
10 |
wxID_FRAGGLELISTFRAMELISTVIEWMAIN, wxID_FRAGGLELISTFRAMEPANEL1, |
11 |
] = map(lambda _init_ctrls: wxNewId(), range(4)) |
12 |
|
13 |
class FraggleListFrame(wxMDIChildFrame): |
14 |
def _init_ctrls(self, prnt): |
15 |
# generated method, don't edit |
16 |
wxMDIChildFrame.__init__(self, id=wxID_FRAGGLELISTFRAME, name='', |
17 |
parent=prnt, pos=wxPoint(356, 363), size=wxSize(397, 240), |
18 |
style=wxDEFAULT_FRAME_STYLE, title='Topic details') |
19 |
self.SetClientSize(wxSize(389, 213)) |
20 |
|
21 |
self.panel1 = wxPanel(id=wxID_FRAGGLELISTFRAMEPANEL1, name='panel1', |
22 |
parent=self, pos=wxPoint(0, 0), size=wxSize(389, 213), |
23 |
style=wxTAB_TRAVERSAL) |
24 |
|
25 |
self.buttonClose = wxButton(id=wxID_FRAGGLELISTFRAMEBUTTONCLOSE, |
26 |
label='X', name='buttonClose', parent=self.panel1, pos=wxPoint(8, |
27 |
8), size=wxSize(16, 16), style=0) |
28 |
self.buttonClose.SetAutoLayout(True) |
29 |
EVT_BUTTON(self.buttonClose, wxID_FRAGGLELISTFRAMEBUTTONCLOSE, |
30 |
self.OnButtoncloseButton) |
31 |
|
32 |
self.listViewMain = wxListView(id=wxID_FRAGGLELISTFRAMELISTVIEWMAIN, |
33 |
name=u'listViewMain', parent=self.panel1, pos=wxPoint(8, 40), |
34 |
size=wxSize(376, 168), style=wxLC_REPORT) |
35 |
|
36 |
def __init__(self, parent): |
37 |
self._init_ctrls(parent) |
38 |
# get engine-instance (singleton) |
39 |
import __main__ |
40 |
self.engine = __main__.engine |
41 |
#self.load_content() |
42 |
|
43 |
def OnButtoncloseButton(self, event): |
44 |
self.Destroy() |
45 |
event.Skip() |
46 |
|
47 |
def load_content(self): |
48 |
topicid = int(self.GetName()) |
49 |
topicdata = self.engine.query_remote(topicid) |
50 |
|
51 |
if topicdata: |
52 |
|
53 |
# 1. generate columns |
54 |
row0 = topicdata[0] |
55 |
colid = 0 |
56 |
for column in row0.keys(): |
57 |
self.listViewMain.InsertColumn( |
58 |
col=colid, |
59 |
format=wxLIST_FORMAT_LEFT, |
60 |
heading=column, |
61 |
width=-1 |
62 |
) |
63 |
colid += 1 |
64 |
|
65 |
# 2. fill entries |
66 |
itemid = 0 |
67 |
for entry in topicdata: |
68 |
self.listViewMain.InsertStringItem(itemid, entry.keys()[0]) |
69 |
colid = 0 |
70 |
columnlist = entry.keys() |
71 |
columnlist.pop() |
72 |
for column in columnlist: |
73 |
#print column |
74 |
#item = wxListItem() |
75 |
#item.SetText(entry[column]) |
76 |
#item.SetId(itemid) |
77 |
#item.SetColumn(colid) |
78 |
|
79 |
#item.se |
80 |
#self.listViewTopics.SetItem(item) |
81 |
#self.listViewTopics.InsertItem(item) |
82 |
self.listViewMain.SetStringItem(itemid, colid, entry[column]) |
83 |
colid += 1 |
84 |
itemid += 1 |
85 |
|