Beispiel #1
0
    def cam_tab( self ):
        """
        The cam module Preff Tab.

        Arguments:
        - self: The main object pointer.
        """

        frame = Gtk.Frame()

        camBox = Gtk.Grid()
        camBox.set_column_spacing(6)

        mapperActive = Gtk.CheckButton( _("Show Point Mapper") )
        mapperActive.set_active( self.cfg.getboolean( "gui", "showPointMapper" ) )
        mapperActive.connect( "toggled", self._checkToggled, "gui", "showPointMapper" )

        camBox.add( mapperActive )

        showCapture = Gtk.CheckButton( _("Show Capture") )
        showCapture.set_active( self.cfg.getboolean( "gui", "showCapture" ) )
        showCapture.connect( "toggled", self._checkToggled, "gui", "showCapture" )

        camBox.attach_next_to( showCapture, mapperActive, Gtk.PositionType.BOTTOM, 1, 1 )

        camBox.show_all()

        frame.add( camBox )
        frame.show()

        self.noteBook.insert_page(frame, Gtk.Label(label= _("Camera")), -1)
Beispiel #2
0
    def mouseTab( self ):
        """
        The cam module Preff Tab.

        Arguments:
        - self: The main object pointer.
        """

        frame = Gtk.Frame()

        camBox = Gtk.Grid()
        camBox.set_column_spacing(6)

        reqMov = self.addSpin( _("Step Speed: "), "stepSpeed", self.cfg.getint( "mouse", "stepSpeed" ), "mouse", "stepSpeed" )
        camBox.add( reqMov )

    ###############################################
    #                         #
    #    THE WHEEL HAS ALREADY BEEN DISCOVERED    #
    #     SO, LETS USE MOUSETWEAK INSTEAD OF      #
    #      ADD THIS SUPPORT TO MOUSETRAP.     #
    ###############################################

#     defClickF = gtk.frame( _( "Default Click:" ) )
#
#     defClicks = {  "b1c"   :  _("Left Click"),
#            "b1d"   :  _("Double Click"),
#            "b1p"   :  _("Drag/Drop Click"),
#            "b3c"   :  _("Right Click")}
#
#     defClicksInv = dict((v,k) for k,v in defClicks.iteritems())
#
#     defClick = gtk.combo_box_new_text()
#     defClick.append_text(defClicks[self.cfg.get( "mouse", "defClick" )])
#
#     defClicklBl = gtk.Label(self.cfg.get( "mouse", "defClick" ))
#     self.preffWidgets['defClick'] = defClicklBl
#
#     for mode in defClicks:
#         if mode == self.cfg.get( "mouse", "defClick" ):
#         continue
#         defClick.append_text( defClicks[mode] )
#
#     defClick.connect('changed', self._comboChanged, "mouse", "defClick", defClicksInv)
#     defClick.set_active(0)
#
#     defClickF.add( defClick)
#     camBox.pack_start( defClickF, False, False )

        camBox.show_all()

        frame.add( camBox )
        frame.show()

        self.noteBook.insert_page(frame, Gtk.Label(label= _("Mouse")), -1)
Beispiel #3
0
    def buildInterface( self ):
        """
        Builds the preffGUI.

        Arguments:
        - self: The main object pointer.
        """

        accelGroup = Gtk.AccelGroup()
        self.add_accel_group( accelGroup )

        accelGroup = accelGroup

        self.set_title( _("mouseTrap Preferences") )
        self.set_size_request( 300, 100)
        self.connect( "destroy", self.close)

        self.window = Gtk.Grid()

        self.noteBook = Gtk.Notebook()
        self.noteBook.set_tab_pos( Gtk.PositionType.TOP )
        self.window.add( self.noteBook )
        self.noteBook.show()

        self.main_gui_tab()
        self.cam_tab()
        self.algorithm_tab()
        self.addons_tab()
        self.mouseTab()
        self.debug_tab()

        ####################
        # Bottom's buttons #
        ####################
        self.buttonsBox = Gtk.Grid()

        self.acceptButton = Gtk.Button( _("Accept"), stock=Gtk.STOCK_OK)
        self.acceptButton.connect("clicked", self.acceptButtonClick )
        self.buttonsBox.add( self.acceptButton )

        self.cancelButton = Gtk.Button( _("Accept"), stock=Gtk.STOCK_CANCEL )
        self.cancelButton.connect("clicked", self.close )
        self.buttonsBox.add( self.cancelButton )

        self.applyButton = Gtk.Button( _("Accept"), stock=Gtk.STOCK_APPLY )
        self.applyButton.connect( "clicked", self.applyButtonClick )
        self.buttonsBox.add( self.applyButton )

        self.buttonsBox.show_all()

        self.window.attach_next_to(self.buttonsBox, self.noteBook, Gtk.PositionType.BOTTOM, 1, 1)
        self.window.show_all()
        self.add( self.window )
        self.show()
