Esempio n. 1
0
    def _create_toolbar(self):
        """ Creates a toolbar panel. """

        toolbar = MainToolbarPanel(self, self._prefsIO)

        toolbar.AddButton(FILTER_CHECK_ID,
                          FILTER_CHECK,
                          'Check',
                          tooltip="Choose the tier(s) to check.")
        toolbar.AddButton(FILTER_UNCHECK_ID,
                          FILTER_UNCHECK,
                          'Uncheck',
                          tooltip="Uncheck all the tier(s) of the page.")
        toolbar.AddButton(
            PREVIEW_ID,
            TIER_PREVIEW,
            'View',
            tooltip="Preview one checked tier of the selected file.")
        toolbar.AddSpacer()
        toolbar.AddButton(
            DESCRIPTIVES_ID,
            SPREADSHEETS,
            'Statistics',
            tooltip="Estimates descriptive statistics of checked tier(s).")
        toolbar.AddButton(USERCHECK_ID,
                          USERCHECK,
                          'User\nAgreement',
                          tooltip="Estimates Kappa of checked tier(s).")
        toolbar.AddSpacer()

        return toolbar
    def _create_toolbar(self):
        """Creates a toolbar panel."""

        toolbar = MainToolbarPanel(self, self._prefsIO)

        toolbar.AddButton(RENAME_ID,
                          TIER_RENAME,
                          'Rename',
                          tooltip="Rename the selected tier.")

        toolbar.AddButton(wx.ID_DELETE,
                          TIER_DELETE,
                          'Delete',
                          tooltip="Delete the selected tier.")

        toolbar.AddButton(wx.ID_CUT,
                          TIER_CUT,
                          'Cut',
                          tooltip="Cut the selected tier.")

        toolbar.AddButton(wx.ID_COPY,
                          TIER_COPY,
                          "Copy",
                          tooltip="Copy the selected tier.")

        toolbar.AddButton(wx.ID_PASTE,
                          TIER_PASTE,
                          "Paste",
                          tooltip="Paste the selected tier.")

        toolbar.AddButton(DUPLICATE_ID,
                          TIER_DUPLICATE,
                          "Duplicate",
                          tooltip="Duplicate the selected tier.")

        toolbar.AddButton(wx.ID_UP,
                          TIER_MOVE_UP,
                          "Move Up",
                          tooltip="Move up the selected tier.")

        toolbar.AddButton(wx.ID_DOWN,
                          TIER_MOVE_DOWN,
                          "Move Down",
                          tooltip="Move down the selected tier.")

        toolbar.AddButton(TIER_RADIUS_ID,
                          TIER_RADIUS,
                          "Radius",
                          tooltip="Fix the vagueness of each boundary. "
                          "Useful only for .xra file format.")

        toolbar.AddButton(PREVIEW_ID,
                          TIER_PREVIEW,
                          "View",
                          tooltip="Preview of the selected tier.")

        return toolbar
Esempio n. 3
0
    def _create_toolbar(self):
        """ Simulate the creation of a toolbar. """

        toolbar = MainToolbarPanel(self, self._prefsIO)
        toolbar.AddButton(wx.ID_ADD,
                          ADD_FILE_ICON,
                          "Add files",
                          tooltip="Add files into the list.")
        toolbar.AddButton(ID_TB_ADDDIR,
                          ADD_DIR_ICON,
                          "Add dir",
                          tooltip="Add a folder into the list.")
        toolbar.AddButton(wx.ID_REMOVE,
                          REMOVE_ICON,
                          "Remove",
                          tooltip="Remove files of the list.")
        toolbar.AddButton(wx.ID_DELETE,
                          DELETE_ICON,
                          "Delete",
                          tooltip="Delete definitively files of the computer.")
        toolbar.AddButton(wx.ID_SAVEAS,
                          EXPORT_AS_ICON,
                          "Copy",
                          tooltip="Copy files.")
        toolbar.AddButton(wx.ID_SAVE,
                          EXPORT_ICON,
                          "Export",
                          tooltip="Export files.")
        return toolbar
    def _create_toolbar(self):
        """Creates a toolbar panel."""

        toolbar = MainToolbarPanel(self, self._prefsIO)

        toolbar.AddButton(FILTER_CHECK_ID, FILTER_CHECK,
                          'Check',
                          tooltip="Choose the tier(s) to check.")
        toolbar.AddButton(FILTER_UNCHECK_ID, FILTER_UNCHECK,
                          'Uncheck',
                          tooltip="Uncheck all the tier(s) of the page.")
        toolbar.AddButton(wx.ID_DELETE, TIER_DELETE,
                          'Delete',
                          tooltip="Delete all the checked tier(s) of the page.")
        toolbar.AddButton(PREVIEW_ID, TIER_PREVIEW,
                          'View',
                          tooltip="Preview a tier of the selected file.")
        toolbar.AddSpacer()

        toolbar.AddButton(FILTER_SEL_ID, FILTER_SINGLE,
                          'Single',
                          tooltip="Filter checked tier(s) depending on "
                                  "its annotations.")
        toolbar.AddButton(FILTER_REL_ID, FILTER_RELATION,
                          'Relation',
                          tooltip="Filter checked tier(s) depending on "
                                  "time-relations of its annotation with "
                                  "annotations of another tier.")
        toolbar.AddSpacer()

        return toolbar
