[mousetrap] Pylint +10



commit 22e8c90f78414dc41db51b8cbfdcd3a8adcfc365
Author: Flavio Percoco Premoli <flaper87 gmail com>
Date:   Sun May 17 13:00:02 2009 +0200

    Pylint +10
---
 .gitignore                         |    2 +
 src/mousetrap/debug.py             |    7 +-
 src/mousetrap/lib/dbusd.py         |    5 +-
 src/mousetrap/lib/httpd.py         |   36 +++-
 src/mousetrap/lib/mouse.py         |   59 +++---
 src/mousetrap/lib/settings.py      |    4 +-
 src/mousetrap/mousetrap.py         |   18 ++-
 src/mousetrap/start                |    5 +-
 src/mousetrap/ui/dialogs.py        |  463 ++++++++++++++++++------------------
 src/mousetrap/ui/main.py           |  384 ++----------------------------
 src/mousetrap/ui/scripts/screen.py |   13 +-
 src/mousetrap/ui/settings_gui.py   |  100 ++++----
 src/mousetrap/ui/widgets.py        |   48 ++--
 src/ocvfw/_ocv.py                  |   44 ++--
 src/ocvfw/debug.py                 |   17 +-
 src/ocvfw/dev/camera.py            |    7 +-
 src/ocvfw/idm/forehead.py          |    3 +-
 src/ocvfw/pocv.py                  |    2 +-
 18 files changed, 470 insertions(+), 747 deletions(-)

diff --git a/.gitignore b/.gitignore
index 55dfbdb..a0eebaf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
 *.pyc
 prepare.sh
 .svn
+environment.py
+i18n.py
diff --git a/src/mousetrap/debug.py b/src/mousetrap/debug.py
index 0f0f0e0..5770641 100644
--- a/src/mousetrap/debug.py
+++ b/src/mousetrap/debug.py
@@ -26,9 +26,8 @@ __date__      = "$Date$"
 __copyright__ = "Copyright (c) 2008 Flavio Percoco Premoli"
 __license__   = "GPLv2"
 
-import sys
 import logging
-import traceback
+#import traceback
 
 modules = {}
 
@@ -40,8 +39,6 @@ def checkModule( module ):
     - module: The module requesting a logger.
     """
 
-    global modules
-
     level = logging.DEBUG
 
     formatter = logging.Formatter("%(levelname)s: %(name)s -> %(message)s")
@@ -178,7 +175,7 @@ def traceit(frame, event, arg):
            or name == "UserDict":
             return traceit
         line = linecache.getline(filename, lineno)
-        log(ALL, "Trace", "TRACE %s:%s: %s" % (name, lineno, line.rstrip()))
+        debug("ALL", "TRACE %s:%s: %s" % (name, lineno, line.rstrip()))
     return traceit
 
 #if debugLevel == EXTREME:
diff --git a/src/mousetrap/lib/dbusd.py b/src/mousetrap/lib/dbusd.py
index ee548a5..0a9c167 100755
--- a/src/mousetrap/lib/dbusd.py
+++ b/src/mousetrap/lib/dbusd.py
@@ -30,6 +30,7 @@ __license__   = "GPLv2"
 
 import dbus
 import dbus.service
+import mousetrap.debug as debug
 from dbus.mainloop.glib import DBusGMainLoop
 
 dbusserver = None
@@ -39,6 +40,9 @@ bus = dbus.SessionBus(mainloop=main_loop)
 DBUS_NAME = "org.gnome.mousetrap"
 DBUS_PATH = "/org/gnome/mousetrap"
 
+# pylint: disable-msg=R0923
+# Server: Interface not implemented
+
 class DbusServer(dbus.service.Object):
     """DBus service"""
 
@@ -51,7 +55,6 @@ class DbusServer(dbus.service.Object):
         - mouseTrap: The mouseTrap onject pointer
         """
 
-        global bus
         bus_name = dbus.service.BusName(DBUS_NAME, bus=bus)
         dbus.service.Object.__init__(self, bus_name, DBUS_PATH)
 
diff --git a/src/mousetrap/lib/httpd.py b/src/mousetrap/lib/httpd.py
index 0a07fc8..9d98d5a 100644
--- a/src/mousetrap/lib/httpd.py
+++ b/src/mousetrap/lib/httpd.py
@@ -28,9 +28,7 @@ __date__      = "$Date$"
 __copyright__ = "Copyright (c) 2008 Flavio Percoco Premoli"
 __license__   = "GPLv2"
 
-import threading
 import thread
-import gobject
 import BaseHTTPServer
 
 
@@ -52,12 +50,24 @@ class _HTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
         pass
 
     def do_GET(self):
+        """
+        Handles the GET requests
+
+        Arguments:
+        - self: The main object pointer.
+        """
         self.send_response(200)
         self.send_header("Content-type", "text/html")
         self.end_headers()
         self.wfile.write("<html><body><p>mouseTrap 0.1</p></body></html>")
 
     def do_POST(self):
+        """
+        Handles the POST requests
+
+        Arguments:
+        - self: The main object pointer.
+        """
         contentLength = self.headers.getheader('content-length')
         if contentLength:
             contentLength = int(contentLength)
@@ -75,6 +85,13 @@ class HttpdServer:
     """Runs a _HTTPRequestHandler in a separate thread."""
 
     def __init__( self, port ):
+        """
+        HttpdServer Init Class.
+
+        Arguments:
+        - self: The main object pointer.
+        - port: The port to use for the server.
+        """
         self.httpd     = None
         self.run       = True
         self.port      = port
@@ -83,6 +100,9 @@ class HttpdServer:
     def start(self):
         """
         Try to start an HTTP server on self.settings.httpPort
+
+        Arguments:
+        - self: The main object pointer.
         """
 
         while not self.connected:
@@ -98,9 +118,21 @@ class HttpdServer:
         thread.start_new_thread(self.__handler, ())
 
     def is_running(self):
+        """
+        Returns True if running
+
+        Arguments:
+        - self: The main object pointer.
+        """
         return self.connected
 
     def __handler( self ):
+        """
+        Http Server main loop. While running will handle new requests.
+
+        Arguments:
+        - self: The main object pointer.
+        """
         while self.run:
             self.httpd.handle_request()
 
diff --git a/src/mousetrap/lib/mouse.py b/src/mousetrap/lib/mouse.py
index d819008..0b4b0d7 100644
--- a/src/mousetrap/lib/mouse.py
+++ b/src/mousetrap/lib/mouse.py
@@ -28,6 +28,7 @@ __license__   = "GPLv2"
 
 import gtk
 import pyatspi
+import mousetrap.debug as debug
 import mousetrap.environment as env
 import Xlib.ext.xtest as xtest
 
@@ -52,7 +53,7 @@ xDisplay   = display.Display()
 isGnome = False
 if env.desktop == "gnome":
     isGnome = True
-    #debug.debug( "mousetrap.mouse", "GNOME desktop has been detected" )
+    debug.debug( "mousetrap.mouse", "GNOME desktop has been detected" )
 
     ## pyatspi registry for gnome users
     reg = pyatspi.Registry
@@ -100,8 +101,8 @@ def click( x = None, y = None, button = "bc1" ):
         except:
             isGnome = False
     else:
-        for click in clickType[button[2]]:
-            xDisplay.xtest_fake_input(click, int(button[1]), clickVal[click])
+        for action in clickType[button[2]]:
+            xDisplay.xtest_fake_input(action, int(button[1]), clickVal[action])
         xDisplay.flush()
 
     return True
@@ -132,29 +133,31 @@ def move( x=0, y=0, point=None ):
 
     return True
 
+###########################################
+#               DEPRECATED
 # Dictionary Dispatcher
-dsp = { "move"      : move,
-        "click"     : click,
-        "position"  : position }
-
-def handler( func ):
-    """
-    Mouse functions decorator.
-
-    Arguments:
-    - func: The function called to access the decorator.
-
-    Return The wrapper
-    """
-
-    def wrapper( *arg, **kw ):
-        """
-        Wrapper function.
-
-        This functions will execute the required function passing the arguments to it.
-
-        Return the function executed
-        """
-        return dsp[arg[0]]( *arg[1:], **kw )
-
-    return wrapper
+# dsp = { "move"      : move,
+#         "click"     : click,
+#         "position"  : position }
+#
+# def handler( func ):
+#     """
+#     Mouse functions decorator.
+#
+#     Arguments:
+#     - func: The function called to access the decorator.
+#
+#     Return The wrapper
+#     """
+#
+#     def wrapper( *arg, **kw ):
+#         """
+#         Wrapper function.
+#
+#         This functions will execute the required function passing the arguments to it.
+#
+#         Return the function executed
+#         """
+#         return dsp[arg[0]]( *arg[1:], **kw )
+#
+#     return wrapper
diff --git a/src/mousetrap/lib/settings.py b/src/mousetrap/lib/settings.py
index e9c5a38..b3767fb 100755
--- a/src/mousetrap/lib/settings.py
+++ b/src/mousetrap/lib/settings.py
@@ -31,7 +31,7 @@ import os
 import ConfigParser
 import mousetrap.environment as env
 