Beispiel #4
0
    def create_labled_input(self, key):
        """
        Creates a textbox with a lable.

        Arguments:
        - self: The main object pointer.
        - key: The parent key.
        """
        hbox = Gtk.HBox()
        label = Gtk.Label(_(key.capitalize()))

        label.set_use_underline( True )
        label.show()

        hbox.pack_start(label, True, True, 0)

        val = str(self.idm_stgs[key]["value"])

        if self.cfg.get(self.idm, key):
            val = self.cfg.get(self.idm, key)

        entry = Gtk.Entry()

        entry.set_text(val)
        entry.connect("changed", self.value_changed, key)
        entry.show()
        hbox.pack_start(entry, True, True, 0)
        hbox.show_all()

        return hbox
Beispiel #5
0
def warningDialog( message, parent ):
    """
    Creates a warning dialog using the messageDialog function.

    Arguments:
    - message: The dialog message
    - parent: The parent window. None if there's not one.
    """
    return messageDialog( _("Information Dialog"), message, parent,  Gtk.STOCK_DIALOG_WARNING )
Beispiel #6
0
def errorDialog( message, parent ):
    """
    Creates an error dialog using the messageDialog function.

    Arguments:
    - message: The dialog message
    - parent: The parent window. None if there's not one.
    """
    return messageDialog( _("Error Dialog"), message, parent,  Gtk.STOCK_DIALOG_ERROR )
Beispiel #7
0
    def __init__(self, controller):
        AddonsBase.__init__(self, controller)

        if self.cfg.getboolean("main", "startCam") and self.cfg.get("main", "algorithm") == "forehead":
            self.button = Gtk.Button(_("Recalc Point"))
            self.button.connect("clicked", self.recalc)
            self.button.show()
            self.add_item(self.button)
            debug.debug("addon.recalc", "Recalc Addon started")
Beispiel #8
0
    def __init__(self, cfg, name, stgs):
        """
        Idm Settings window.

        Arguments:
        self: The main object pointer.
        cfg: The config object.
        stgs: The idm's settings dict to parse.
        """
        super(IdmSettings, self).__init__()

        self.cfg = cfg
        self.idm_stgs = eval(stgs)
        self.idm = name.lower()
        self.tmp = {}

        self.set_title(_("%s Config's Dialog" % self.idm.capitalize()))

        self.main_vbox = Gtk.VBox(spacing=6)
        self.add_widgets()

        buttons_box = Gtk.HBox(spacing=6)

        button = Gtk.Button( _("Accept"), stock=Gtk.STOCK_OK )

        button.connect("clicked", self.accept_button)
        buttons_box.pack_start(button, False, False, 0)

        button = Gtk.Button( _("Cancel"), stock=Gtk.STOCK_CANCEL )

        button.connect("clicked", self.cancel_button)
        buttons_box.pack_start(button, False, False, 0)

        buttons_box.show_all()

        self.main_vbox.pack_start(buttons_box, False, False, 0)

        self.main_vbox.show_all()
        self.show_all()
        self.add(self.main_vbox)

        if not self.cfg.has_section(self.idm):
            self.cfg.add_section(self.idm)
Beispiel #9
0
    def __init__(self, controller):
        AddonsBase.__init__(self, controller)

        if self.cfg.getboolean("main", "startCam") and \
                self.cfg.get("main", "algorithm") == "forehead":
            self.button = gtk.Button(_("Recalc Point"))
            self.button.connect("clicked", self.recalc)
            self.button.show()
            self.add_item(self.button)
            debug.debug("addon.recalc", "Recalc Addon started")
Beispiel #10
0
    def main_gui_tab( self ):
        """
        The mainGui Preff Tab.

        Arguments:
        - self: The main object pointer.
        """

        frame = Gtk.Frame()

        general_box = Gtk.Grid()
        general_box.set_column_spacing(6)

