def main(): def str_examples(): examples = """ Usage example:\n cif2spg.py silicon.cif => Open CIF file and visualize info on the spacegroup. cif2spg.py -g silicon.cif => Same as above but use the GUI. """ return examples def show_examples_and_exit(err_msg=None, error_code=1): """Display the usage of the script.""" sys.stderr.write(str_examples()) if err_msg: sys.stderr.write("Fatal Error\n" + err_msg + "\n") sys.exit(error_code) parser = argparse.ArgumentParser(epilog=str_examples(), formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('cif_file', nargs=1, help="CIF File") parser.add_argument('-g', '--gui', action="store_true", help="Enable GUI") # Parse command line. try: options = parser.parse_args() except: show_examples_and_exit(error_code=1) cif_file = options.cif_file[0] structure = abilab.Structure.from_file(cif_file) #print(structure.to_abivars()) finder = SymmetryFinder(structure, symprec=1e-5, angle_tolerance=5) data = finder.get_symmetry_dataset() from pprint import pprint if not options.gui: pprint(data) else: from StringIO import StringIO import wx from abipy.gui.editor import SimpleTextViewer stream = StringIO() pprint(data, stream=stream) stream.seek(0) text = "".join(stream) app = wx.App() frame = SimpleTextViewer(None, text=text) frame.Show() app.MainLoop() return 0
def OnShow(self, event): s = self._convert() SimpleTextViewer(self, text=s, title=self.structure.formula).Show()
def task_show_deps(parent, task): """Show the dependencies of the task.""" text = task.str_deps() SimpleTextViewer(parent, text).Show()
def show_history(parent, task): """Show the history of the task.""" text = "\n".join(task.history) SimpleTextViewer(parent, text).Show()
def OnShowInput(self, event): """Show the fftprof input in an external window.""" fft_input = self.MakeInput() SimpleTextViewer(self, fft_input).Show()