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 v2 or later 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 #===========================================================128 #===========================================================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 = None86 #-------------------------------------------------------- 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 #--------------------------------------------------------130 """Plugin to encapsulate the manual window.""" 131 132 tab_name = _('Manual') 133 #-------------------------------------------------------- 136 #--------------------------------------------------------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 #=========================================================== 246138 #self._widget = ManualHtmlPanel (parent, ...) 139 self._widget = wx.Panel(parent, -1) 140 return self._widget141 #--------------------------------------------------------143 return ('help', _('User &manual (local)'))144 #-------------------------------------------------------- 148 #--------------------------------------------------------
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sat Aug 3 03:56:34 2013 | http://epydoc.sourceforge.net |