def onSaveCfg(self, event):
        cfg.cfg_nicknames_to_dicts()        #  save any new settings to dictionary
        if gbl.mon_ID != 0:
            cfg.mon_nicknames_to_dicts(gbl.mon_ID)

        r = self.TopLevelParent.config.cfgSaveAs(self)
        if r:                                                                                                   #       TODO: progress indicator of some sort?
            self.TopLevelParent.SetStatusText('Configuration saved.')
            winsound.Beep(600,200)
        else:
            self.TopLevelParent.SetStatusText('Configuration not saved.')
            winsound.Beep(600,200)
Esempio n. 2
0
    def onGoToPage(
        self, page_num
    ):  # --------------------------------------------- for changing pages without an event
        gbl.statbar.SetStatusText(' ')
        old_ID = gbl.mon_ID

        if old_ID != 0:  # ------------------------------------------------------------------ leaving a monitor page
            cfg.mon_nicknames_to_dicts(
                old_ID)  # save any changes made to the monitor
            self.notebookPages[old_ID].clearVideo()  # remove video and timer

        if old_ID == 0:  # ---------------------------------------------------------- leaving the configuration page
            cfg.cfg_nicknames_to_dicts(
            )  # save any new changes to config parameters

            try:  # ------ don't know if thumbnails or console are showing
                self.notebookPages[0].scrolledThumbs.clearThumbGrid(
                )  # remove all thumbnails, timers, and threads
            except:
                pass
            try:  # ------ don't know if thumbnails or console are showing
                self.notebookPages[0].scrolledThumbs.clearConsoleGrid(
                )  # remove all thumbnails, timers, and threads
            except:
                pass

        # -------------------------------------------------------------------------------- update to the new page number
        gbl.mon_ID = page_num

        if page_num == 0:  # -------------------------------------------------------- going to configuration page
            cfg.cfg_dict_to_nicknames()  # load configuration page parameters
            self.notebookPages[0].fillTable()  # update the configuration table
            self.notebookPages[0].scrolledThumbs.refreshThumbGrid(
            )  # update and start the thumbnails window


#            self.notebookPages[0].scrolledThumbs.SetScrollbars(1,1,1,1)                                                # does not restore scrollbars
#            self.Layout()

        else:  # ---------------------------------------------------------------------- going to a monitor page
            if gbl.mon_ID != 0:
                cfg.mon_dict_to_nicknames(
                )  # update nicknames to values for the selected monitor

            self.notebookPages[
                gbl.mon_ID].previewPanel.parent.refreshVideo()  # start video

        self.notebookPages[0].scrolledThumbs.EnableScrolling(1, 1)
        self.notebookPages[0].Layout()

        print('check')
    def onAddMonitor(
        self, event
    ):  # ---------------------------------------------------------------    Add monitor
        """
        adds a monitor to the list 

        more than 9 monitors creates issues due to differences between alphabetical and numerical sorting.
            Avoiding problems by not allowing more than 9 monitors.
        """
        cfg.cfg_nicknames_to_dicts(
        )  # -------------------------------------------- save current cfg settings

        if gbl.monitors >= 9:  # no more than 9 monitors allowed
            self.TopLevelParent.SetStatusText(
                'Too many monitors.  Cannot add another.')
            winsound.Beep(600, 200)
            return False

        # -------------------------------------------------------------------- put new monitor settings in gbl nicknames
        gbl.cfg_dict.append({})  # add a dictionary to the cfg_dict list
        cfg.cfg_dict_to_nicknames()

        gbl.monitors += 1  # increase the number of monitors
        gbl.mon_ID = gbl.monitors  # update the current mon_ID
        gbl.mon_name = 'Monitor%d' % gbl.mon_ID  # update the monitor name

        #        if gbl.source_type == 0:                         # create new webcam name if this is a webcam
        #            gbl.webcams_inuse.append(gbl.mon_name)       # only one webcam is supported, but multiple monitors can use it
        #            gbl.webcams += 1
        #            gbl.source = 'Webcam%d' % gbl.webcams
        #            gbl.source = 'Webcam1'                      # only one webcam is supported, but multiple monitors can use it

        cfg.cfg_nicknames_to_dicts(
        )  # ---------------------------------- save new configuration settings to cfg_dict
        cfg.mon_nicknames_to_dicts(
            gbl.mon_ID
        )  # ----------------------------------------- apply new monitor settings to cfg_dict

        # --------------------------------------------------------------------------------- add monitor page to notebook
        self.parent.addMonitorPage()

        gbl.mon_ID = gbl.cfg_dict[0]['monitors']
        cfg.mon_dict_to_nicknames()
        self.Parent.notebookPages[0].fillTable(
        )  # update the configuration table
        self.scrolledThumbs.refreshThumbGrid()  # create the thumbnail window

        #        self.SetSizerAndFit(self.cfgPanelSizer)
        #        self.Layout()

        gbl.mon_ID = 0
