Exemple #1
0
    def __init__(self, parent):
        PanedWindow.__init__(self, parent, background="white")

        self.parent = parent
        self.init_data()
        self.init_log()
        self.init_ui()
        self.update_status()
Exemple #2
0
 def __init__(self, master, lists):
     """MultiListbox class constructor
     Args:
         master - parent view
         lists - columns
     Author: Pavel"""
     PanedWindow.__init__(self,
                          master,
                          borderwidth=1,
                          showhandle=False,
                          sashwidth=2,
                          sashpad=0,
                          relief=SUNKEN)
     self.lists = []
     self.columns = []
     for l, w in lists:
         self.columns.append(l)
         frame = Frame(self)
         frame.pack(side=LEFT, expand=YES, fill=BOTH)
         tl = Label(frame, text=l, borderwidth=2, relief=GROOVE)
         tl.pack(fill=X)
         tl.bind('<Button-1>', self.clickon)
         lb = Listbox(frame,
                      bg=ListBox_color,
                      width=w,
                      borderwidth=0,
                      selectborderwidth=0,
                      relief=FLAT,
                      exportselection=FALSE,
                      selectmode=MULTIPLE)
         lb.pack(expand=YES, fill=BOTH)
         self.lists.append(lb)
         lb.bind('<B1-Motion>', lambda e, s=self: s._select(e.y))
         lb.bind('<Button-1>', lambda e, s=self: s._select(e.y))
         lb.bind('<Leave>', lambda e: 'break')
         lb.bind('<B2-Motion>', lambda e, s=self: s._b2motion(e.x, e.y))
         lb.bind('<Button-2>', lambda e, s=self: s._button2(e.x, e.y))
         lb.bind('<Button-4>',
                 lambda e, s=self: s._scroll(SCROLL, 1, PAGES))
         lb.bind('<Button-5>',
                 lambda e, s=self: s._scroll(SCROLL, -1, PAGES))
         self.add(frame)
     Label(master, borderwidth=1, relief=FLAT).pack(fill=X)
     sb = Scrollbar(master,
                    orient=VERTICAL,
                    command=self._scroll,
                    borderwidth=1)
     sb.pack(fill=Y, side=RIGHT, expand=NO)
     for l in self.lists:
         l['yscrollcommand'] = sb.set
         l.bind("<MouseWheel>",
                lambda e, s=self: s._scroll(SCROLL, e.delta, UNITS))
     #self.add(frame)
     self.pack(expand=YES, fill=BOTH)
     self.sorted_by = -1
     self.previousWheel = 0
    def __init__(self,
                 master,
                 color="gray",
                 size=60,
                 sashpad=2,
                 disallow_dragging=False,
                 on_click=None,
                 image=None,
                 cursor=None,
                 opaqueresize=True):
        Tk_PanedWindow.__init__(self,
                                master,
                                showhandle=False,
                                orient=self.ORIENT,
                                sashpad=sashpad,
                                opaqueresize=opaqueresize)

        self._active_sash = None
        self._on_click = on_click
        self._image = image
        self._color = color
        self._cursor = cursor

        self._configure_callbacks = []

        if not opaqueresize:
            disallow_dragging = True

        self._disallow_dragging = disallow_dragging

        self._handle_list = []
        self._list_of_panes = []

        if self.ORIENT == VERTICAL:
            self._width = size
            self._height = 2 * sashpad
        else:
            self._width = 2 * sashpad
            self._height = size

        if opaqueresize:
            self.bind('<Button-1>', self._on_mark_sash)
            self.bind('<B1-Motion>', self._on_drag_sash)
            self.bind('<ButtonRelease-1>', self._on_release)
