예제 #1
0
    def run(self):
        while self.running:
            while self.last_key_stroke == None:
                if not self.running:
                    break
            if not self.running:
                break

            # time.sleep(self.time_interval)
            time_delta = 0
            while time_delta <= self.time_interval:
                time_delta = time.time() - self.last_key_stroke

            if str(ini_worker.get_param_from_ini(self.configFile, self.section, self.param)) != str(self.value):
                ini_worker.write_to_section(self.configFile,
                                            self.section,
                                            self.param,
                                            self.value)

            self.last_key_stroke = None

        print '--|X|-- key guard unplugged'
예제 #2
0
    def run(self):
        while self.running:
            while self.last_key_stroke == None:
                if not self.running:
                    break
            if not self.running:
                break

            # time.sleep(self.time_interval)
            time_delta = 0
            while time_delta <= self.time_interval:
                time_delta = time.time() - self.last_key_stroke

            if str(
                    ini_worker.get_param_from_ini(
                        self.configFile, self.section, self.param)) != str(
                            self.value):
                ini_worker.write_to_section(self.configFile, self.section,
                                            self.param, self.value)

            self.last_key_stroke = None

        print '--|X|-- key guard unplugged'
예제 #3
0
    def __init__(self, pluginPath, corePath, configFile):
        self.pluginPath = pluginPath
        self.corePath = corePath
        self.workingDir = sys.path[0]
        self.configFile = self.corePath + '\\' + configFile
        self.PGconfigFile = self.workingDir + '\\' + 'PG_config.ini'
        self.PGconfigFileCore = self.corePath + '\\' + 'PG_config.ini'
        self.PG_expanded = False
        self.current_y_pxpos_elem = 0
        self.param_dict = {}
        self.section_EC_stat = {}
        self.KST = key_stroke_timer.key_stroke_timer(self.configFile)
        self.MIN_SIZE_W = 20
        self.black_list = ['collapse', 'create', 'hideSection', 'show', 'filterStrategy', 'offsetType']

        self.GOC = guard.guard_of_changes(self)  # init observer thread
        self.GOC.start()  # start observer thread

        wx.Dialog.__init__(self, None, title='MW Parameter guard', size=UI.WMAIN['size'],
                           style=wx.SYSTEM_MENU | # wx.CAPTION |  # ~wx.CLOSE_BOX |
                                 wx.TAB_TRAVERSAL | wx.STAY_ON_TOP | wx.RESIZE_BORDER)  # | wx.TRANSPARENT_WINDOW)

        self.SetMinSize((1, 1))

        PG_XY = ini_worker.get_param_from_ini(self.PGconfigFileCore, 'UISETTINGS', 'lastWindowPosition')
        PG_XY = PG_XY.strip()[1:-1].split(',')
        PG_SIZE = ini_worker.get_param_from_ini(self.PGconfigFileCore, 'UISETTINGS', 'lastWindowSize')
        PG_SIZE = PG_SIZE.strip()[1:-1].split(',')


        self.MAIN_DISPLAY_SIZE = get_monitors()
        if len(self.MAIN_DISPLAY_SIZE) == 1:
            self.DISPLAY_SIZE = self.MAIN_DISPLAY_SIZE[0]
        else:
            self.DISPLAY_SIZE = self.MAIN_DISPLAY_SIZE[1]

        self.DISPLAY_SIZE = self.MAIN_DISPLAY_SIZE[0]

        #self.MoveXY(int(PG_XY[0]), int(PG_XY[1]))
        self.MoveXY(int(self.DISPLAY_SIZE.width)-10, 0)
        #self.SetSizeWH(int(PG_SIZE[0]), int(PG_SIZE[1]))
        self.SetSizeWH(int(PG_SIZE[0]), self.DISPLAY_SIZE.height)

        self.Bind(wx.EVT_SIZE, self.OnSize, self)
        # self.Bind(wx.EVT_ENTER_WINDOW, self.onMouseOver)
        # self.Bind(wx.EVT_LEAVE_WINDOW, self.onMouseLeave)
        # self.Bind(wx.EVT_LEFT_DOWN, self.onLMouseDown)
        self.Bind(wx.EVT_MOUSE_EVENTS, self.onMouseEvents)

        atable = wx.AcceleratorTable([(wx.ACCEL_NORMAL, wx.WXK_ESCAPE, wx.ID_EXIT)])
        self.SetAcceleratorTable(atable)
        wx.EVT_MENU(self, wx.ID_EXIT, self.OnExit)

        self.SetBackgroundColour(wx.Colour(UI.WCOLOR['BG'][0],
                                           UI.WCOLOR['BG'][1],
                                           UI.WCOLOR['BG'][2]))

        self.SetTransparent(220)
        self.Show()

        #fn = self.corePath + '\\bin\\images\\paramGuard.ico'
        #self.icon = wx.Icon(fn, wx.BITMAP_TYPE_ICO)
        #self.SetIcon(self.icon)

        self.section_list = ini_worker.get_sections_list_from_ini(self.configFile)  # list

        param_indentation = 10  # whitespace

        for section in self.section_list:

            self.section_EC_stat.update(
                {section: ini_worker.get_param_from_ini(self.configFile, section, 'collapse')})

            section_params = ini_worker.get_section_from_ini(self.configFile, section)
            for param, value in section_params.iteritems():
                if param == 'hideSection':
                    hideSection = value

            if not hideSection:

                self.param_dict[section] = {}

                font = wx.Font(9, wx.DEFAULT, wx.NORMAL, wx.BOLD)

                headline = wx.StaticText(self,
                                         label=section,
                                         pos=(UI.THEADERSTART['pos'][0],
                                              UI.THEADERSTART['pos'][1] + self.current_y_pxpos_elem))

                headline.SetForegroundColour(UI.TCOLOR['FG'])  # set text color
                headline.SetFont(font)
                headline.Bind(wx.EVT_ENTER_WINDOW, self.onMouseOver)
                #headline.Bind(wx.EVT_LEAVE_WINDOW, self.onMouseLeave)

                button = wx.Button(self,
                                   name=section,
                                   label="",
                                   pos=(UI.BEXPAND['pos'][0], self.current_y_pxpos_elem + 11),
                                   size=UI.BEXPAND['size'])

                button.Bind(wx.EVT_BUTTON, self.expandCollapse)
                button.SetBackgroundColour(UI.BCOLOR['BG'])  # set color
                button.SetToolTipString('Click to expand/collapse section')
                button.Bind(wx.EVT_ENTER_WINDOW, self.onMouseOver)
                #button.Bind(wx.EVT_LEAVE_WINDOW, self.onMouseLeave)

                self.current_y_pxpos_elem += 20

                # params in sections (edit boxes)
                font = wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL)
                ui_elem_handler_dict = {}

                for param, value in section_params.iteritems():

                    if type(value) == str:
                        splitted_value = value.split(';')
                        if len(splitted_value) > 1:
                            if splitted_value[1].strip() == 'X':
                                self.black_list.append(param)

                    if param not in self.black_list:

                        text = wx.StaticText(self,
                                             label=param,
                                             pos=(UI.THEADERSTART['pos'][0] + param_indentation,
                                                  UI.THEADERSTART['pos'][1] + self.current_y_pxpos_elem))

                        text.SetForegroundColour(UI.PARAMCOLOR['FG'])  # set text color
                        text.Bind(wx.EVT_ENTER_WINDOW, self.onMouseOver)
                        #text.Bind(wx.EVT_LEAVE_WINDOW, self.onMouseLeave)

                        editbox = (wx.TextCtrl(self,
                                               name=section + ' - ' + param,
                                               value=str(value),
                                               pos=(UI.EBOX['pos'][0], UI.THEADERSTART['pos'][1] + self.current_y_pxpos_elem),
                                               size=UI.EBOX['size'],
                                               style=wx.TE_PROCESS_ENTER))

                        editbox.SetForegroundColour(UI.ECOLOR2['FG'])  # set color
                        editbox.SetBackgroundColour(UI.ECOLOR2['BG'])  # set color

                        editbox.Bind(wx.EVT_TEXT, self.EvtText)
                        editbox.Bind(wx.EVT_ENTER_WINDOW, self.onMouseOver)
                        #editbox.Bind(wx.EVT_LEAVE_WINDOW, self.onMouseLeave)


                        elem_dict = {param: [{'ebox': [editbox, value]},
                                             {'headline': headline},
                                             {'text': text},
                                             {'button': button}]}

                        ui_elem_handler_dict.update(elem_dict)

                        self.current_y_pxpos_elem += 20

                    self.param_dict[section].update(ui_elem_handler_dict)

        self.expandCollapse(None, refresh=True)
        self.refresh_UI()
        self.KST.start()