-class settings( ConfigParser.ConfigParser ):
+class Settings( ConfigParser.ConfigParser ):
 
     def optionxform( self, optionstr ):
         return optionstr
@@ -69,7 +69,7 @@ class settings( ConfigParser.ConfigParser ):
             conf.write("\nstepSpeed = 5")
 
 def load():
-    cfg = settings()
+    cfg = Settings()
     if not os.path.exists( env.configPath ):
         os.mkdir( env.configPath )
         cfg.write_first()
diff --git a/src/mousetrap/mousetrap.py b/src/mousetrap/mousetrap.py
index 1f3618f..5524b70 100644
--- a/src/mousetrap/mousetrap.py
+++ b/src/mousetrap/mousetrap.py
@@ -36,14 +36,16 @@ __license__   = "GPLv2"
 import sys
 sys.argv[0] = "mousetrap"
 
-import gtk
 import gobject
 from ocvfw import pocv
 from ui.main import MainGui
 from ui.scripts.screen import ScriptClass
-from lib import mouse, httpd, dbusd, settings
+from lib import httpd, dbusd, settings
 
 class Controller():
+    """
+    MouseTrap's Controller Class
+    """
 
     def __init__(self):
         """
@@ -101,9 +103,21 @@ class Controller():
         return ScriptClass()
 
     def update_frame(self):
+        """
+        Updates the User Interface frame with the latest capture.
+
+        Arguments:
+        - self: The main object pointer.
+        """
         self.itf.update_frame(self.idm.get_image(), self.idm.get_pointer())
         return True
 
     def update_pointers(self):
+        """
+        Gets the new mouse pointer position based on the las calcs.
+
+        Arguments:
+        - self: The main object pointer.
+        """
         self.itf.script.update_items(self.idm.get_pointer())
         return True
diff --git a/src/mousetrap/start b/src/mousetrap/start
index 6cfeadf..449d59e 100755
--- a/src/mousetrap/start
+++ b/src/mousetrap/start
@@ -21,5 +21,6 @@ getDesktop() {
 }
 
 getDesktop
-export PYTHONPATH=$PYTHONPATH:../
-/usr/bin/python -c "import mousetrap; mousetrap.Controller().start();" "$ARGS"
+export PYTHONPATH=/usr/lib/python2.6/site-packages:../
+cd ..
+/usr/bin/python -c "import mousetrap.mousetrap as mousetrap; mousetrap.Controller().start();" "$ARGS"
diff --git a/src/mousetrap/ui/dialogs.py b/src/mousetrap/ui/dialogs.py
index 58685e0..dfc494e 100755
--- a/src/mousetrap/ui/dialogs.py
+++ b/src/mousetrap/ui/dialogs.py
@@ -18,7 +18,7 @@
 # You should have received a copy of the GNU General Public License
 # along with mouseTrap.  If not, see <http://www.gnu.org/licenses/>.
 
-""" A group of formated dialogs functions used by mouseTrap. """
+""" A group of formated dialogs functions used by mousetrap. """
 
 __id__        = "$Id$"
 __version__   = "$Revision$"
@@ -27,10 +27,7 @@ __copyright__ = "Copyright (c) 2008 Flavio Percoco Premoli"
 __license__   = "GPLv2"
 
 import gtk
-import sys
-import time
 from i18n import _
-import mousetrap.environment as env
 
 def addLabelMessage( dialog, message ):
     """
