示例#1
0
    def __init__(self, master, app_variables, **kwargs):
        """

        Parameters
        ----------
        master
            The master widget
        app_variables : AppVariables
        kwargs
            keyword arguments passed through to the Frame constructor
        """

        self.app_variables = app_variables
        Frame.__init__(self, master, **kwargs)

        self.button_panel = Frame(self, relief=tkinter.RIDGE,
                                  borderwidth=2)  # type: Frame
        self.new_button = Button(self.button_panel,
                                 text='New Annotation',
                                 width=28)  # type: Button
        self.new_button.grid(row=0, column=0, sticky='NW')
        self.edit_button = Button(self.button_panel,
                                  text='Edit Selected Annotation',
                                  width=28)  # type: Button
        self.edit_button.grid(row=1, column=0, sticky='NW')
        self.zoom_button = Button(self.button_panel,
                                  text='Zoom to Selected Annotation',
                                  width=28)  # type: Button
        self.zoom_button.grid(row=2, column=0, sticky='NW')
        self.move_button = Button(self.button_panel,
                                  text='Move Selected Annotation',
                                  width=28)  # type: Button
        self.move_button.grid(row=3, column=0, sticky='NW')
        self.frame1 = Frame(self.button_panel)
        self.units_label = Label(self.frame1,
                                 text='Units:',
                                 relief=tkinter.RIDGE)
        self.units_label.pack(side=tkinter.LEFT)
        self.units_value = Combobox(self.frame1, text='')
        self.units_value.pack(side=tkinter.LEFT)
        self.frame1.grid(row=4, column=0, sticky='NW')
        self.button_panel.grid(row=0, column=0, sticky='NSEW')

        self.viewer = RCSCollectionViewer(self, app_variables)
        self.viewer.frame.grid(row=1, column=0, sticky='NSEW')
        self.grid_rowconfigure(1, weight=1)
        self.grid_columnconfigure(0, weight=1)

        self.units_value.on_selection(self.callback_units_select)
示例#2
0
    def __init__(self, parent):
        """

        Parameters
        ----------
        parent
        """

        Frame.__init__(self, parent)

        self.parent = parent

        self.button_style = ttk.Style()
        self.button_style.configure('ToggleOff.TButton',
                                    font=('Arial', 24),
                                    foreground="gray50",
                                    background="PaleTurquoise3",
                                    width=3,
                                    sticky='CENTER')
        self.button_style.configure('ToggleOn.TButton',
                                    font=('Arial', 24),
                                    foreground="black",
                                    background="PaleTurquoise1",
                                    width=3,
                                    sticky='CENTER')

        self.button_rev = Button(self.parent,
                                 text="\u25C0",
                                 takefocus=0,
                                 style='ToggleOff.TButton')
        self.button_prev = Button(self.parent,
                                  text="-1",
                                  takefocus=0,
                                  style='ToggleOff.TButton')
        self.button_next = Button(self.parent,
                                  text="+1",
                                  takefocus=0,
                                  style='ToggleOff.TButton')
        self.button_fwd = Button(self.parent,
                                 text="\u25B6",
                                 takefocus=0,
                                 style='ToggleOff.TButton')
示例#3
0
    def __init__(self, master, app_variables, **kwargs):
        """

        Parameters
        ----------
        master
            The master widget
        app_variables : AppVariables
        kwargs
            keyword arguments passed through to the Frame constructor
        """

        Frame.__init__(self, master, **kwargs)

        self.button_panel = Frame(self, relief=tkinter.RIDGE,
                                  borderwidth=2)  # type: Frame
        self.new_button = Button(self.button_panel,
                                 text='New Annotation',
                                 width=28)  # type: Button
        self.new_button.grid(row=0, column=0, sticky='NW')
        self.edit_button = Button(self.button_panel,
                                  text='Edit Selected Annotation',
                                  width=28)  # type: Button
        self.edit_button.grid(row=1, column=0, sticky='NW')
        self.zoom_button = Button(self.button_panel,
                                  text='Zoom to Selected Annotation',
                                  width=28)  # type: Button
        self.zoom_button.grid(row=2, column=0, sticky='NW')
        self.move_button = Button(self.button_panel,
                                  text='Move Selected Annotation',
                                  width=28)  # type: Button
        self.move_button.grid(row=3, column=0, sticky='NW')
        self.button_panel.grid(row=0, column=0, sticky='NSEW')

        self.viewer = LabelCollectionViewer(self, app_variables)
        self.viewer.frame.grid(row=1, column=0, sticky='NSEW')
        self.grid_rowconfigure(1, weight=1)
        self.grid_columnconfigure(0, weight=1)