Esempio n. 4
0
    def onSaveCfg(self, event):
        cfg.cfg_nicknames_to_dicts()  # save any new settings to dictionary
        if gbl.mon_ID != 0:
            cfg.mon_nicknames_to_dicts(
                gbl.mon_ID)  # save current monitor settings to dictionary

        r = self.TopLevelParent.config.cfgSaveAs(
            self)  # save the configuration
        if r:
            self.pickCFGfile.ChangeValue(r)
            gbl.shouldSaveCfg = False
            gbl.statbar.SetStatusText('Configuration saved.')
            winsound.Beep(300, 200)

        else:
            gbl.statbar.SetStatusText('Configuration not saved.')
            winsound.Beep(600, 200)
Esempio n. 5
0
    def repaginate(self):
        # page 0 (config page) will not be affected except for thumbnails

        self.Unbind(wx.EVT_NOTEBOOK_PAGE_CHANGING)             # prevent changes from triggering events
        self.Unbind(wx.EVT_NOTEBOOK_PAGE_CHANGED)             # prevent changes from triggering events

        # -------------------------------------------------------------------- delete each page from notebook (except 0)
        for gbl.mon_ID in range(len(self.notebookPages)-1, 0, -1):
            self.notebookPages[gbl.mon_ID].clearVideo()      # stop & remove video, timer, and thread for monitor pages
            del self.notebookPages[gbl.mon_ID]               # remove page from list of pages
            self.DeletePage(gbl.mon_ID)                      # remove page from notebook object

        # --------------------------------------------------------- stop configuration page thumbnail and console timers
        self.notebookPages[0].scrolledThumbs.clearGrid(self.notebookPages[0].panelType)

        # -------------------------------------------------------------------------------------- recreate notebook pages
        cfg.cfg_dict_to_nicknames()                  # load configuration parameters into globals
        self.notebookPages[0].scrolledThumbs.thumbPanels = ['videoMonitors']  # initiate a new thumbnail list;

        # ----------------------------------------------------------------------------------- add back each monitor page
        for gbl.mon_ID in range(1, gbl.monitors+1):                         # pages are numbered by monitor number
            cfg.mon_dict_to_nicknames()                                     # load monitor configuration into globals
            gbl.mon_name = 'Monitor%d' % gbl.mon_ID                         # correct mon_name
            cfg.mon_nicknames_to_dicts(gbl.mon_ID)                          # save new mon_name
            self.addMonitorPage()                                           # add monitor page to notebook

        self.notebookPages[0].fillTable()                                   # update the configuration table
        self.notebookPages[0].scrolledThumbs.refreshGrid()             # update the scrolled thumbs window

        gbl.mon_ID = 0          # ------------------------------------------------------------ go to configuration page
        self.SetSelection(gbl.mon_ID)

        self.notebookPages[0].scrolledThumbs.EnableScrolling(1, 1)
        self.notebookPages[0].Layout()

        self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED,  self.onPageChanged)          # restore binding
 def onClearMask(self, event):
     self.ROIs = []
     gbl.genmaskflag = True
     cfg.mon_nicknames_to_dicts(self.mon_ID)
     self.refreshVideo()