@@ -156,13 +153,16 @@ def createDialog( title, parent, flags, buttons ):
     - buttons: A tuple with the gtk.Buttons to show. E.g: ( gtk.STOCK_OK, gtk.STOCK_CANCEL )
     """
 
+    # For some reason pylint says that a VBox doesn't have a set_spacing or pack_start member.
+    # pylint: disable-msg=E1101
+    # createDialog: Class 'vbox' has no 'set_spacing' member
+    # createDialog: Class 'vbox' has no 'pack_start' member
     dialog = gtk.Dialog( title, parent, flags, buttons )
     dialog.set_default_size(150, 100)
     dialog.set_position(gtk.WIN_POS_CENTER)
     dialog.set_border_width(8)
     dialog.vbox.set_spacing ( 4 )
 
-    #vbox = gtk.VBox(spacing=4)
     hbox = gtk.HBox(spacing=4)
 
     #bbox = gtk.HButtonBox()
@@ -170,6 +170,10 @@ def createDialog( title, parent, flags, buttons ):
     #bbox.set_layout(gtk.BUTTONBOX_END)
 
     dialog.vbox.pack_start(hbox, True, True)
+    # pylint: enable-msg=E1101
+    # createDialog: Class 'vbox' has no 'set_spacing' member
+    # createDialog: Class 'vbox' has no 'pack_start' member
+
     #vbox.pack_start(bbox, False)
 
     #dialog.add(vbox)
@@ -278,226 +282,231 @@ class IdmSettings(gtk.Window):
         hbox.show_all()
         return hbox
 
-class ClicksDialog( gtk.Window ):
-    """
-    A Class for the Click Dialog.
-
-    Arguments:
-    - gtk.Window: Window for the buttons.
-    """
-
-    def __init__( self, gui ):
-        """
-        Initialize the Clicks Dialog.
-
-        Arguments:
-        - self: The main object pointer.
-        - mouseTrap: The mouseTrap object pointer.
-        - cAm: The camera object pointer
-        """
-
-        gtk.Window.__init__( self )
-
-        self.gui = gui
-        self.mouseTrap = mouseTrap
-
-        self.set_property("skip-taskbar-hint", True)
-        self.set_keep_above( True )
-        self.set_size_request( 500 , 120)
-        self.set_default_size( 500 , 120)
-        self.width, self.height = self.get_default_size()
-
-        self.set_title(_('Clicks Panel'))
-
-        self.set_app_paintable(True)
-        #self.set_decorated(False)
-
-        self.buttons = []
-        self.blue  = '#1161d9'
-        self.green = '#60da11'
-        evtBox = gtk.EventBox()
-
-        buttonsBox = gtk.HBox( spacing = 6 )
-        buttonsBox.show_all()
-
-        self.leftClick = gtk.Button()
-        self.leftClick.add(self._newImageButton(_("Left Click"),
-                                                  "%s/images/leftClick.png" % env.mTDataDir))
-        self.leftClick.connect("clicked", self.executeClick, 'b1c')
-        self.leftClick.show()
-        self.buttons.append( self.leftClick )
-        buttonsBox.pack_start( self.leftClick )
-
-        self.doubleClick = gtk.Button()
-        self.doubleClick.add(self._newImageButton(_("Double Click"),
-                                                    "%s/images/doubleClick.png" % env.mTDataDir))
-        self.doubleClick.connect("clicked", self.executeClick, 'b1d')
-        self.doubleClick.show()
-        self.buttons.append( self.doubleClick )
-        buttonsBox.pack_start( self.doubleClick )
-
-        self.leftHold = gtk.Button()
-        self.leftHold.add(self._newImageButton(_("Drag/Drop Click"),
-                                                 "%s/images/leftHold.png" % env.mTDataDir))
-        self.leftHold.connect("clicked", self.executeClick, 'b1p')
-        self.leftHold.show()
-        self.buttons.append( self.leftHold )
-        buttonsBox.pack_start( self.leftHold )
-
-        #~ self.middleClick = gtk.Button()
-        #~ self.middleClick.add(self._newImageButton(_("Middle Click"), "%s/images/middleClick.png" % env.mTDataDir))
-        #~ self.middleClick.connect("clicked", self.executeClick, 'b2c')
-        #~ self.middleClick.show()
-        #~ self.buttons.append( self.middleClick )
-        #~ buttonsBox.pack_start( self.middleClick )
-
-        self.rightClick = gtk.Button()
-        self.rightClick.add(self._newImageButton(_("Right Click"),
-                                                   "%s/images/rightClick.png" % env.mTDataDir))
-        self.rightClick.connect("clicked", self.executeClick, 'b3c')
-        self.rightClick.show()
-        self.buttons.append( self.rightClick )
-        buttonsBox.pack_start( self.rightClick )
-
-        self.add( buttonsBox  )
-
-    def showPanel( self ):
-        """
-        Shows the panel
-
-        Arguments:
-        - self: The main object pointer.
-        """
-
-        X = Y = 0
-
-        poss = mouseTrap.mice( "position" )
-
-        # We'll change the click panel position to be sure that
-        # it won't appear under another window or worse under a
-        # popup menu.
-        if poss[0] in xrange( env.screen["width"]/2 ):
-            X = env.screen["width"] - self.width
-
-
-        if poss[1] in xrange( env.screen["height"]/2 ):
-            Y = env.screen["height"] - self.height
-
-
-        self.move(X, Y)
-
-        if self.get_focus():
-            self.buttons[ self.buttons.index(self.get_focus()) ].get_child().modify_bg( gtk.STATE_NORMAL,
-                                                                                        gtk.gdk.color_parse(self.blue))
-
-        self.set_focus(self.buttons[0])
-        self.buttons[0].get_child().modify_bg( gtk.STATE_NORMAL, gtk.gdk.color_parse(self.green))
-        self.show_all()
-
-        mouseTrap.setState( "clk-dialog" )
-
-    def hidePanel( self, *args ):
-        """
-        Hides the panel
-
-        Arguments:
-        - self: The main object pointer.
-        - args: The event arguments
-        """
-        self.hide()
-        mouseTrap.setState( "active" )
-
-    def pressButton( self, *args ):
-        """
-        Press the focused button
-
-        Arguments:
-        - self: The main object pointer.
-        - args: The event arguments
-        """
-
-        self.get_focus().clicked()
-
-    def prevBtn( self, *args ):
-        """
-        Move to the prev button
-
-        Arguments:
-        - self: The main object pointer.
-        - args: The event arguments
-        """
-
-        self.buttons[ self.buttons.index(self.get_focus()) ].get_child().modify_bg( gtk.STATE_NORMAL,
-                                                                                    gtk.gdk.color_parse(self.blue))
-        self.buttons[ self.buttons.index(self.get_focus()) - 1 ].grab_focus()
-        self.buttons[ self.buttons.index(self.get_focus()) ].get_child().modify_bg( gtk.STATE_NORMAL,
-                                                                                    gtk.gdk.color_parse(self.green))
-
-    def nextBtn( self, *args ):
-        """
-        Move to the next button
-
-        Arguments:
-        - self: The main object pointer.
-        - args: The event arguments
-        """
-
-        index = self.buttons.index(self.get_focus()) + 1
-        if index >= len(self.buttons):
-            index = 0
-        self.buttons[ index -1 ].get_child().modify_bg( gtk.STATE_NORMAL,
-                                                        gtk.gdk.color_parse(self.blue))
-        self.buttons[ index ].grab_focus()
-        self.buttons[ index ].get_child().modify_bg( gtk.STATE_NORMAL,
-                                                     gtk.gdk.color_parse(self.green))
-
-    def executeClick( self, widget, button ):
-        """
-        Execute the selected click
-
-        Arguments:
-        - self: The main object pointer.
-        - widget: The button clicked.
-        - button: The mouse button that should be pressed.
-        """
-
-        self.gui.clickDlgHandler( button )
-        self.hidePanel()
-
-    def _newImageButton( self, label, image ):
-        """
-        Creates an image button from an image file
-
-        Arguments:
-        - self: The main object pointer
-        - label: The buttons label
-        - image: The image path
-
-        Returns ButtonLabelBox A gtk.HBox that contains the new image stock button.
-        """
-        evt = gtk.EventBox()
-
-        buttonLabelBox = gtk.VBox()
-
-        im = gtk.Image()
-        im.set_from_file( image )
-        im.show
-
-        label = gtk.Label( label )
-        label.set_alignment( 0.0, 0.5 )
-        label.set_use_underline( True )
-
-        buttonLabelBox.pack_start( im )
-        buttonLabelBox.pack_start( label )
-        buttonLabelBox.show_all()
-
-        evt.add(buttonLabelBox)
-        evt.modify_bg( gtk.STATE_NORMAL, gtk.gdk.color_parse(self.blue))
-        evt.modify_bg( gtk.STATE_PRELIGHT, gtk.gdk.color_parse(self.green))
-        return evt
+###############################################
+#                                             #
+#    THE WHEEL HAS ALREADY BEEN DISCOVERED    #
+#     SO, LETS USE MOUSETWEAK INSTEAD OF      #
+#      ADD THIS SUPPORT TO MOUSETRAP.         #
+###############################################
+# class ClicksDialog( gtk.Window ):
+#     """
+#     A Class for the Click Dialog.
+#
+#     Arguments:
+#     - gtk.Window: Window for the buttons.
+#     """
+#
+#     def __init__( self, gui ):
+#         """
+#         Initialize the Clicks Dialog.
+#
+#         Arguments:
+#         - self: The main object pointer.
+#         - mouseTrap: The mouseTrap object pointer.
+#         - cAm: The camera object pointer
+#         """
+#
+#         gtk.Window.__init__( self )
+#
+#         self.gui = gui
+#
+#         self.set_property("skip-taskbar-hint", True)
+#         self.set_keep_above( True )
+#         self.set_size_request( 500 , 120)
+#         self.set_default_size( 500 , 120)
+#         self.width, self.height = self.get_default_size()
+#
+#         self.set_title(_('Clicks Panel'))
+#
+#         self.set_app_paintable(True)
+#         #self.set_decorated(False)
+#
+#         self.buttons = []
+#         self.blue  = '#1161d9'
+#         self.green = '#60da11'
+#         evtBox = gtk.EventBox()
+#
+#         buttonsBox = gtk.HBox( spacing = 6 )
+#         buttonsBox.show_all()
+#
+#         self.leftClick = gtk.Button()
+#         self.leftClick.add(self._newImageButton(_("Left Click"),
+#                                                   "%s/images/leftClick.png" % env.mTDataDir))
+#         self.leftClick.connect("clicked", self.executeClick, 'b1c')
+#         self.leftClick.show()
+#         self.buttons.append( self.leftClick )
+#         buttonsBox.pack_start( self.leftClick )
+#
+#         self.doubleClick = gtk.Button()
+#         self.doubleClick.add(self._newImageButton(_("Double Click"),
+#                                                     "%s/images/doubleClick.png" % env.mTDataDir))
+#         self.doubleClick.connect("clicked", self.executeClick, 'b1d')
+#         self.doubleClick.show()
+#         self.buttons.append( self.doubleClick )
+#         buttonsBox.pack_start( self.doubleClick )
+#
+#         self.leftHold = gtk.Button()
+#         self.leftHold.add(self._newImageButton(_("Drag/Drop Click"),
+#                                                  "%s/images/leftHold.png" % env.mTDataDir))
+#         self.leftHold.connect("clicked", self.executeClick, 'b1p')
+#         self.leftHold.show()
+#         self.buttons.append( self.leftHold )
+#         buttonsBox.pack_start( self.leftHold )
+#
+#         #~ self.middleClick = gtk.Button()
+#         #~ self.middleClick.add(self._newImageButton(_("Middle Click"), "%s/images/middleClick.png" % env.mTDataDir))
+#         #~ self.middleClick.connect("clicked", self.executeClick, 'b2c')
+#         #~ self.middleClick.show()
+#         #~ self.buttons.append( self.middleClick )
+#         #~ buttonsBox.pack_start( self.middleClick )
+#
+#         self.rightClick = gtk.Button()
+#         self.rightClick.add(self._newImageButton(_("Right Click"),
+#                                                    "%s/images/rightClick.png" % env.mTDataDir))
+#         self.rightClick.connect("clicked", self.executeClick, 'b3c')
+#         self.rightClick.show()
+#         self.buttons.append( self.rightClick )
+#         buttonsBox.pack_start( self.rightClick )
+#
+#         self.add( buttonsBox  )
+#
+#     def showPanel( self ):
+#         """
+#         Shows the panel
+#
+#         Arguments:
+#         - self: The main object pointer.
+#         """
+#
+#         X = Y = 0
+#
+#         poss = mouseTrap.mice( "position" )
+#
+#         # We'll change the click panel position to be sure that
+#         # it won't appear under another window or worse under a
+#         # popup menu.
+#         if poss[0] in xrange( env.screen["width"]/2 ):
+#             X = env.screen["width"] - self.width
+#
+#
+#         if poss[1] in xrange( env.screen["height"]/2 ):
+#             Y = env.screen["height"] - self.height
+#
+#
+#         self.move(X, Y)
+#
+#         if self.get_focus():
+#             self.buttons[ self.buttons.index(self.get_focus()) ].get_child().modify_bg( gtk.STATE_NORMAL,
+#                                                                                         gtk.gdk.color_parse(self.blue))
+#
+#         self.set_focus(self.buttons[0])
+#         self.buttons[0].get_child().modify_bg( gtk.STATE_NORMAL, gtk.gdk.color_parse(self.green))
+#         self.show_all()
+#
+#         mouseTrap.setState( "clk-dialog" )
+#
+#     def hidePanel( self, *args ):
+#         """
+#         Hides the panel
+#
+#         Arguments:
+#         - self: The main object pointer.
+#         - args: The event arguments
+#         """
+#         self.hide()
+#         mouseTrap.setState( "active" )
+#
+#     def pressButton( self, *args ):
+#         """
+#         Press the focused button
+#
+#         Arguments:
+#         - self: The main object pointer.
+#         - args: The event arguments
+#         """
+#
+#         self.get_focus().clicked()
+#
+#     def prevBtn( self, *args ):
+#         """
+#         Move to the prev button
+#
+#         Arguments:
+#         - self: The main object pointer.
+#         - args: The event arguments
+#         """
+#
+#         self.buttons[ self.buttons.index(self.get_focus()) ].get_child().modify_bg( gtk.STATE_NORMAL,
+#                                                                                     gtk.gdk.color_parse(self.blue))
+#         self.buttons[ self.buttons.index(self.get_focus()) - 1 ].grab_focus()
+#         self.buttons[ self.buttons.index(self.get_focus()) ].get_child().modify_bg( gtk.STATE_NORMAL,
+#                                                                                     gtk.gdk.color_parse(self.green))
+#
+#     def nextBtn( self, *args ):
+#         """
+#         Move to the next button
+#
+#         Arguments:
+#         - self: The main object pointer.
+#         - args: The event arguments
+#         """
+#
+#         index = self.buttons.index(self.get_focus()) + 1
+#         if index >= len(self.buttons):
+#             index = 0
+#         self.buttons[ index -1 ].get_child().modify_bg( gtk.STATE_NORMAL,
+#                                                         gtk.gdk.color_parse(self.blue))
+#         self.buttons[ index ].grab_focus()
+#         self.buttons[ index ].get_child().modify_bg( gtk.STATE_NORMAL,
+#                                                      gtk.gdk.color_parse(self.green))
+#
+#     def executeClick( self, widget, button ):
+#         """
+#         Execute the selected click
+#
+#         Arguments:
+#         - self: The main object pointer.
+#         - widget: The button clicked.
+#         - button: The mouse button that should be pressed.
+#         """
+#
+#         self.gui.clickDlgHandler( button )
+#         self.hidePanel()
+#
+#     def _newImageButton( self, label, image ):
+#         """
+#         Creates an image button from an image file
+#
+#         Arguments:
+#         - self: The main object pointer
+#         - label: The buttons label
+#         - image: The image path
+#
+#         Returns ButtonLabelBox A gtk.HBox that contains the new image stock button.
+#         """
+#         evt = gtk.EventBox()
+#
+#         buttonLabelBox = gtk.VBox()
+#
+#         im = gtk.Image()
+#         im.set_from_file( image )
+#         im.show
+#
+#         label = gtk.Label( label )
+#         label.set_alignment( 0.0, 0.5 )
+#         label.set_use_underline( True )
+#
+#         buttonLabelBox.pack_start( im )
+#         buttonLabelBox.pack_start( label )
+#         buttonLabelBox.show_all()
+#
+#         evt.add(buttonLabelBox)
+#         evt.modify_bg( gtk.STATE_NORMAL, gtk.gdk.color_parse(self.blue))
+#         evt.modify_bg( gtk.STATE_PRELIGHT, gtk.gdk.color_parse(self.green))
+#         return evt
 
 
-class cairoTransGui( gtk.Window ):
+class CairoTransGui( gtk.Window ):
 
     def __init__( self, message ):
         gtk.Window.__init__(self)