示例#4
0
    def __init__(self, master, app_variables, **kwargs):
        """

        Parameters
        ----------
        master
        app_variables : AppVariables
        kwargs
        """

        self.app_variables = app_variables
        self.current_annotation = None  # type: Union[None, LabelFeature]
        Frame.__init__(self, master, **kwargs)

        self.update_label_button = Button(
            self, text='Update Label',
            command=self.callback_update_label)  # type: Button
        self.update_label_button.grid(row=0,
                                      column=0,
                                      columnspan=2,
                                      sticky='NE',
                                      padx=3,
                                      pady=3)

        self.viewer = TreeviewWithScrolling(
            self, columns=('confidence', ),
            selectmode=tkinter.BROWSE)  # type: TreeviewWithScrolling
        self.viewer.heading('#0', text='Label')
        self.viewer.heading('#1', text='Confidence')
        self.viewer.frame.grid(row=1, column=0, sticky='NSEW', padx=3, pady=3)
        # NB: reference the frame for packing, since it's already packed into a frame

        self.label_specifics = LabelSpecificsPanel(self,
                                                   app_variables,
                                                   border=1,
                                                   relief=tkinter.RIDGE)
        self.label_specifics.grid(row=1,
                                  column=1,
                                  sticky='NSEW',
                                  padx=3,
                                  pady=3)
        self.grid_rowconfigure(1, weight=1)
        self.grid_columnconfigure(0, weight=1)
        self.grid_columnconfigure(1, weight=1)
        self.update_annotation()

        self.viewer.bind('<<TreeviewSelect>>',
                         self.callback_label_selected_on_viewer)
示例#5
0
    def __init__(self, label_schema, start_item=None):
        """

        Parameters
        ----------
        label_schema : str|LabelSchema
        start_item : None|str
            The initial item selected
        """

        # validate label schema input
        if isinstance(label_schema, str):
            label_schema = LabelSchema.from_file(label_schema)
        if not isinstance(label_schema, LabelSchema):
            raise TypeError(
                'label_schema must be either a path to am appropriate .json file or a '
                'LabelSchema object. Got type {}'.format(type(label_schema)))

        # initialize the selected value option
        self._selected_value = ''

        self.root = tkinter.Toplevel()
        self.root.geometry('250x400')
        self.root.wm_title('Select Label Schema Entry')

        self.viewer = SchemaViewer(self.root, label_schema=label_schema)
        self.viewer.frame.pack(side=tkinter.TOP,
                               expand=tkinter.TRUE,
                               fill=tkinter.BOTH)
        self.set_selected_value(start_item)
        self.submit_button = Button(self.root,
                                    text='Submit',
                                    command=self.set_value)
        self.submit_button.pack(side=tkinter.BOTTOM, expand=tkinter.TRUE)
        self.root.grab_set()
        self.root.wait_window()
