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