Exemple #4
0
    def __init__(self,
                 master,
                 reader=None,
                 annotation_collection=None,
                 **kwargs):
        """

        Parameters
        ----------
        master
            tkinter.Tk|tkinter.TopLevel
        reader : None|str|BaseReader|GeneralCanvasImageReader
        annotation_collection : None|str|FileLabelCollection
        kwargs
        """

        self.variables = AppVariables()  # type: AppVariables

        if 'sashrelief' not in kwargs:
            kwargs['sashrelief'] = tkinter.RIDGE
        if 'orient' not in kwargs:
            kwargs['orient'] = tkinter.HORIZONTAL
        PanedWindow.__init__(self, master, **kwargs)
        WidgetWithMetadata.__init__(self, master)
        self.pack(expand=tkinter.TRUE, fill=tkinter.BOTH)

        self.image_panel = ImagePanel(self)
        self.image_panel.canvas.set_canvas_size(400, 500)
        self.add(self.image_panel,
                 width=400,
                 height=700,
                 padx=3,
                 pady=3,
                 sticky='NSEW',
                 stretch=tkinter.FIRST)

        self.collection_panel = LabelCollectionPanel(
            self, self.variables)  # type: LabelCollectionPanel

        self.add(self.collection_panel,
                 width=200,
                 height=700,
                 padx=3,
                 pady=3,
                 sticky='NSEW')

        # file menu
        self.menu_bar = tkinter.Menu()
        self.file_menu = tkinter.Menu(self.menu_bar, tearoff=0)
        self.file_menu.add_command(label="Open Image",
                                   command=self.select_image_file)
        self.file_menu.add_command(label="Open Directory",
                                   command=self.select_image_directory)
        self.file_menu.add_separator()
        self.file_menu.add_command(label="Open Existing Annotation File",
                                   command=self.select_annotation_file)
        self.file_menu.add_command(label="Create New Annotation File",
                                   command=self.create_new_annotation_file)
        self.file_menu.add_separator()
        self.file_menu.add_command(label="Save Annotation File",
                                   command=self.save_annotation_file)
        self.file_menu.add_separator()
        self.file_menu.add_command(label="Exit", command=self.exit)
        # edit popup menu
        self.edit_menu = tkinter.Menu(self.menu_bar, tearoff=0)
        self.edit_menu.add_command(label='Edit Label Schema',
                                   command=self.callback_edit_schema)
        self.edit_menu.add_separator()
        self.edit_menu.add_command(label='Replicate Selected',
                                   command=self.callback_replicate_feature)
        self.edit_menu.add_separator()
        self.edit_menu.add_command(label='Delete Selected',
                                   command=self.callback_delete_feature)

        # metadata popup menu
        self.metadata_menu = tkinter.Menu(self.menu_bar, tearoff=0)
        self.metadata_menu.add_command(label="Metaicon",
                                       command=self.metaicon_popup)
        self.metadata_menu.add_command(label="Metaviewer",
                                       command=self.metaviewer_popup)
        self._valid_data_shown = tkinter.IntVar(self, value=0)
        self.metadata_menu.add_checkbutton(label='ValidData',
                                           variable=self._valid_data_shown,
                                           command=self.show_valid_data)
        # configure menubar
        self.menu_bar.add_cascade(label="File", menu=self.file_menu)
        self.menu_bar.add_cascade(label="Edit", menu=self.edit_menu)
        self.menu_bar.add_cascade(label="Metadata", menu=self.metadata_menu)
        self.master.config(menu=self.menu_bar)

        # hide unwanted elements on the panel toolbars
        self.image_panel.hide_tools(['new_shape', 'select'])
        self.image_panel.hide_shapes()
        self.image_panel.hide_select_index()
        # disable tools until an image is selected
        self.image_panel.disable_tools()

        self.collection_panel.new_button.config(
            command=self.callback_new_annotation)
        self.collection_panel.edit_button.config(
            command=self.callback_popup_annotation)
        self.collection_panel.zoom_button.config(
            command=self.callback_zoom_to_feature)
        self.collection_panel.move_button.config(
            command=self.callback_move_feature)

        # set up context panel canvas event listeners
        self.image_panel.canvas.bind('<<ImageIndexPreChange>>',
                                     self.handle_image_index_prechange)
        self.image_panel.canvas.bind('<<ImageIndexChanged>>',
                                     self.handle_image_index_changed)
        self.image_panel.canvas.bind('<<ShapeCreate>>',
                                     self.shape_create_on_canvas)
        self.image_panel.canvas.bind('<<ShapeCoordsFinalized>>',
                                     self.shape_finalized_on_canvas)
        self.image_panel.canvas.bind('<<ShapeDelete>>',
                                     self.shape_delete_on_canvas)
        self.image_panel.canvas.bind('<<ShapeSelect>>',
                                     self.shape_selected_on_canvas)

        # set up the label_panel viewer event listeners
        self.collection_panel.viewer.bind('<<TreeviewSelect>>',
                                          self.feature_selected_on_viewer)

        self.annotate_popup = tkinter.Toplevel(master)
        self.annotate_popup.geometry('700x500')
        self.annotate = LabelPanel(self.annotate_popup,
                                   self.variables)  # type: LabelPanel
        self.annotate.hide_on_close()
        self.annotate_popup.withdraw()

        # bind actions/listeners from annotate popup
        self.annotate.tab_panel.geometry_tab.bind(
            '<<GeometryPropertyChanged>>', self.geometry_selected_on_viewer)
        self.annotate.button_panel.delete_button.config(
            command=self.callback_delete_geometry)
        self.annotate.button_panel.cancel_button.config(
            command=self.callback_popup_cancel)
        self.annotate.button_panel.apply_button.config(
            command=self.callback_popup_apply)

        # bind the new geometry buttons explicitly
        self.annotate.tab_panel.geometry_tab.geometry_buttons.point.config(
            command=self.callback_new_point)
        self.annotate.tab_panel.geometry_tab.geometry_buttons.line.config(
            command=self.callback_new_line)
        self.annotate.tab_panel.geometry_tab.geometry_buttons.rectangle.config(
            command=self.callback_new_rect)
        self.annotate.tab_panel.geometry_tab.geometry_buttons.ellipse.config(
            command=self.callback_new_ellipse)
        self.annotate.tab_panel.geometry_tab.geometry_buttons.polygon.config(
            command=self.callback_new_polygon)

        # bind the label specifics submit button specifically
        self.annotate.tab_panel.label_tab.label_specifics.submit_button.config(
            command=self.callback_submit_label)

        self.set_reader(reader)
        self.set_annotations(annotation_collection)
        self.annotate.update_annotation_collection()
Exemple #5
0
 def __init__(self, *args, **kwargs):
     PanedWindow.__init__(self, orient=HORIZONTAL, *args, **kwargs)
Exemple #6
0
 def __init__(self, *args, **kwargs):
     PanedWindow.__init__(self, orient=VERTICAL, *args, **kwargs)
     self.focused_area = None