示例#6
0
    def __init__(self, master, label_schema=None, **kwargs):
        """

        Parameters
        ----------
        master : tkinter.Tk|tkinter.TopLevel
        label_schema : None|str|LabelSchema
        kwargs
            keyword arguments for Frame
        """

        self.variables = AppVariables()
        self.master = master
        Frame.__init__(self, master, **kwargs)

        self.frame1 = Frame(self, borderwidth=1, relief=tkinter.RIDGE)

        self.version_label = Label(self.frame1,
                                   text='Version Number:',
                                   relief=tkinter.RIDGE,
                                   justify=tkinter.LEFT,
                                   padding=5,
                                   width=18)
        self.version_label.grid(row=0, column=0, sticky='NEW')
        self.version_entry = Entry(self.frame1, text='')
        self.version_entry.grid(row=0, column=1, sticky='NEW')

        self.version_date_label = Label(self.frame1,
                                        text='Version Date:',
                                        relief=tkinter.RIDGE,
                                        justify=tkinter.LEFT,
                                        padding=5,
                                        width=18)
        self.version_date_label.grid(row=1, column=0, sticky='NEW')
        self.version_date_entry = Entry(self.frame1, text='')
        self.version_date_entry.grid(row=1, column=1, sticky='NEW')

        self.classification_label = Label(self.frame1,
                                          text='Classification:',
                                          relief=tkinter.RIDGE,
                                          justify=tkinter.LEFT,
                                          padding=5,
                                          width=18)
        self.classification_label.grid(row=2, column=0, sticky='NEW')
        self.classification_entry = Entry(self.frame1, text='')
        self.classification_entry.grid(row=2, column=1, sticky='NEW')

        self.confidence_label = Label(self.frame1,
                                      text='Confidence Values:',
                                      relief=tkinter.RIDGE,
                                      justify=tkinter.LEFT,
                                      padding=5,
                                      width=18)
        self.confidence_label.grid(row=3, column=0, sticky='NEW')
        self.confidence_entry = Entry(self.frame1, text='')
        self.confidence_entry.grid(row=3, column=1, sticky='NEW')

        self.geometries_label = Label(self.frame1,
                                      text='Geometries:',
                                      relief=tkinter.RIDGE,
                                      justify=tkinter.LEFT,
                                      padding=5,
                                      width=18)
        self.geometries_label.grid(row=4, column=0, sticky='NEW')
        self.geometries_entry = Entry(self.frame1, text='')
        self.geometries_entry.grid(row=4, column=1, sticky='NEW')

        self.frame1.grid_columnconfigure(1, weight=1)
        self.frame1.pack(side=tkinter.TOP, fill=tkinter.X)

        self.frame2 = Frame(self, borderwidth=1, relief=tkinter.RIDGE)
        self.new_button = Button(self.frame2, text='New Entry')
        self.new_button.pack(side=tkinter.LEFT, padx=5, pady=5)
        self.edit_button = Button(self.frame2, text='Edit Entry')
        self.edit_button.pack(side=tkinter.LEFT, padx=5, pady=5)
        self.delete_button = Button(self.frame2, text='Delete Entry')
        self.delete_button.pack(side=tkinter.LEFT, padx=5, pady=5)
        self.move_up_button = Button(self.frame2, text='Move Entry Up')
        self.move_up_button.pack(side=tkinter.LEFT, padx=5, pady=5)
        self.move_down_button = Button(self.frame2, text='Move Entry Down')
        self.move_down_button.pack(side=tkinter.LEFT, padx=5, pady=5)
        self.frame2.pack(side=tkinter.TOP, fill=tkinter.X)

        self.schema_viewer = SchemaViewer(self)
        self.schema_viewer.frame.pack(side=tkinter.BOTTOM,
                                      expand=tkinter.TRUE,
                                      fill=tkinter.BOTH)
        # NB: it's already packed inside a frame

        self.pack(expand=tkinter.YES, fill=tkinter.BOTH)

        # set up the menu bar
        menu = tkinter.Menu()
        filemenu = tkinter.Menu(menu, tearoff=0)
        filemenu.add_command(label="Open Schema", command=self.callback_open)
        filemenu.add_command(label="New Schema",
                             command=self.callback_new_schema)
        filemenu.add_separator()
        filemenu.add_command(label="Save", command=self.save)
        filemenu.add_command(label="Save As", command=self.callback_save_as)
        filemenu.add_separator()
        filemenu.add_command(label="Exit", command=self.exit)
        menu.add_cascade(label="File", menu=filemenu)
        self.master.config(menu=menu)

        # setup entry configs and some validation callbacks
        self.schema_viewer.bind('<<TreeviewSelect>>',
                                self.item_selected_on_viewer)

        self.version_entry.config(validate='focusout',
                                  validatecommand=self.register(
                                      self._version_entry_validate))
        self.version_date_entry.config(state='disabled')
        self.classification_entry.config(validate='focusout',
                                         validatecommand=self.register(
                                             self._classification_validate))
        self.confidence_entry.config(validate='focusout',
                                     validatecommand=self.register(
                                         self._confidence_validate))
        self.geometries_entry.config(
            validate='focusout',
            validatecommand=(self.register(self._geometry_validate), ),
            invalidcommand=(self.register(self._geometry_invalid), ))
        self.edit_button.config(command=self.callback_edit_entry)
        self.new_button.config(command=self.callback_new_entry)
        self.delete_button.config(command=self.callback_delete_entry)
        self.move_up_button.config(command=self.callback_move_up)
        self.move_down_button.config(command=self.callback_move_down)

        # setup the entry panel
        self.entry_popup = tkinter.Toplevel(self.master)
        self.entry = LabelEntryPanel(self.entry_popup, self.variables)
        self.entry.hide_on_close()
        self.entry_popup.withdraw()

        self.entry.save_button.config(command=self.callback_save_entry)

        self.set_label_schema(label_schema)
