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 |
|
|
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: |
|
topicid = int(self.GetName()) |
|
|
topicdata = self.engine.query_remote(topicid) |
|
|
|
|
|
if topicdata: |
|
59 |
|
|
60 |
# 1. generate columns |
# 1. generate columns |
61 |
row0 = topicdata[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 topicdata: |
#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 |
#print column |
# self.listViewMain.SetStringItem(itemid, colid, entry[column]) |
81 |
#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 |
|
82 |
|
|
83 |
|
# set custom data |
84 |
|
#self.listViewMain.SetItemData(itemid, itemid) |
85 |
|
|
86 |
|
#itemid += 1 |
87 |
|
|
88 |
|
def OnListViewMainLeftDclick(self, event): |
89 |
|
#event.Skip() |
90 |
|
list_selection = self.listViewMain.GetFocusedItem() |
91 |
|
list_item = self.listViewMain.GetItem(list_selection) |
92 |
|
#wxMessageBox(str(item.GetData())) |
93 |
|
idx = list_item.GetData() |
94 |
|
entries = self.payload['1'] |
95 |
|
|
96 |
|
item = entries[str(idx)] |
97 |
|
|
98 |
|
# create new MDI frame |
99 |
|
frame = FraggleItemFrame.create(self.parent) |
100 |
|
frame.SetName(str(idx)) |
101 |
|
frame.SetTitle(str("Item No."+item['id'])) |
102 |
|
|
103 |
|
# calculate new position (right lower offset of 15px to us) |
104 |
|
pos = self.GetPosition() + wxPoint(25, 25) |
105 |
|
frame.Move(pos) |
106 |
|
self.parent.Fit() |
107 |
|
|
108 |
|
# patch topic metadata to point to an item instead of a list |
109 |
|
# use keyname as query argument |
110 |
|
#topicmeta = self.topicmeta |
111 |
|
#topicmeta['result'] = 'item' |
112 |
|
#topicmeta['target']['arguments'] = item['keyname'] |
113 |
|
#frame.load_content(topicmeta) |