def __init__(self): super().__init__() finder_tab = tk.Frame(self._tool_tabs) self._tool_tabs.add(finder_tab, text='Finder') widgets_desc = [finder_grp] widgets = json_to_tk(finder_tab, widgets_desc) widgets['start_btn']['command'] = self._on_start_click widgets['stop_btn']['command'] = self._on_stop_click self.__start_button = widgets['start_btn'] self._make_window_manager_tab() self.replica_finder = ReplicaFinder() self.__dir_indicator = dir_indicator = DirIndicator(self.tk_object) dir_indicator.pack(fill='x') cwd = os.getcwd() if os.path.altsep is not None: # Windows OS cwd = cwd.replace(os.path.altsep, os.path.sep) dir_indicator.change_dir(cwd) self.__treeview = treeview = ReplicaTreeview(self.tk_object) treeview.pack(expand='yes', fill='both') self.replica_finder.add_observer(treeview) self.replica_finder.add_observer(self) widgets_desc = [status_frm] widgets = json_to_tk(self.tk_object, widgets_desc) self.__busy_light = widgets['light_lbl'] self.__current_dir_label = widgets['current_dir_lbl']
def __init__(self, *args, **kwargs): FigureWindow.__init__(self, *args, **kwargs) tool_tabs = self._tool_tabs widgets_desc = [ dict(class_=Group, pack=dict(side='left', fill='y'), setattr={'name': 'Load'}, children=[ dict(class_='Button', config=dict(text='Load', command=self._on_load)) ]) ] tab = tk.Frame(tool_tabs) json_to_tk(tab, widgets_desc) tool_tabs.add(tab, text='S2P Files') self._make_view_tab() self._make_marker_tab() self._make_export_tab() self._make_window_manager_tab() figure_book = self.figure_book figure_book.make_figures(figure_meta=[ dict(name='Real', polar=False), dict(name='Image', polar=False), dict(name='Mag (dB)', polar=False), dict(name='Phase (deg)', polar=False) ]) self.__freq_range = np.r_[0:1] real_figure = figure_book[0] real_figure.plot_function = lambda current_data, *args, **kwargs:\ real_figure.plot(self.__freq_range, current_data.real, *args, **kwargs) imag_figure = figure_book[1] imag_figure.plot_function = lambda current_data, *args, **kwargs:\ imag_figure.plot(self.__freq_range, current_data.imag, *args, **kwargs) mag_figure = figure_book[2] mag_figure.plot_function = lambda current_data, *args, **kwargs:\ mag_figure.plot(self.__freq_range, 20*np.log10(np.abs(current_data)), *args, **kwargs) phase_figure = figure_book[3] phase_figure.plot_function = lambda current_data, *args, **kwargs:\ phase_figure.plot(self.__freq_range, np.angle(current_data)/2/np.pi*360, *args, **kwargs) self.__filename = ''
def __init__(self): super().__init__() tool_tabs = self._tool_tabs widgets_desc = [load_grp, unpack_grp] tab = tkinter.Frame(tool_tabs) widgets = json_to_tk(tab, widgets_desc) widgets['load_btn']['command'] = self._on_load widgets['unpack_btn']['command'] = self._on_unpack tool_tabs.add(tab, text='Unrar') self._make_window_manager_tab() tk_object = self.tk_object self.treeview = treeview = ContentTree(tk_object) treeview.tree_view.pack(expand='yes', fill='both') self.__path = None
def _make_widgets(self): tool_tabs = self.window_node._tool_tabs self.__topmost = topmost = IntVar(0) copy_id_icon = ImageTk.PhotoImage( file=Scripting.root_node.get_gui_image_path( 'WindowManager_CopyID.png')) self.__gui_images.append(copy_id_icon) copy_path_icon = ImageTk.PhotoImage( file=Scripting.root_node.get_gui_image_path( 'WindowManager_CopyPath.png')) self.__gui_images.append(copy_path_icon) def on_scale(val): self.set_opacity(val) widgets_desc = [{ "class": Group, "pack": { "side": "left", "fill": "y" }, "setattr": { "name": "Info" }, "children": [{ "class": "Label", "init": { "text": f"ID: {id(self.window_node)}" } }, { "class": "Button", "init": { "text": "Copy ID ", "image": copy_id_icon, "compound": "left", "command": self._on_copy_id_click } }, { "class": "Button", "init": { "text": "Copy Path", "image": copy_path_icon, "compound": "left", "command": self._on_copy_path_click } }] }, { "class": Group, "pack": { "side": "left", "fill": "y" }, "setattr": { "name": "Attributes" }, "children": [{ "class": "Checkbutton", "init": { "text": "Topmost", "variable": topmost, "command": self._on_topmost_click } }, { "class": "Scale", "init": { "from_": 0.2, "to": 1.0, "orient": "horizontal", "value": 1.0, "command": on_scale } }, { "class": "Label", "init": { "text": "Opacity" } }] }] tab = Frame(tool_tabs) json_to_tk(tab, widgets_desc) tool_tabs.add(tab, text='Window Manager')
def __init__(self, *args, **kwargs): FigureWindow.__init__(self, *args, **kwargs) tool_tabs = self._tool_tabs def on_refresh(): with code_printer(): self.refresh() widgets_desc = [ dict(class_=Group, pack=dict(side='left', fill='y'), setattr={'name': 'Instrument'}, children=[ dict(class_='LabeledEntry', name='entry_inst_name', setattr={ 'label_text': 'Name', 'entry_width': 8 }), dict(class_='Button', pack=dict(fill='x'), config=dict(text='Connect', command=self._on_connect_click)), dict(class_='Button', pack=dict(fill='x'), config=dict(text='Refresh', command=on_refresh)) ]), dict(class_=Group, pack=dict(side='left', fill='y'), setattr={'name': 'Frequency'}, children=[ dict(class_='Label', name='label_start_stop'), dict(class_='Label', name='label_center_span') ]) ] tab = tk.Frame(tool_tabs) self.__tab_widgets = json_to_tk(tab, widgets_desc) tool_tabs.add(tab, text='Analyzer') self._make_view_tab() self._make_marker_tab() self._make_export_tab() self._make_window_manager_tab() figure_book = self.figure_book figure_book.make_figures(figure_meta=[dict(name='Curve', polar=False)]) self.__driver = None figure = figure_book[0] def plot_function(current_data, *args, **kwargs): driver = self.__driver start = driver.frequency_start stop = driver.frequency_stop point_num = len(current_data) frequencies = np.linspace(start, stop, point_num) figure.plot(frequencies, current_data, *args, **kwargs) figure.plot_function = plot_function
def on_connect(self): self._gui_images = [] tool_tabs = self._tool_tabs widgets_desc = [connect_grp, window_grp, utils_grp] tab = tk.Frame(tool_tabs) widgets = json_to_tk(tab, widgets_desc) widgets['get_active_btn']['command'] = self.__on_get_active widgets['create_btn']['command'] = self.__on_create widgets['foreground_btn']['command'] = self.__on_foreground widgets['copypath_btn']['command'] = self.__on_copy_path self.__utils_group = utils_group = widgets['utils_grp'] # Utils panel if no item is selected. self.__null_utils_frame = null_utils_frame = tk.Frame(utils_group) null_utils_frame.pack(fill='both') tk.Label(null_utils_frame, text='No Utils Available').pack(fill='both') self.__current_utils_frame = null_utils_frame # Utils panel if a Word instance is selected. self.__word_utils_frame = word_utils_frame = tk.Frame(utils_group) ttk.Button(word_utils_frame, text='Insert PSD', command=self.__on_insert_psd).pack(fill='x') ttk.Button(word_utils_frame, text='Update PSD', command=self.__on_update_psd).pack(fill='x') # Utils panel if an Excel instance is selected. self.__excel_utils_frame = excel_utils_frame = tk.Frame(utils_group) tk.Label(excel_utils_frame, text='Excel Utils').pack(fill='both') tool_tabs.add(tab, text='Office') self._make_window_manager_tab() self.__treeview = treeview = AppTreeview(self.tk_object) treeview.pack(expand='yes', fill='both') treeview._tree.bind('<<TreeviewSelect>>', self.__on_select) app_dict = self.root_node.toolboxes["msoffice"].app_dict treeview.update(app_dict) @SimpleObserver def app_observer(event): # At this moment it seems that we cannot access the message loop, # since if we use after method of tk, it will block. import time @self.root_node.thread_manager.new_thread_do def wait(treeview=treeview): # Wait for 2.5 sec. If we call treeview.update immediately, # it will block (maybe because the update method will access the app model tree). time.sleep(2.5) @self.root_node.thread_manager.main_thread_do(block=False) def update_tree(): kwargs = event.kwargs event_desc = ' '.join( (kwargs['app'], kwargs['source'], event.name)) if event_desc in { 'Word Application NewDocument', 'Word Application DocumentOpen', 'Word Application Quit', 'Word Document Close' }: treeview.update(app_dict) self.__app_observer = app_observer app_dict.add_observer(app_observer)
def __init__(self): super().__init__() tool_tabs = self._tool_tabs widgets_desc = [ load_grp, export_grp, resize_grp, external_viewer_grp, wallpaper_grp ] tab = tk.Frame(tool_tabs) widgets = json_to_tk(tab, widgets_desc) self.__scale_label = widgets['scale_label'] self.__image_scale = widgets['image_scale'] self.__image_scale['command'] = self._on_scale self.__wallpaper_position = widgets['wallpaper_position_combo'] self.__wallpaper_position.current(0) widgets['load_btn']['command'] = self._on_load_psd widgets['export_all_btn']['command'] = self._on_export_selected widgets['export_selected_btn']['command'] = self._on_export_selected widgets['launch_viewer_btn']['command'] = self._on_launch_viewer widgets['set_wallpaper_btn']['command'] = self._on_set_wallpaper tool_tabs.add(tab, text='PSD Files') tk_object = self.tk_object paned = tk.PanedWindow(tk_object) paned.config(sashwidth=4, sashrelief='groove', bg='forestgreen') paned.pack(expand='yes', fill='both') image_book = ttk.Notebook(paned) paned.add(image_book, stretch='always') all_canvas = ScrolledCanvas(image_book) image_book.add(all_canvas, text='Merged') sel_canvas = ScrolledCanvas(image_book) image_book.add(sel_canvas, text='Selected') self.__layer_tree = layer_tree = LayerTree(paned) paned.add(layer_tree.tree_view, stretch='never') self._make_window_manager_tab() self.__psd_image = None self.__pil_image = None self.__tk_image = None self.__image_id = None self.__psd_path = '' self.__mtime = 0.0 self.__scale = 100 self.__all_canvas = all_canvas self.__timer = TkTimer(widget=self.tk_object) @self.__timer.add_observer def watch(event=None): if self.__psd_path: mtime = self.__psd_path.stat().st_mtime if mtime > self.__mtime: with code_printer(False): self.load(self.__psd_path)