class _Feedback(WidgetPanel): _widget_list = ( ('title_label', ), ('acceptable_label', 'acceptable_button'), ('feedback_label', 'feedback_text'), ('cancel_button', 'submit_button')) title_label = widget_descriptors.LabelDescriptor( 'title_label', default_text='', docstring='The overall title') # type: basic_widgets.Label acceptable_label = widget_descriptors.LabelDescriptor( 'acceptable_label', default_text='acceptable?', docstring='') # type: basic_widgets.Label acceptable_button = widget_descriptors.RadioButtonDescriptor( 'acceptable_button', docstring='') # type: basic_widgets.RadioButton feedback_label = widget_descriptors.LabelDescriptor( 'feedback_label', default_text='feedback', docstring='') # type: basic_widgets.Label feedback_text = widget_descriptors.TextDescriptor( 'feedback_text', docstring='The widget to provide log information') # type: basic_widgets.Text cancel_button = widget_descriptors.ButtonDescriptor( 'cancel_button', default_text='Cancel', docstring='') # type: basic_widgets.Button submit_button = widget_descriptors.ButtonDescriptor( 'submit_button', default_text='Submit', docstring='') # type: basic_widgets.Button def __init__(self, root, title_text): """ Parameters ---------- root : tkinter.Toplevel title_text : str """ WidgetPanel.__init__(self, root) self.init_w_rows() self.title_label.set_text(title_text)
class InfoPanel(WidgetPanel): _widget_list = ( "canvas_distance_label", "canvas_distance_val", "pixel_distance_label", "pixel_distance_val", "geo_distance_label", "geo_distance_val") canvas_distance_label = widget_descriptors.LabelDescriptor( "canvas_distance_label", default_text="canvas distance:") # type: basic_widgets.Label pixel_distance_label = widget_descriptors.LabelDescriptor( "pixel_distance_label", default_text="pixel distance:") # type: basic_widgets.Label geo_distance_label = widget_descriptors.LabelDescriptor( "geo_distance_label", default_text="geo distance:") # type: basic_widgets.Label canvas_distance_val = widget_descriptors.EntryDescriptor( "canvas_distance_val", default_text="") # type: basic_widgets.Entry pixel_distance_val = widget_descriptors.EntryDescriptor( "pixel_distance_val", default_text="") # type: basic_widgets.Entry geo_distance_val = widget_descriptors.EntryDescriptor( "geo_distance_val", default_text="") # type: basic_widgets.Entry def __init__(self, parent): WidgetPanel.__init__(self, parent) self.init_w_box_layout(n_columns=2, column_widths=[20, 10], row_heights=5) self.canvas_distance_label.config(anchor=tkinter.CENTER, relief=tkinter.RIDGE) self.pixel_distance_label.config(anchor=tkinter.CENTER, relief=tkinter.RIDGE) self.geo_distance_label.config(anchor=tkinter.CENTER, relief=tkinter.RIDGE) self.canvas_distance_val.config(state='disabled') self.pixel_distance_val.config(state='disabled') self.geo_distance_val.config(state='disabled')
class _Buttons(WidgetPanelNoLabel): """ The panel of buttons for validation tasks. """ _widget_list = ( ('local_fs_label', 'local_fs_button'), ('full_fs_label', 'full_fs_button'), ('sign_label', 'sign_button'), ('noise_label', 'noise_button'), ('geolocation_label', 'geolocation_button')) local_fs_label = widget_descriptors.LabelDescriptor( 'local_fs_label', default_text='Perform local frequency support analysis', docstring='') # type: basic_widgets.Label local_fs_button = widget_descriptors.ButtonDescriptor( 'local_fs_button', default_text='Frequency Support Tool', docstring='') # type: basic_widgets.Button full_fs_label = widget_descriptors.LabelDescriptor( 'full_fs_label', default_text='Perform full image frequency analysis', docstring='') # type: basic_widgets.Label full_fs_button = widget_descriptors.ButtonDescriptor( 'full_fs_button', default_text='Frequency Analysis Tool', docstring='') # type: basic_widgets.Button sign_label = widget_descriptors.LabelDescriptor( 'sign_label', default_text='Perform Fourier analysis', docstring='') # type: basic_widgets.Label sign_button = widget_descriptors.ButtonDescriptor( 'sign_button', default_text='Aperture Tool', docstring='') # type: basic_widgets.Button noise_label = widget_descriptors.LabelDescriptor( 'noise_label', default_text='Perform noise analysis', docstring='') # type: basic_widgets.Label noise_button = widget_descriptors.ButtonDescriptor( 'noise_button', default_text='RCS Tool', docstring='') # type: basic_widgets.Button geolocation_label = widget_descriptors.LabelDescriptor( 'geolocation_label', default_text='Perform basic geolocation analysis', docstring='') # type: basic_widgets.Label geolocation_button = widget_descriptors.ButtonDescriptor( 'geolocation_button', default_text='Create kmz', docstring='') # type: basic_widgets.Button def __init__(self, parent): """ Parameters ---------- parent """ WidgetPanelNoLabel.__init__(self, parent) self.init_w_rows()
class Panel1(WidgetPanel): _widget_list = ( 'button', 'combobox', 'scale', 'label', 'label_frame', 'entry', # 'text', # omit this one for now, because it's broken 'spinbox', 'radio_button_panel', 'update_radio_selection', 'check_button') button = widget_descriptors.ButtonDescriptor("button") # type: basic_widgets.Button combobox = widget_descriptors.ComboboxDescriptor("combobox") # type: basic_widgets.Combobox scale = widget_descriptors.ScaleDescriptor("scale") # type: basic_widgets.Scale label = widget_descriptors.LabelDescriptor("label") # type: basic_widgets.Label label_frame = widget_descriptors.LabelFrameDescriptor("label_frame") # type: basic_widgets.LabelFrame entry = widget_descriptors.EntryDescriptor("entry", default_text="") # type: basic_widgets.Entry text = widget_descriptors.TextDescriptor("text") # type: basic_widgets.Text spinbox = widget_descriptors.SpinboxDescriptor("spinbox", default_text="") # type: basic_widgets.Spinbox radio_button_panel = widget_descriptors.PanelDescriptor("radio_button_panel", RadioPanel) # type: RadioPanel update_radio_selection = widget_descriptors.ButtonDescriptor("update_radio_selection") # type: basic_widgets.Button check_button = widget_descriptors.CheckButtonDescriptor("check_button") # type: basic_widgets.CheckButton def __init__(self, parent): WidgetPanel.__init__(self, parent) self.parent = parent self.init_w_vertical_layout() # callbacks self.update_radio_selection.on_left_mouse_click(self.callback_update_radio_selection) def callback_update_radio_selection(self, event): selection = self.radio_button_panel.selection() if selection == self.radio_button_panel.button_1: self.radio_button_panel.set_text("button 1") elif selection == self.radio_button_panel.button_2: self.radio_button_panel.set_text("button 2") elif selection == self.radio_button_panel.button_3: self.radio_button_panel.set_text("button 3")
class BandSelection(WidgetPanel): """ Band selection tool for RGB display. """ _widget_list = ("red_label", "red_selection", "green_label", "green_selection", "blue_label", "blue_selection", "alpha_label", "alpha_selection") red_label = widget_descriptors.LabelDescriptor("red_label", default_text="red") green_label = widget_descriptors.LabelDescriptor("green_label", default_text="green") blue_label = widget_descriptors.LabelDescriptor("blue_label", default_text="blue") alpha_label = widget_descriptors.LabelDescriptor("alpha_label", default_text="alpha") red_selection = widget_descriptors.ComboboxDescriptor( "red_selection") # type: basic_widgets.Combobox green_selection = widget_descriptors.ComboboxDescriptor( "green_selection") # type: basic_widgets.Combobox blue_selection = widget_descriptors.ComboboxDescriptor( "blue_selection") # type: basic_widgets.Combobox alpha_selection = widget_descriptors.ComboboxDescriptor( "alpha_selection") # type: basic_widgets.Combobox def __init__(self, parent): """ Parameters ---------- parent The parent widget. """ WidgetPanel.__init__(self, parent) self.init_w_box_layout(n_columns=2, column_widths=10)
class PyplotControlPanel(WidgetPanel): _widget_list = ("color_palette_label", "color_palette", "n_colors_label", "n_colors", "scale", "rescale_y_axis_per_frame", "fps_label", "fps_entry", "animate") color_palette_label = widget_descriptors.LabelDescriptor( "color_palette_label") # type: basic_widgets.Label color_palette = widget_descriptors.ComboboxDescriptor( "color_palette") # type: basic_widgets.Combobox n_colors_label = widget_descriptors.LabelDescriptor( "n_colors_label") # type: basic_widgets.Label n_colors = widget_descriptors.SpinboxDescriptor( "n_colors") # type: basic_widgets.Spinbox scale = widget_descriptors.ScaleDescriptor( "scale") # type: basic_widgets.Scale rescale_y_axis_per_frame = widget_descriptors.ComboboxDescriptor( "rescale_y_axis_per_frame") # type: basic_widgets.Combobox animate = widget_descriptors.ButtonDescriptor( "animate") # type: basic_widgets.Button fps_label = widget_descriptors.LabelDescriptor( "fps_label") # type: basic_widgets.Label fps_entry = widget_descriptors.EntryDescriptor( "fps_entry") # type: basic_widgets.Entry def __init__(self, parent): WidgetPanel.__init__(self, parent) self.init_w_basic_widget_list(4, [4, 1, 1, 3]) self.color_palette.update_combobox_values( SeabornPaletteNames.get_seaborn_palette_names_list()) self.n_colors.config(from_=0) self.n_colors.config(to=10) self.scale.set(0) self.rescale_y_axis_per_frame.update_combobox_values( [SCALE_Y_AXIS_PER_FRAME_TRUE, SCALE_Y_AXIS_PER_FRAME_FALSE]) self.fps_label.set_text("fps") self.fps_entry.set_text("30")
class Toolbar(WidgetPanelNoLabel): tool_controls = ( 'tool_label', 'zoom_in', 'zoom_out', 'pan', 'select', 'view', 'select_closest_shape', 'edit_shape', 'shift_shape', 'new_shape') shape_controls = ('shape_label', 'point', 'line', 'arrow', 'rect', 'ellipse', 'polygon', 'text') other_controls = ("save_canvas", "save_image", "remap_label", "remap_combo", "select_index_label", "select_index_combo") _widget_list = (tool_controls, shape_controls, other_controls) # create the tool descriptors tool_label = widget_descriptors.LabelDescriptor( 'tool_label', default_text='tool:', docstring='The label for the tool series of radiobuttons.') # type: basic_widgets.Label zoom_in = widget_descriptors.RadioButtonDescriptor( 'zoom_in', default_text='Zoom In', docstring='Zoom in selector.') # type: basic_widgets.RadioButton zoom_out = widget_descriptors.RadioButtonDescriptor( 'zoom_out', default_text='Zoom Out', docstring='Zoom out selector.') # type: basic_widgets.RadioButton pan = widget_descriptors.RadioButtonDescriptor( 'pan', default_text='Pan', docstring='Pan selector.') # type: basic_widgets.RadioButton select = widget_descriptors.RadioButtonDescriptor( 'select', default_text='Select', docstring='Select selector.') # type: basic_widgets.RadioButton view = widget_descriptors.RadioButtonDescriptor( 'view', default_text='View', docstring='View selector.') # type: basic_widgets.RadioButton select_closest_shape = widget_descriptors.RadioButtonDescriptor( 'select_closest_shape', default_text='Choose\nShape', docstring='Select closest shape selector.') # type: basic_widgets.RadioButton edit_shape = widget_descriptors.RadioButtonDescriptor( 'edit_shape', default_text='Edit\nShape', docstring='Edit shape selector.') # type: basic_widgets.RadioButton shift_shape = widget_descriptors.RadioButtonDescriptor( 'shift_shape', default_text='Shift\nShape', docstring='Shift shape selector.') # type: basic_widgets.RadioButton new_shape = widget_descriptors.RadioButtonDescriptor( 'new_shape', default_text='New\nShape', docstring='New shape selector.') # type: basic_widgets.RadioButton # create the shape descriptors shape_label = widget_descriptors.LabelDescriptor( 'shape_label', default_text='shape type:', docstring='The label for the shape series of radiobuttons.') # type: basic_widgets.Label point = widget_descriptors.RadioButtonDescriptor( 'point', default_text='point', docstring='point selector.') # type: basic_widgets.RadioButton line = widget_descriptors.RadioButtonDescriptor( 'line', default_text='line', docstring='line selector.') # type: basic_widgets.RadioButton arrow = widget_descriptors.RadioButtonDescriptor( 'arrow', default_text='arrow', docstring='arrow selector.') # type: basic_widgets.RadioButton rect = widget_descriptors.RadioButtonDescriptor( 'rect', default_text='rect', docstring='rect selector.') # type: basic_widgets.RadioButton ellipse = widget_descriptors.RadioButtonDescriptor( 'ellipse', default_text='ellipse', docstring='ellipse selector.') # type: basic_widgets.RadioButton polygon = widget_descriptors.RadioButtonDescriptor( 'polygon', default_text='polygon', docstring='polygon selector.') # type: basic_widgets.RadioButton text = widget_descriptors.RadioButtonDescriptor( 'text', default_text='text', docstring='text selector.') # type: basic_widgets.RadioButton # the remaining element descriptors save_canvas = widget_descriptors.ButtonDescriptor( 'save_canvas', default_text='save canvas', docstring='Save the present canvas and contents to image file.') # type: basic_widgets.Button save_image = widget_descriptors.ButtonDescriptor( 'save_image', default_text='save image', docstring='Save the present canvas to image file.') # type: basic_widgets.Button remap_label = widget_descriptors.LabelDescriptor( 'remap_label', default_text='remap:', docstring='The remap label.') # type: basic_widgets.Label remap_combo = widget_descriptors.ComboboxDescriptor( 'remap_combo', default_text='density', docstring='The remap value') # type: basic_widgets.Combobox select_index_label = widget_descriptors.LabelDescriptor( 'select_index_label', default_text='image\nindex:', docstring='The image index selection label.') # type: basic_widgets.Label select_index_combo = widget_descriptors.ComboboxDescriptor( 'select_index_combo', default_text='', docstring='The image index selection') # type: basic_widgets.Combobox def __init__(self, parent): """ Parameters ---------- parent : ImagePanel """ WidgetPanelNoLabel.__init__(self, parent) self.init_w_rows()
class FileSelector(WidgetPanel): """ File selector interface. """ _widget_list = ("select_file", "fname_label") select_file = widget_descriptors.ButtonDescriptor( "select_file", default_text="file selector") # type: basic_widgets.Button fname_label = widget_descriptors.LabelDescriptor( "fname_label", default_text="") # type: basic_widgets.Label def __init__(self, parent): """ Parameters ---------- parent The parent widget. """ WidgetPanel.__init__(self, parent) tkinter.LabelFrame.__init__(self, parent) self.config(borderwidth=0) self.fname = None self.init_w_horizontal_layout() self.fname_filters = [('All files', '*')] # in practice this would be overridden if the user wants more things to happen after selecting a file. self.select_file.on_left_mouse_click(self.event_select_file) self.initialdir = os.path.expanduser("~") self.fname_label.config(state='disabled') def set_fname_filters(self, filter_list): """ Parameters ---------- filter_list : List[str] Returns ------- None """ self.fname_filters = filter_list def set_initial_dir(self, directory): """ Set the initial directory, the default opening location. Parameters ---------- directory : str Returns ------- None """ self.initialdir = directory def event_select_file(self, event): """ The file selection event. Parameters ---------- event Returns ------- str """ self.fname = askopenfilename(initialdir=self.initialdir, filetypes=self.fname_filters) self.fname_label.set_text(self.fname) return self.fname def event_new_file(self, event): """ The new file selection event. Parameters ---------- event Returns ------- None """ self.fname = asksaveasfilename(initialdir=self.initialdir, filetypes=self.fname_filters) self.fname_label.config(text=self.fname)
class Toolbar(WidgetPanel): top_level_controls = ("zoom_in", "zoom_out", "pan", "margins_checkbox", "axes_labels_checkbox", "save_canvas", "save_image") axes_labels_controls = ("title_label", "title", "x_label", "x", "y_label", "y") margin_controls = ("left_margin_label", "left_margin", "right_margin_label", "right_margin", "top_margin_label", "top_margin", "bottom_margin_label", "bottom_margin") _widget_list = (top_level_controls, axes_labels_controls, margin_controls) zoom_in = widget_descriptors.ButtonDescriptor( "zoom_in") # type: basic_widgets.Button zoom_out = widget_descriptors.ButtonDescriptor( "zoom_out") # type: basic_widgets.Button pan = widget_descriptors.ButtonDescriptor( "pan") # type: basic_widgets.Button margins_checkbox = widget_descriptors.CheckButtonDescriptor( "margins_checkbox", default_text="margins") # type: basic_widgets.CheckButton axes_labels_checkbox = widget_descriptors.CheckButtonDescriptor( "axes_labels_checkbox", default_text="axes labels") # type: basic_widgets.CheckButton save_canvas = widget_descriptors.ButtonDescriptor( "save_canvas", default_text="save canvas") # type: basic_widgets.Button save_image = widget_descriptors.ButtonDescriptor( "save_image", default_text="save image") # type: basic_widgets.Button left_margin_label = widget_descriptors.LabelDescriptor( "left_margin_label", default_text="left margin") # type: basic_widgets.Label right_margin_label = widget_descriptors.LabelDescriptor( "right_margin_label", default_text="right margin") # type: basic_widgets.Label top_margin_label = widget_descriptors.LabelDescriptor( "top_margin_label", default_text="top margin") # type: basic_widgets.Label bottom_margin_label = widget_descriptors.LabelDescriptor( "bottom_margin_label", default_text="bottom margin") # type: basic_widgets.Label title_label = widget_descriptors.LabelDescriptor( "title_label", default_text="title") # type: basic_widgets.Label x_label = widget_descriptors.LabelDescriptor( "x_label", default_text="x label") # type: basic_widgets.Label y_label = widget_descriptors.LabelDescriptor( "y_label", default_text="y label") # type: basic_widgets.Label title = widget_descriptors.EntryDescriptor( "title", default_text="") # type: basic_widgets.Entry x = widget_descriptors.EntryDescriptor( "x", default_text="") # type: basic_widgets.Entry y = widget_descriptors.EntryDescriptor( "y", default_text="") # type: basic_widgets.Entry left_margin = widget_descriptors.EntryDescriptor( "left_margin", default_text="0") # type: basic_widgets.Entry right_margin = widget_descriptors.EntryDescriptor( "right_margin", default_text="0") # type: basic_widgets.Entry top_margin = widget_descriptors.EntryDescriptor( "top_margin", default_text="0") # type: basic_widgets.Entry bottom_margin = widget_descriptors.EntryDescriptor( "bottom_margin", default_text="0") # type: basic_widgets.Entry def __init__(self, parent): WidgetPanel.__init__(self, parent) self.init_w_rows()