def set_canvas(self, img, **kwargs): """Set the main image canvas with the image to be displayed and the corresponding histogram """ self._slider_hist_column = 3 super(TWHFeatures, self).set_canvas(img, **kwargs) self._canvas.grid(row=0, column=0, rowspan=2, columnspan=2, sticky=N + S + W + E) self._canvas_hist.grid(row=0, column=2, rowspan=2, columnspan=1, sticky=N + S + W + E) self._sbox_shi = settingsbox.SettingsBox( self, sbox=[[ "maxCorners", "qualityLevel", "minDistance", "blockSize", "k" ], [50, 0.01, 3, 3, 0.04], ["int", "float", "float", "int", "float"]], func=self.create_shi, button="Shi") self._sbox_shi.grid(row=2, column=0, rowspan=6, sticky=W + E) self._sbox_star = settingsbox.SettingsBox( self, sbox=[[ "maxSize", "responseThreshold", "lineThresholdProjected", "lineThresholdBinarized", "suppressNonmaxSize" ], [40, 30, 10, 8, 5], ["int", "int", "int", "int", "int"]], func=self.create_star, button="STAR") self._sbox_star.grid(row=2, column=1, rowspan=6, sticky=W + E) self._sbox_sift = settingsbox.SettingsBox( self, sbox=[[ "nfeatures", "nOctaveLayers", "contrastThreshold", "edgeThreshold", "sigma" ], [0, 3, 0.04, 10, 1.6], ["int", "int", "float", "int", "float"]], func=self.create_sift, button="SIFT") self._sbox_sift.grid(row=2, column=2, rowspan=6, sticky=W + E) self._button_quit.grid(row=8, column=0, columnspan=4, sticky=W + E)
def __init__( self, parent, bbox=list(), cbox=list(), sbox=list(), **kwargs ): super(CSBox, self).__init__(parent, **kwargs) self._bbox = buttonbox.ButtonBox(self, bbox=bbox, **kwargs) self._bbox.pack(side=TOP, fill=X) self._cbox = combobox.ComboBox(self, cbox=cbox, **kwargs) self._cbox.pack(side=TOP, fill=X) self._sbox = settingsbox.SettingsBox(self, sbox=sbox, **kwargs) self._sbox.pack(side=TOP, fill=X)
def initialize_window(self, show=list(), classes=dict()): """Set the geometry of the main window""" # settings -------------------------------------------------------- self._root = Tk() show["grid"] = gu.get_value(show, "grid", [2, 2]) classes = classes if classes else [{ "name": "Default", "color": [255, 255, 0] }] # general window settings ----------------------------------------- self._root.title("RSVis - Exploring and Viewing RS-Data") self._root.geometry("1100x900") self._root.columnconfigure(1, weight=1) self._root.rowconfigure(0, weight=1) self._root.rowconfigure(1, weight=0) # key bindings ---------------------------------------------------- self._root.bind("q", self.key_q) self._keys = {"q": "Exit RSVis."} for o in self._options: if o["key"] is not None: self._keys.update({o["key"]: o["description"]}) # set the input / output logger self._logger = rsvis.utils.logger.Logger( logger=lambda log: self._textbox.insert("1.0", "{}\n".format(log))) self._data.logger = self._logger self._opener = opener.GeneralOpener(logger=self._logger) # comboboxes (mouse behavior/ classes) ---------------------------- idx_row = 1 self._cbox_area = combobox.ComboBox( self._root, [["Histogram"], [["Grid", "Objects"]], ["Grid"], ["str"]], func=self.set_area_event) self._cbox_area.grid(row=idx_row, column=0, sticky=N + W + S + E) idx_row += 1 self._cbox_class = combobox.ComboBox( self._root, [["Class"], [[c["name"] for c in classes]], [classes[0]["name"]], ["str"]], func=self.set_class) self._cbox_class.grid(row=idx_row, column=0, sticky=N + W + S + E) idx_row += 1 self._cbox_test = combobox.ComboBox( self._root, [["Testing"], [self._param["vis"]["test_menu"]], [self._param["vis"]["test"]], ["str"]]) self._cbox_test.grid(row=idx_row, column=0, sticky=N + W + S + E) idx_row += 1 # canvas variables ------------------------------------------------ self._variables = { "class": lambda value=False: self._cbox_class.get(value=value) } # settingsboxes (label image) ------------------------------------- if self._data.get_label(query="label"): self._sbox_label_img = combobox.ComboBox( self._root, cbox=[["Label Image"], [self._data.get_label(query="label")], [0], ["str"]]) self._sbox_label_img.grid(row=idx_row, column=0, sticky=N + W + S + E) self._variables["labelimg"] = lambda: self._sbox_label_img.get() idx_row += 1 # settingsboxes (label image) ------------------------------------- if self._data.get_label(query="height"): self._sbox_height_img = combobox.ComboBox( self._root, cbox=[["Label Image"], [self._data.get_label(query="height")], [0], ["str"]]) self._sbox_height_img.grid(row=idx_row, column=0, sticky=N + W + S + E) self._variables["heightimg"] = lambda: self._sbox_height_img.get() idx_row += 1 if self._obj: self._sbox_objects = combobox.ComboBox( self._root, cbox=[["Objects"], [list(self._obj.keys())], [0], ["str"]]) self._sbox_objects.grid(row=idx_row, column=0, sticky=N + W + S + E) self._variables["objects"] = lambda: self._sbox_objects.get() idx_row += 1 # settingsboxes (grid) -------------------------------------------- self._sbox_grid = settingsbox.SettingsBox( self._root, sbox=[["Dimension x (Grid)", "Dimension y (Grid)"], show["grid"], ["int", "int"]], func=self.set_grid) self._sbox_grid.grid(row=idx_row, column=0, sticky=N + W + S + E) idx_row += 1 # textfield (grid) ------------------------------------------------ self._row_settings = idx_row - 1 self._textbox_scrollbar = Scrollbar(self._root) self._textbox = Text(self._root, height=3, font=("Courier", 8)) self._textbox_scrollbar.grid(row=1, column=2, rowspan=self._row_settings, sticky=N + S) self._textbox.grid(row=1, column=1, rowspan=self._row_settings, sticky=N + S + W + E) self._textbox_scrollbar.config(command=self._textbox.yview) self._textbox.config(yscrollcommand=self._textbox_scrollbar.set) # main image window ----------------------------------------------- self._frame = rsvis.tools.rscanvasframe.RSVisCanvasFrame( self._root, self._data.get_img_in(), self._data, popup=self.set_popup, classes=classes, variables=self._variables, objects=self._obj, logger=self._logger, **show) self._frame.grid(row=0, column=0, columnspan=3, sticky=N + S + W + E) # menubar (File / Options / Information) -------------------------- self._menubar = Menu(self._root) # menubar "File" filemenu = Menu(self._menubar, tearoff=0) filemenu.add_command(label="Open", command=lambda: self.open(self.get_img_path())) filemenu.add_command( label="Save", command=lambda obj=self.get_obj(), img_out=self._data.get_img_out( ): img_out( obj.get_img_path(), obj.get_img(), prefix=obj.get_img_spec())) filemenu.add_separator() filemenu.add_command(label="Exit", command=widgets.quit) self._menubar.add_cascade(label="File", menu=filemenu) # menubar "Options" widgets.add_option_menu(self._menubar, self._options, self._root, self.get_obj()) # menubar "Information" widgets.add_info_menu(self._menubar, self._root, self._root, lambda obj=self: self.show_help()) self._root.config(menu=self._menubar)