#     mWindowActive = Gtk.CheckButton( _("Show main window") )
#     mWindowActive.set_active( self.cfg.getboolean( "gui", "showMainGui" ) )
#     mWindowActive.connect( "toggled", self._checkToggled, "gui", "showMainGui" )
#
#     mainGuiBox.add( mWindowActive )

        cAmActive = Gtk.CheckButton( _("Activate Camera module") )
        cAmActive.set_active( self.cfg.getboolean( "main", "startCam" ) )
        cAmActive.connect( "toggled", self._checkToggled, "main", "startCam" )

        general_box.add( cAmActive )

        flipImage = Gtk.CheckButton( _("Flip Image") )
        flipImage.set_active( self.cfg.getboolean( "cam",  "flipImage" ) )
        flipImage.connect( "toggled", self._checkToggled, "cam", "flipImage" )

        general_box.attach_next_to( flipImage, cAmActive, Gtk.PositionType.BOTTOM, 1, 1 )

        inputDevIndex = self.addSpin( _("Input Video Device Index: "), "inputDevIndex",
                        self.cfg.getint( "cam", "inputDevIndex" ), "cam", "inputDevIndex", 0)
        general_box.attach_next_to( inputDevIndex, flipImage, Gtk.PositionType.BOTTOM, 1, 1 )

        general_box.show_all()

        frame.add( general_box )
        frame.show()

        self.noteBook.insert_page(frame, Gtk.Label(label= _("General")), -1)
Beispiel #11
0
    def debug_tab( self ):
        """
        The debuging Preff Tab.

        Arguments:
        - self: The main object pointer.
        """

        frame = Gtk.Frame()

        debugBox = Gtk.Grid()
        debugBox.set_column_spacing(6)

        levelHbox = Gtk.Grid()
        levelHbox.set_row_spacing(4)

        levellabel = Gtk.Label(label= _("Debugging Level:") )
        levellabel.set_alignment( 0.0, 0.5 )
        levellabel.show()
        levelHbox.add( levellabel )

        adj = Gtk.Adjustment( self.cfg.getint( "main", "debugLevel" ), 10, 50, 10, 1, 0)
        levelSpin = Gtk.SpinButton()
        levelSpin.set_adjustment(adj)
        levelSpin.set_wrap( True )
        levelHbox.add( levelSpin )
        levelSpin.connect( "value-changed", self._spinChanged, "main", "debugLevel" )

        debugBox.add( levelHbox )

        debugBox.show_all()

        frame.add( debugBox )
        frame.show()

        self.noteBook.insert_page(frame, Gtk.Label(label= _("Debug")), -1)
Beispiel #12
0
def confirmDialog( message, parent ):
    """
    Creates a confirmation dialog.

    Arguments:
    - message: The dialog message
    - parent: The parent window. None if there's not one.
    """

    dialog = createDialog( _( "Confirmation Dialog" ), parent,
                            Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, \
                            (Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT, \
                            Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT))
    addImage( dialog, Gtk.STOCK_DIALOG_WARNING, True)
    addLabelMessage( dialog, message )
    return dialog.run()
Beispiel #13
0
    def usage(self):
        """
        Prints the usage

        Arguments:
        - self: The main object pointer
        """

        print(( _("Usage: mouseTrap [OPTION...]")))

        # '-?, --help' that is used to display usage information.
        #
        print(( "-?, -h, --help              " + \
                _("        Show this help message")))


        # Option:
        # '-i' that is used to set the input camera index. E.g: -i 0
        print(( "-s, --set            " + \
                _("              Sets new value to Non Boolean options E.g -s inputDevIndex-1")))

        # Options:
        # -e, --enable Allow the users to enable modules not permantly
        print(( "-e, --enable=[" \
            + "main-window" + "|" \
            + "cam") + "]")

        print(( _("     Enable the selected options")))

        # Options:
        # -d, --disable Allow the users to disable modules not permanently.
        print(( "-d, --disable=[" \
            + "main-window" + "|" \
            + "cam" + "]"))

        print(( _("    Disable the selected options")))

        # Options:
        # -t --timeout To change the mouse timeout not permanently.
        print(( "-v, --version      " + \
                _("                 Shows mouseTrap version")))

        print(( _("\nReport bugs to [email protected]")))
