Ejemplo n.º 1
0
    def changeConfig(self):  # TODO doesn't erase consoles
        # ------------------------------ see if user wants to save current configuration before changing to another one.
        if gbl.shouldSaveCfg:
            cfg.Q_wantToSave(
                self)  # asks user if config should be saved, & if so, saves

        gbl.shouldSaveCfg = False

        gbl.cfg_dict = [gbl.cfg_dict[0], gbl.cfg_dict[1]
                        ]  # remove all but monitors 1 from dictionary

        self.GrandParent.config.loadConfigFile(
            self.filePathName)  # load the new file
        gbl.mon_ID = 1
        cfg.cfg_dict_to_nicknames()  # copy config parameters to nicknames
        cfg.mon_dict_to_nicknames()  # copy monitor 1 parameters to nicknames

        # -------------------------------------------------------------------- clear out previous scrolled window panels
        self.scrolledThumbs.clearGrid(self.panelType)

        # -------------------------------------------------------- load new configuration into table and scrolled window
        self.fillTable()  # put new configuration into the table
        self.pickCFGfile.ChangeValue(
            self.filePathName)  # update the config file text control

        cfg.cfg_dict_to_nicknames()  # load configuration page parameters
        self.fillTable()  # update the configuration table
        self.scrolledThumbs.refreshGrid(
        )  # update and start the thumbnails window
        self.parent.repaginate(
        )  # add monitor pages to notebook & end on config page

        self.scrolledThumbs.EnableScrolling(1, 1)
        self.Layout()
Ejemplo n.º 2
0
    def __init__(self, parent):
        wx.Panel.__init__(self,
                          parent,
                          wx.ID_ANY,
                          size=(640, 480),
                          name=gbl.mon_name)

        self.parent = parent
        self.mon_ID = gbl.mon_ID
        cfg.cfg_dict_to_nicknames(
        )  # set all nicknames for this monitor.  use these so changes will be saved on page change.
        cfg.mon_dict_to_nicknames()
        self.start_datetime = gbl.start_datetime
        self.mon_name = gbl.mon_name
        self.preview_size = gbl.preview_size
        self.preview_fps = gbl.preview_fps
        self.line_thickness = gbl.line_thickness
        self.source = gbl.source
        self.monitors = gbl.monitors
        self.data_folder = gbl.data_folder
        self.source_type = gbl.source_type
        self.source_fps = gbl.source_fps
        self.issdmonitor = gbl.issdmonitor
        self.track_type = gbl.track_type
        self.track = gbl.track
        self.mask_file = gbl.mask_file

        self.widgets()
        self.binders()
        self.sizers()
Ejemplo n.º 3
0
    def __init__(self, parent):

        wx.Notebook.__init__(self,
                             parent,
                             id=wx.ID_ANY,
                             style=wx.NB_LEFT,
                             name='NotebookNameStr')  # initialize notebook

        self.notebookPages = []

        self.notebookPages.append(
            cfgPanel.cfgPanel(self))  # -----configuration page is element 0
        cfg.cfg_dict_to_nicknames(
        )  # load configuration parameters into globals
        self.AddPage(self.notebookPages[0], 'Configuration')

        for gbl.mon_ID in range(
                1, gbl.monitors +
                1):  # monitor pages are numbered by monitor number
            cfg.mon_dict_to_nicknames(
            )  # load monitor configuration into globals
            self.addMonitorPage()  # add monitor page to notebook

        self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.onPageChanged)
        self.Layout()

        gbl.mon_ID = 0  # set mon_ID to zero which is configuration page
Ejemplo n.º 4
0
    def __init__(self, parent, size=(800,200)):

        wx.Panel.__init__(self, parent, size=size, name='cfgPanel')
        self.parent = parent
        self.mon_ID = 0                                    # the config page has mon_ID[0]
        cfg.cfg_dict_to_nicknames()

        self.makeWidgets()                          # start, stop, and browse buttons
        self.binders()
        self.sizers()                            # Set sizers
Ejemplo n.º 5
0
    def changeConfig(self):
        gbl.cfg_dict = [gbl.cfg_dict[0], gbl.cfg_dict[1]]       # remove all but monitors 1 from dictionary

        self.GrandParent.config.loadConfigFile(self.filePathName)
        gbl.mon_ID = 1
        cfg.cfg_dict_to_nicknames()
        cfg.mon_dict_to_nicknames()

        self.fillTable()                                        # put new configuration into the table
#        self.scrolledThumbs.refreshThumbGrid()                  # create the thumbnail window
        self.parent.repaginate()                                # add monitor pages to notebook & end on config page
        self.pickCFGfile.SetValue(self.filePathName)
Ejemplo n.º 6
0
    def repaginate(
        self
    ):  # -------------------------------------- update notebook after number of pages has changed
        # page 0 (config page) will not be affected except for thumbnails               # then go to configuration page

        # -------------------------------------------------------------------- delete each page from notebook (except 0)
        self.Unbind(wx.EVT_NOTEBOOK_PAGE_CHANGED
                    )  # prevent page changing while deleting pages
        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
            #            self.notebookPages.pop(gbl.mon_ID)               # remove page from list of 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
        try:  # ------ don't know if thumbnails or console are showing
            self.notebookPages[0].scrolledThumbs.clearThumbGrid()
        except:
            pass
        try:  # ------ don't know if thumbnails or console are showing
            self.notebookPages[0].scrolledThumbs.clearConsoleGrid()
        except:
            pass

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

        # ----------------------------------------------------------------------------------- add back each monitor page
        for gbl.mon_ID in range(
                1, gbl.monitors +
                1):  # monitor pages are numbered by monitor number
            cfg.mon_dict_to_nicknames(
            )  # load monitor configuration into globals
            self.addMonitorPage()  # add monitor page to notebook

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

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

        self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED,
                  self.onPageChanged)  # restore binding