示例#7
0
    def __init__(self, master, app_variables, **kwargs):
        """

        Parameters
        ----------
        master : tkinter.Tk|tkinter.ToplLevel
        app_variables : AppVariables
        kwargs
            keyword arguments passed through for frame
        """

        self._app_variables = app_variables
        self._current_id = None
        self._parent_id = None
        self._new_entry = False
        self.id_changed = None  # state variable for external usage

        self.master = master
        Frame.__init__(self, master, **kwargs)
        self.header_message = Label(self, text='', padding=5)
        self.header_message.grid(row=0,
                                 column=0,
                                 sticky='NSEW',
                                 padx=3,
                                 pady=3)

        self.frame2 = Frame(self, borderwidth=1, relief=tkinter.RIDGE)
        self.id_label = Label(self.frame2,
                              text='ID:',
                              borderwidth=1,
                              relief=tkinter.RIDGE,
                              padding=5,
                              width=10)
        self.id_label.grid(row=0, column=0, sticky='NW', padx=3, pady=3)
        self.id_entry = Entry(self.frame2, text='')
        self.id_entry.grid(row=0, column=1, sticky='NEW', padx=3, pady=3)

        self.name_label = Label(self.frame2,
                                text='Name:',
                                borderwidth=1,
                                relief=tkinter.RIDGE,
                                padding=5,
                                width=10)
        self.name_label.grid(row=1, column=0, sticky='NW', padx=3, pady=3)
        self.name_entry = Entry(self.frame2, text='')
        self.name_entry.grid(row=1, column=1, sticky='NEW', padx=3, pady=3)

        self.parent_label = Label(self.frame2,
                                  text='Parent:',
                                  borderwidth=1,
                                  relief=tkinter.RIDGE,
                                  padding=5,
                                  width=10)
        self.parent_label.grid(row=2, column=0, sticky='NW', padx=3, pady=3)
        self.parent_button = Button(self.frame2, text='<Choose>')
        self.parent_button.grid(row=2, column=1, sticky='NEW', padx=3, pady=3)

        self.frame2.grid_columnconfigure(1, weight=1)
        self.frame2.grid(row=1, column=0, sticky='NSEW', padx=3, pady=3)

        self.frame3 = Frame(self, borderwidth=1, relief=tkinter.RIDGE)
        self.cancel_button = Button(self.frame3, text='Cancel')
        self.cancel_button.pack(side=tkinter.RIGHT)
        self.save_button = Button(self.frame3, text='Save')
        self.save_button.pack(side=tkinter.RIGHT)
        self.frame3.grid(row=2, column=0, sticky='NSEW', padx=3, pady=3)
        self.grid_rowconfigure(1, weight=1)
        self.grid_columnconfigure(0, weight=1)
        self.pack(fill=tkinter.BOTH, expand=tkinter.TRUE)

        # callbacks
        self.parent_button.config(command=self.parent_callback)
        self.cancel_button.config(command=self.cancel_callback)
        # save_button bound by controlling parent

        self.update_label_schema()
