~ubuntu-branches/ubuntu/vivid/mago/vivid

« back to all changes in this revision

Viewing changes to mago/backend/pymouse/base.py

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2011-02-08 13:32:13 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110208133213-m1og7ey0m990chg6
Tags: 0.3+bzr20-0ubuntu1
* debian/rules:
  - updated to debhelper 7
  - use dh_python2 instead of python-central
* debian/pycompat:
  - removed, no longer needed
* debian/control:
  - dropped cdbs and python-central dependencies
* bzr snapshot of the current trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: iso-8859-1 -*-
2
 
 
3
 
#   Copyright 2010 Pepijn de Vos
4
 
#
5
 
#   Licensed under the Apache License, Version 2.0 (the "License");
6
 
#   you may not use this file except in compliance with the License.
7
 
#   You may obtain a copy of the License at
8
 
#
9
 
#       http://www.apache.org/licenses/LICENSE-2.0
10
 
#
11
 
#   Unless required by applicable law or agreed to in writing, software
12
 
#   distributed under the License is distributed on an "AS IS" BASIS,
13
 
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 
#   See the License for the specific language governing permissions and
15
 
#   limitations under the License.
16
 
 
17
 
"""The goal of PyMouse is to have a cross-platform way to control the mouse.
18
 
PyMouse should work on Windows, Mac and any Unix that has xlib.
19
 
 
20
 
See http://github.com/pepijndevos/PyMouse for more information.
21
 
"""
22
 
 
23
 
from threading import Thread
24
 
 
25
 
class PyMouseMeta(object):
26
 
 
27
 
    def press(self, x, y, button = 1):
28
 
        """Press the mouse on a givven x, y and button.
29
 
        Button is defined as 1 = left, 2 = right, 3 = middle."""
30
 
 
31
 
        raise NotImplementedError
32
 
 
33
 
    def release(self, x, y, button = 1):
34
 
        """Release the mouse on a givven x, y and button.
35
 
        Button is defined as 1 = left, 2 = right, 3 = middle."""
36
 
 
37
 
        raise NotImplementedError
38
 
 
39
 
    def click(self, x, y, button = 1):
40
 
        """Click the mouse on a givven x, y and button.
41
 
        Button is defined as 1 = left, 2 = right, 3 = middle."""
42
 
 
43
 
        self.press(x, y, button)
44
 
        self.release(x, y, button)
45
 
 
46
 
    def move(self, x, y):
47
 
        """Move the mouse to a givven x and y"""
48
 
 
49
 
        raise NotImplementedError
50
 
 
51
 
    def position(self):
52
 
        """Get the current mouse position in pixels.
53
 
        Returns a tuple of 2 integers"""
54
 
 
55
 
        raise NotImplementedError
56
 
 
57
 
    def screen_size(self):
58
 
        """Get the current screen size in pixels.
59
 
        Returns a tuple of 2 integers"""
60
 
 
61
 
        raise NotImplementedError
62
 
 
63
 
class PyMouseEventMeta(Thread):
64
 
    
65
 
    def __init__(self, capture=False):
66
 
        Thread.__init__(self)
67
 
        self.daemon = True
68
 
        self.capture = capture
69
 
        self.state = True
70
 
 
71
 
    def stop(self):
72
 
        self.state = False
73
 
 
74
 
    def click(self, x, y, button, press):
75
 
        """Subclass this method with your click event handler"""
76
 
 
77
 
        pass
78
 
 
79
 
    def move(self, x, y):
80
 
        """Subclass this method with your move event handler"""
81
 
 
82
 
        pass