def _set_frame_color_maps(self): labelframe = self.labelframe_color_maps frame = tk.Frame(labelframe) frame.grid(row=0, column=0, sticky='nw') tkw.grid_configure(labelframe) cmap_list = core.Colormaps().get_list() self.widget_selected_cmap = tkw.ComboboxWidget( frame, items=cmap_list, title='', callback_target=self._on_select_colormap, row=0, column=0, sticky='w') # self.button_save_cmap = tk.Button(frame, text='Save colormaps', command=self._save_colormap, bg='lightgreen') # self.button_save_cmap.grid(row=0, column=1, sticky='w', padx=5, pady=5) self.widget_listbox_cmap = tkw.ListboxSelectionWidget( frame, row=1, column=0, sticky='nw', target=self._on_select_par_for_colormap) tkw.grid_configure(frame, nr_rows=2) self.current_pars_in_cmap = {}
def _create_new_user(self): def _create_user(): source_user = widget_source_user.get_value().strip() new_user_name = widget_new_user_name.get_value().strip() if not new_user_name: gui.show_information('Create user', 'No user name given!') return if not source_user: source_user = None try: self.user_manager.add_user(new_user_name, source_user) if intvar_load_user.get(): self._change_user(new_user_name) self._update_menubar_users() except GUIExceptionUserError as e: gui.show_error( 'Creating user', '{}\nUser not created. Try again!'.format(e.message)) popup_frame.destroy() def _cancel(): popup_frame.destroy() popup_frame = tk.Toplevel(self) current_user_list = [''] + self.user_manager.get_user_list() grid = dict(sticky='w', padx=5, pady=5) widget_source_user = tkw.ComboboxWidget(popup_frame, title='Create copy of user', items=current_user_list, **grid) widget_new_user_name = tkw.EntryWidget(popup_frame, row=1, **grid) intvar_load_user = tk.IntVar() widget_checkbutton_load_user = tk.Checkbutton( popup_frame, text="Load new user", variable=intvar_load_user) widget_checkbutton_load_user.grid(row=1, column=1, **grid) intvar_load_user.set(1) widget_button_done = tk.Button(popup_frame, text='Create user', command=_create_user) widget_button_done.grid(row=2, column=0, **grid) widget_button_done = tk.Button(popup_frame, text='Cancel', command=_cancel) widget_button_done.grid(row=2, column=1, **grid) tkw.grid_configure(popup_frame, nr_rows=3, nr_columns=2)
def _set_frame_plot_style(self): labelframe = self.labelframe_plot_style frame = tk.Frame(labelframe) frame.grid(row=0, column=0, sticky='nw') tkw.grid_configure(labelframe) style_list = plt.style.available self.widget_selected_plotstyle = tkw.ComboboxWidget( frame, items=style_list, title='', callback_target=self._on_select_plotstyle, row=0, column=0, sticky='nw') self.widget_selected_plotstyle.set_value( self.user.layout.setdefault('plotstyle', self.settings['default']['plotstyle'])) tk.Label( frame, text= 'Note that you have to restart\nthe program to activate the\nnew plot style.' ).grid(row=1, column=0, pady=10, sticky='nw') tkw.grid_configure(frame, nr_rows=2)
def _set_frame_add_file(self): """ Created 20180821 by Magnus """ #---------------------------------------------------------------------- # Three main frames frame = self.frame_add frame_data = tk.LabelFrame(frame, text='Get data file') frame_settings = tk.LabelFrame(frame, text='Settings file') frame_sampling_type = tk.LabelFrame(frame, text='Sampling type') frame_platform_depth = tk.LabelFrame(frame, text='Platform depth') frame_load = tk.Frame(frame) # Grid padx = 5 pady = 5 frame_data.grid(row=0, column=0, columnspan=4, sticky='nsew', padx=padx, pady=pady) frame_settings.grid(row=1, column=0, sticky='nsew', padx=padx, pady=pady) frame_sampling_type.grid(row=1, column=1, sticky='nsew', padx=padx, pady=pady) frame_platform_depth.grid(row=1, column=2, sticky='nsew', padx=padx, pady=pady) frame_load.grid(row=1, column=3, sticky='nsew', padx=padx, pady=pady) # Gridconfigure tkw.grid_configure(frame, nr_rows=2, nr_columns=4, r0=50) # frame.grid_rowconfigure(0, weight=1) # frame.grid_rowconfigure(1, weight=1) # frame.grid_rowconfigure(2, weight=1) # frame.grid_columnconfigure(0, weight=1) #---------------------------------------------------------------------- # Data frame self.button_get_ferrybox_data_file = tk.Button( frame_data, text='Ferrybox CMEMS', command=lambda: self._get_data_file_path('Ferrybox CMEMS')) self.button_get_fixed_platform_data_file = tk.Button( frame_data, text='Fixed platform CMEMS', command=lambda: self._get_data_file_path('Fixed platforms CMEMS')) self.button_get_ctd_data_file = tk.Button( frame_data, text='CTD-profile', command=lambda: self._get_data_file_path('CTD SHARK')) self.button_get_sampling_file = tk.Button( frame_data, text='SHARKweb bottle data', command=lambda: self._get_data_file_path('PhysicalChemical SHARK')) tkw.disable_widgets(self.button_get_ctd_data_file) self.stringvar_data_file = tk.StringVar() self.entry_data_file = tk.Entry(frame_data, textvariable=self.stringvar_data_file, state='disabled') # Grid padx = 5 pady = 5 self.button_get_ferrybox_data_file.grid(row=0, column=0, padx=padx, pady=pady, sticky='nsew') self.button_get_fixed_platform_data_file.grid(row=0, column=1, padx=padx, pady=pady, sticky='nsew') self.button_get_ctd_data_file.grid(row=0, column=2, padx=padx, pady=pady, sticky='nsew') self.button_get_sampling_file.grid(row=0, column=3, padx=padx, pady=pady, sticky='nsew') self.entry_data_file.grid(row=1, column=0, columnspan=5, padx=padx, pady=pady, sticky='nsew') # Gridconfigure tkw.grid_configure(frame_data, nr_rows=2, nr_columns=4) #---------------------------------------------------------------------- # Settings frame self.combobox_widget_settings_file = tkw.ComboboxWidget( frame_settings, items=[], title='', prop_combobox={'width': 40}, column=0, columnspan=1, row=0, sticky='nsew') self._update_settings_combobox_widget() self.button_import_settings_file = ttk.Button( frame_settings, text='Import settings file', command=self._import_settings_file) self.button_import_settings_file.grid(row=0, column=1, padx=padx, pady=pady, sticky='nsew') tkw.grid_configure(frame_settings, nr_rows=1, nr_columns=2) #---------------------------------------------------------------------- # Sampling type frame self.combobox_widget_sampling_type = tkw.ComboboxWidget( frame_sampling_type, items=sorted(self.session.get_sampling_types()), title='', prop_combobox={'width': 30}, column=0, columnspan=1, row=0, sticky='nsew') # Platform depth frame self.entry_widget_platform_depth = tkw.EntryWidget( frame_platform_depth, entry_type='int', prop_entry=dict(width=5), row=0, column=0, padx=padx, pady=pady, sticky='nsew') self.entry_widget_platform_depth.disable_widget() tk.Label(frame_platform_depth, text='meters').grid(row=0, column=1, padx=padx, pady=pady, sticky='nsew') tkw.grid_configure(frame_platform_depth) # Gridconfigure tkw.grid_configure(frame_sampling_type) # Load file button self.button_load_file = tk.Button(frame_load, text='Load file', command=self._load_file, bg='lightgreen', font=(30)) self.button_load_file.grid(row=0, column=0, padx=padx, pady=pady, sticky='nsew') self.button_load_file.configure(state='disabled') tkw.grid_configure(frame_load)
def _set_frame_map(self): def save_color(item): color = self.combobox_map_color[item].get_value() if color: self.user.map_prop.set(item, color) self.labels_map_color[item].config(fg=color) # self.combobox_map_color[item].set_background_color(color) frame = self.labelframe_map padx = 5 pady = 5 frame_boundaries = tk.LabelFrame(frame, text='Boundaries') frame_boundaries.grid(row=0, column=0, padx=padx, pady=pady, sticky='nw') frame_properties = tk.LabelFrame(frame, text='Properties') frame_properties.grid(row=1, column=0, padx=padx, pady=pady, sticky='nw') tkw.grid_configure(frame, nr_rows=2) # -------------------------------------------------------------------------------------------------------------- # Boundaries # Labels tk.Label(frame_boundaries, text='Latitude MIN').grid(row=0, column=0, sticky='w', padx=padx, pady=pady) tk.Label(frame_boundaries, text='Latitude MAX').grid(row=1, column=0, sticky='w', padx=padx, pady=pady) tk.Label(frame_boundaries, text='Longitude MIN').grid(row=2, column=0, sticky='w', padx=padx, pady=pady) tk.Label(frame_boundaries, text='Longitude MAX').grid(row=3, column=0, sticky='w', padx=padx, pady=pady) # Entries prop_entry = {'width': 10} self.widget_lat_min = tkw.EntryWidget( frame_boundaries, entry_type='float', entry_id='lat_min', prop_entry=prop_entry, callback_on_focus_out=self._on_change_map_boundries, row=0, column=1, sticky='w', padx=padx, pady=pady) self.widget_lat_max = tkw.EntryWidget( frame_boundaries, entry_type='float', entry_id='lat_max', prop_entry=prop_entry, callback_on_focus_out=self._on_change_map_boundries, row=1, column=1, sticky='w', padx=padx, pady=pady) self.widget_lon_min = tkw.EntryWidget( frame_boundaries, entry_type='float', entry_id='lon_min', prop_entry=prop_entry, callback_on_focus_out=self._on_change_map_boundries, row=2, column=1, sticky='w', padx=padx, pady=pady) self.widget_lon_max = tkw.EntryWidget( frame_boundaries, entry_type='float', entry_id='lon_max', prop_entry=prop_entry, callback_on_focus_out=self._on_change_map_boundries, row=3, column=1, sticky='w', padx=padx, pady=pady) tk.Label(frame_boundaries, text="""Hit RETURN to confirm. Note that you have to restart the program to activate the new boundries.""").grid(row=4, column=0, columnspan=2, pady=10, sticky='nw') tkw.grid_configure(frame_boundaries, nr_rows=4, nr_columns=2) # Link entries self.widget_lat_min.south_entry = self.widget_lat_max self.widget_lat_max.south_entry = self.widget_lon_min self.widget_lon_min.south_entry = self.widget_lon_max self.widget_lon_max.south_entry = self.widget_lat_min # Map resolution self.widget_map_resolution = None # -------------------------------------------------------------------------------------------------------------- # Properties # TODO: ferrybox_track_color_background # TODO: fixed_platform_color_background # TODO: fixed_platforms_markersize_background # TODO: physicalchemical_color_background # TODO: physicalchemical_markersize_background map_color_list = [ 'ferrybox_track_color', 'ferrybox_track_color_highlighted', 'ferrybox_track_color_background', 'fixed_platform_color_background', 'physicalchemical_color_background' ] default_colors = dict(ferrybox_track_color_background='gray', ferrybox_track_color='pink', ferrybox_track_color_highlighted='red', fixed_platform_color_background='gray', physicalchemical_color_background='gray') self.combobox_map_color = {} self.labels_map_color = {} grid_items = dict(sticky='w') r = 0 for item in map_color_list: title = item.replace('_', ' ').capitalize() default_color = self.user.map_prop.setdefault( item, default_colors.get(item, 'black')) self.labels_map_color[item] = tk.Label(frame_properties, text=title) self.labels_map_color[item].grid(row=r, column=0, sticky='w', padx=padx, pady=pady) self.labels_map_color[item].config(fg=default_color) self.combobox_map_color[item] = tkw.ComboboxWidget( frame_properties, callback_target=lambda x=item: save_color(x), items=self.color_list, default_item=default_color, align='horizontal', grid_items=grid_items, row=r, column=1, padx=padx, pady=pady, sticky='e') save_color(item) r += 1