Esempio n. 5
0
    def _create_toolbar(self, parent):
        """Creates the default toolbar."""

        toolbar = MainToolbarPanel(parent, self._prefsIO)
        toolbar.AddButton(wx.ID_ADD,
                          ADD_FILE_ICON,
                          "Add files",
                          tooltip="Add files into the list.")
        toolbar.AddButton(wx.ID_REMOVE,
                          REMOVE_ICON,
                          "Remove",
                          tooltip="Remove files of the list.")
        toolbar.AddButton(ID_TB_NEWTAB,
                          TAB_NEW_ICON,
                          "New tab",
                          tooltip="Open a new page in the notebook.")
        toolbar.AddButton(ID_TB_CLOSETAB,
                          TAB_CLOSE_ICON,
                          "Close tab",
                          tooltip="Close the current page in the notebook.")
        toolbar.AddSpacer()
        return toolbar
Esempio n. 6
0
    def _create_toolbar(self):
        """ Creates a toolbar panel. """

        activated = True
        if self._manager is None:
            activated = False

        toolbar = MainToolbarPanel(self, self._preferences)
        toolbar.AddSpacer()
        toolbar.AddButton(
            IMPORT_ID,
            PLUGIN_IMPORT_ICON,
            'Install',
            tooltip="Install a plugin in SPPAS plugins directory.",
            activated=activated)
        toolbar.AddButton(
            REMOVE_ID,
            PLUGIN_REMOVE_ICON,
            'Delete',
            tooltip="Delete a plugin of SPPAS plugins directory.",
            activated=activated)
        toolbar.AddSpacer()
        return toolbar