@@ -526,10 +535,10 @@ class cairoTransGui( gtk.Window ):
         cr.set_operator(1)
         cr.paint()
 
-        cr.set_source_rgba (255.0, 255.0, 255.0, 100.0);
-        cr.set_font_size (50);
-        cr.move_to (0,70);
-        cr.show_text (self.message);
+        cr.set_source_rgba (255.0, 255.0, 255.0, 100.0)
+        cr.set_font_size (50)
+        cr.move_to (0, 70)
+        cr.show_text (self.message)
         cr.fill()
         cr.stroke()
         return False
diff --git a/src/mousetrap/ui/main.py b/src/mousetrap/ui/main.py
index 435af0c..3e45955 100644
--- a/src/mousetrap/ui/main.py
+++ b/src/mousetrap/ui/main.py
@@ -28,9 +28,10 @@ __copyright__ = "Copyright (c) 2008 Flavio Percoco Premoli"
 __license__   = "GPLv2"
 
 import gtk
+import dialogs
 import settings_gui
-from math import pi
-
+import mousetrap.debug as debug
+import mousetrap.environment as env
 
 class MainGui( gtk.Window ):
     """
@@ -102,7 +103,7 @@ class MainGui( gtk.Window ):
         self.buttonsBox.pack_start( self.closeButton, True, True )
 
         self.helpButton = gtk.Button(stock=gtk.STOCK_HELP)
-        #self.helpButton.connect("clicked", self._loadHelp)
+        self.helpButton.connect("clicked", self._loadHelp)
         self.buttonsBox.pack_start( self.helpButton, True, True )
 
         self.vBox.pack_start( self.buttonsBox, False, False )
@@ -186,25 +187,7 @@ class MainGui( gtk.Window ):
 #
 #         mouseTrap.calcPoint()
 #
-#     def updateView( self, img ):
-#         """
-#         Updates the GUI widgets (Image, Mapper)
-#
-#         Arguments:
-#         - self: The main object pointer.
-#         """
-#
-#         self.mapper.updateView()
-#
-#         cv.cvResize( img, self.image, cv.CV_INTER_AREA )
-#
-#         buff = gtk.gdk.pixbuf_new_from_data( self.image.imageData, gtk.gdk.COLORSPACE_RGB, \
-#                                         False, 8, int(self.image.width), int(self.image.height), \
-#                                         self.image.widthStep )
-#
-#         #sets new pixbuf
-#         self.capture.set_from_pixbuf(buff)
-#
+
     def _newStockImageButton( self, label, stock ):
         """
         Creates an image button from gtk's stock.
@@ -241,363 +224,36 @@ class MainGui( gtk.Window ):
         """
 
         settings_gui.showPreffGui(self.ctr)
-#
-#     def clickDlgHandler( self, button = False ):
-#         """
-#         Process the Events related to the click panel.
-#
-#         Arguments:
-#         - self: The main object pointer.
-#         - button: the button click to perform if not false.
-#         """
-#
-#         poss = mouseTrap.mice( "position" )
-#
-#         if button:
-#             self.clickDialog.hide()
-#             mouseTrap.mice("click", poss[0], poss[1], button )
-#             return
-#
-#         if not self.clickDialog.props.visible:
-#             self.clickDialog.showPanel()
-#             return
-#
-#     def _loadHelp( self, *args ):
-#         """
-#         Shows the user manual.
-#
-#         Arguments:
-#         - self: The main object pointer.
-#         - *args: The widget callback arguments.
-#         """
-#
-#         try:
-#             import gnome
-#             gnome.help_display_uri("ghelp:%s/docs/mousetrap.xml" % env.mTDataDir)
-#         except ImportError:
-#             dialogs.errorDialog(
-#             "mouseTrap needs <b>gnome</b> module to show the help. Please install gnome-python and try again.", None )
-#             debug.exception( "mainGui", "The help load failed" )
 
-    def close( self, *args ):
-        """
-        Close Function for the quit button. This will kill mouseTrap.
 
-        Arguments:
-        - self: The main object pointer.
-        - *args: The widget callback arguments.
+    def _loadHelp( self, *args ):
         """
