source: trunk/anuga_core/source/anuga/pmesh/PmwBlt.py @ 8279

Last change on this file since 8279 was 8125, checked in by wilsonr, 13 years ago

Changes to address ticket 360.

File size: 24.2 KB
Line 
1"""
2Pmw copyright
3
4Copyright 1997-1999 Telstra Corporation Limited,
5Australia Copyright 2000-2002 Really Good Software Pty Ltd, Australia
6
7Permission is hereby granted, free of charge, to any person obtaining
8a copy of this software and associated documentation files (the
9"Software"), to deal in the Software without restriction, including
10without limitation the rights to use, copy, modify, merge, publish,
11distribute, sublicense, and/or sell copies of the Software, and to
12permit persons to whom the Software is furnished to do so, subject to
13the following conditions:
14
15The above copyright notice and this permission notice shall be
16included in all copies or substantial portions of the Software.
17
18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
26
27"""
28
29
30# Python interface to some of the commands of the 2.4 version of the
31# BLT extension to tcl.
32
33import string
34import Tkinter
35
36# Supported commands:
37_busyCommand = '::blt::busy'
38_vectorCommand = '::blt::vector'
39_graphCommand = '::blt::graph'
40_testCommand = '::blt::*'
41_chartCommand = '::blt::stripchart'
42_tabsetCommand = '::blt::tabset'
43
44_haveBlt = None
45_haveBltBusy = None
46
47def _checkForBlt(window):
48    global _haveBlt
49    global _haveBltBusy
50
51    # Blt may be a package which has not yet been loaded. Try to load it.
52    try:
53        window.tk.call('package', 'require', 'BLT')
54    except Tkinter.TclError:
55        # Another way to try to dynamically load blt:
56        try:
57            window.tk.call('load', '', 'Blt')
58        except Tkinter.TclError:
59            pass
60
61    _haveBlt= (window.tk.call('info', 'commands', _testCommand) != '')
62    _haveBltBusy = (window.tk.call('info', 'commands', _busyCommand) != '')
63
64def haveblt(window):
65    if _haveBlt is None:
66        _checkForBlt(window)
67    return _haveBlt
68
69def havebltbusy(window):
70    if _haveBlt is None:
71        _checkForBlt(window)
72    return _haveBltBusy
73
74def _loadBlt(window):
75    if _haveBlt is None:
76        if window is None:
77            window = Tkinter._default_root
78            if window is None:
79                window = Tkinter.Tk()
80        _checkForBlt(window)
81
82def busy_hold(window, cursor = None):
83    _loadBlt(window)
84    if cursor is None:
85        window.tk.call(_busyCommand, 'hold', window._w)
86    else:
87        window.tk.call(_busyCommand, 'hold', window._w, '-cursor', cursor)
88
89def busy_release(window):
90    _loadBlt(window)
91    window.tk.call(_busyCommand, 'release', window._w)
92
93def busy_forget(window):
94    _loadBlt(window)
95    window.tk.call(_busyCommand, 'forget', window._w)
96
97#=============================================================================
98# Interface to the blt vector command which makes it look like the
99# builtin python list type.
100# The -variable, -command, -watchunset creation options are not supported.
101# The dup, merge, notify, offset, populate, seq and variable methods
102# and the +, -, * and / operations are not supported.
103
104# Blt vector functions:
105def vector_expr(expression):
106    tk = Tkinter._default_root.tk
107    strList = tk.splitlist(tk.call(_vectorCommand, 'expr', expression))
108    return tuple(map(string.atof, strList))
109
110def vector_names(pattern = None):
111    tk = Tkinter._default_root.tk
112    return tk.splitlist(tk.call(_vectorCommand, 'names', pattern))
113
114class Vector:
115    _varnum = 0
116    def __init__(self, size=None, master=None):
117        # <size> can be either an integer size, or a string "first:last".
118        _loadBlt(master)
119        if master:
120            self._master = master
121        else:
122            self._master = Tkinter._default_root
123        self.tk = self._master.tk
124        self._name = 'PY_VEC' + str(Vector._varnum)
125        Vector._varnum = Vector._varnum + 1
126        if size is None:
127            self.tk.call(_vectorCommand, 'create', self._name)
128        else:
129          self.tk.call(_vectorCommand, 'create', '%s(%s)' % (self._name, size))
130    def __del__(self):
131        self.tk.call(_vectorCommand, 'destroy', self._name)
132    def __str__(self):
133        return self._name
134
135    def __repr__(self):
136        return '[' + string.join(map(str, self), ', ') + ']'
137    def __cmp__(self, list):
138        return cmp(self[:], list)
139
140    def __len__(self): 
141        return self.tk.getint(self.tk.call(self._name, 'length'))
142    def __getitem__(self, key): 
143        oldkey = key
144        if key < 0:
145            key = key + len(self)
146        try:
147            return self.tk.getdouble(self.tk.globalgetvar(self._name, str(key)))
148        except Tkinter.TclError:
149            raise IndexError, oldkey
150    def __setitem__(self, key, value): 
151        if key < 0:
152            key = key + len(self)
153        return self.tk.globalsetvar(self._name, str(key), float(value))
154
155    def __delitem__(self, key):
156        if key < 0:
157            key = key + len(self)
158        return self.tk.globalunsetvar(self._name, str(key))
159
160    def __getslice__(self, start, end):
161        length = len(self)
162        if start < 0:
163            start = 0
164        if end > length:
165            end = length
166        if start >= end:
167            return []
168        end = end - 1  # Blt vector slices include end point.
169        text = self.tk.globalgetvar(self._name, str(start) + ':' + str(end))
170        return map(self.tk.getdouble, self.tk.splitlist(text))
171
172    def __setslice__(self, start, end, list):
173        if start > end:
174            end = start
175        self.set(self[:start] + list + self[end:])
176
177    def __delslice__(self, start, end):
178        if start < end:
179            self.set(self[:start] + self[end:])
180
181    def __add__(self, list):
182        return self[:] + list
183    def __radd__(self, list):
184        return list + self[:]
185    def __mul__(self, n):
186        return self[:] * n
187    __rmul__ = __mul__
188
189    # Python builtin list methods:
190    def append(self, *args):
191        self.tk.call(self._name, 'append', args)
192    def count(self, obj):
193        return self[:].count(obj)
194    def index(self, value):
195        return self[:].index(value)
196    def insert(self, index, value):
197        self[index:index] = [value]
198    def remove(self, value):
199        del self[self.index(value)]
200    def reverse(self):
201        s = self[:]
202        s.reverse()
203        self.set(s)
204    def sort(self, *args):
205        s = self[:]
206        s.sort()
207        self.set(s)
208
209    # Blt vector instance methods:
210    # append - same as list method above
211    def clear(self):
212        self.tk.call(self._name, 'clear')
213    def delete(self, *args):
214        self.tk.call((self._name, 'delete') + args)
215    def expr(self, expression):
216        self.tk.call(self._name, 'expr', expression)
217    def length(self, newSize=None): 
218        return self.tk.getint(self.tk.call(self._name, 'length', newSize))
219    def range(self, first, last=None):
220        # Note that, unlike self[first:last], this includes the last
221        # item in the returned range.
222        text = self.tk.call(self._name, 'range', first, last)
223        return map(self.tk.getdouble, self.tk.splitlist(text))
224    def search(self, start, end=None):
225        return self._master._getints(self.tk.call(
226                self._name, 'search', start, end))
227    def set(self, list):
228        if not isinstance(list, tuple):
229            list = tuple(list)
230        self.tk.call(self._name, 'set', list)
231
232    # The blt vector sort method has different semantics to the python
233    # list sort method.  Call these blt_sort:
234    def blt_sort(self, *args):
235        self.tk.call((self._name, 'sort') + args)
236    def blt_sort_reverse(self, *args):
237        self.tk.call((self._name, 'sort', '-reverse') + args)
238
239    # Special blt vector indexes:
240    def min(self):
241        return self.tk.getdouble(self.tk.globalgetvar(self._name, 'min'))
242    def max(self):
243        return self.tk.getdouble(self.tk.globalgetvar(self._name, 'max'))
244
245    # Method borrowed from Tkinter.Var class:
246    def get(self):
247        return self[:]
248
249#=============================================================================
250
251# This is a general purpose configure routine which can handle the
252# configuration of widgets, items within widgets, etc.  Supports the
253# forms configure() and configure('font') for querying and
254# configure(font = 'fixed', text = 'hello') for setting.
255
256def _doConfigure(widget, subcommand, option, kw):
257
258    if not option and not kw:
259        # Return a description of all options.
260        ret = {}
261        options = widget.tk.splitlist(widget.tk.call(subcommand))
262        for optionString in options:
263            optionInfo = widget.tk.splitlist(optionString)
264            option = optionInfo[0][1:]
265            ret[option] = (option,) + optionInfo[1:]
266        return ret
267
268    if option:
269        # Return a description of the option given by <option>.
270        if kw:
271            # Having keywords implies setting configuration options.
272            # Can't set and get in one command!
273            raise ValueError, 'cannot have option argument with keywords'
274        option = '-' + option
275        optionInfo = widget.tk.splitlist(widget.tk.call(subcommand + (option,)))
276        return (optionInfo[0][1:],) + optionInfo[1:]
277
278    # Otherwise, set the given configuration options.
279    widget.tk.call(subcommand + widget._options(kw))
280
281#=============================================================================
282
283class Graph(Tkinter.Widget):
284    # Wrapper for the blt graph widget, version 2.4.
285
286    def __init__(self, master=None, cnf={}, **kw):
287        _loadBlt(master)
288        Tkinter.Widget.__init__(self, master, _graphCommand, cnf, kw)
289
290    def bar_create(self, name, **kw):
291        self.tk.call((self._w, 'bar', 'create', name) + self._options(kw))
292
293    def line_create(self, name, **kw):
294        self.tk.call((self._w, 'line', 'create', name) + self._options(kw))
295
296    def extents(self, item):
297        return self.tk.getint(self.tk.call(self._w, 'extents', item))
298
299    def invtransform(self, winX, winY):
300        return self._getdoubles(
301                self.tk.call(self._w, 'invtransform', winX, winY))
302
303    def inside(self, x, y):
304        return self.tk.getint(self.tk.call(self._w, 'inside', x, y))
305
306    def snap(self, photoName):
307        self.tk.call(self._w, 'snap', photoName)
308
309    def transform(self, x, y):
310        return self._getdoubles(self.tk.call(self._w, 'transform', x, y))
311
312    def axis_cget(self, axisName, key):
313        return self.tk.call(self._w, 'axis', 'cget', axisName, '-' + key)
314    def axis_configure(self, axes, option=None, **kw):
315        # <axes> may be a list of axisNames.
316        if isinstance(axes, basestring):
317            axes = [axes]
318        subcommand = (self._w, 'axis', 'configure') + tuple(axes)
319        return _doConfigure(self, subcommand, option, kw)
320    def axis_create(self, axisName, **kw):
321        self.tk.call((self._w, 'axis', 'create', axisName) + self._options(kw))
322    def axis_delete(self, *args):
323        self.tk.call((self._w, 'axis', 'delete') + args)
324    def axis_invtransform(self, axisName, value):
325        return self.tk.getdouble(self.tk.call(
326                self._w, 'axis', 'invtransform', axisName, value))
327    def axis_limits(self, axisName):
328        return self._getdoubles(self.tk.call(
329                self._w, 'axis', 'limits', axisName))
330    def axis_names(self, *args):
331        return self.tk.splitlist(
332                self.tk.call((self._w, 'axis', 'names') + args))
333    def axis_transform(self, axisName, value):
334        return self.tk.getint(self.tk.call(
335                self._w, 'axis', 'transform', axisName, value))
336
337    def xaxis_cget(self, key):
338        return self.tk.call(self._w, 'xaxis', 'cget', '-' + key)
339    def xaxis_configure(self, option=None, **kw):
340        subcommand = (self._w, 'xaxis', 'configure')
341        return _doConfigure(self, subcommand, option, kw)
342    def xaxis_invtransform(self, value):
343        return self.tk.getdouble(self.tk.call(
344                self._w, 'xaxis', 'invtransform', value))
345    def xaxis_limits(self):
346        return self._getdoubles(self.tk.call(self._w, 'xaxis', 'limits'))
347    def xaxis_transform(self, value):
348        return self.tk.getint(self.tk.call(
349                self._w, 'xaxis', 'transform', value))
350    def xaxis_use(self, axisName = None):
351        return self.tk.call(self._w, 'xaxis', 'use', axisName)
352
353    def x2axis_cget(self, key):
354        return self.tk.call(self._w, 'x2axis', 'cget', '-' + key)
355    def x2axis_configure(self, option=None, **kw):
356        subcommand = (self._w, 'x2axis', 'configure')
357        return _doConfigure(self, subcommand, option, kw)
358    def x2axis_invtransform(self, value):
359        return self.tk.getdouble(self.tk.call(
360                self._w, 'x2axis', 'invtransform', value))
361    def x2axis_limits(self):
362        return self._getdoubles(self.tk.call(self._w, 'x2axis', 'limits'))
363    def x2axis_transform(self, value):
364        return self.tk.getint(self.tk.call(
365                self._w, 'x2axis', 'transform', value))
366    def x2axis_use(self, axisName = None):
367        return self.tk.call(self._w, 'x2axis', 'use', axisName)
368
369    def yaxis_cget(self, key):
370        return self.tk.call(self._w, 'yaxis', 'cget', '-' + key)
371    def yaxis_configure(self, option=None, **kw):
372        subcommand = (self._w, 'yaxis', 'configure')
373        return _doConfigure(self, subcommand, option, kw)
374    def yaxis_invtransform(self, value):
375        return self.tk.getdouble(self.tk.call(
376                self._w, 'yaxis', 'invtransform', value))
377    def yaxis_limits(self):
378        return self._getdoubles(self.tk.call(self._w, 'yaxis', 'limits'))
379    def yaxis_transform(self, value):
380        return self.tk.getint(self.tk.call(
381                self._w, 'yaxis', 'transform', value))
382    def yaxis_use(self, axisName = None):
383        return self.tk.call(self._w, 'yaxis', 'use', axisName)
384
385    def y2axis_cget(self, key):
386        return self.tk.call(self._w, 'y2axis', 'cget', '-' + key)
387    def y2axis_configure(self, option=None, **kw):
388        subcommand = (self._w, 'y2axis', 'configure')
389        return _doConfigure(self, subcommand, option, kw)
390    def y2axis_invtransform(self, value):
391        return self.tk.getdouble(self.tk.call(
392                self._w, 'y2axis', 'invtransform', value))
393    def y2axis_limits(self):
394        return self._getdoubles(self.tk.call(self._w, 'y2axis', 'limits'))
395    def y2axis_transform(self, value):
396        return self.tk.getint(self.tk.call(
397                self._w, 'y2axis', 'transform', value))
398    def y2axis_use(self, axisName = None):
399        return self.tk.call(self._w, 'y2axis', 'use', axisName)
400
401    def crosshairs_cget(self, key):
402        return self.tk.call(self._w, 'crosshairs', 'cget', '-' + key)
403    def crosshairs_configure(self, option=None, **kw):
404        subcommand = (self._w, 'crosshairs', 'configure')
405        return _doConfigure(self, subcommand, option, kw)
406    def crosshairs_off(self):
407        self.tk.call(self._w, 'crosshairs', 'off')
408    def crosshairs_on(self):
409        self.tk.call(self._w, 'crosshairs', 'on')
410    def crosshairs_toggle(self):
411        self.tk.call(self._w, 'crosshairs', 'toggle')
412
413    def element_activate(self, name, *args):
414        self.tk.call((self._w, 'element', 'activate', name) + args)
415    def element_bind(self, tagName, sequence=None, func=None, add=None):
416        return self._bind((self._w, 'element', 'bind', tagName),
417                sequence, func, add)
418    def element_unbind(self, tagName, sequence, funcid=None):
419        self.tk.call(self._w, 'element', 'bind', tagName, sequence, '')
420        if funcid:
421            self.deletecommand(funcid)
422
423    def element_cget(self, name, key):
424        return self.tk.call(self._w, 'element', 'cget', name, '-' + key)
425
426    def element_closest(self, x, y, *args, **kw):
427        var = 'python_private_1'
428        success = self.tk.getint(self.tk.call(
429                (self._w, 'element', 'closest', x, y, var) +
430                        self._options(kw) + args))
431        if success:
432            rtn = {}
433            rtn['dist'] = self.tk.getdouble(self.tk.globalgetvar(var, 'dist'))
434            rtn['x'] = self.tk.getdouble(self.tk.globalgetvar(var, 'x'))
435            rtn['y'] = self.tk.getdouble(self.tk.globalgetvar(var, 'y'))
436            rtn['index'] = self.tk.getint(self.tk.globalgetvar(var, 'index'))
437            rtn['name'] = self.tk.globalgetvar(var, 'name')
438            return rtn
439        else:
440            return None
441
442    def element_configure(self, names, option=None, **kw):
443        # <names> may be a list of elemNames.
444        if isinstance(names, basestring):
445            names = [names]
446        subcommand = (self._w, 'element', 'configure') + tuple(names)
447        return _doConfigure(self, subcommand, option, kw)
448
449    def element_deactivate(self, *args):
450        self.tk.call((self._w, 'element', 'deactivate') + args)
451
452    def element_delete(self, *args):
453        self.tk.call((self._w, 'element', 'delete') + args)
454    def element_exists(self, name):
455        return self.tk.getboolean(
456                self.tk.call(self._w, 'element', 'exists', name))
457
458    def element_names(self, *args):
459        return self.tk.splitlist(
460                self.tk.call((self._w, 'element', 'names') + args))
461    def element_show(self, nameList=None):
462        if nameList is not None:
463            nameList = tuple(nameList)
464        return self.tk.splitlist(
465                self.tk.call(self._w, 'element', 'show', nameList))
466    def element_type(self, name):
467        return self.tk.call(self._w, 'element', 'type', name)
468
469    def grid_cget(self, key):
470        return self.tk.call(self._w, 'grid', 'cget', '-' + key)
471    def grid_configure(self, option=None, **kw):
472        subcommand = (self._w, 'grid', 'configure')
473        return _doConfigure(self, subcommand, option, kw)
474
475    def grid_off(self):
476        self.tk.call(self._w, 'grid', 'off')
477    def grid_on(self):
478        self.tk.call(self._w, 'grid', 'on')
479    def grid_toggle(self):
480        self.tk.call(self._w, 'grid', 'toggle')
481
482    def legend_activate(self, *args):
483        self.tk.call((self._w, 'legend', 'activate') + args)
484    def legend_bind(self, tagName, sequence=None, func=None, add=None):
485        return self._bind((self._w, 'legend', 'bind', tagName),
486                sequence, func, add)
487    def legend_unbind(self, tagName, sequence, funcid=None):
488        self.tk.call(self._w, 'legend', 'bind', tagName, sequence, '')
489        if funcid:
490            self.deletecommand(funcid)
491
492    def legend_cget(self, key):
493        return self.tk.call(self._w, 'legend', 'cget', '-' + key)
494    def legend_configure(self, option=None, **kw):
495        subcommand = (self._w, 'legend', 'configure')
496        return _doConfigure(self, subcommand, option, kw)
497    def legend_deactivate(self, *args):
498        self.tk.call((self._w, 'legend', 'deactivate') + args)
499    def legend_get(self, pos):
500        return self.tk.call(self._w, 'legend', 'get', pos)
501
502    def pen_cget(self, name, key):
503        return self.tk.call(self._w, 'pen', 'cget', name, '-' + key)
504    def pen_configure(self, names, option=None, **kw):
505        # <names> may be a list of penNames.
506        if isinstance(names, basestring):
507            names = [names]
508        subcommand = (self._w, 'pen', 'configure') + tuple(names)
509        return _doConfigure(self, subcommand, option, kw)
510    def pen_create(self, name, **kw):
511        self.tk.call((self._w, 'pen', 'create', name) + self._options(kw))
512    def pen_delete(self, *args):
513        self.tk.call((self._w, 'pen', 'delete') + args)
514    def pen_names(self, *args):
515        return self.tk.splitlist(self.tk.call((self._w, 'pen', 'names') + args))
516
517    def postscript_cget(self, key):
518        return self.tk.call(self._w, 'postscript', 'cget', '-' + key)
519    def postscript_configure(self, option=None, **kw):
520        subcommand = (self._w, 'postscript', 'configure')
521        return _doConfigure(self, subcommand, option, kw)
522    def postscript_output(self, fileName=None, **kw):
523        prefix = (self._w, 'postscript', 'output')
524        if fileName is None:
525            return self.tk.call(prefix + self._options(kw))
526        else:
527            self.tk.call(prefix + (fileName,) + self._options(kw))
528
529    def marker_after(self, first, second=None):
530        self.tk.call(self._w, 'marker', 'after', first, second)
531    def marker_before(self, first, second=None):
532        self.tk.call(self._w, 'marker', 'before', first, second)
533    def marker_bind(self, tagName, sequence=None, func=None, add=None):
534        return self._bind((self._w, 'marker', 'bind', tagName),
535                sequence, func, add)
536    def marker_unbind(self, tagName, sequence, funcid=None):
537        self.tk.call(self._w, 'marker', 'bind', tagName, sequence, '')
538        if funcid:
539            self.deletecommand(funcid)
540
541    def marker_cget(self, name, key):
542        return self.tk.call(self._w, 'marker', 'cget', name, '-' + key)
543    def marker_configure(self, names, option=None, **kw):
544        # <names> may be a list of markerIds.
545        if isinstance(names, basestring):
546            names = [names]
547        subcommand = (self._w, 'marker', 'configure') + tuple(names)
548        return _doConfigure(self, subcommand, option, kw)
549    def marker_create(self, type, **kw):
550        return self.tk.call(
551                (self._w, 'marker', 'create', type) + self._options(kw))
552
553    def marker_delete(self, *args):
554        self.tk.call((self._w, 'marker', 'delete') + args)
555    def marker_exists(self, name):
556        return self.tk.getboolean(
557                self.tk.call(self._w, 'marker', 'exists', name))
558    def marker_names(self, *args):
559        return self.tk.splitlist(
560                self.tk.call((self._w, 'marker', 'names') + args))
561    def marker_type(self, name):
562        type = self.tk.call(self._w, 'marker', 'type', name)
563        if type == '':
564            type = None
565        return type
566
567#=============================================================================
568class Stripchart(Graph):
569    # Wrapper for the blt stripchart widget, version 2.4.
570
571    def __init__(self, master=None, cnf={}, **kw):
572        _loadBlt(master)
573        Tkinter.Widget.__init__(self, master, _chartCommand, cnf, kw)
574
575#=============================================================================
576class Tabset(Tkinter.Widget): 
577
578    # Wrapper for the blt TabSet widget, version 2.4.
579
580    def __init__(self, master=None, cnf={}, **kw):
581        _loadBlt(master)
582        Tkinter.Widget.__init__(self, master, _tabsetCommand, cnf, kw)
583
584    def activate(self, tabIndex):
585        self.tk.call(self._w, 'activate', tabIndex)
586
587    # This is the 'bind' sub-command:
588    def tag_bind(self, tagName, sequence=None, func=None, add=None):
589        return self._bind((self._w, 'bind', tagName), sequence, func, add)
590
591    def tag_unbind(self, tagName, sequence, funcid=None):
592        self.tk.call(self._w, 'bind', tagName, sequence, '')
593        if funcid:
594            self.deletecommand(funcid)
595
596    def delete(self, first, last = None):
597        self.tk.call(self._w, 'delete', first, last)
598
599    # This is the 'focus' sub-command:
600    def tab_focus(self, tabIndex):
601        self.tk.call(self._w, 'focus', tabIndex)
602       
603    def get(self, tabIndex):
604        return self.tk.call(self._w, 'get', tabIndex)
605
606    def index(self, tabIndex):
607        index = self.tk.call(self._w, 'index', tabIndex)
608        if index == '':
609            return None
610        else:
611            return self.tk.getint(self.tk.call(self._w, 'index', tabIndex))
612
613    def insert(self, position, name1, *names, **kw):
614        self.tk.call(
615            (self._w, 'insert', position, name1) + names + self._options(kw))
616
617    def invoke(self, tabIndex):
618        return self.tk.call(self._w, 'invoke', tabIndex)
619
620    def move(self, tabIndex1, beforeOrAfter, tabIndex2):
621        self.tk.call(self._w, 'move', tabIndex1, beforeOrAfter, tabIndex2)
622       
623    def nearest(self, x, y):
624        return self.tk.call(self._w, 'nearest', x, y)
625
626    def scan_mark(self, x, y):
627        self.tk.call(self._w, 'scan', 'mark', x, y)
628
629    def scan_dragto(self, x, y):
630        self.tk.call(self._w, 'scan', 'dragto', x, y)
631
632    def see(self, index):
633        self.tk.call(self._w, 'see', index)
634       
635    def see(self, tabIndex):
636        self.tk.call(self._w,'see',tabIndex)
637       
638    def size(self):
639        return self.tk.getint(self.tk.call(self._w, 'size'))
640
641    def tab_cget(self, tabIndex, option):
642        if option[:1] != '-':
643            option = '-' + option
644        if option[-1:] == '_':
645            option = option[:-1]
646        return self.tk.call(self._w, 'tab', 'cget', tabIndex, option)
647
648    def tab_configure(self, tabIndexes, option=None, **kw):
649        # <tabIndexes> may be a list of tabs.
650        if isinstance(tabIndexes, (basestring, int)):
651            tabIndexes = [tabIndexes]
652        subcommand = (self._w, 'tab', 'configure') + tuple(tabIndexes)
653        return _doConfigure(self, subcommand, option, kw)
654
655    def tab_names(self, *args):
656        return self.tk.splitlist(self.tk.call((self._w, 'tab', 'names') + args))
657
658    def tab_tearoff(self, tabIndex, newName = None):
659        if newName is None:
660            name = self.tk.call(self._w, 'tab', 'tearoff', tabIndex)
661            return self.nametowidget(name)
662        else:
663            self.tk.call(self._w, 'tab', 'tearoff', tabIndex, newName)
664
665    def view(self):
666        s = self.tk.call(self._w, 'view')
667        return tuple(map(self.tk.getint, self.tk.splitlist(s)))
668    def view_moveto(self, fraction):
669        self.tk.call(self._w, 'view', 'moveto', fraction)
670    def view_scroll(self, number, what):
671        self.tk.call(self._w, 'view', 'scroll', number, what)
Note: See TracBrowser for help on using the repository browser.