1 |
#Boa:MDIParent:fraggleViewport |
#Boa:MDIParent:fraggleViewport |
2 |
|
|
3 |
import wx |
# $Id$ |
4 |
|
# $Log$ |
5 |
|
# Revision 1.11 2004/08/26 23:10:12 xabbu |
6 |
|
# xmlrpc class added |
7 |
|
# |
8 |
|
# Revision 1.10 2004/08/26 18:19:27 joko |
9 |
|
# now using FraggleTopicFrame |
10 |
|
# |
11 |
|
# Revision 1.9 2004/08/26 15:21:13 joko |
12 |
|
# renamed namespaces |
13 |
|
# added key shortcuts to menu-items |
14 |
|
# correct "showAbout" code |
15 |
|
# |
16 |
|
|
17 |
|
import os |
18 |
from wxPython.wx import * |
from wxPython.wx import * |
19 |
|
from wxPython.stc import * |
20 |
|
|
21 |
import fraggleDialogPrefs |
import fraggleDialogPrefs |
22 |
import fraggleCtlPreferences |
import fraggleCtlPreferences |
23 |
|
import FraggleAboutDialog |
24 |
|
import FraggleTopicFrame |
25 |
|
import FraggleXMLRPC |
26 |
|
|
27 |
def create(parent): |
def create(parent): |
28 |
return fraggleViewport(parent) |
return fraggleViewport(parent) |
29 |
|
|
30 |
[wxID_FRAGGLEVIEWPORT] = map(lambda _init_ctrls: wxNewId(), range(1)) |
[wxID_FRAGGLEVIEWPORT, wxID_FRAGGLEVIEWPORTBUTTONSYNC, |
31 |
|
wxID_FRAGGLEVIEWPORTSTYLEDTEXTCTRL1, |
32 |
|
] = map(lambda _init_ctrls: wxNewId(), range(3)) |
33 |
|
|
34 |
[wxID_FRAGGLEVIEWPORTMENU1FPREFS, wxID_FRAGGLEVIEWPORTMENU1ITEMS1, |
[wxID_FRAGGLEVIEWPORTMENU1FPREFS, wxID_FRAGGLEVIEWPORTMENU1ITEMS1, |
35 |
] = map(lambda _init_coll_menu1_Items: wxNewId(), range(2)) |
] = map(lambda _init_coll_menu1_Items: wxNewId(), range(2)) |
36 |
|
|
37 |
|
[wxID_FRAGGLEVIEWPORTMENU2ABOUT, wxID_FRAGGLEVIEWPORTMENU2CONT, |
38 |
|
] = map(lambda _init_coll_menu2_Items: wxNewId(), range(2)) |
39 |
|
|
40 |
|
[wxID_FRAGGLEVIEWPORTMENU2ABOUT, wxID_FRAGGLEVIEWPORTMENU2CONT, |
41 |
|
] = map(lambda _init_coll_menu2_Items: wxNewId(), range(2)) |
42 |
|
|
43 |
class fraggleViewport(wxMDIParentFrame): |
class fraggleViewport(wxMDIParentFrame): |
44 |
|
def _init_coll_menu2_Items(self, parent): |
45 |
|
# generated method, don't edit |
46 |
|
|
47 |
|
parent.Append(helpString='Contents', id=wxID_FRAGGLEVIEWPORTMENU2CONT, |
48 |
|
item='Contents', kind=wxITEM_NORMAL) |
49 |
|
parent.Append(helpString='About', id=wxID_FRAGGLEVIEWPORTMENU2ABOUT, |
50 |
|
item='About', kind=wxITEM_NORMAL) |
51 |
|
|
52 |
def _init_coll_menu1_Items(self, parent): |
def _init_coll_menu1_Items(self, parent): |
53 |
# generated method, don't edit |
# generated method, don't edit |
54 |
|
|
55 |
parent.Append(wxID_FRAGGLEVIEWPORTMENU1FPREFS, '&Preferences', "", |
parent.Append(helpString='Configure Netfraggle', |
56 |
wx.ITEM_NORMAL) |
id=wxID_FRAGGLEVIEWPORTMENU1FPREFS, item='Preferences', |
57 |
parent.Append(wxID_FRAGGLEVIEWPORTMENU1ITEMS1, '&Exit Netfraggle', "", |
kind=wxITEM_NORMAL) |
58 |
wx.ITEM_NORMAL) |
parent.Append(helpString='Exit Netfraggle', |
59 |
EVT_MENU(self, wxID_FRAGGLEVIEWPORTMENU1FPREFS, self.OnMenu1items0Menu) |
id=wxID_FRAGGLEVIEWPORTMENU1ITEMS1, item='Exit', |
60 |
EVT_MENU(self, wxID_FRAGGLEVIEWPORTMENU1ITEMS1, self.OnMenu1items1Menu) |
kind=wxITEM_NORMAL) |
61 |
|
|
62 |
def _init_coll_menuBar1_Menus(self, parent): |
def _init_coll_menuBar1_Menus(self, parent): |
63 |
# generated method, don't edit |
# generated method, don't edit |
64 |
|
|
65 |
parent.Append(menu=self.menu1, title='File') |
parent.Append(menu=self.menu1, title='&File') |
66 |
|
parent.Append(menu=self.menu2, title='&Help') |
67 |
|
|
68 |
def _init_utils(self): |
def _init_utils(self): |
69 |
# generated method, don't edit |
# generated method, don't edit |
73 |
self.menu1 = wxMenu(title='') |
self.menu1 = wxMenu(title='') |
74 |
self._init_coll_menu1_Items(self.menu1) |
self._init_coll_menu1_Items(self.menu1) |
75 |
|
|
76 |
|
self.menu2 = wxMenu(title='') |
77 |
|
self._init_coll_menu2_Items(self.menu2) |
78 |
|
|
79 |
self._init_coll_menuBar1_Menus(self.menuBar1) |
self._init_coll_menuBar1_Menus(self.menuBar1) |
80 |
|
|
81 |
def _init_ctrls(self, prnt): |
def _init_ctrls(self, prnt): |
82 |
# generated method, don't edit |
# generated method, don't edit |
83 |
wxMDIParentFrame.__init__(self, id=wxID_FRAGGLEVIEWPORT, |
wxMDIParentFrame.__init__(self, id=wxID_FRAGGLEVIEWPORT, |
84 |
name='fraggleViewport', parent=prnt, pos=wxPoint(277, 313), |
name='fraggleViewport', parent=prnt, pos=wxPoint(525, 292), |
85 |
size=wxSize(683, 307), |
size=wxSize(341, 296), |
86 |
style=wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, |
style=wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, |
87 |
title='wxMDIParentFrame1') |
title='NetFraggle 0.0.1') |
88 |
self._init_utils() |
self._init_utils() |
89 |
self.SetClientSize(wxSize(683, 284)) |
self.SetClientSize(wxSize(341, 273)) |
90 |
self.SetMenuBar(self.menuBar1) |
self.SetMenuBar(self.menuBar1) |
91 |
|
|
92 |
|
self.buttonsync = wxButton(id=wxID_FRAGGLEVIEWPORTBUTTONSYNC, |
93 |
|
label='Sync', name='buttonsync', parent=self, pos=wxPoint(104, |
94 |
|
240), size=wxSize(136, 24), style=0) |
95 |
|
EVT_BUTTON(self.buttonsync, wxID_FRAGGLEVIEWPORTBUTTONSYNC, |
96 |
|
self.OnButtonsyncButton) |
97 |
|
|
98 |
|
self.styledTextCtrl1 = wxStyledTextCtrl(id=wxID_FRAGGLEVIEWPORTSTYLEDTEXTCTRL1, |
99 |
|
name='styledTextCtrl1', parent=self, pos=wxPoint(8, 16), |
100 |
|
size=wxSize(328, 216), style=0) |
101 |
|
|
102 |
def __init_preferences__(self): |
def __init_preferences__(self): |
103 |
self.preferencesCtl = fraggleCtlPreferences.create(self) |
self.preferencesCtl = fraggleCtlPreferences.create(self) |
104 |
self.dialogPrefs = fraggleDialogPrefs.create(self) |
self.dialogPrefs = fraggleDialogPrefs.create(self) |
105 |
|
self.dialogPrefs.loadConfig() |
106 |
|
self.dialogPrefs.updateConfig() |
107 |
|
|
108 |
|
# new as of 2004-08-26: TopicFrame |
109 |
|
self.topicFrame = FraggleTopicFrame.create(self) |
110 |
|
self.topicFrame.Move(wxPoint(10, 10)) |
111 |
|
|
112 |
|
#frame.Show() |
113 |
|
#frame.Destroy() |
114 |
|
def __init_xmlrpc__(self): |
115 |
|
self.xml_rpc = FraggleXMLRPC.create(self, self.preferencesCtl.configList) |
116 |
|
|
117 |
|
def __init_taskbar_icon__(self): |
118 |
|
if os.name == 'posix': |
119 |
|
pass |
120 |
|
elif os.name == 'nt': |
121 |
|
self.tbicon = wxTaskBarIcon() |
122 |
|
icon = wxIcon('mixxx.ico', wxBITMAP_TYPE_ICO) |
123 |
|
self.tbicon.SetIcon(icon, '') |
124 |
|
wxEVT_TASKBAR_LEFT_DCLICK(self.tbicon, self.OnTaskBarLeftDClick) |
125 |
|
wxEVT_TASKBAR_RIGHT_UP(self.tbicon, self.OnTaskBarRightClick) |
126 |
|
|
127 |
def __init__(self, parent): |
def __init__(self, parent): |
128 |
self._init_ctrls(parent) |
self._init_ctrls(parent) |
129 |
self.__init_preferences__() |
self.__init_preferences__() |
130 |
|
self.__init_taskbar_icon__() |
131 |
|
self.__init_xmlrpc__() |
132 |
|
|
|
|
|
133 |
def OnMenu1items0Menu(self, event): |
def OnMenu1items0Menu(self, event): |
134 |
try: |
try: |
135 |
self.dialogPrefs.ShowModal() |
self.dialogPrefs.ShowModal() |
136 |
finally: |
finally: |
137 |
self.dialogPrefs.Destroy() |
self.dialogPrefs.Hide() |
138 |
event.Skip() |
event.Skip() |
139 |
|
|
140 |
def OnMenu1items1Menu(self, event): |
def OnMenu1items1Menu(self, event): |
141 |
self.Destroy() |
self.Destroy() |
142 |
event.Skip() |
event.Skip() |
143 |
|
|
144 |
|
|
145 |
|
def OnMenu2items0Menu(self, event): |
146 |
|
try: |
147 |
|
self.dialogPrefs.ShowModal() |
148 |
|
finally: |
149 |
|
pass |
150 |
|
event.Skip() |
151 |
|
|
152 |
|
def OnMenu2items1Menu(self, event): |
153 |
|
"""Show about screen""" |
154 |
|
dlg = FraggleAboutDialog.create(self) |
155 |
|
dlg.ShowModal() |
156 |
|
dlg.Destroy() |
157 |
|
|
158 |
|
def OnTaskBarLeftDClick(self, event): |
159 |
|
event.Skip() |
160 |
|
|
161 |
|
def OnTaskBarRightClick(self, event): |
162 |
|
event.Skip() |
163 |
|
|
164 |
|
def OnButtonsyncButton(self, event): |
165 |
|
fragglexml = self.xml_rpc.FraggleSync() |
166 |
|
print fragglexml |
167 |
|
import codecs |
168 |
|
(UTF8_encode, UTF8_decode, |
169 |
|
UTF8_streamreader, UTF8_streamwriter) = codecs.lookup('UTF-8') |
170 |
|
text = UTF8_decode(repr(fragglexml))[0] |
171 |
|
text = fragglexml.data |
172 |
|
self.styledTextCtrl1.AddText(text) |
173 |
|
event.Skip() |