-        exit()
-        #self.mTp.quit(0)
-
-
-class CoordsGui(gtk.DrawingArea):
-    """
-    A Class for the Point Mapper and its functions.
-
-    Arguments:
-    - gtk.DrawingArea: Widget where the mapper will be drawed
-    """
-
-    def __init__( self ):
-        """
-        Initialize the Point Mapper.
+        Shows the user manual.
 
         Arguments:
         - self: The main object pointer.
-        - mouseTrap: The mouseTrap object pointer.
-        - cAm: The camera object pointer
-        """
-
-        gtk.DrawingArea.__init__(self)
-
-        self.areas    = []
-        self.axis     = False
-        self.context  = None
-        self.set_size_request(200, 160)
-        self.add_events( gtk.gdk.BUTTON_PRESS_MASK |
-                         gtk.gdk.BUTTON_RELEASE_MASK |
-                         gtk.gdk.BUTTON1_MOTION_MASK )
-
-        self.triggers = []
-
-        self.connect("expose_event", self.expose)
-
-        #Desplazamiento
-        self.desp = 0
-
-        self.pointer = [ 0, 0 ]
-
-        self.connect("motion_notify_event", self.motion_notify_event)
-#
-#     def registerArea( self, area ):
-#         """
-#         Registers a new area.
-#
-#         Arguments:
-#         - self: The main object pointer.
-#         - area: The area to register
-#         """
-#         self.areas.append( area )
-#
-#     def registerTrigger( self, X, Y, size, callback, *args, **kwds ):
-#         """
-#         Registers a new trigger.
-#
-#         Arguments:
-#         - self: The main object pointer.
-#         - X: The X possition.
-#         - Y: The Y possition.
-#         - size: The trigger point size.
-#         - callback: The callback function
-#         - *args: Extra arguments to pass to the callback function.
-#         - **kwds: Extra keywords to pass to the callback function.
-#         """
-#         self.triggers.append( { "X" : X, "Y" : Y, "size" : size } )
-#
-#         events.registerTrigger( {  "X" : X, "Y" : Y, "size" : size, "last" : 0,
-#                                    "callback" : callback, "args" : args, "kwds" : kwds })
-#
-    def motion_notify_event(self, *args):
-        print("PASA")
-
-    def draw_rectangle( self, x, y, width, height, color ):
-        """
-        Draws a rectangle in the DrawingArea.
-
-        Arguments:
-        - context: The Cairo Context.
-        - initX: The initial X possition.
-        - initY: The initial Y possition.
-        - width: The rectangle width.
-        - height: The rectangle height.
-        - color: An RGB color tuple. E.g: ( 255, 255, 255 )
+        - *args: The widget callback arguments.
         """
 
-        r, g, b = color
-        self.context.set_source_rgb(r, g, b)
-        self.context.rectangle( x, y, width, height)
-        self.context.stroke()
+        try:
+            import gnome
+            gnome.help_display_uri("ghelp:%s/docs/mousetrap.xml" % env.mTDataDir)
+        except ImportError:
+            dialogs.errorDialog(
+            "mouseTrap needs <b>gnome</b> module to show the help. Please install gnome-python and try again.", None )
+            debug.exception( "mainGui", "The help load failed" )
 
-        return True
-#
-#     def updateView( self ):
-#         """
-#         Updates the Point Mapper view using the expose_event
-#
-#         Arguments:
-#         - self: The main object pointer.
-#         """
-#
-#         self.queue_draw()
-#         return True
-#
-    def expose( self, widget, event ):
+    def close( self, *args ):
         """
-        Draws in the Point Mapper calling the functions that will
-        draw the plane and point.
+        Close Function for the quit button. This will kill mouseTrap.
 
         Arguments:
         - self: The main object pointer.
-        - widget: The Drawing area.
-        - event: The event information.
+        - *args: The widget callback arguments.
         """
+        exit()
+        #self.mTp.quit(0)
 
-        self.context = self.window.cairo_create()
-        self.context.rectangle(event.area.x, event.area.y,
-                               event.area.width, event.area.height)
-        self.context.clip()
-
-        self.draw_rectangle( 4, 5, 100, 100, (255,255,255) )
-        return True
-
-#
-#         if "clk-dialog" in mouseTrap.getState():
-#             self.dialogMapper()
-#             return True
-#
-# 	if self.axis:
-# 	    self.drawAxis()
-#
-#         self.drawAreas()
-#         self.drawTriggers()
-#
-#         pointer = mouseTrap.getModVar( "cam", "mpPointer" )
-#
-#         if pointer:
-#             self.drawPoint( pointer.x, pointer.y, 4 )
-#
-#         return True
-#
-#     def drawTriggers( self ):
-#         """
-#         Draws the registered triggers.
-#
-#         Arguments:
-#         - self: The main object pointer.
-#         """
-#         for trigger in self.triggers:
-#
-#             color = "orange"
-#
-#             if self.pointer[0] in xrange( trigger["X"] - 2, trigger["X"] + 2 ) \
-#                    and self.pointer[1] in xrange( trigger["Y"] - 2, trigger["Y"] + 2 ):
-#                 color = "blue"
-#
-#             self.drawPoint( trigger["X"], trigger["Y"], trigger["size"], color )
-#
-#     def drawAreas( self ):
-#         """
-# 	Draws the areas and the parts requested ( Corner's Points, Axis)
-#
-#         Arguments:
-#         - self: The main object pointer.
-# 	"""
-#         for area in self.areas:
-#             self.drawRectangle( self.context,  area.xInit, area.yInit,
-#                                 area.width, area.height, (0, 0, 102))
-# 	    if area.drawCorners:
-# 		self.drawCorners( area )
-#
-#
-#     def drawAxis( self ):
-# 	"""
-# 	Draws the axis of the plane
-#
-# 	Arguments:
-# 	- self: The main object pointer
-# 	"""
-#
-#         self.drawLine( self.context, 100, 0, 100, 160, (255, 255, 255))
-#
-#         self.drawLine( self.context, 0, 80, 200, 80, (255, 255, 255))
-#
-#     def drawCorners( self, area):
-# 	"""
-# 	Draw the corner's points for the given area.
-#
-# 	Arguments:
-# 	- self: The main object pointer.
-# 	- area: The area requesting the corners
-# 	"""
-#
-#         self.drawPoint( area.xInit, area.yInit, 3, "orange")
-#
-#         self.drawPoint( area.xEnd, area.yEnd, 3, "orange" )
-#
-#         self.drawPoint( area.xEnd, area.yInit, 3, "orange" )
-#
-#         self.drawPoint( area.xInit, area.yEnd, 3, "orange" )
-#
-#     def drawPoint(self, X, Y, size, color = 'green'):
-#         """
-#         Draws the point
-#
-#         Arguments:
-#         - self: The main object pointer.
-#         - X: The X possition.
-#         - Y: The Y possition
-#         - size: The point diameter.
-#         - color: A RGB color tuple. E.g (255,255,255)
-#         """
-#
-#         self.pointer = [ X, Y ]
-#         self.context.move_to( X, Y)
-#         self.context.arc(X, Y, size, 0, 2 * pi)
-#
-#         if color == 'green':
-#             self.context.set_source_rgb(0.7, 0.8, 0.1)
-#         elif color == 'blue':
-#             self.context.set_source_rgb(0.5, 0.65, 12)
-#         else:
-#             self.context.set_source_rgb(10, 0.8, 0.1)
-#
-#         self.context.fill_preserve()
-#         self.context.stroke()
-#         return True
-#
-#     def drawLine( self, ctx, x1, y1, x2, y2, color ):
-#         """
-#         Draws a Line
-#
-#         Arguments:
-#         - self:  The main object pointer.
-#         - ctx:   The Cairo Context.
-#         - x1:    The Starting X coord.
-#         - y1:    The Starting Y coord.
-#         - x2:    The Ending X coord.
-#         - y2:    The Ending Y coord.
-#         - color: The line color.
-#         """
-#
-#         ctx.move_to( x1, y1 )
-#         ctx.line_to( x2, y2 )
-#         ctx.set_line_width( 1.0 )
-#         ctx.set_source_rgb( color[0], color[1], color[2])
-#         ctx.stroke()
-#         return True
-#
-#     def dialogMapper( self ):
-#
-#         reqLim = 10
-#
-#         self.context.set_font_size( 20 )
-#         self.context.set_source_rgb( 255, 255, 255 )
-#
-#         self.drawRectangle( self.context, 100 - reqLim, 80 - reqLim, reqLim*2, reqLim*2, (255,255,255))
-#
-# class MapperArea:
-#
-#     def __init__( self ):
-#
-#         self.xInit = None
-#         self.yInit = None
-#         self.xEnd  = None
-#         self.yEnd  = None
-#         self.width = None
-#         self.height = None
-# 	self.drawCorners = False
-#
-#         self.events = None
-#
-#         self.events    = { "point-move" : [],
-#                       "top-left-corner" : [],
-#                      "top-right-corner" : [],
-#                    "bottom-left-corner" : [],
-#                   "bottom-right-corner" : [] }
-#
-#
-#         self.eventTypes = [ "point-move",
-#                    "top-left-corner",
-#                    "top-right-corner",
-#                    "bottom-left-corner",
-#                    "bottom-right-corner" ]
-#
-#     def area( self, xInit, yInit, xEnd, yEnd, corners = False ):
-#
-#         if not int(xInit) or not int(yInit) or not int(xEnd) or not int(yEnd):
-#             debug.error( "mainGui", "All arguments must be INT" )
-#
-#         self.xInit = xInit
-#         self.yInit = yInit
-#         self.xEnd  = xEnd
-#         self.yEnd  = yEnd
-#
-#         self.width  = xEnd - xInit
-#         self.height = yEnd - yInit
-# 	self.drawCorners = corners
-#
-#     def connect( self, eventType, callback, state = "active",*args, **kwds ):
-#
-#         self.events[ eventType ].append( { "callback" : callback,
-#                                            "state"    : state,
-#                                            "args"     : args,
-#                                            "kwds"     : kwds } )
-#
-#         events.registerArea( self )
-#
-#
-#
 def showMainGui( ):
     """
     Loads the mainGUI components and launch it.
diff --git a/src/mousetrap/ui/scripts/screen.py b/src/mousetrap/ui/scripts/screen.py
index 7f391f8..470ef5a 100644
--- a/src/mousetrap/ui/scripts/screen.py
+++ b/src/mousetrap/ui/scripts/screen.py
@@ -27,10 +27,12 @@ __date__      = "$Date$"
 __copyright__ = "Copyright (c) 2008 Flavio Percoco Premoli"
 __license__   = "GPLv2"
 
-import gtk
-import time
 import mousetrap.environment as env
 import mousetrap.lib.mouse as mouse
+
+# pylint: disable-msg=F0401
+# Unable to import 'widgets' (No module named widgets)
+# Widgets is in the parent folder
 from ..widgets import Mapper
 
 # The name given for the config file
@@ -40,6 +42,9 @@ setName = "screen"
 modes = { "screen|abs"  :  "Mouse Absolute Movements",
           "screen|rel"  :  "Mouse Relative Movements"}
 
+# We get too many E1101 messages, but We know what we're doing.
+# Mapper does have those methods.
+# pylint: disable-msg=E1101
 class ScriptClass(Mapper):
 
     def __init__(self):
@@ -54,10 +59,6 @@ class ScriptClass(Mapper):
         self.point = point
         self.calc_move()
         self.queue_draw()
-        try:
-            pass
-        except:
-            pass
 
     def expose_event(self, widget, event):
         self.width, self.height = self.allocation[2], self.allocation[3]
diff --git a/src/mousetrap/ui/settings_gui.py b/src/mousetrap/ui/settings_gui.py
index e5a3b3f..3c62925 100755
--- a/src/mousetrap/ui/settings_gui.py
+++ b/src/mousetrap/ui/settings_gui.py
@@ -28,13 +28,12 @@ __copyright__ = "Copyright (c) 2008 Flavio Percoco Premoli"
 __license__   = "GPLv2"
 
 import gtk
-import sys
 import dialogs
 from i18n import _
 from ocvfw import pocv
 import mousetrap.environment as env
 
-class preffGui( gtk.Window ):
+class PreffGui( gtk.Window ):
     """
     The Class for the preferences GUI.
 