예제 #4
0
    def __init__(self, pluginPath, corePath, configFile):
        self.pluginPath = pluginPath
        self.corePath = corePath
        self.workingDir = sys.path[0]
        self.configFile = self.corePath + '\\' + configFile
        self.PGconfigFile = self.workingDir + '\\' + 'PG_config.ini'
        self.PGconfigFileCore = self.corePath + '\\' + 'PG_config.ini'
        self.PG_expanded = False
        self.current_y_pxpos_elem = 0
        self.param_dict = {}
        self.section_EC_stat = {}
        self.KST = key_stroke_timer.key_stroke_timer(self.configFile)
        self.MIN_SIZE_W = 20
        self.black_list = [
            'collapse', 'create', 'hideSection', 'show', 'filterStrategy',
            'offsetType'
        ]

        self.GOC = guard.guard_of_changes(self)  # init observer thread
        self.GOC.start()  # start observer thread

        wx.Dialog.__init__(
            self,
            None,
            title='MW Parameter guard',
            size=UI.WMAIN['size'],
            style=wx.SYSTEM_MENU |  # wx.CAPTION |  # ~wx.CLOSE_BOX |
            wx.TAB_TRAVERSAL | wx.STAY_ON_TOP
            | wx.RESIZE_BORDER)  # | wx.TRANSPARENT_WINDOW)

        self.SetMinSize((1, 1))

        PG_XY = ini_worker.get_param_from_ini(self.PGconfigFileCore,
                                              'UISETTINGS',
                                              'lastWindowPosition')
        PG_XY = PG_XY.strip()[1:-1].split(',')
        PG_SIZE = ini_worker.get_param_from_ini(self.PGconfigFileCore,
                                                'UISETTINGS', 'lastWindowSize')
        PG_SIZE = PG_SIZE.strip()[1:-1].split(',')

        self.MAIN_DISPLAY_SIZE = get_monitors()
        if len(self.MAIN_DISPLAY_SIZE) == 1:
            self.DISPLAY_SIZE = self.MAIN_DISPLAY_SIZE[0]
        else:
            self.DISPLAY_SIZE = self.MAIN_DISPLAY_SIZE[1]

        self.DISPLAY_SIZE = self.MAIN_DISPLAY_SIZE[0]

        #self.MoveXY(int(PG_XY[0]), int(PG_XY[1]))
        self.MoveXY(int(self.DISPLAY_SIZE.width) - 10, 0)
        #self.SetSizeWH(int(PG_SIZE[0]), int(PG_SIZE[1]))
        self.SetSizeWH(int(PG_SIZE[0]), self.DISPLAY_SIZE.height)

        self.Bind(wx.EVT_SIZE, self.OnSize, self)
        # self.Bind(wx.EVT_ENTER_WINDOW, self.onMouseOver)
        # self.Bind(wx.EVT_LEAVE_WINDOW, self.onMouseLeave)
        # self.Bind(wx.EVT_LEFT_DOWN, self.onLMouseDown)
        self.Bind(wx.EVT_MOUSE_EVENTS, self.onMouseEvents)

        atable = wx.AcceleratorTable([(wx.ACCEL_NORMAL, wx.WXK_ESCAPE,
                                       wx.ID_EXIT)])
        self.SetAcceleratorTable(atable)
        wx.EVT_MENU(self, wx.ID_EXIT, self.OnExit)

        self.SetBackgroundColour(
            wx.Colour(UI.WCOLOR['BG'][0], UI.WCOLOR['BG'][1],
                      UI.WCOLOR['BG'][2]))

        self.SetTransparent(220)
        self.Show()

        #fn = self.corePath + '\\bin\\images\\paramGuard.ico'
        #self.icon = wx.Icon(fn, wx.BITMAP_TYPE_ICO)
        #self.SetIcon(self.icon)

        self.section_list = ini_worker.get_sections_list_from_ini(
            self.configFile)  # list

        param_indentation = 10  # whitespace

        for section in self.section_list:

            self.section_EC_stat.update({
                section:
                ini_worker.get_param_from_ini(self.configFile, section,
                                              'collapse')
            })

            section_params = ini_worker.get_section_from_ini(
                self.configFile, section)
            for param, value in section_params.iteritems():
                if param == 'hideSection':
                    hideSection = value

            if not hideSection:

                self.param_dict[section] = {}

                font = wx.Font(9, wx.DEFAULT, wx.NORMAL, wx.BOLD)

                headline = wx.StaticText(self,
                                         label=section,
                                         pos=(UI.THEADERSTART['pos'][0],
                                              UI.THEADERSTART['pos'][1] +
                                              self.current_y_pxpos_elem))

                headline.SetForegroundColour(UI.TCOLOR['FG'])  # set text color
                headline.SetFont(font)
                headline.Bind(wx.EVT_ENTER_WINDOW, self.onMouseOver)
                #headline.Bind(wx.EVT_LEAVE_WINDOW, self.onMouseLeave)

                button = wx.Button(self,
                                   name=section,
                                   label="",
                                   pos=(UI.BEXPAND['pos'][0],
                                        self.current_y_pxpos_elem + 11),
                                   size=UI.BEXPAND['size'])

                button.Bind(wx.EVT_BUTTON, self.expandCollapse)
                button.SetBackgroundColour(UI.BCOLOR['BG'])  # set color
                button.SetToolTipString('Click to expand/collapse section')
                button.Bind(wx.EVT_ENTER_WINDOW, self.onMouseOver)
                #button.Bind(wx.EVT_LEAVE_WINDOW, self.onMouseLeave)

                self.current_y_pxpos_elem += 20

                # params in sections (edit boxes)
                font = wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL)
                ui_elem_handler_dict = {}

                for param, value in section_params.iteritems():

                    if type(value) == str:
                        splitted_value = value.split(';')
                        if len(splitted_value) > 1:
                            if splitted_value[1].strip() == 'X':
                                self.black_list.append(param)

                    if param not in self.black_list:

                        text = wx.StaticText(
                            self,
                            label=param,
                            pos=(UI.THEADERSTART['pos'][0] + param_indentation,
                                 UI.THEADERSTART['pos'][1] +
                                 self.current_y_pxpos_elem))

                        text.SetForegroundColour(
                            UI.PARAMCOLOR['FG'])  # set text color
                        text.Bind(wx.EVT_ENTER_WINDOW, self.onMouseOver)
                        #text.Bind(wx.EVT_LEAVE_WINDOW, self.onMouseLeave)

                        editbox = (wx.TextCtrl(self,
                                               name=section + ' - ' + param,
                                               value=str(value),
                                               pos=(UI.EBOX['pos'][0],
                                                    UI.THEADERSTART['pos'][1] +
                                                    self.current_y_pxpos_elem),
                                               size=UI.EBOX['size'],
                                               style=wx.TE_PROCESS_ENTER))

                        editbox.SetForegroundColour(
                            UI.ECOLOR2['FG'])  # set color
                        editbox.SetBackgroundColour(
                            UI.ECOLOR2['BG'])  # set color

                        editbox.Bind(wx.EVT_TEXT, self.EvtText)
                        editbox.Bind(wx.EVT_ENTER_WINDOW, self.onMouseOver)
                        #editbox.Bind(wx.EVT_LEAVE_WINDOW, self.onMouseLeave)

                        elem_dict = {
                            param: [{
                                'ebox': [editbox, value]
                            }, {
                                'headline': headline
                            }, {
                                'text': text
                            }, {
                                'button': button
                            }]
                        }

                        ui_elem_handler_dict.update(elem_dict)

                        self.current_y_pxpos_elem += 20

                    self.param_dict[section].update(ui_elem_handler_dict)

        self.expandCollapse(None, refresh=True)
        self.refresh_UI()
        self.KST.start()