Esempio n. 7
0
class SingleFilterPanel(wx.Panel):
    """Panel to fix the filters to be used.

    :author:  Brigitte Bigi
    :contact: [email protected]
    :license: GPL

    """
    def __init__(self, parent, prefsIO):
        wx.Panel.__init__(self, parent, size=(580, 320))
        self.SetBackgroundColour(prefsIO.GetValue('M_BG_COLOUR'))

        # Members
        self.preferences = prefsIO
        self.data = []

        self._create_toolbar()
        self._create_filterlist()
        self.Bind(wx.EVT_BUTTON, self.ProcessEvent)

        self.opt = wx.CheckBox(self,
                               label='Replace tag of annotations '
                               'by the filter name.')
        self.opt.SetBackgroundColour(prefsIO.GetValue('M_BG_COLOUR'))

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.toolbar,
                  proportion=0,
                  flag=wx.EXPAND | wx.TOP | wx.LEFT | wx.RIGHT,
                  border=4)

        sizer.Add(self.filterlist,
                  proportion=1,
                  flag=wx.EXPAND | wx.LEFT | wx.RIGHT,
                  border=4)

        sizer.Add(self.opt, proportion=0, flag=wx.EXPAND | wx.TOP, border=5)

        self.SetSizer(sizer)
        self.SetMinSize((380, 280))
        self.SetAutoLayout(True)
        self.Center()

    # -------------------------------------------------------------------------

    def _create_toolbar(self):

        self.toolbar = MainToolbarPanel(self, self.preferences)

        self.toolbar.AddButton(ID_ADD_LABEL,
                               FILTER_ADD_LABEL,
                               "+ Tag",
                               tooltip="Add a filter on the content of "
                               "each annotation of the tier.")

        self.toolbar.AddButton(ID_ADD_TIME,
                               FILTER_ADD_TIME,
                               "+ Loc",
                               tooltip="Add a localization to start or "
                               "to end filtering.")

        self.toolbar.AddButton(ID_ADD_DURATION,
                               FILTER_ADD_DURATION,
                               "+ Dur",
                               tooltip="Add a filter on the duration of "
                               "each annotations of the tier.")

        self.toolbar.AddSpacer()

        self.toolbar.AddButton(ID_CLEAR,
                               FILTER_REMOVE,
                               "- Remove",
                               tooltip="Remove checked filters of the list.")

    # -------------------------------------------------------------------------

    def _create_filterlist(self):

        self.filterlist = CheckListCtrl(self,
                                        -1,
                                        style=wx.LC_REPORT | wx.BORDER_NONE)
        self.filterlist.SetBackgroundColour(
            self.preferences.GetValue('M_BG_COLOUR'))
        self.filterlist.SetFont(self.preferences.GetValue('M_FONT'))

        cols = ("Filter", "Function", "Value")
        for i, col in enumerate(cols):
            self.filterlist.InsertColumn(i, col)
        self.filterlist.SetColumnWidth(1, 120)
        self.filterlist.SetFocus()

    # ------------------------------------------------------------------------
    # Callbacks to any kind of event
    # ------------------------------------------------------------------------

    def ProcessEvent(self, event):
        """Process an event.

        Processes an event., searching event tables and calling zero or more
        suitable event handler function(s).  Note that the ProcessEvent
        method is called from the wxPython docview framework directly since
        wxPython does not have a virtual ProcessEvent function.

        """
        pid = event.GetId()

        if pid == ID_ADD_LABEL:
            self.OnAddLabel(event)
            return True

        elif pid == ID_ADD_TIME:
            self.OnAddTime(event)
            return True

        elif pid == ID_ADD_DURATION:
            self.OnAddDuration(event)
            return True

        elif pid == ID_CLEAR:
            self.OnRemove(event)
            return True

        return wx.GetApp().ProcessEvent(event)

    # ----------------------------------------------------------------------
    # Callbacks
    # ----------------------------------------------------------------------

    def OnAddLabel(self, event):
        dlg = LabelFilterDialog(self, self.preferences)
        if dlg.ShowModal() == wx.ID_OK:
            data = dlg.GetData()
            self._add_filter(data)
            self.data.append(data)
        dlg.Destroy()

    def OnAddTime(self, event):
        dlg = TimeFilterDialog(self, self.preferences)
        if dlg.ShowModal() == wx.ID_OK:
            data = dlg.GetData()
            self._add_filter(data)
            self.data.append(data)
        dlg.Destroy()

    def OnAddDuration(self, event):
        dlg = DurationFilterDialog(self, self.preferences)
        dlg.Show()
        if dlg.ShowModal() == wx.ID_OK:
            data = dlg.GetData()
            self._add_filter(data)
            self.data.append(data)
        dlg.Destroy()

    def OnRemove(self, event):
        # fix a list of selected idem indexes
        selected = []
        currentf = self.filterlist.GetFirstSelected()
        while currentf != -1:
            nextf = self.filterlist.GetNextSelected(currentf)
            selected.append(currentf)
            currentf = nextf

        # remove selected items (starting from end!)
        for index in reversed(selected):
            self.data.pop(index)
            self.filterlist.DeleteItem(index)

    # ----------------------------------------------------------------------
    # Public Methods
    # ----------------------------------------------------------------------

    def GetSelectedData(self):
        """Return list of the selected data defined in the notebook."""

        all_data = list()
        sel_list = self.filterlist.GetFirstSelected()
        while sel_list != -1:
            all_data.append(self.data[sel_list])
            sel_list = self.filterlist.GetNextSelected(sel_list)

        return all_data

    # ----------------------------------------------------------------------
    # Private methods
    # ----------------------------------------------------------------------

    def _add_filter(self, data):
        """Add a filter in the list."""

        index = self.filterlist.GetItemCount()

        self.filterlist.InsertStringItem(index, data[0])
        self.filterlist.SetStringItem(index, 1, data[1])
        self.filterlist.SetStringItem(index, 2, str(data[2]))
        self.filterlist.Select(index, on=True)