@@ -57,7 +56,7 @@ class preffGui( gtk.Window ):
         self.cfg = self.ctr.cfg
         self.preffWidgets = dict()
 
-    def _SetWindowsIcon( self ):
+    def setWindowsIcon( self ):
         """
         Sets the icon for the preffGUI.
 
@@ -73,7 +72,7 @@ class preffGui( gtk.Window ):
 
         gtk.window_set_default_icon(icon)
 
-    def _buildInterface( self ):
+    def buildInterface( self ):
         """
         Builds the preffGUI.
 
@@ -90,12 +89,12 @@ class preffGui( gtk.Window ):
         self.set_size_request( 600 , 400)
         self.connect( "destroy", self.close)
 
-        self.Table = gtk.Table( 3, 6, False )
+        self.table = gtk.Table( 3, 6, False )
 
-        self.NoteBook = gtk.Notebook()
-        self.NoteBook.set_tab_pos( gtk.POS_TOP )
-        self.Table.attach( self.NoteBook, 0, 6, 0, 1 )
-        self.NoteBook.show()
+        self.noteBook = gtk.Notebook()
+        self.noteBook.set_tab_pos( gtk.POS_TOP )
+        self.table.attach( self.noteBook, 0, 6, 0, 1 )
+        self.noteBook.show()
 
         self.main_gui_tab()
         self.cam_tab()
@@ -106,25 +105,25 @@ class preffGui( gtk.Window ):
         ####################
         # Bottom's buttons #
         ####################
-        self.ButtonsBox = gtk.HBox( False, spacing=6 )
+        self.buttonsBox = gtk.HBox( False, spacing=6 )
 
-        self.AcceptButton = gtk.Button( _("Accept"), stock=gtk.STOCK_OK)
-        self.AcceptButton.connect("clicked", self.acceptButtonClick )
-        self.ButtonsBox.pack_end( self.AcceptButton )
+        self.acceptButton = gtk.Button( _("Accept"), stock=gtk.STOCK_OK)
+        self.acceptButton.connect("clicked", self.acceptButtonClick )
+        self.buttonsBox.pack_end( self.acceptButton )
 
-        CancelButton = gtk.Button( _("Accept"), stock=gtk.STOCK_CANCEL )
-        CancelButton.connect("clicked", self.close )
-        self.ButtonsBox.pack_end( CancelButton)
+        cancelButton = gtk.Button( _("Accept"), stock=gtk.STOCK_CANCEL )
+        cancelButton.connect("clicked", self.close )
+        self.buttonsBox.pack_end( cancelButton)
 
-        self.ApplyButton = gtk.Button( _("Accept"), stock=gtk.STOCK_APPLY )
-        self.ApplyButton.connect( "clicked", self.applyButtonClick )
-        self.ButtonsBox.pack_end( self.ApplyButton )
+        self.applyButton = gtk.Button( _("Accept"), stock=gtk.STOCK_APPLY )
+        self.applyButton.connect( "clicked", self.applyButtonClick )
+        self.buttonsBox.pack_end( self.applyButton )
 
-        self.ButtonsBox.show_all()
+        self.buttonsBox.show_all()
 
-        self.Table.attach(self.ButtonsBox, 1, 2, 2, 3, 'fill', False)
-        self.Table.show()
-        self.add( self.Table )
+        self.table.attach(self.buttonsBox, 1, 2, 2, 3, 'fill', False)
+        self.table.show()
+        self.add( self.table )
         self.show()
 
     def main_gui_tab( self ):
@@ -135,7 +134,7 @@ class preffGui( gtk.Window ):
         - self: The main object pointer.
         """
 
-        Frame = gtk.Frame()
+        frame = gtk.Frame()
 
         general_box = gtk.VBox( spacing = 6 )
 
@@ -157,15 +156,16 @@ class preffGui( gtk.Window ):
 
         general_box.pack_start( flipImage, False, False )
 
-        inputDevIndex = self.addSpin( _("Input Video Device Index: "), "inputDevIndex", self.cfg.getint( "cam", "inputDevIndex" ), "cam", "inputDevIndex", 0)
+        inputDevIndex = self.addSpin( _("Input Video Device Index: "), "inputDevIndex",
+                        self.cfg.getint( "cam", "inputDevIndex" ), "cam", "inputDevIndex", 0)
         general_box.pack_start( inputDevIndex, False, False )
 
         general_box.show_all()
 
-        Frame.add( general_box )
-        Frame.show()
+        frame.add( general_box )
+        frame.show()
 
-        self.NoteBook.insert_page(Frame, gtk.Label( _("General") ) )
+        self.noteBook.insert_page(frame, gtk.Label( _("General") ) )
 
     def cam_tab( self ):
         """
@@ -175,7 +175,7 @@ class preffGui( gtk.Window ):
         - self: The main object pointer.
         """
 
-        Frame = gtk.Frame()
+        frame = gtk.Frame()
 
         camBox = gtk.VBox( spacing = 6 )
 
@@ -193,10 +193,10 @@ class preffGui( gtk.Window ):
 
         camBox.show_all()
 
-        Frame.add( camBox )
-        Frame.show()
+        frame.add( camBox )
+        frame.show()
 
-        self.NoteBook.insert_page(Frame, gtk.Label( _("Camera") ) )
+        self.noteBook.insert_page(frame, gtk.Label( _("Camera") ) )
 
     def algorithm_tab( self ):
         """
@@ -206,7 +206,7 @@ class preffGui( gtk.Window ):
         - self: The main object pointer.
         """
 
-        Frame = gtk.Frame()
+        frame = gtk.Frame()
 
         algo_box = gtk.VBox( spacing = 6 )
 
@@ -260,10 +260,10 @@ class preffGui( gtk.Window ):
 
         algo_box.show_all()
 
-        Frame.add( algo_box )
-        Frame.show()
+        frame.add( algo_box )
+        frame.show()
 
-        self.NoteBook.insert_page(Frame, gtk.Label( _("Algorithm") ) )
+        self.noteBook.insert_page(frame, gtk.Label( _("Algorithm") ) )
 
     def mouseTab( self ):
         """
