Package teamwork :: Package widgets :: Package htmlViewer :: Module tkinit
[hide private]
[frames] | no frames]

Source Code for Module teamwork.widgets.htmlViewer.tkinit

  1  ## vim:ts=4:et:nowrap 
  2  ## 
  3  ##---------------------------------------------------------------------------## 
  4  ## 
  5  ## PySol -- a Python Solitaire game 
  6  ## 
  7  ## Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer 
  8  ## Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer 
  9  ## Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer 
 10  ## Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer 
 11  ## Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer 
 12  ## Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer 
 13  ## All Rights Reserved. 
 14  ## 
 15  ## This program is free software; you can redistribute it and/or modify 
 16  ## it under the terms of the GNU General Public License as published by 
 17  ## the Free Software Foundation; either version 2 of the License, or 
 18  ## (at your option) any later version. 
 19  ## 
 20  ## This program is distributed in the hope that it will be useful, 
 21  ## but WITHOUT ANY WARRANTY; without even the implied warranty of 
 22  ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 23  ## GNU General Public License for more details. 
 24  ## 
 25  ## You should have received a copy of the GNU General Public License 
 26  ## along with this program; see the file COPYING. 
 27  ## If not, write to the Free Software Foundation, Inc., 
 28  ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
 29  ## 
 30  ## Markus F.X.J. Oberhumer 
 31  ## <markus@oberhumer.com> 
 32  ## http://www.oberhumer.com/pysol 
 33  ## 
 34  ##---------------------------------------------------------------------------## 
 35   
 36   
 37  # imports 
 38  import os, sys, string, types 
 39  import Tkinter, Canvas 
 40   
 41   
 42  # /*********************************************************************** 
 43  # // patch lib-tk/Tkinter.py 
 44  # ************************************************************************/ 
 45   
 46  # ignore self.tk.deletecommand() failures in Misc.destroy, or else the 
 47  # destruction of a (withdrawn & transient) toplevel may fail somewhere 
 48  # in the middle, possibly making Tk hang under Windows 
