コード例 #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
ファイル: schema_editor.py プロジェクト: kirkjens/sarpy_apps
    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)
コード例 #3
0
ファイル: schema_editor.py プロジェクト: kirkjens/sarpy_apps
    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()
コード例 #4
0
    def __init__(self, parent):
        """

        Parameters
        ----------
        parent: Frame
        """

        Frame.__init__(self, parent)

        self['padding'] = 5

        self.start_pulse_label = Label(self, text='0')

        self.label_channel = Label(self, text='Channel')
        self.cbx_channel = Combobox(self, state='readonly')
        self.var_cbx_channel = tkinter.StringVar()
        self.cbx_channel.configure(justify='left',
                                   textvariable=self.var_cbx_channel,
                                   width=30,
                                   values=[],
                                   state='disabled')

        self.label_pulse = Label(self, text='Pulse')
        self.entry_pulse = Entry(self)
        self.entry_pulse.set_text('0')
        self.entry_pulse.configure(justify='right', width=6)
        self.entry_callback = self.register(self._only_numeric_input)
        self.entry_pulse.configure(validate="key",
                                   validatecommand=(self.entry_callback, "%P"))

        self.fullscale = Label(self, text='0')

        self.start_pulse_label.grid(row=0, column=0, padx=5, sticky='w')
        self.label_channel.grid(row=0, column=1, padx=5, sticky='e')
        self.cbx_channel.grid(row=0, column=2, padx=5)
        self.label_pulse.grid(row=0, column=3, padx=5)
        self.entry_pulse.grid(row=0, column=4, padx=5, sticky='w')
        self.fullscale.grid(row=0, column=5, padx=5, sticky='e')
        self.columnconfigure(0, weight=0)
        self.columnconfigure(1, weight=1)
        self.columnconfigure(2, weight=0)
        self.columnconfigure(3, weight=0)
        self.columnconfigure(4, weight=1)
        self.columnconfigure(5, weight=0)

        self.var_pulse_number = tkinter.StringVar(value='0')
        self.scale_pulse = Scale(
            self,
            from_=0,
            to=0,
            length=600,
            orient='horizontal',
            command=lambda s: self.var_pulse_number.set(s))
        self.scale_pulse.configure(variable=self.var_pulse_number)
        self.scale_pulse.grid(row=1,
                              column=0,
                              columnspan=6,
                              padx=5,
                              pady=8,
                              sticky='esw')
コード例 #5
0
ファイル: labeling_tool.py プロジェクト: kirkjens/sarpy_apps
    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)