source: anuga_core/source/anuga/pmesh/PmwBlt.py @ 5421

Last change on this file since 5421 was 3491, checked in by duncan, 18 years ago

adding copyright info to pmw code

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