| Home | Trees | Indices | Help |
|
|---|
|
|
1 # a simple wrapper for the Manual class
2
3 """GNUMed manuals in a HTML browser window
4
5 A very basic HTML browser with back/forward history buttons
6 with the main pourpose of browsing the gnumed manuals
7 The manuals should reside where the manual_path points to.
8
9 @copyright: GPL
10 @thanks: this code has been heavily "borrowed" from
11 Robin Dunn's extraordinary wxPython sample
12 """
13 #===========================================================
14 # $Source: /home/ncq/Projekte/cvs2git/vcs-mirror/gnumed/gnumed/client/wxpython/gui/gmManual.py,v $
15 # $Id: gmManual.py,v 1.49 2009-07-17 09:27:38 ncq Exp $
16 __version__ = "$Revision: 1.49 $"
17 __author__ = "H.Herb, I.Haywood, H.Berger, K.Hilbert"
18
19 import os, sys, os.path, logging
20
21 import wx
22 import wx.html
23
24 from Gnumed.pycommon import gmTools
25 from Gnumed.wxpython import gmPlugin, images_for_gnumed_browser16_16, images_gnuMedGP_Toolbar
26
27 _log = logging.getLogger('gm.ui')
28 _log.info(__version__)
29
30 ID_MANUALCONTENTS = wx.NewId()
31 ID_MANUALBACK = wx.NewId()
32 ID_MANUALFORWARD = wx.NewId()
33 ID_MANUALHOME = wx.NewId()
34 ID_MANUALBABELFISH = wx.NewId()
35 ID_MANUALPRINTER = wx.NewId()
36 ID_MANUALOPENFILE = wx.NewId()
37 ID_MANUALBOOKMARKS = wx.NewId()
38 ID_MANUALADDBOOKMARK = wx.NewId()
39 ID_MANUALVIEWSOURCE = wx.NewId()
40 ID_MANUALRELOAD = wx.NewId()
41 ID_VIEWSOURCE = wx.NewId()
42 #===========================================================
50 #===========================================================
53 wx.Panel.__init__(self, parent, -1)
54 self.frame = frame
55
56 # get base directory for manuals from broker
57 paths = gmTools.gmPaths(app_name = u'gnumed', wx = wx)
58 candidates = [
59 os.path.join(paths.local_base_dir, 'doc', 'user-manual'),
60 '/usr/share/doc/gnumed/user-manual/',
61 os.path.join(paths.system_app_data_dir, 'doc', 'user-manual')
62 ]
63 for self.docdir in candidates:
64 if os.access(self.docdir, os.R_OK):
65 _log.info('found Manual path [%s]', self.docdir)
66 break
67
68 self.box = wx.BoxSizer(wx.VERTICAL)
69
70 infobox = wx.BoxSizer(wx.HORIZONTAL)
71 n = wx.NewId()
72 self.infoline = wx.TextCtrl(self, n, style=wx.TE_READONLY)
73 self.infoline.SetBackgroundColour(wx.LIGHT_GREY)
74 infobox.Add(self.infoline, 1, wx.GROW|wx.ALL)
75 self.box.Add(infobox, 0, wx.GROW)
76
77 self.html = ManualHtmlWindow(self, -1)
78 self.html.SetRelatedFrame(frame, "")
79 self.html.SetRelatedStatusBar(0)
80 self.box.Add(self.html, 1, wx.GROW)
81
82 self.SetSizer(self.box)
83 self.SetAutoLayout(True)
84
85 self.already_loaded = None
86 #--------------------------------------------------------
91 #--------------------------------------------------------
95 #--------------------------------------------------------
97 name = os.path.join(self.docdir, 'index.html')
98 if os.access (name, os.F_OK):
99 self.html.LoadPage(name)
100 else:
101 _log.error("cannot load local document %s", name)
102 self.html.LoadPage('http://wiki.gnumed.de/bin/view/Gnumed/GnumedManual?template=viewprint')
103 #--------------------------------------------------------
105 dlg = wx.FileDialog(self, wildcard = '*.htm*', style=wx.OPEN)
106 if dlg.ShowModal():
107 path = dlg.GetPath()
108 self.html.LoadPage(path)
109 dlg.Destroy()
110 #--------------------------------------------------------
113 #--------------------------------------------------------
116 #--------------------------------------------------------
118 return 1
119 # FIXME:
120 #from wxPython.lib.dialogs import wx.ScrolledMessageDialog
121 source = self.html.GetParser().GetSource()
122 dlg = wx.ScrolledMessageDialog(self, source, _('HTML Source'))
123 dlg.ShowModal()
124 dlg.Destroy()
125 #--------------------------------------------------------
128 #===========================================================
130 """Plugin to encapsulate the manual window."""
131
132 tab_name = _('Manual')
133 #--------------------------------------------------------
136 #--------------------------------------------------------
138 #self._widget = ManualHtmlPanel (parent, ...)
139 self._widget = wx.Panel(parent, -1)
140 return self._widget
141 #--------------------------------------------------------
143 return ('help', _('User &manual (local)'))
144 #--------------------------------------------------------
148 #--------------------------------------------------------
151 #--------------------------------------------------------
152 #def populate_toolbar (self, tb, widget):
153 #tool1 = tb.AddTool(
154 # ID_MANUALCONTENTS,
155 # images_for_gnumed_browser16_16.getcontentsBitmap(),
156 # shortHelpString=_("GNUmed manual contents"),
157 # isToggle=False
158 #)
159 #wx.EVT_TOOL (tb, ID_MANUALCONTENTS, widget.OnShowDefault)
160
161 # tool1 = tb.AddTool(
162 # ID_MANUALOPENFILE,
163 # images_for_gnumed_browser16_16.getfileopenBitmap(),
164 # shortHelpString="Open File",
165 # isToggle=True
166 # )
167 # wx.EVT_TOOL (tb, ID_MANUALOPENFILE, widget.OnLoadFile)
168
169 #tool1 = tb.AddTool(
170 # ID_MANUALBACK,
171 # images_for_gnumed_browser16_16.get1leftarrowBitmap(),
172 # shortHelpString=_("Back"),
173 # isToggle=False
174 #)
175 #wx.EVT_TOOL (tb, ID_MANUALBACK, widget.OnBack)
176
177 #tool1 = tb.AddTool(
178 # ID_MANUALFORWARD,
179 # images_for_gnumed_browser16_16.get1rightarrowBitmap(),
180 # shortHelpString=_("Forward"),
181 # isToggle=False
182 #)
183 #wx.EVT_TOOL (tb, ID_MANUALFORWARD, widget.OnForward)
184
185 # #tool1 = tb.AddTool(
186 # # ID_MANUALRELOAD,
187 # # images_for_gnumed_browser16_16.getreloadBitmap(),
188 # # shortHelpString=_("Reload"),
189 # # isToggle=True
190 # #)
191
192 # #tb.AddSeparator()
193
194 # #tool1 = tb.AddTool(
195 # # ID_MANUALHOME,
196 # # images_for_gnumed_browser16_16.getgohomeBitmap(),
197 # # shortHelpString=_("Home"),
198 # # isToggle=True
199 # #)
200 # #wx.EVT_TOOL (tb, ID_MANUALHOME, widget.OnShowDefault)
201
202 # #tb.AddSeparator()
203
204 # #tool1 = tb.AddTool(
205 # # ID_MANUALBABELFISH,
206 # # images_for_gnumed_browser16_16.getbabelfishBitmap(),
207 # # shortHelpString=_("Translate text"),
208 # # isToggle=False
209 # #)
210 # #wx.EVT_TOOL (tb, ID_MANUALBABELFISH, widget.OnBabelFish )
211
212 # #tb.AddSeparator()
213
214 # #tool1 = tb.AddTool(
215 # # ID_MANUALBOOKMARKS,
216 # # images_for_gnumed_browser16_16.getbookmarkBitmap(),
217 # # shortHelpString=_("Bookmarks"),
218 # # isToggle=True
219 # #)
220 # #wx.EVT_TOOL (tb, ID_MANUALBOOKMARKS, widget.OnBookmarks)
221
222 # #tool1 = tb.AddTool(
223 # # ID_MANUALADDBOOKMARK,
224 # # images_for_gnumed_browser16_16.getbookmark_addBitmap(),
225 # # shortHelpString=_("Add Bookmark"),
226 # # isToggle=True
227 # #)
228 # #wx.EVT_TOOL (tb, ID_MANUALADDBOOKMARK, widget.OnAddBookmark)
229
230 # tool1 = tb.AddTool(
231 # ID_VIEWSOURCE,
232 # images_for_gnumed_browser16_16.getviewsourceBitmap(),
233 # shortHelpString="View Source",
234 # isToggle=True
235 # )
236 # wx.EVT_TOOL (tb, ID_VIEWSOURCE, widget.OnViewSource)
237
238 #tool1 = tb.AddTool(
239 # ID_MANUALPRINTER,
240 # images_for_gnumed_browser16_16.getprinterBitmap(),
241 # shortHelpString = _("Print manual page"),
242 # isToggle=False
243 #)
244 #wx.EVT_TOOL (tb, ID_MANUALPRINTER, widget.OnPrint)
245 #===========================================================
246 # $Log: gmManual.py,v $
247 # Revision 1.49 2009-07-17 09:27:38 ncq
248 # - cleanup
249 #
250 # Revision 1.48 2008/07/10 21:09:31 ncq
251 # - call path detection with app name and wx
252 #
253 # Revision 1.47 2008/07/10 08:39:20 ncq
254 # - no more toolbar
255 #
256 # Revision 1.46 2008/06/26 17:02:26 ncq
257 # - argument defaults for OnSetTitle
258 #
259 # Revision 1.45 2008/03/06 18:32:31 ncq
260 # - standard lib logging only
261 #
262 # Revision 1.44 2008/01/22 12:25:47 ncq
263 # - better menu item
264 #
265 # Revision 1.43 2007/08/07 21:42:40 ncq
266 # - cPaths -> gmPaths
267 #
268 # Revision 1.42 2007/06/11 20:26:34 ncq
269 # - fix spurious ":"s
270 #
271 # Revision 1.41 2007/06/10 10:13:33 ncq
272 # - somewhat improved logging
273 #
274 # Revision 1.40 2007/05/08 11:17:09 ncq
275 # - need to import gmTools
276 #
277 # Revision 1.39 2007/05/07 12:35:20 ncq
278 # - improve use of gmTools.cPaths()
279 #
280 # Revision 1.38 2007/04/11 20:47:34 ncq
281 # - nore more 'resource dir'
282 #
283 # Revision 1.37 2007/02/19 17:21:18 ncq
284 # - docs are in /usr/share/doc/gnumed/
285 #
286 # Revision 1.36 2006/11/26 17:46:42 ncq
287 # - if loading from the web use template viewprint for better results
288 #
289 # Revision 1.35 2006/07/24 14:58:07 ncq
290 # - acceptably smart access to user manual
291 #
292 # Revision 1.34 2006/05/20 18:56:03 ncq
293 # - use receive_focus() interface
294 #
295 # Revision 1.33 2006/05/15 13:40:02 ncq
296 # - turn into new-style notebook plugin
297 #
298 # Revision 1.32 2005/10/27 21:55:09 shilbert
299 # wxHTMLEasyPrinting caused gmManual to hang
300 # needs to be reimplemented
301 #
302 # Revision 1.31 2005/10/03 13:49:21 sjtan
303 # using new wx. temporary debugging to stdout(easier to read). where is rfe ?
304 #
305 # Revision 1.30 2005/09/28 21:27:30 ncq
306 # - a lot of wx2.6-ification
307 #
308 # Revision 1.29 2005/09/26 18:01:52 ncq
309 # - use proper way to import wx26 vs wx2.4
310 # - note: THIS WILL BREAK RUNNING THE CLIENT IN SOME PLACES
311 # - time for fixup
312 #
313 # Revision 1.28 2005/07/23 14:20:15 shilbert
314 # - fix path so docs will be found when using MS Windows
315 #
316 # Revision 1.27 2005/07/15 20:56:07 ncq
317 # - load User Manual from proper location (breaks loading from CVS tree copy for now)
318 #
319 # Revision 1.26 2005/06/30 10:24:00 cfmoro
320 # String corrections
321 #
322 # Revision 1.25 2005/06/29 12:38:42 cfmoro
323 # Keep only functional really buttons
324 #
325 # Revision 1.24 2004/12/27 18:42:05 shilbert
326 # - added some missing _() for i18n
327 #
328 # Revision 1.23 2004/08/04 17:16:02 ncq
329 # - wx.NotebookPlugin -> cNotebookPlugin
330 # - derive cNotebookPluginOld from cNotebookPlugin
331 # - make cNotebookPluginOld warn on use and implement old
332 # explicit "main.notebook.raised_plugin"/ReceiveFocus behaviour
333 # - ReceiveFocus() -> receive_focus()
334 #
335 # Revision 1.22 2004/07/18 20:30:54 ncq
336 # - wxPython.true/false -> Python.True/False as Python tells us to do
337 #
338 # Revision 1.21 2004/06/25 12:37:21 ncq
339 # - eventually fix the import gmI18N issue
340 #
341 # Revision 1.20 2004/06/20 16:50:51 ncq
342 # - carefully fool epydoc
343 #
344 # Revision 1.19 2004/06/20 06:49:21 ihaywood
345 # changes required due to Epydoc's OCD
346 #
347 # Revision 1.18 2004/06/13 22:31:49 ncq
348 # - gb['main.toolbar'] -> gb['main.top_panel']
349 # - self.internal_name() -> self.__class__.__name__
350 # - remove set_widget_reference()
351 # - cleanup
352 # - fix lazy load in _on_patient_selected()
353 # - fix lazy load in ReceiveFocus()
354 # - use self._widget in self.GetWidget()
355 # - override populate_with_data()
356 # - use gb['main.notebook.raised_plugin']
357 #
358 # Revision 1.17 2004/03/18 09:43:02 ncq
359 # - import gmI18N if standalone
360 #
361 # Revision 1.16 2004/03/12 13:25:15 ncq
362 # - import, cleanup
363 #
364 # Revision 1.15 2004/03/02 10:21:10 ihaywood
365 # gmDemographics now supports comm channels, occupation,
366 # country of birth and martial status
367 #
368 # Revision 1.14 2004/02/25 09:46:22 ncq
369 # - import from pycommon now, not python-common
370 #
371 # Revision 1.13 2003/11/17 10:56:40 sjtan
372 #
373 # synced and commiting.
374 #
375 # Revision 1.1 2003/10/23 06:02:40 sjtan
376 #
377 # manual edit areas modelled after r.terry's specs.
378 #
379 # Revision 1.12 2003/04/28 12:11:30 ncq
380 # - refactor name() to not directly return _(<name>)
381 #
382 # Revision 1.11 2003/02/15 14:55:55 ncq
383 # - whitespace fixup, dynamic loading sped up
384 #
385 # Revision 1.10 2003/02/15 14:39:59 ncq
386 # - cleanup
387 # - comment out a few "un-needed" buttons
388 #
389 # Revision 1.9 2003/02/15 14:21:49 ncq
390 # - on demand loading of Manual
391 # - further pluginization of showmeddocs
392 #
393 # Revision 1.8 2003/02/13 17:38:35 ncq
394 # - cvs keywords, cleanup
395 #
396
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Mon Nov 29 04:04:42 2010 | http://epydoc.sourceforge.net |