def __init__(self, images=None, rotations='', show_bonds=False, expr=None): if not isinstance(images, Images): images = Images(images) self.images = images self.observers = [] self.config = read_defaults() if show_bonds: self.config['show_bonds'] = True menu = self.get_menu_data() self.window = ui.ASEGUIWindow(close=self.exit, menu=menu, config=self.config, scroll=self.scroll, scroll_event=self.scroll_event, press=self.press, move=self.move, release=self.release, resize=self.resize) View.__init__(self, rotations) Status.__init__(self) self.subprocesses = [] # list of external processes self.movie_window = None self.vulnerable_windows = [] self.simulation = {} # Used by modules on Calculate menu. self.module_state = {} # Used by modules to store their state. self.arrowkey_mode = self.ARROWKEY_SCAN self.move_atoms_mask = None self.set_frame(len(self.images) - 1, focus=True) # Used to move the structure with the mouse self.prev_pos = None self.last_scroll_time = time() self.orig_scale = self.scale if len(self.images) > 1: self.movie() if expr is None: expr = self.config['gui_graphs_string'] if expr is not None and expr != '' and len(self.images) > 1: self.plot_graphs(expr=expr, ignore_if_nan=True)
def __init__(self, images=None, rotations='', show_unit_cell=True, show_bonds=False): # Try to change into directory of file you are viewing try: os.chdir(os.path.split(sys.argv[1])[0]) # This will fail sometimes (e.g. for starting a new session) except: pass if not images: images = Images() images.initialize([Atoms()]) self.images = images self.config = read_defaults() menu = self.get_menu_data(show_unit_cell, show_bonds) self.window = ui.ASEGUIWindow(close=self.exit, menu=menu, config=self.config, scroll=self.scroll, scroll_event=self.scroll_event, press=self.press, move=self.move, release=self.release, resize=self.resize) View.__init__(self, rotations) Status.__init__(self) self.graphs = [] # list of matplotlib processes self.graph_wref = [] # list of weakrefs to Graph objects self.movie_window = None self.vulnerable_windows = [] self.simulation = {} # Used by modules on Calculate menu. self.module_state = {} # Used by modules to store their state. self.arrowkey_mode = self.ARROWKEY_SCAN self.move_atoms_mask = None
def __init__(self, config, images=None, element_colors=None): """Initialise the GUI. Parameters ---------- config: ViewConfig initial configuration settings images : ase.gui.images.Images list of ase.Atoms, with some settings for visualisations (mainly radii) element_colors: list[tuple] hex colour for each atomic number (defaults to 'jmol' scheme) """ if not isinstance(images, Images): images = Images(images) self.images = images self.observers = [] self.config = attr.asdict(config) # aliases required by ui.ASEGUIWindow self.config["gui_foreground_color"] = self.config["canvas_color_foreground"] self.config["gui_background_color"] = self.config["canvas_color_background"] self.config["swap_mouse"] = self.config["gui_swap_mouse"] menu = self.get_menu_data() self.window = ui.ASEGUIWindow( close=self.exit, menu=menu, config=self.config, scroll=self.scroll, scroll_event=self.scroll_event, press=self.press, move=self.move, release=self.release, resize=self.resize, ) # used by ``View.update_labels`` label_sites = {"index": 1, "magmom": 2, "element": 3, "charge": 4}.get( self.config["atom_label_by"], 0 ) if not self.config["atom_show_label"]: label_sites = 0 self.window["show-labels"] = label_sites View.__init__(self, self.config["rotations"]) if element_colors: self.colors = dict(enumerate(element_colors)) self.subprocesses = [] # list of external processes self.movie_window = None self.vulnerable_windows = [] self.simulation = {} # Used by modules on Calculate menu. self.module_state = {} # Used by modules to store their state. self.arrowkey_mode = self.ARROWKEY_SCAN self.move_atoms_mask = None self.set_frame(len(self.images) - 1, focus=True) # Used to move the structure with the mouse self.prev_pos = None self.last_scroll_time = self.t0 = time() self.orig_scale = self.scale self.xy = None if len(self.images) > 1: self.movie()