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 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 ButtonPanel(WidgetPanel): _widget_list = ("line_draw", "point_draw") line_draw = widget_descriptors.ButtonDescriptor("line_draw", default_text="line") # type: basic_widgets.Button point_draw = widget_descriptors.ButtonDescriptor("point_draw", default_text="point") # type: basic_widgets.Button def __init__(self, parent): WidgetPanel.__init__(self, parent) self.init_w_box_layout(1, column_widths=8, row_heights=5)
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 PrimaryPanel(WidgetPanel): _widget_list = ('button_1', 'panel_1') button_1 = widget_descriptors.ButtonDescriptor("button_1", default_text="asdf") # type: basic_widgets.Button button_2 = widget_descriptors.ButtonDescriptor("button_2") # type: basic_widgets.Button panel_1 = widget_descriptors.PanelDescriptor("panel_1", Panel1) # type: Panel1 def __init__(self, primary): primary_frame = tkinter.Frame(primary) WidgetPanel.__init__(self, primary_frame) self.init_w_horizontal_layout() primary_frame.pack()
class Controls(WidgetPanel): """ Band selection tool for RGB display. """ _widget_list = ("pan", "select") pan = widget_descriptors.ButtonDescriptor("pan") # type: basic_widgets.Combobox select = widget_descriptors.ButtonDescriptor("select") # type: basic_widgets.Combobox def __init__(self, parent): """ Parameters ---------- parent The parent widget. """ WidgetPanel.__init__(self, parent) self.init_w_vertical_layout()
class CanvasDemoButtonPanel(WidgetPanel): _widget_list = ( "fname_select", "rect_select", "draw_line", "draw_arrow", "draw_rect", "draw_polygon", "draw_point", "edit", "color_selector", "remap_dropdown", ) fname_select = widget_descriptors.ButtonDescriptor( "fname_select") # type: basic_widgets.Button rect_select = widget_descriptors.ButtonDescriptor( "rect_select") # type: basic_widgets.Button draw_line = widget_descriptors.ButtonDescriptor( "draw_line") # type: basic_widgets.Button draw_arrow = widget_descriptors.ButtonDescriptor( "draw_arrow") # type: basic_widgets.Button draw_rect = widget_descriptors.ButtonDescriptor( "draw_rect") # type: basic_widgets.Button draw_polygon = widget_descriptors.ButtonDescriptor( "draw_polygon") # type: basic_widgets.Button draw_point = widget_descriptors.ButtonDescriptor( "draw_point") # type: basic_widgets.Button color_selector = widget_descriptors.ButtonDescriptor( "color_selector") # type: basic_widgets.Button edit = widget_descriptors.ButtonDescriptor( "edit") # type: basic_widgets.Button remap_dropdown = widget_descriptors.ComboboxDescriptor( "remap_dropdown") # type: basic_widgets.Combobox def __init__(self, parent): WidgetPanel.__init__(self, parent) self.init_w_box_layout(2, column_widths=20) self.remap_dropdown.update_combobox_values([ "density", "brighter", "darker", "high contrast", "linear", "log", "pedf", "nrl" ])
class ButtonPanel(WidgetPanel): """ Basic button panel. """ _widget_list = ("single_plot", "multi_plot", "animated_plot") single_plot = widget_descriptors.ButtonDescriptor( "single_plot") # type: basic_widgets.Button multi_plot = widget_descriptors.ButtonDescriptor( "multi_plot") # type: basic_widgets.Button animated_plot = widget_descriptors.ButtonDescriptor( "animated_plot") # type: basic_widgets.Button def __init__(self, parent): """ Parameters ---------- parent The parent widget. """ WidgetPanel.__init__(self, parent) self.init_w_horizontal_layout()
class Buttons(WidgetPanel): _widget_list = ("draw_rect", "draw_line", "draw_arrow", "draw_point", "draw_polygon", "edit_shape") draw_rect = widget_descriptors.ButtonDescriptor("draw_rect", default_text="rect") # type: Button draw_line = widget_descriptors.ButtonDescriptor("draw_line", default_text="line") # type: Button draw_arrow = widget_descriptors.ButtonDescriptor("draw_arrow", default_text="arrow") # type: Button draw_point = widget_descriptors.ButtonDescriptor("draw_point", default_text="point") # type: Button draw_polygon = widget_descriptors.ButtonDescriptor("draw_polygon", default_text="polygon") # type: Button edit_shape = widget_descriptors.ButtonDescriptor("edit_shape", default_text="edit") # type: Button def __init__(self, primary): self.primary = primary WidgetPanel.__init__(self, primary) self.init_w_vertical_layout()
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()