@@ -273,7 +273,7 @@ class preffGui( gtk.Window ):
         - self: The main object pointer.
         """
 
-        Frame = gtk.Frame()
+        frame = gtk.Frame()
 
         camBox = gtk.VBox( spacing = 6 )
 
@@ -287,7 +287,7 @@ class preffGui( gtk.Window ):
         #      ADD THIS SUPPORT TO MOUSETRAP.         #
         ###############################################
 
-#         defClickF = gtk.Frame( _( "Default Click:" ) )
+#         defClickF = gtk.frame( _( "Default Click:" ) )
 #
 #         defClicks = {  "b1c"   :  _("Left Click"),
 #                        "b1d"   :  _("Double Click"),
@@ -315,10 +315,10 @@ class preffGui( gtk.Window ):
 
         camBox.show_all()
 
-        Frame.add( camBox )
-        Frame.show()
+        frame.add( camBox )
+        frame.show()
 
-        self.NoteBook.insert_page(Frame, gtk.Label( _("Mouse") ) )
+        self.noteBook.insert_page(frame, gtk.Label( _("Mouse") ) )
 
     def debug_tab( self ):
         """
@@ -329,7 +329,7 @@ class preffGui( gtk.Window ):
         """
 
 
-        Frame = gtk.Frame()
+        frame = gtk.Frame()
 
         debugBox = gtk.VBox( spacing = 6 )
 
@@ -350,10 +350,10 @@ class preffGui( gtk.Window ):
 
         debugBox.show_all()
 
-        Frame.add( debugBox )
-        Frame.show()
+        frame.add( debugBox )
+        frame.show()
 
-        self.NoteBook.insert_page(Frame, gtk.Label( _("Debug") ) )
+        self.noteBook.insert_page(frame, gtk.Label( _("Debug") ) )
 
 
     def show_alg_pref(self, widget, liststore):
@@ -466,7 +466,7 @@ class preffGui( gtk.Window ):
         index = widget.get_active()
         self.cfg.set( section, option, modes[model[index][0]] )
 
-    def addSpin( self, label, var, startValue, section, option, min = 1, max = 15):
+    def addSpin( self, label, var, startValue, section, option, min_ = 1, max_ = 15):
         """
         Creates a new spin button inside a HBox and return it.
 
@@ -484,7 +484,7 @@ class preffGui( gtk.Window ):
         spinLbl.show()
         spinHbox.pack_start( spinLbl, False, False )
 
-        adj = gtk.Adjustment( startValue, min, max, 1, 1, 0)
+        adj = gtk.Adjustment( startValue, min_, max_, 1, 1, 0)
         spinButton = gtk.SpinButton( adj, 0.0, 0 )
         spinButton.set_wrap( True )
         spinButton.connect( "value-changed", self._spinChanged, section, option )
@@ -513,6 +513,6 @@ def showPreffGui(controller):
     - mouseTrap: The mouseTrap object pointer.
     """
 
-    GUI = preffGui(controller)
-    GUI._SetWindowsIcon()
-    GUI._buildInterface()
+    gui = PreffGui(controller)
+    gui.setWindowsIcon()
+    gui.buildInterface()
diff --git a/src/mousetrap/ui/widgets.py b/src/mousetrap/ui/widgets.py
index f6955ec..cf4ca52 100644
--- a/src/mousetrap/ui/widgets.py
+++ b/src/mousetrap/ui/widgets.py
@@ -27,9 +27,7 @@ __date__      = "$Date$"
 __copyright__ = "Copyright (c) 2008 Flavio Percoco Premoli"
 __license__   = "GPLv2"
 
-import sys
 import gtk
-import pango
 import cairo
 import gobject
 from gtk import gdk
@@ -52,11 +50,18 @@ class Mapper(gtk.Widget):
 #         self._layout = self.create_pango_layout(text)
 #         self._layout.set_font_description(pango.FontDescription("Sans Serif 16"))
 
-    # GtkWidget
     def do_realize(self):
-        """Called when the widget should create all of its
+        """
+        Called when the widget should create all of its
         windowing resources.  We will create our gtk.gdk.Window
-        and load our star pixmap."""
+        and load our star pixmap.
+        """
+
+        # For some reason pylint says that a VBox doesn't have a set_spacing or pack_start member.
+        # pylint: disable-msg=E1101
+        # Mapper.do_realize: Class 'style' has no 'attach' member
+        # Mapper.do_realize: Class 'style' has no 'set_background' member
+        # Mapper.do_realize: Class 'style' has no 'fg_gc' member
 
         # First set an internal flag telling that we're realized
         self.set_flags(self.flags() | gtk.REALIZED)
@@ -93,6 +98,7 @@ class Mapper(gtk.Widget):
         # an array or graphic contexts used for drawing the forground
         # colours
         self.gc = self.style.fg_gc[gtk.STATE_NORMAL]
+        # pylint: enable-msg=E1101
 
         #self.connect("motion_notify_event", self.motion_notify_event)
 
@@ -119,10 +125,17 @@ class Mapper(gtk.Widget):
 
         # If we're realized, move and resize the window to the
         # requested coordinates/positions
+        # pylint: disable-msg=W0142
+        # Mapper.do_size_allocate: Used * or ** magic
+        # WE DO NEED THE *
         if self.flags() & gtk.REALIZED:
             self.window.move_resize(*allocation)
+        # pylint: enable-msg=W0142
 
     def expose_event(self, widget, event):
+        """
+        Mapper expose event.
+        """
         # The do_expose_event is called when the widget is asked to draw itself
         # Remember that this will be called a lot of times, so it's usually
         # a good idea to write this code as optimized as it can be, don't
@@ -151,7 +164,7 @@ class Mapper(gtk.Widget):
 #                             5.0)
         return True
 
-        # And draw the text in the middle of the allocated space
+#         And draw the text in the middle of the allocated space
 #         fontw, fonth = self._layout.get_pixel_size()
 #         cr.move_to((w - fontw)/2, (h - fonth)/2)
 #         cr.update_layout(self._layout)
@@ -159,10 +172,12 @@ class Mapper(gtk.Widget):
 
     def draw_rectangle(self, x, y, width, height, color, line):
         """
+        A Method to draw rectangles.
         """
+
         cr = self.window.cairo_create()
         cr.set_source_color(color)
-        cr.rectangle(x, y,width, height)
+        cr.rectangle(x, y, width, height)
         cr.set_line_width(line)
         cr.set_line_join(cairo.LINE_JOIN_ROUND)
         cr.stroke()
@@ -187,18 +202,6 @@ class Mapper(gtk.Widget):
 
         return True
 
-    def on_expose_show(self, area):
-        """
-        Here are registered the areas that should be shown by the expose event.
-
-        Argumnets:
-        - self: The main object pointer.
-        """
-        if area not in AV_AREAS:
-            return False
-
-#         self.on_expose_areas[]
-
     def connect_point_event(self, event, x, y, width, height, callback):
         """
         Connects a new event in the spesified areas.
@@ -216,9 +219,10 @@ class Mapper(gtk.Widget):
         if event not in self.events:
             return False
 
-        self.events[event].append( {"x_range" : range(reg_event["x"], reg_event["x"] + reg_event["width"]),
-                                    "y_range" : range(reg_event["x"], reg_event["y"] + reg_event["height"]),
-                                    "callback" : callback} )
+#         Working on Mapper events
+#         self.events[event].append( {"x_range" : range(reg_event["x"], reg_event["x"] + reg_event["width"]),
+#                                     "y_range" : range(reg_event["x"], reg_event["y"] + reg_event["height"]),
+#                                     "callback" : callback} )
 
     def motion_notify_event(self, event):
         """
diff --git a/src/ocvfw/_ocv.py b/src/ocvfw/_ocv.py
index c82e369..d4ddbfa 100644
--- a/src/ocvfw/_ocv.py
+++ b/src/ocvfw/_ocv.py
@@ -27,22 +27,18 @@ __date__      = "$Date$"
 __copyright__ = "Copyright (c) 2008 Flavio Percoco Premoli"
 __license__   = "GPLv2"
 
-import gtk
 import time
-import gobject
 import debug
-from math import cos,sin,sqrt, pi
 
 
 try:
-    import opencv
     from opencv import cv
     from opencv import highgui
 except:
     print "This modules depends of opencv libraries"
 
 
-class ocvfw:
+class Ocvfw:
     """
     This Class controlls the main camera functions.
     It works as a little framework for OpenCV.
@@ -88,7 +84,6 @@ class ocvfw:
         Returns a list with the matches.
         """
 
-        print(haarCascade)
         cascade = cv.cvLoadHaarClassifierCascade( haarCascade, self.imgSize )
 
         if not cascade:
@@ -98,7 +93,7 @@ class ocvfw:
 
         cv.cvClearMemStorage( self.storage )
 
-        points = cv.cvHaarDetectObjects( self.small_img, cascade, self.storage, 1.2, 2, method, cv.cvSize(20,20) )
+        points = cv.cvHaarDetectObjects( self.small_img, cascade, self.storage, 1.2, 2, method, cv.cvSize(20, 20) )
 
         if points:
             matches = [ [ cv.cvPoint( int(r.x*self.imageScale), int(r.y*self.imageScale)), \
@@ -107,7 +102,7 @@ class ocvfw:
             debug.debug( "ocvfw", "cmGetHaarPoints: detected some matches" )
             return matches
 
-    def get_haar_roi_points(self, haarCascade, rect, origSize=(0,0), method=cv.CV_HAAR_DO_CANNY_PRUNING):
+    def get_haar_roi_points(self, haarCascade, rect, origSize=(0, 0), method=cv.CV_HAAR_DO_CANNY_PRUNING):
         """
         Search for points matching the haarcascade selected.
 