49 -def Misc__destroy(self):
50 if self._tclCommands is not None: 51 for name in self._tclCommands: 52 try: 53 self.tk.deletecommand(name) 54 #print '- Tkinter: deleted command', name 55 except: 56 pass 57 self._tclCommands = None
58 59 # fix Python 1.5.2 _tagcommands bug
60 -def Canvas__tag_bind(self, tagOrId, sequence=None, func=None, add=None):
61 return self._bind((self._w, "bind", tagOrId), sequence, func, add)
62 63 #
64 -def Canvas__xview(self, *args):
65 if not args: 66 return self._getdoubles(self.tk.call(self._w, 'xview')) 67 if args[0] == "moveto": 68 return self.xview_moveto(float(args[1])) 69 elif args[0] == "scroll": 70 return self.xview_scroll(int(args[1]), args[2])
71 -def Canvas__xview_moveto(self, fraction):
72 fraction = max(fraction, 0.0) 73 return self.tk.call(self._w, 'xview', 'moveto', fraction)
74 -def Canvas__xview_scroll(self, number, what):
75 if number < 0: 76 v = self._getdoubles(self.tk.call(self._w, 'xview')) 77 if v[0] <= 0.0001: 78 return 79 return self.tk.call(self._w, 'xview', 'scroll', number, what)
80 -def Canvas__yview(self, *args):
81 if not args: 82 return self._getdoubles(self.tk.call(self._w, 'yview')) 83 if args[0] == "moveto": 84 return self.yview_moveto(float(args[1])) 85 elif args[0] == "scroll": 86 return self.yview_scroll(int(args[1]), args[2])
87 -def Canvas__yview_moveto(self, fraction):
88 fraction = max(fraction, 0.0) 89 return self.tk.call(self._w, 'yview', 'moveto', fraction)
90 -def Canvas__yview_scroll(self, number, what):
91 if number < 0: 92 v = self._getdoubles(self.tk.call(self._w, 'yview')) 93 if v[0] <= 0.0001: 94 return 95 return self.tk.call(self._w, 'yview', 'scroll', number, what)
96 97 # fix missing "newstate" parm
98 -def Wm__wm_state(self, newstate=None):
99 return self.tk.call('wm', 'state', self._w, newstate)
100 101 # these are missing in class Text (probably some others as well)
102 -def Text__xview_moveto(self, fraction):
103 return self.tk.call(self._w, "xview", "moveto", fraction)
104 -def Text__xview_scroll(self, number, what):
105 return self.tk.call(self._w, "xview", "scroll", number, what)
106 -def Text__yview_moveto(self, fraction):
107 return self.tk.call(self._w, "yview", "moveto", fraction)
108 -def Text__yview_scroll(self, number, what):
109 return self.tk.call(self._w, "yview", "scroll", number, what)
110 111 112 Tkinter.Misc.destroy = Misc__destroy 113 Tkinter.Canvas.tag_bind = Canvas__tag_bind 114 Tkinter.Canvas.xview = Canvas__xview 115 Tkinter.Canvas.xview_moveto = Canvas__xview_moveto 116 Tkinter.Canvas.xview_scroll = Canvas__xview_scroll 117 Tkinter.Canvas.yview = Canvas__yview 118 Tkinter.Canvas.yview_moveto = Canvas__yview_moveto 119 Tkinter.Canvas.yview_scroll = Canvas__yview_scroll 120 Tkinter.Wm.wm_state = Wm__wm_state 121 Tkinter.Wm.state = Wm__wm_state # obsolete 122 Tkinter.Text.xview_moveto = Text__xview_moveto 123 Tkinter.Text.xview_scroll = Text__xview_scroll 124 Tkinter.Text.yview_moveto = Text__yview_moveto 125 Tkinter.Text.yview_scroll = Text__yview_scroll 126 127 128 # /*********************************************************************** 129 # // patch lib-tk/Canvas.py 130 # ************************************************************************/ 131 132 # fix inconsistent bbox() return value
133 -def CanvasItem__bbox(self):
134 return self.canvas.bbox(self.id)
135 -def Group__bbox(self):
136 return self.canvas.bbox(self.id)
137 138 # fix missing "add" parm
139 -def CanvasItem__bind(self, sequence=None, command=None, add=None):
140 return self.canvas.tag_bind(self.id, sequence, command, add)
141 -def Group__bind(self, sequence=None, command=None, add=None):
142 return self.canvas.tag_bind(self.id, sequence, command, add)
143 144 # fix missing "funcid" parm
145 -def CanvasItem__unbind(self, sequence, funcid=None):
146 return self.canvas.tag_unbind(self.id, sequence, funcid)
147 -def Group__unbind(self, sequence, funcid=None):
148 return self.canvas.tag_unbind(self.id, sequence, funcid)
149 150 # call tag_raise / tag_lower
151 -def CanvasItem__tkraise(self, abovethis=None):
152 return self.canvas.tag_raise(self.id, abovethis)
153 -def CanvasItem__lower(self, belowthis=None):
154 return self.canvas.tag_lower(self.id, belowthis)
155 -def Group__tkraise(self, abovethis=None):
156 return self.canvas.tag_raise(self.id, abovethis)
157 -def Group__lower(self, belowthis=None):
158 return self.canvas.tag_lower(self.id, belowthis)
159 160 161 # other problems in Canvas.Group: 162 # - inconsistent usage of self.id and self.tag 163 # - calls the obsolete Tkinter.Canvas._do method 164 165 166 Canvas.CanvasItem.bbox = CanvasItem__bbox 167 Canvas.Group.bbox = Group__bbox 168 Canvas.CanvasItem.bind = CanvasItem__bind 169 Canvas.Group.bind = Group__bind 170 Canvas.CanvasItem.unbind = CanvasItem__unbind 171 Canvas.Group.unbind = Group__unbind 172 Canvas.CanvasItem.tkraise = CanvasItem__tkraise 173 Canvas.CanvasItem.lower = CanvasItem__lower 174 Canvas.Group.tkraise = Group__tkraise 175 Canvas.Group.lower = Group__lower 176 177 178 # /*********************************************************************** 179 # // PySol extra patches 180 # ************************************************************************/ 181 182 # do not catch any exceptions in a Tkinter callback
183 -def CallWrapper____call__(self, *args):
184 if self.subst: 185 args = apply(self.subst, args) 186 return apply(self.func, args)
187 188 Tkinter.CallWrapper.__call__ = CallWrapper____call__ 189