Beispiel #14
0
    def addons_tab( self ):
        """
        The cam module Preff Tab.

        Arguments:
        - self: The main object pointer.
        """

        frame = Gtk.Frame()

        algo_box = Gtk.Grid()
        algo_box.set_column_spacing(6)

        liststore = Gtk.ListStore(bool, str, str, str)

        conf_button = Gtk.Button(stock=Gtk.STOCK_PREFERENCES)
        conf_button.connect('clicked', self.show_alg_pref, liststore)
        conf_button.set_sensitive(False)

        tree_view = Gtk.TreeView(liststore)
        tree_view.connect("cursor-changed", self._tree_view_click, conf_button)

        toggle_cell = Gtk.CellRendererToggle()
        toggle_cell.connect( 'toggled', self._enable_disable_addon, liststore)
        toggle_cell.set_property('activatable', True)

        name_cell = Gtk.CellRendererText()
        desc_cell = Gtk.CellRendererText()

        toggle_column = Gtk.TreeViewColumn(_('Active'), toggle_cell)
        name_column = Gtk.TreeViewColumn(_('Name'))
        desc_column = Gtk.TreeViewColumn(_('Description'))

        for add in self.adds.get_addons_list():
            add_inf = self.adds.get_addon_inf(add)

            if not add_inf:
                continue

            state = False
            if add_inf["name"].lower() in self.cfg.getList("main", "addon"):
                state = True
            # FIXME: I don't know what the purpose of this liststore is,
            # but it wants strings, so let's not argue for now. ;)
            liststore.append([state, add_inf["name"], add_inf["dsc"], str(add_inf["stgs"])])

        tree_view.append_column(toggle_column)
        tree_view.append_column(name_column)
        tree_view.append_column(desc_column)

        name_column.pack_start(name_cell, True)
        desc_column.pack_start(desc_cell, True)

        toggle_column.add_attribute( toggle_cell, "active", 0 )
        toggle_column.set_max_width(30)
        #toggle_column.set_attributes( toggle_cell, background=2 )
        name_column.set_attributes(name_cell, text=1)
        desc_column.set_attributes(desc_cell, text=2)

        algo_box.add(tree_view)
        algo_box.attach_next_to(conf_button, tree_view, Gtk.PositionType.BOTTOM, 1, 1)

        algo_box.show_all()

        frame.add( algo_box )
        frame.show()

        self.noteBook.insert_page(frame, Gtk.Label(label= _("Addons")), -1)
Beispiel #15
0
    def algorithm_tab( self ):
        """
        The cam module Preff Tab.

         Arguments:
        - self: The main object pointer.
        """

        frame = Gtk.Frame()

        algo_box = Gtk.Grid()
        algo_box.set_column_spacing(6)

        liststore = Gtk.ListStore(bool, str, str, str)

        conf_button = Gtk.Button(stock=Gtk.STOCK_PREFERENCES)
        conf_button.connect('clicked', self.show_alg_pref, liststore)
        conf_button.set_sensitive(False)

        scripts_combo = Gtk.ComboBoxText()
        scripts_combo.append_text(self.cfg.get("scripts", "name"))

        for script in get_scripts_list():
            if script.lower() != self.cfg.get("scripts", "name"):
                scripts_combo.append_text(script)

        scripts_combo.connect('changed', self._comboChanged, "scripts", "name")
        scripts_combo.set_active(0)

        tree_view = Gtk.TreeView(liststore)
        tree_view.connect("cursor-changed", self._tree_view_click, conf_button)

        toggle_cell = Gtk.CellRendererToggle()
        toggle_cell.set_radio(True)
        toggle_cell.connect( 'toggled', self._toggle_cell_changed, liststore)
        toggle_cell.set_property('activatable', True)
        #toggle_cell.set_property('background-set' , True)

        name_cell = Gtk.CellRendererText()
        desc_cell = Gtk.CellRendererText()

        toggle_column = Gtk.TreeViewColumn(_('Active Algorithms'), toggle_cell)
        name_column = Gtk.TreeViewColumn(_('Installed Algorithms'))
        desc_column = Gtk.TreeViewColumn(_('Description'))

        for alg in pocv.get_idms_list():
            alg_inf = pocv.get_idm_inf(alg)

            if not alg_inf:
                continue

            state = False
            if alg_inf["name"].lower() in self.cfg.get("main", "algorithm").lower():
                state = True
            # FIXME: I don't know what the purpose of this liststore is,
            # but it wants strings, so let's not argue for now. ;)
            liststore.append([state, alg_inf["name"], alg_inf["dsc"], str(alg_inf["stgs"])])

            #liststore.append([False, "%s: %s" % (alg_inf["name"], alg_inf["dsc"]), alg_inf["stgs"]])

        tree_view.append_column(toggle_column)
        tree_view.append_column(name_column)
        tree_view.append_column(desc_column)

        name_column.pack_start(name_cell, True)
        desc_column.pack_start(desc_cell, True)

        toggle_column.add_attribute( toggle_cell, "active", 0 )
        toggle_column.set_max_width(30)
        #toggle_column.set_attributes( toggle_cell, background=2 )
        name_column.set_attributes(name_cell, text=1)
        desc_column.set_attributes(desc_cell, text=2)

        algo_box.add(tree_view)
        algo_box.attach_next_to(conf_button, tree_view, Gtk.PositionType.BOTTOM, 1, 1)
        algo_box.attach_next_to(scripts_combo, conf_button, Gtk.PositionType.BOTTOM, 1, 1)

        algo_box.show_all()

        frame.add( algo_box )
        frame.show()

        self.noteBook.insert_page(frame, Gtk.Label(label= _("Algorithm")), -1)