示例#8
0
    def __init__(self, master, app_variables, **kwargs):
        """

        Parameters
        ----------
        master
        app_variables : AppVariables
        kwargs
        """

        self.app_variables = app_variables
        self.current_metadata_list = None  # type: Union[None, LabelMetadataList]
        self.in_progess_metadata = None  # type: Union[None, LabelMetadata]
        self.has_confidence = False
        Frame.__init__(self, master, **kwargs)

        self.object_type_label = Label(self,
                                       text='Type:',
                                       relief=tkinter.RIDGE,
                                       width=15,
                                       padding=3)
        self.object_type_label.grid(row=0,
                                    column=0,
                                    sticky='NEW',
                                    padx=3,
                                    pady=3)
        self.object_type_button = Button(self, text='<Choose>')
        self.object_type_button.grid(row=0,
                                     column=1,
                                     sticky='NEW',
                                     padx=3,
                                     pady=3)

        self.comment_label = Label(self,
                                   text='Comment:',
                                   relief=tkinter.RIDGE,
                                   width=15,
                                   padding=3)
        self.comment_label.grid(row=1, column=0, sticky='NEW', padx=3, pady=3)
        self.comment_text = TextWithScrolling(self, height=5)
        self.comment_text.frame.grid(row=1,
                                     column=1,
                                     sticky='NSEW',
                                     padx=3,
                                     pady=3)

        self.confidence_label = Label(self,
                                      text='Confidence:',
                                      relief=tkinter.RIDGE,
                                      width=15,
                                      padding=3)
        self.confidence_label.grid(row=2,
                                   column=0,
                                   sticky='NEW',
                                   padx=3,
                                   pady=3)
        self.confidence_combo = Combobox(self)
        self.confidence_combo.grid(row=2,
                                   column=1,
                                   sticky='NEW',
                                   padx=3,
                                   pady=3)

        self.user_id_label = Label(self,
                                   text='User ID:',
                                   relief=tkinter.RIDGE,
                                   width=15,
                                   padding=3)
        self.user_id_label.grid(row=3, column=0, sticky='NEW', padx=3, pady=3)
        self.user_id_value = Entry(self,
                                   text='',
                                   relief=tkinter.RIDGE,
                                   width=15,
                                   state='disabled')
        self.user_id_value.grid(row=3, column=1, sticky='NEW', padx=3, pady=3)

        self.timestamp_label = Label(self,
                                     text='Timestamp:',
                                     relief=tkinter.RIDGE,
                                     width=15,
                                     padding=3)
        self.timestamp_label.grid(row=4,
                                  column=0,
                                  sticky='NEW',
                                  padx=3,
                                  pady=3)
        self.timestamp_value = Entry(self,
                                     text='',
                                     relief=tkinter.RIDGE,
                                     width=15,
                                     state='disabled')
        self.timestamp_value.grid(row=4,
                                  column=1,
                                  sticky='NEW',
                                  padx=3,
                                  pady=3)

        self.frame1 = Frame(self, borderwidth=1, relief=tkinter.RIDGE)
        self.cancel_button = Button(self.frame1, text='Cancel')
        self.cancel_button.pack(side=tkinter.RIGHT)
        self.submit_button = Button(self.frame1, text='Submit')
        self.submit_button.pack(side=tkinter.RIGHT)
        self.frame1.grid(row=5, column=0, columnspan=2, sticky='NSEW')
        self.grid_rowconfigure(2, weight=1)
        self.grid_columnconfigure(1, weight=1)

        self.object_type_button.config(
            command=self.callback_select_object_type)
        self.cancel_button.config(command=self.callback_cancel)