/usr/share/pyshared/pycocumalib/HistoryWidget.py is in pycocuma 0.4.5-6-7.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | """
Searchable Combobox for Contact Display Names
"""
# Copyright (C) 2004 Henning Jacobs <henning@srcco.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# $Id: HistoryWidget.py 89 2004-09-11 18:58:51Z henning $
from Tkinter import *
import Pmw
import InputWidgets
import ToolTip
import broadcaster
class HistoryWidget(Pmw.MegaWidget):
def __init__(self, parent = None, command = None, prevCommand = None, nextCommand = None, **kw):
# Define the megawidget options.
INITOPT = Pmw.INITOPT
optiondefs = (
('height', 16, INITOPT),
('width', 16, INITOPT),
('borderwidth', 2, INITOPT),
('padx', 0, INITOPT),
('pady', 0, INITOPT),
('sticky', 'ew', INITOPT),
)
self.defineoptions(kw, optiondefs)
Pmw.MegaWidget.__init__(self, parent)
frame = self.interior()
frame.grid(column=2,row=1, sticky=self['sticky'])
self.btnPrev = InputWidgets.ArrowButton(frame, direction='left', command = self.prev)
self.btnNext = InputWidgets.ArrowButton(frame, direction='right', command = self.next)
self.btnPrev.grid(column=0, row=0)
self.btnNext.grid(column=1, row=0)
self.btnPrev.configure(state='disabled')
self.btnNext.configure(state='disabled')
self.prevCommand = prevCommand or command
self.nextCommand = nextCommand or command
ToolTip.ToolTip(self.btnPrev, "Go back in history")
ToolTip.ToolTip(self.btnNext, "Go forward in history")
self._list = []
self._currIndex = 0
def addHistory(self, item):
# only add to history if not already present
if len(self._list)==0 or item != self._list[-1]:
self._list.append(item)
if len(self._list) > 1:
self._currIndex = len(self._list) - 1
self.btnPrev.configure(state='normal')
def prev(self):
if self._currIndex > 0:
self._currIndex -= 1
if self.prevCommand is not None:
self.prevCommand(self._list[self._currIndex])
self.btnNext.configure(state='normal')
if self._currIndex < 1:
self.btnPrev.configure(state='disabled')
def next(self):
if self._currIndex + 1 < len(self._list):
self._currIndex += 1
if self.nextCommand is not None:
self.nextCommand(self._list[self._currIndex])
self.btnPrev.configure(state='normal')
if self._currIndex+1 >= len(self._list):
self.btnNext.configure(state='disabled')
def getHistory(self):
return self._list
def configure(self, **kws):
if kws.has_key('state'):
self.btnPrev.configure(state=kws['state'])
self.btnNext.configure(state=kws['state'])
del kws['state']
Pmw.MegaWidget.configure(self, **kws)
|