Esempio n. 8
0
class SingleFilterPanel(wx.Panel):
    """
    @author:  Brigitte Bigi
    @contact: [email protected]
    @license: GPL
    @summary: Panel to fix filters to be used with Sel predicate.

    """

    def __init__(self, parent, prefsIO):
        wx.Panel.__init__(self, parent, size=(580, 320))
        self.SetBackgroundColour(prefsIO.GetValue('M_BG_COLOUR'))

        # Members
        self.preferences = prefsIO
        self.data = []

        self._create_toolbar()
        self._create_filterlist()
        self.Bind(wx.EVT_BUTTON, self.ProcessEvent)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.toolbar,     proportion=0, flag=wx.EXPAND|wx.TOP|wx.LEFT|wx.RIGHT, border=4)
        sizer.Add(self.filterlist,  proportion=1, flag=wx.EXPAND|wx.LEFT|wx.RIGHT, border=4)
        self.SetSizer(sizer)
        self.SetAutoLayout( True )


    def _create_toolbar(self):

        self.toolbar = MainToolbarPanel(self, self.preferences)
        self.toolbar.AddButton( ID_ADD_LABEL, FILTER_ADD_LABEL, "Label", tooltip="Add a filter on the content of each annotation of the tier.")
        self.toolbar.AddButton( ID_ADD_TIME, FILTER_ADD_TIME,   "Time",  tooltip="Add a filter to fix the time to start or to end to filter.")
        self.toolbar.AddButton( ID_ADD_DURATION, FILTER_ADD_DURATION, "Duration", tooltip="Add a filter on the duration of each annotations of the tier.")
        self.toolbar.AddSpacer()
        self.toolbar.AddButton( ID_CLEAR, FILTER_REMOVE, "Remove", tooltip="Remove checked filters of the list.")


    def _create_filterlist(self):

        self.filterlist = CheckListCtrl(self, -1, style=wx.LC_REPORT|wx.BORDER_NONE)
        self.filterlist.SetBackgroundColour(self.preferences.GetValue('M_BG_COLOUR'))
        self.filterlist.SetFont( self.preferences.GetValue('M_FONT') )

        cols = ("Filter", "Function", "Value", "Option")
        for i, col in enumerate(cols):
            self.filterlist.InsertColumn(i, col)
            self.filterlist.SetColumnWidth(i, 120)
        self.filterlist.SetFocus()

    # ------------------------------------------------------------------------
    # Callbacks to any kind of event
    # ------------------------------------------------------------------------

    def ProcessEvent(self, event):
        """
        Processes an event, searching event tables and calling zero or more
        suitable event handler function(s).  Note that the ProcessEvent
        method is called from the wxPython docview framework directly since
        wxPython does not have a virtual ProcessEvent function.
        """
        id = event.GetId()

        if id == ID_ADD_LABEL:
            self.OnAddLabel(event)
            return True

        elif id == ID_ADD_TIME:
            self.OnAddTime(event)
            return True

        elif id == ID_ADD_DURATION:
            self.OnAddDuration(event)
            return True

        elif id == ID_CLEAR:
            self.OnRemove(event)
            return True

        return wx.GetApp().ProcessEvent(event)

    # ----------------------------------------------------------------------
    # Callbacks
    # ----------------------------------------------------------------------

    def OnAddLabel(self, event):
        dlg = LabelFilterDialog(self, self.preferences)
        if dlg.ShowModal() == wx.ID_OK:
            data = dlg.GetData()
            self._add_filter( data )
            self.data.append( data )
        dlg.Destroy()

    def OnAddTime(self, event):
        dlg = TimeFilterDialog(self, self.preferences)
        if dlg.ShowModal() == wx.ID_OK:
            data = dlg.GetData()
            self._add_filter( data )
            self.data.append( data )
        dlg.Destroy()

    def OnAddDuration(self, event):
        dlg = DurationFilterDialog(self, self.preferences)
        dlg.Show()
        if dlg.ShowModal() == wx.ID_OK:
            data = dlg.GetData()
            self._add_filter( data )
            self.data.append( data )
        dlg.Destroy()

    def OnRemove(self, event):
        # fix a list of selected idem indexes
        selected = []
        currentf = self.filterlist.GetFirstSelected()
        while currentf != -1:
            nextf = self.filterlist.GetNextSelected( currentf )
            selected.append( currentf )
            currentf = nextf

        # remove selected items (starting from end!)
        for index in reversed(selected):
            self.data.pop( index )
            self.filterlist.DeleteItem( index )

    # ----------------------------------------------------------------------
    # Public Methods
    # ----------------------------------------------------------------------

    def GetPredicates(self):
        """ Return a predicate, constructed from the data. """

        predicates = []
        sellist = self.filterlist.GetFirstSelected()
        while sellist != -1:
            d = self.data[sellist]
            p = _genPredicateSel( **d ).generate()
            predicates.append( p )
            sellist = self.filterlist.GetNextSelected( sellist )

        return predicates

    # ----------------------------------------------------------------------
    # Private methods
    # ----------------------------------------------------------------------

    def _add_filter(self, data):
        """ Add a filter in the list. """

        row = self._format_data(data)
        index = self.filterlist.GetItemCount()

        self.filterlist.InsertStringItem( index, row[0] )
        for i in range(1,len(row)):
            self.filterlist.SetStringItem( index, i, row[i] )
        self.filterlist.Select( index,on=True )


    def _format_data(self, data):
        """ Format data to be included in the list. """

        opt = ""
        if "label" in data['type'].lower() and 'string' in data['type'].lower():
            values = ", ".join( data['value'] )
            if data['case_sensitive'] is True:
                opt = "Case-sensitive"
            else:
                opt = "Case-insensitive"
        else:
            values = str(data['value'][0])

        if 'opt' in data.keys() and data['opt'] == "any":
            opt += " Alternatives"

        return (data['type'], data['name'], values, opt)