def reset_dialog(self, widget=None): """Layout the widgets in the main frame We'll let 'TkEnergy' layout the initial set of widgets, then add the extra widgets for controlling optimization """ row = super().reset_dialog() convergence = self['convergence'].get() method = self['method'].get() widgets = [] widgets_2 = [] self['method'].grid(row=row, column=0, columnspan=2, sticky=tk.EW) widgets.append(self['method']) row += 1 self['cycles'].grid(row=row, column=1, sticky=tk.EW) widgets_2.append(self['cycles']) row += 1 if convergence not in ('normal', 'precise', 'relative'): self['gnorm'].grid(row=row, column=1, sticky=tk.EW) widgets_2.append(self['gnorm']) row += 1 if method[0:2] == 'EF' or method[0] == '$': self['recalc'].grid(row=row, column=1, sticky=tk.EW) widgets_2.append(self['recalc']) row += 1 self['dmax'].grid(row=row, column=1, sticky=tk.EW) widgets_2.append(self['dmax']) row += 1 sw.align_labels(widgets) sw.align_labels(widgets_2) return row
def reset_dialog(self, widget=None): """Layout the widgets in the dialog This initial function simply lays them out row by rows with aligned labels. You may wish a more complicated layout that is controlled by values of some of the control parameters. """ # Remove any widgets previously packed frame = self["frame"] for slave in frame.grid_slaves(): slave.grid_forget() # What type of file? extension = "" filename = self["file"].get().strip() file_type = self["file type"].get() if self.is_expr(filename) or self.is_expr(file_type): extension = "all" else: if file_type != "from extension": extension = file_type.split()[0] else: if filename != "": path = PurePath(filename) extension = path.suffix if extension == ".gz": extension = path.stem.suffix # Get the metadata for the format metadata = get_format_metadata(extension) # and put the correct ones back in. row = 0 widgets = [] for item in ("file", "file type"): self[item].grid(row=row, column=0, columnspan=2, sticky=tk.EW) widgets.append(self[item]) row += 1 sw.align_labels(widgets) items = [] if extension == "all" or not metadata["single_structure"]: items.append("structures") items.append("remove hydrogens") if len(items) > 0: widgets = [] for item in items: self[item].grid(row=row, column=1, sticky=tk.EW) widgets.append(self[item]) row += 1 sw.align_labels(widgets) # Set the widths and expansion frame.columnconfigure(0, minsize=50) frame.columnconfigure(1, weight=1)
def reset_dialog(self, widget=None): """Layout the widgets in the main frame We'll let 'TkEnergy' layout the initial set of widgets, then add the extra widgets for controlling optimization """ row = super().reset_dialog() widgets = [] for key in ('trans', 'let'): self[key].grid(row=row, column=0, columnspan=2, sticky=tk.EW) widgets.append(self[key]) row += 1 sw.align_labels(widgets) return row
def reset_dialog(self, widget=None): """Layout the widgets in the dialog. The widgets are chosen by default from the information in System_parameter. This function simply lays them out row by row with aligned labels. You may wish a more complicated layout that is controlled by values of some of the control parameters. If so, edit or override this method Parameters ---------- widget : Tk Widget = None Returns ------- None See Also -------- TkSystem.create_dialog """ # Remove any widgets previously packed frame = self['frame'] for slave in frame.grid_slaves(): slave.grid_forget() # Shortcut for parameters P = self.node.parameters # keep track of the row in a variable, so that the layout is flexible # if e.g. rows are skipped to control such as 'method' here row = 0 widgets = [] for key in P: self[key].grid(row=row, column=0, sticky=tk.EW) widgets.append(self[key]) row += 1 # Align the labels sw.align_labels(widgets)
def reset_dialog(self, widget=None): convergence = self['convergence'].get() frame = self['frame'] for slave in frame.grid_slaves(): slave.grid_forget() widgets = [] row = 0 self['structure'].grid(row=row, column=0, columnspan=2, sticky=tk.EW) widgets.append(self['structure']) row += 1 self['hamiltonian'].grid(row=row, column=0, columnspan=2, sticky=tk.EW) widgets.append(self['hamiltonian']) row += 1 self['convergence'].grid(row=row, column=0, columnspan=2, sticky=tk.EW) widgets.append(self['convergence']) row += 1 sw.align_labels(widgets) if convergence == 'relative': self['relative'].grid(row=row, column=1, sticky=tk.W) row += 1 elif convergence == 'absolute': self['absolute'].grid(row=row, column=1, sticky=tk.W) row += 1 elif convergence not in ('normal', 'precise'): # variable ... so put in all possibilities self['relative'].grid(row=row, column=1, sticky=tk.W) row += 1 self['absolute'].grid(row=row, column=1, sticky=tk.W) row += 1 sw.align_labels((self['relative'], self['absolute'])) frame.columnconfigure(0, minsize=30) return row
def reset_dialog(self, widget=None): """Layout the widgets in the dialog. The widgets are chosen by default from the information in Set Cell_parameter. This function simply lays them out row by row with aligned labels. You may wish a more complicated layout that is controlled by values of some of the control parameters. If so, edit or override this method Parameters ---------- widget : Tk Widget = None Returns ------- None See Also -------- TkSetCell.create_dialog """ # Remove any widgets previously packed frame = self['frame'] for slave in frame.grid_slaves(): slave.grid_forget() method = self['method'].get() # keep track of the row in a variable, so that the layout is flexible # if e.g. rows are skipped to control such as 'method' here row = 0 widgets = [] self['method'].grid(row=row, column=0, columnspan=2, sticky=tk.W) row += 1 if method == 'density': self['density'].grid(row=row, column=1, sticky=tk.EW) widgets.append(self['density']) row += 1 elif method == 'volume': self['volume'].grid(row=row, column=1, sticky=tk.EW) widgets.append(self['volume']) row += 1 elif method == 'cell parameters': for parameter in ('a', 'b', 'c', 'alpha', 'beta', 'gamma'): self[parameter].grid(row=row, column=1, sticky=tk.EW) widgets.append(self[parameter]) row += 1 elif method == 'uniform contraction/expansion': self['expansion'].grid(row=row, column=1, sticky=tk.EW) widgets.append(self['expansion']) row += 1 else: raise RuntimeError(f"Don't recognize method '{method}'!") # Align the labels sw.align_labels(widgets) # Offset the columns self['frame'].grid_columnconfigure(0, minsize=50) self['frame'].grid_columnconfigure(1, weight=1)
def reset_dialog(self, widget=None): solvent = self['solvent'].get() method = self['method'].get() submethod = self['submethod'].get() logger.debug('reset_dialog: {}'.format(solvent)) frame = self['frame'] for slave in frame.grid_slaves(): slave.grid_forget() row = 0 self['solvent'].grid(row=row, column=0, columnspan=2, sticky=tk.W) row += 1 if solvent == 'water' or solvent[0] == '$': self['water_model'].grid(row=row, column=1, sticky=tk.W) row += 1 self['method'].grid(row=row, column=0, columnspan=2, sticky=tk.EW) if method == "within a sphere of solvent": raise NotImplementedError( 'Solvating with a sphere not implemented yet!') else: self['submethod'].grid(row=row, column=3, sticky=tk.W) if submethod == ( "fixing the volume and adding a given number of molecules" ): row += 1 self['number of molecules'].grid(row=row, column=1, sticky=tk.EW) elif submethod == "fixing the volume and filling to a density": row += 1 self['density'].grid(row=row, column=1, columnspan=2, sticky=tk.EW) elif submethod == ( "with the density and number of molecules of solvent"): row += 1 self['density'].grid(row=row, column=1, columnspan=3, sticky=tk.W) row += 1 self['number of molecules'].grid(row=row, column=1, columnspan=3, sticky=tk.W) sw.align_labels([self['density'], self['number of molecules']]) elif submethod == ( "with the density and approximate number of atoms of " "solvent"): row += 1 self['density'].grid(row=row, column=1, sticky=tk.EW) row += 1 self['approximate number of atoms'].grid(row=row, column=1, sticky=tk.EW) sw.align_labels( [self['density'], self['approximate number of atoms']]) row += 1 frame.columnconfigure(0, minsize=60)