def selectall_roiList(self): self.roiListbox.selection_clear(0, 'end') self.roiListbox.selection_set(0, 'end') ROIdisplay.draw_selec(self, '<Button-1>')
def create_window(self): try: self.rt_Window.destroy() except AttributeError: pass self.rt_Window = tk.Toplevel(self) self.rt_Window.title('ROI Manager Tracking') #self.rt_Window.geometry('240x350-80+50') self.rt_Window.resizable(0,1) self.rt_Window.protocol('WM_DELETE_WINDOW', lambda: ROImanager.close(self)) self.rt_Window.columnconfigure(0, weight = 1) self.rt_Window.rowconfigure(1, weight = 1) self.rt_drawFrame = ttk.Frame(self.rt_Window) self.roicircleButton = ttk.Button(self.rt_drawFrame, text = 'Circle', style = 'SunkableButton.TButton', command = lambda: ROImanager.draw_circle(self)) self.roirectButton = ttk.Button(self.rt_drawFrame, text = 'Rectangle', style = 'SunkableButton.TButton', command = lambda: ROImanager.draw_rectangle(self)) self.roipolyButton = ttk.Button(self.rt_drawFrame, text = 'Polygon') self.rt_middleFrame = ttk.Frame(self.rt_Window) self.rt_middleFrame.rowconfigure(0, weight = 1) self.rt_middleFrame.columnconfigure([0,1], weight = 1) self.roilistFrame = ttk.LabelFrame(self.rt_middleFrame, text = 'ROIs') self.roilistFrame.rowconfigure(0, weight = 1) self.roiListbox = tk.Listbox(self.roilistFrame, width = 15, selectmode = 'extended') self.roiListbox.bind('<<ListboxSelect>>', lambda event, arg = self: ROIdisplay.draw_selec(self, event)) self.roilistScrollbar = ttk.Scrollbar(self.roilistFrame) self.roilistScrollbar.config(command = self.roiListbox.yview) self.roiListbox.config(yscrollcommand = self.roilistScrollbar.set) self.rt_manageFrame = ttk.Frame(self.rt_middleFrame) self.roiselectallButton = ttk.Button(self.rt_manageFrame, text = 'Select All', command = lambda: ROImanager.selectall_roiList(self)) self.roiclearallButton = ttk.Button(self.rt_manageFrame, text = 'Clear All', command = lambda: ROImanager.clearall_roiList(self)) self.roideleteallButton = ttk.Button(self.rt_manageFrame, text = 'Delete All', command = lambda: ROImanager.keepdelall_roi(self, 0)) self.roikeepallButton = ttk.Button(self.rt_manageFrame, text = 'Keep All', command = lambda: ROImanager.keepdelall_roi(self, 1)) self.roideleteselecButton = ttk.Button(self.rt_manageFrame, text = 'Delete Selection', command = lambda: ROImanager.keepdelsel_roi(self, 0)) self.roikeepselecButton = ttk.Button(self.rt_manageFrame, text = 'Keep Selection', command = lambda: ROImanager.keepdelsel_roi(self,1)) self.rt_bottomFrame = ttk.Frame(self.rt_Window) self.rt_bottomFrame.columnconfigure([0,1], weight = 1) self.roioptionsButton = ttk.Button(self.rt_bottomFrame, text = 'Options', command = lambda: ROImanager.create_options(self)) self.roicloseButton = ttk.Button(self.rt_bottomFrame, text = 'Close', command = lambda: ROImanager.close(self)) self.rt_drawFrame.grid(row = 0, column = 0, sticky = 'nsew') self.roicircleButton.grid(row = 0, column = 0, sticky = 'nsew', padx = 2, pady = 10) self.roirectButton.grid(row = 0, column = 1, sticky = 'nsew', padx = 2, pady = 10) self.roipolyButton.grid(row = 0, column = 2, sticky = 'nsew', padx = 2, pady = 10) self.rt_middleFrame.grid(row = 1, column = 0, sticky = 'nsew') self.roilistFrame.grid(row = 0, column = 0, sticky = 'ns') self.roiListbox.grid(row = 0, column = 0, sticky = 'ns') self.roilistScrollbar.grid(row = 0, column = 1, sticky = 'ns') self.rt_manageFrame.grid(row = 0, column = 1, sticky = 'nsew') self.roiselectallButton.grid(row = 0, column = 0, sticky = 'nsew', pady = 2, padx = 2) self.roiclearallButton.grid(row = 1, column = 0, sticky = 'nsew', pady = 2, padx = 2) self.roideleteallButton.grid(row = 2, column = 0, sticky = 'nsew', pady = 2, padx = 2) self.roikeepallButton.grid(row = 3, column = 0, sticky = 'nsew', pady = 2, padx = 2) self.roideleteselecButton.grid(row = 4, column = 0, sticky = 'nsew', pady = 2, padx = 2) self.roikeepselecButton.grid(row = 5, column = 0, sticky = 'nsew', pady = 2, padx = 2) self.rt_bottomFrame.grid(row = 2, column = 0, sticky = 'nsew') self.roioptionsButton.grid(row = 0, column = 0, sticky = 'nsew', padx = 10, pady = 10) self.roicloseButton.grid(row = 0, column = 1, sticky = 'nsew', padx = 10, pady = 10) try: self._roipath[-1] ROImanager.setstate_roi(self) ROIdisplay.show_roi(self) ROImanager.update_roiList(self) except AttributeError: ROImanager.setstate_noroi(self)