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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations)
Mon Sep 13 21:10:18 2004 UTC (19 years, 9 months ago) by xabbu
Branch: MAIN
Changes since 1.2: +30 -26 lines
File MIME type: text/x-python
+ function getContent altered and partially commented out for testing of the nql querying interface

1 joko 1.1 #Boa:MDIChild:FraggleListFrame
2    
3     from wxPython.wx import *
4     from wxPython.stc import *
5 joko 1.2 import FraggleItemFrame
6 joko 1.1
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 joko 1.2 EVT_LEFT_DCLICK(self.listViewMain, self.OnListViewMainLeftDclick)
37 joko 1.1
38     def __init__(self, parent):
39 joko 1.2 self.parent = parent
40 joko 1.1 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 xabbu 1.3
50 joko 1.1 def load_content(self):
51 xabbu 1.3 self.payload = self.engine.listItems('xmlpage')
52     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 joko 1.1
59 xabbu 1.3 # if self.payload:
60 joko 1.1
61     # 1. generate columns
62 xabbu 1.3 # row0 = self.payload[0]
63     # colid = 0
64     # for column in row0.keys():
65     # self.listViewMain.InsertColumn(
66     # col=colid,
67     # format=wxLIST_FORMAT_LEFT,
68     # heading=column,
69     # width=-1
70     # )
71     # colid += 1
72 joko 1.1
73     # 2. fill entries
74 xabbu 1.3 #itemid = 0
75     #for entry in self.payload:
76     # self.listViewMain.InsertStringItem(itemid, entry.keys()[0])
77     # colid = 0
78     # columnlist = entry.keys()
79     # columnlist.pop()
80     # for column in columnlist:
81     # self.listViewMain.SetStringItem(itemid, colid, entry[column])
82     # colid += 1
83 joko 1.2
84     # set custom data
85 xabbu 1.3 #self.listViewMain.SetItemData(itemid, itemid)
86 joko 1.2
87 xabbu 1.3 #itemid += 1
88 joko 1.2
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)

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