@@ -121,9 +116,12 @@ class ocvfw:
 
         cascade = cv.cvLoadHaarClassifierCascade( haarCascade, self.imgSize )
 
-        cv.cvClearMemStorage( self.storage )
+        if not cascade:
+            debug.exception( "ocvfw", "The Haar Classifier Cascade load failed" )
 
-        imageROI = cv.cvGetSubRect( self.img, rect )
+        cv.cvClearMemStorage(self.storage)
+
+        imageROI = cv.cvGetSubRect(self.img, rect)
 
         if cascade:
             points = cv.cvHaarDetectObjects( imageROI, cascade, self.storage,
@@ -227,16 +225,17 @@ class ocvfw:
         # set back the self.imgPoints we keep
         self.img_lkpoints["current"] = new_points
 
-    def wait_key( self, int ):
+    def wait_key(self, num):
         """
         Simple call to the highgui.cvWaitKey function, which has to be called periodically.
 
         Arguments:
         - self: The main object pointer.
+        - num: An int value.
         """
-        return highgui.cvWaitKey( int )
+        return highgui.cvWaitKey(num)
 
-    def swap_lkpoints( self ):
+    def swap_lkpoints(self):
         """
         Swap the LK method variables so the new points will be the last points.
         This function has to be called after showing the new points.
@@ -251,14 +250,14 @@ class ocvfw:
         self.img_lkpoints["last"], self.img_lkpoints["current"] = \
                                    self.img_lkpoints["current"], self.img_lkpoints["last"]
 
-    def start_camera( self, input, params = None ):
+    def start_camera(self, idx, params = None):
         """
         Starts the camera capture using highgui.
 
         Arguments:
         - params: A list with the capture properties. NOTE: Not implemented yet.
         """
-        self.capture = highgui.cvCreateCameraCapture( int(input) )
+        self.capture = highgui.cvCreateCameraCapture( int(idx) )
         debug.debug( "ocvfw", "cmStartCamera: Camera Started" )
 
     def query_image(self, bgr=False, flip=False):
@@ -273,7 +272,6 @@ class ocvfw:
         """
 
         frame = highgui.cvQueryFrame( self.capture )
-        #frame = highgui.cvRetrieveFrame( self.capture )
 
         if not  self.img:
             self.storage        = cv.cvCreateMemStorage(0)
@@ -293,6 +291,12 @@ class ocvfw:
         self.wait_key(10)
         return True
 
+
+    ##########################################
+    #                                        #
+    #          THIS IS NOT USED YET          #
+    #                                        #
+    ##########################################
     def get_motion_points(self, imgRoi=None):
         """
         Calculate the motion points in the image.
@@ -307,7 +311,7 @@ class ocvfw:
         """
 
         mv = []
-        N = 4
+        n_ = 4
 
         timestamp = time.clock()/1.0
 
@@ -333,7 +337,7 @@ class ocvfw:
 
             cv.cvZero( self.mhi )
 
-            for i in range( N ):
+            for i in range( n_ ):
                 self.buf[i] = cv.cvCreateImage( imgSize, 8, 1 )
                 cv.cvZero( self.buf[i] )
 
@@ -342,8 +346,8 @@ class ocvfw:
         # convert frame to grayscale
         cv.cvCvtColor( img, self.buf[self.lastFm], cv.CV_BGR2GRAY )
 
-        # index of (self.lastFm - (N-1))th frame
-        idx2 = ( self.lastFm + 1 ) % N
+        # index of (self.lastFm - (n_-1))th frame
+        idx2 = ( self.lastFm + 1 ) % n_
         self.lastFm = idx2
 
         silh = self.buf[idx2]
diff --git a/src/ocvfw/debug.py b/src/ocvfw/debug.py
index d00bac6..5770641 100644
--- a/src/ocvfw/debug.py
+++ b/src/ocvfw/debug.py
@@ -1,22 +1,22 @@
 # -*- coding: utf-8 -*-
 
-# Ocvfw
+# MouseTrap
 #
 # Copyright 2009 Flavio Percoco Premoli
 #
-# This file is part of Ocvfw.
+# This file is part of mouseTrap.
 #
-# Ocvfw is free software: you can redistribute it and/or modify
+# MouseTrap is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License v2 as published
 # by the Free Software Foundation.
 #
-# Ocvfw is distributed in the hope that it will be useful,
+# mouseTrap is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with Ocvfw.  If not, see <http://www.gnu.org/licenses/>>.
+# along with mouseTrap.  If not, see <http://www.gnu.org/licenses/>.
 
 """The debug module of mouseTrap."""
 
@@ -26,9 +26,8 @@ __date__      = "$Date$"
 __copyright__ = "Copyright (c) 2008 Flavio Percoco Premoli"
 __license__   = "GPLv2"
 
-import sys
 import logging
-import traceback
+#import traceback
 
 modules = {}
 
@@ -40,8 +39,6 @@ def checkModule( module ):
     - module: The module requesting a logger.
     """
 
-    global modules
-
     level = logging.DEBUG
 
     formatter = logging.Formatter("%(levelname)s: %(name)s -> %(message)s")
@@ -178,7 +175,7 @@ def traceit(frame, event, arg):
            or name == "UserDict":
             return traceit
         line = linecache.getline(filename, lineno)
-        log(ALL, "Trace", "TRACE %s:%s: %s" % (name, lineno, line.rstrip()))
+        debug("ALL", "TRACE %s:%s: %s" % (name, lineno, line.rstrip()))
     return traceit
 
 #if debugLevel == EXTREME:
diff --git a/src/ocvfw/dev/camera.py b/src/ocvfw/dev/camera.py
index 9b22939..643f95e 100644
--- a/src/ocvfw/dev/camera.py
+++ b/src/ocvfw/dev/camera.py
@@ -33,7 +33,7 @@ from warnings import *
 from .. import debug
 from opencv import cv
 from opencv import highgui as hg
-from .._ocv import ocvfw as ocv
+from .._ocv import Ocvfw as ocv
 
 
 class __Camera(ocv):
@@ -70,7 +70,7 @@ class Capture(object):
         self.__props       = { "color" : "rgb" }
         self.__camera      = Camera
         self.__camera.set_camera(idx)
-        self.__camera.start();
+        self.__camera.start()
 
         self.__graphics    = { "rect"  : [],
                                "point" : []}
@@ -84,6 +84,7 @@ class Capture(object):
 
         self.roi           = None
 
+        self.forehead      = None
         self.last_update   = 0
         self.last_duration = 0
 
@@ -394,7 +395,7 @@ class Graphic(object):
         """
 
         if self.type == "point":
-                return True
+            return True
 
         return False
 
diff --git a/src/ocvfw/idm/forehead.py b/src/ocvfw/idm/forehead.py
index 2588f73..3372afc 100644
--- a/src/ocvfw/idm/forehead.py
+++ b/src/ocvfw/idm/forehead.py
@@ -28,7 +28,7 @@ __copyright__ = "Copyright (c) 2008 Flavio Percoco Premoli"
 __license__   = "GPLv2"
 
 import ocvfw.commons as commons
-from ocvfw.dev.camera import *
+from ocvfw.dev.camera import Camera, Capture, Point
 
 a_name = "Forehead"
 a_description = "Forehead point tracker based on LK Algorithm"
@@ -74,7 +74,6 @@ class Module(object):
 
         for key in self.stgs:
             pass
-        pass
 
     def set_capture(self, cam):
         self.cap = Capture(async=True, idx=cam)
diff --git a/src/ocvfw/pocv.py b/src/ocvfw/pocv.py
index 69b8d92..d3d5ab3 100644
--- a/src/ocvfw/pocv.py
+++ b/src/ocvfw/pocv.py
@@ -43,7 +43,7 @@ def get_idm(idm):
                       [''])
 
 def get_idms_list():
-    reg = re.compile(r'([A-Za-z0-9]+)\.py$',re.DOTALL)
+    reg = re.compile(r'([A-Za-z0-9]+)\.py$', re.DOTALL)
     dirname = os.path.dirname(__file__)
     return [ mod[0] for mod in [ reg.findall(f) for f in os.listdir("%s/idm/" % dirname)] if mod ]
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]