Ejemplo n.º 7
0
    def __init__(self, parent, size=(800, 200)):

        wx.Panel.__init__(self, parent, size=size, name='cfgPanel')
        self.parent = parent
        self.mon_ID = 0  # the config page has mon_ID == 0
        cfg.cfg_dict_to_nicknames()

        self.monitors = gbl.cfg_dict[0]['monitors']
        self.panelType = 'thumb'  # always start out with playback thumbnails

        self.makeWidgets()  # start, stop, and browse buttons
        self.binders()  # bind event handlers
        self.sizers()  # Set sizers
Ejemplo n.º 8
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')
Ejemplo n.º 9
0
    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
Ejemplo n.º 10
0
    def __init__(self, parent):
        wx.Notebook.__init__(self, parent, id=wx.ID_ANY, style=wx.NB_LEFT, name='Notebook')
        # ------------------------------------------------------------------------------------ create configuration page
        cfg.cfg_dict_to_nicknames()                              # load configuration parameters into global nicknames
        self.notebookPages = []             # create list to contain notebook page information indexed by mon_ID
        self.notebookPages.append(cfgPanel.cfgPanel(self))       # ----- configuration page is element 0
        self.AddPage(self.notebookPages[0], 'Configuration')     # ----- add configuration page to notebook

        # ----------------------------------------------------------------------------------------- create monitor pages
        for gbl.mon_ID in range(1, gbl.monitors+1):                 # monitor page numbers match monitor number
            cfg.mon_dict_to_nicknames()                             # load monitor configuration into global nicknames
            self.notebookPages.append(monPanel.monPanel(self))  # make the monitor page
            self.AddPage(self.notebookPages[gbl.mon_ID], gbl.mon_name)  # add to notebook

        # ------------------------------------------------------------------------------------------- bind event handler
        self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.onPageChanged)

        self.Layout()

        gbl.mon_ID = self.page_num = 0                              # set mon_ID to zero which is configuration page
Ejemplo n.º 11
0
    def onGoToPage(self, nextpage):
        self.page_num = nextpage      # assume page will change. user cancellation sets self.page_num back to gbl.mon_ID
        gbl.statbar.SetStatusText(' ')
# TODO: stop duplicate preview panels
        # ------------------------------------------------------------------------------------------------ save changes
        if gbl.mon_ID != 0:  # ------------------------------------------------------------- leaving a monitor page
            self.page_num = self.notebookPages[gbl.mon_ID].Q_shouldSaveMask(nextpage)# new mask not saved. want to save?

        if gbl.shouldSaveCfg:  # cfg changed. want to save?      --------------------------- leaving any page
            self.page_num = cfg.Q_wantToSave(self.notebookPages[gbl.mon_ID],nextpage)

        if self.page_num <> gbl.mon_ID:  # if the page is still going to change, remove the video panels
            if gbl.mon_ID == 0:  # ------------------------------------------------- leaving the configuration page
                                                                        # remove all thumbnails, timers, and threads
                self.notebookPages[0].scrolledThumbs.clearGrid(self.notebookPages[0].panelType)

            if gbl.mon_ID != 0:  # -------------------------------------------------------------- leaving a monitor page
                self.notebookPages[gbl.mon_ID].clearVideo()             # remove video and timer

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

        if gbl.mon_ID == 0:         # ---------------------------------------------------- refresh configuration page
            cfg.cfg_dict_to_nicknames()                                 # load configuration page parameters
            self.notebookPages[0].fillTable()                           # update the configuration table

            self.notebookPages[0].scrolledThumbs.refreshGrid()     # restart the thumbnail windows
            self.notebookPages[0].scrolledThumbs.EnableScrolling(1, 1)  # restore scrollbars
            self.notebookPages[0].SetSizer(self.notebookPages[gbl.mon_ID].cfgPanelSizer)
            self.notebookPages[0].Layout()
            self.Layout()

                         # ----------------------------------------------------------------- refresh the monitor page
        elif gbl.mon_ID != 0:                 # TODO: why double preview panels?  changing source fixes it
            cfg.mon_dict_to_nicknames()                             # update nicknames for the selected monitor


            self.notebookPages[gbl.mon_ID].refreshVideo()       # restart start video   (monPanel.py)
            self.notebookPages[gbl.mon_ID].SetSizer(self.notebookPages[gbl.mon_ID].mainSizer)
            self.notebookPages[gbl.mon_ID].Layout()
            self.Layout()
Ejemplo n.º 12
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
Ejemplo n.º 13
0
 def update_from_dicts(self):
     cfg.cfg_dict_to_nicknames()
     self.monitors = gbl.cfg_dict[0]['monitors']
     self.panelType = 'thumb'  # always start out with playback thumbnails