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
|
"""
Display line is a mouse tool to display the line index of the line clicked, counting from one, and the line itself.
"""
from __future__ import absolute_import
#Init has to be imported first because it has code to workaround the python bug where relative imports don't work if the module is imported as a main module.
import __init__
__author__ = "Enrique Perez (perez_enrique@yahoo.com)"
__date__ = "$Date: 2008/21/04 $"
__license__ = "GPL 3.0"
class MouseToolBase:
"The mouse tool base class, which does nothing."
def button1( self, event ):
"The left button was clicked, <Button-1> function."
pass
def buttonRelease1( self, event ):
"The left button was released, <ButtonRelease-1> function."
pass
def destroyEverything( self ):
"Destroy items."
self.canvas.delete( 'mouse_item' )
def destroyEverythingGetFocus( self ):
"Destroy items and get the focus for the canvas."
self.destroyEverything()
self.canvas.focus_set()
def getReset( self, window ):
"Reset the mouse tool to default."
self.setWindowItems( window )
self.destroyEverything()
return self
def getTagsGivenXY( self, x, y ):
"Get the tag for the x and y."
tags = self.canvas.itemcget( self.canvas.find_closest( x, y ), 'tags' )
currentEnd = ' current'
if tags.find( currentEnd ) != - 1:
return tags[ : - len( currentEnd ) ]
return tags
def isSelectionTool( self ):
"Return if this mouse tool is a selection tool."
return False
def keyPressDown( self, event ):
"The down arrow was pressed."
pass
def keyPressLeft( self, event ):
"The left arrow was pressed."
pass
def keyPressReturn( self, event ):
"The return key was pressed."
pass
def keyPressRight( self, event ):
"The right arrow was pressed."
pass
def keyPressUp( self, event ):
"The up arrow was pressed."
pass
def motion( self, event, shift = False ):
"The mouse moved, <Motion> function."
pass
def setWindowItems( self, window ):
"Set the canvas and items."
self.canvas = window.canvas
self.repository = window.repository
self.window = window
def update( self ):
"Update the mouse tool."
pass
|