/[cvs]/nfo/projects/netfraggle/bin/FraggleListFrame.py
ViewVC logotype

Contents of /nfo/projects/netfraggle/bin/FraggleListFrame.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations)
Tue Aug 31 09:37:26 2004 UTC (19 years, 10 months ago) by joko
Branch: MAIN
Changes since 1.1: +38 -15 lines
File MIME type: text/x-python
U def load_content: do "getTopicById" here!
U renamed some variables
+ def OnListViewMainLeftDclick

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

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed