How to use the abipy.gui.awx function in abipy

To help you get started, we’ve selected a few abipy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github abinit / abipy / abipy / gui / oncvgui.py View on Github external
def wxapp_oncvpsp(filepath=None):
    """Standalone application."""
    class OncvApp(awx.App):
        def OnInit(self):
            # Enforce WXAgg as matplotlib backend to avoid nasty SIGSEGV in the C++ layer
            # occurring when WX Guis produce plots with other backends.
            import matplotlib
            matplotlib.use('WXAgg')

            frame = WxOncvFrame(None, filepath)
            #frame = my_periodic_table(None)
            #frame = OncvParamsFrame(None, z=12)
            frame.Show(True)
            self.SetTopWindow(frame)
            return True

    app = OncvApp()
    return app
github abinit / abipy / abipy / gui / editor.py View on Github external
num_dirs:
                Maximum number of directories that will be shown in the tab.
        """
        super(TextNotebookFrame, self).__init__(parent, **add_size(kwargs))

        # Add the pages to the notebook with the name to show on the tab
        if not isinstance(text_list, (list, tuple)):
            text_list = [text_list]

        if not isinstance(page_names, (list, tuple)):
            page_names = [page_names]

        assert len(page_names) == len(text_list)

        # Here we create a panel and a notebook on the panel
        nb_panel = awx.Panel(self)

        try:
            style = fnb.FNB_X_ON_TAB | fnb.FNB_NAV_BUTTONS_WHEN_NEEDED
        except AttributeError:
            style = fnb.FNB_X_ON_TAB

        nb = fnb.FlatNotebook(nb_panel, style=style)

        for page_name, text in zip(page_names, text_list):
            page = wx.TextCtrl(nb, -1, text, style=wx.TE_MULTILINE|wx.TE_LEFT|wx.TE_READONLY)

            if num_dirs > 0:
                tokens = page_name.split(os.path.sep)
                page_name = os.path.join(*tokens[-num_dirs:])

            nb.AddPage(page, text=page_name)
github abinit / abipy / abipy / gui / mdfviewer.py View on Github external
def OnMdfCompare(self, event):
        """Compare multiple averaged macroscopic dielectric functions"""
        mdf_type = self.getMdfType()
        cplx_mode = self.getCplxMode()

        if mdf_type == "ALL":
            return awx.showErrorMessage(self, "ALL is not supported by Compare. Please use EXC, RPA, GWRPA")

        plotter = MdfPlotter()
        for path, mdf_file in zip(self.mdf_filepaths, self.mdf_files_list):
            label = os.path.relpath(path)
            mdf = mdf_file.get_mdf(mdf_type)
            plotter.add_mdf(label, mdf)

        plotter.plot(cplx_mode, qpoint=None)
github abinit / abipy / abipy / gui / oncvgui.py View on Github external
def makeInput(self):
        """Build an OncvInput instance from the values specified in the controllers."""
        inp = OncvInput(self.oncv_dims)

        for cls, wxctrl in self.wxctrls.items():
            i = _FIELD_LIST.index(cls)
            inp.fields[i].set_vars(wxctrl.GetParams())

        return inp

    def makeInputString(self):
        """Return a string with the input passed to the pp generator."""
        return str(self.makeInput())


class AeConfTab(awx.Panel):
    def __init__(self, parent, oncv_dims):
        super(AeConfTab, self).__init__(parent)

        # Set the dimensions and build the widgets.
        self.oncv_dims = oncv_dims
        self.buildUI()

    def buildUI(self):
        self.main_sizer = main_sizer = wx.BoxSizer(wx.VERTICAL)

        stext = wx.StaticText(self, -1, "Calculation type:")
        choices = ["scalar-relativistic", "fully-relativistic", "non-relativistic"]
        self.calctype_cbox = wx.ComboBox(
            self, id=-1, name='Calculation type', choices=choices, value=choices[0], style=wx.CB_READONLY)

        add_opts = dict(proportion=0, flag=wx.ALIGN_CENTER_VERTICAL | wx.ALL, border=5)
github abinit / abipy / abipy / gui / sigresviewer.py View on Github external
def onShowQPTable(self, event):
        """Show a table with the QP results for the selected spin, kpoint, band."""
        spin, kpoint, band = event.skb
        qplist = self.sigres.get_qplist(spin, kpoint)
        table = qplist.to_table()
        title = "spin: %d, kpoint: %s" % (spin, kpoint)

        awx.SimpleGridFrame(self, table, labels_from_table=True, title=title).Show()
github abinit / abipy / abipy / gui / editor.py View on Github external
class MyEditorFrame(EditorFrame):
    def __init__(self, parent, filename, **kwargs):
        super(MyEditorFrame, self).__init__(parent, filename=filename, **add_size(kwargs))

    @classmethod
    def from_text(cls, parent, text, **kwargs):
        """Hack so that we can open a string in the Editor."""
        fd, filename = tempfile.mkstemp(text=True)

        with open(filename, "w") as fh:
            fh.write(text)

        return cls(parent, filename, **kwargs)


class TextNotebookFrame(awx.Frame):
    """
    This frame receives a list of strings and displays them in a notebook (read-only mode)
    """
    def __init__(self, parent, text_list, page_names, num_dirs=2, **kwargs):
        """
        Args:
            parent:
                Parent Widget.
            text_list:
                List of strings. Each string is displayed in its own page in the notebook.
            page_names:
                List of strings giving the name of the tab for each string in text_list.
            num_dirs:
                Maximum number of directories that will be shown in the tab.
        """
        super(TextNotebookFrame, self).__init__(parent, **add_size(kwargs))
github abinit / abipy / abipy / gui / gsrviewer.py View on Github external
def bitmap(path):
            return wx.Bitmap(awx.path_img(path))
github abinit / abipy / abipy / gui / editor.py View on Github external
wildcard:
            String with regular expressions separated by |.
            Only the files matching one of the regular expressions will be showed.
            example: wildcard="*.nc|*.txt" shows only the files whose extension is in ["nc", "txt"].

    Returns:
        `wxpython` application.
    """
    app = awx.App()
    frame = TextNotebookFrame.from_files_and_dir(None, filenames=filenames, dirpath=dirpath, walk=walk, wildcard=wildcard)
    frame.Show()
    return app


if __name__ == "__main__":
    app = awx.App()
    frame = EditorNotebookFrame()
    #frame = wx.Frame(None, -1)
    #notebook = EditorNotebook(frame)
    for filename in ["editor.py", "__init__.py"]:
        frame.bufferCreate(filename=filename)

    #Editor(frame)
    frame.Show()
    #frame = EditorFrame()
    #frame.bufferCreate(file.path)
    #frame = EditorNotebookFrame(filename=file.path)
    app.MainLoop()
github abinit / abipy / abipy / gui / mdfviewer.py View on Github external
def bitmap(path):
            return wx.Bitmap(awx.path_img(path))
github abinit / abipy / abipy / gui / baseviewer.py View on Github external
def OnAboutBox(self, event):
        """"Info on the application."""
        awx.makeAboutBox(codename=self.codename, version=self.VERSION,
                         description="", developers="M. Giantomassi")