Exemple #1
0
    def __init__(self, parent, flow, **kwargs):
        super(TaskStatusTreePanel, self).__init__(parent, -1, **kwargs)

        main_sizer = wx.BoxSizer(wx.VERTICAL)
        vbox = wx.BoxSizer(wx.VERTICAL)
        panel1 = awx.Panel(self, -1)
        panel2 = awx.Panel(self, -1)

        self.tree = tree = wx.TreeCtrl(panel1, 1, wx.DefaultPosition, (-1, -1), wx.TR_HIDE_ROOT | wx.TR_HAS_BUTTONS)

        root = self.tree.AddRoot('Task Status')

        # entry = collections.namedtuple("Entry", "task wi ti")
        #print(status2entries)
        self.status2entries = flow.groupby_status()

        self.status_nodes = []
        for status, entries in self.status2entries.items():
            node = tree.AppendItem(root, "%d %s tasks" % (len(entries), str(status)), data=wx.TreeItemData(status))
            self.status_nodes.append(node)
            for entry in entries:
                tree.AppendItem(node, "Task: " + str(entry.task), data=wx.TreeItemData(entry))

        tree.Bind(wx.EVT_TREE_SEL_CHANGED, self.onSelChanged)
        tree.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.onItemRightClick)

        self.display = wx.StaticText(panel2, -1, '', (10, 10), style=wx.ALIGN_LEFT)

        vbox.Add(self.tree, 1, wx.EXPAND)
        main_sizer.Add(panel1, 1, wx.EXPAND)
        main_sizer.Add(panel2, 1, wx.EXPAND)
        panel1.SetSizerAndFit(vbox)

        self.SetSizerAndFit(main_sizer)
        self.Centre()
Exemple #2
0
    def __init__(self, parent, filepath, **kwargs):
        super(AbinitEventsPanel, self).__init__(parent, -1, **kwargs)

        self.filepath = os.path.abspath(filepath)

        parser = EventsParser()
        self.events = events = parser.parse(self.filepath)

        main_sizer = wx.BoxSizer(wx.VERTICAL)
        vbox = wx.BoxSizer(wx.VERTICAL)
        panel1 = awx.Panel(self, -1)
        panel2 = awx.Panel(self, -1)

        self.tree = tree = wx.TreeCtrl(panel1, 1, wx.DefaultPosition, (-1, -1),
                                       wx.TR_HIDE_ROOT | wx.TR_HAS_BUTTONS)

        root = self.tree.AddRoot('Events')

        err_tree = tree.AppendItem(root, "%d Errors" % events.num_errors)
        warn_tree = tree.AppendItem(root, "%d Warnings" % events.num_warnings)
        com_tree = tree.AppendItem(root, "%d Comments" % events.num_comments)

        for e in self.events.errors:
            tree.AppendItem(err_tree,
                            "line: " + str(e.lineno),
                            data=wx.TreeItemData(e.message))

        for w in self.events.warnings:
            tree.AppendItem(warn_tree,
                            "line: " + str(w.lineno),
                            data=wx.TreeItemData(w.message))

        for c in self.events.comments:
            tree.AppendItem(com_tree,
                            "line: " + str(c.lineno),
                            data=wx.TreeItemData(c.message))

        tree.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged, id=1)

        self.display = wx.StaticText(panel2,
                                     -1,
                                     '', (10, 10),
                                     style=wx.ALIGN_LEFT)

        vbox.Add(self.tree, 1, wx.EXPAND)
        main_sizer.Add(panel1, 1, wx.EXPAND)
        main_sizer.Add(panel2, 1, wx.EXPAND)
        panel1.SetSizerAndFit(vbox)

        self.SetSizerAndFit(main_sizer)
        self.Centre()
Exemple #3
0
    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))

        # 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)

        # Finally, put the notebook in a sizer for the nb_panel to manage the layout
        sizer = wx.BoxSizer()
        sizer.Add(nb, 1, wx.EXPAND)

        nb_panel.SetSizerAndFit(sizer)
Exemple #4
0
    def __init__(self, parent, filenames, num_dirs=2, **kwargs):
        """
        Args:
            parent:
                Parent Widget.
            filenames:
                List of filenames.
            num_dirs:
                Maximum number of directories that will be shown in the tab.
        """
        if "title" not in kwargs:
            kwargs["title"] = "Abinit Events"

        super(AbinitEventsNotebookFrame, self).__init__(parent, **kwargs)

        filenames = list_strings(filenames)

        # Remove inexistent files.
        filenames = filter(os.path.exists, filenames)

        if not filenames:
            return

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

        nb = fnb.FlatNotebook(panel)

        for fname in filenames:
            page = AbinitEventsPanel(nb, fname)
            page_name = fname

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

            # Add only files for which we have events.
            #if page.has_events:

            # Add the pages to the notebook with the name to show on the tab
            nb.AddPage(page, text=page_name)

        # Finally, put the notebook in a sizer for the panel to manage the layout
        sizer = wx.BoxSizer()
        sizer.Add(nb, 1, wx.EXPAND)

        panel.SetSizerAndFit(sizer)
Exemple #5
0
    def BuildUi(self):
        main_sizer = wx.BoxSizer(wx.VERTICAL)

        panel = awx.Panel(self, -1)

        self.dos_panel = ElectronDosPanel(panel)
        main_sizer.Add(self.dos_panel, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL,
                       5)

        dos_button = wx.Button(panel, -1, "Compute DOS")
        self.Bind(wx.EVT_BUTTON, self.OnClick, dos_button)

        self.replot_checkbox = wx.CheckBox(panel, id=-1, label="Replot")
        self.replot_checkbox.SetValue(True)

        hsizer = wx.BoxSizer(wx.HORIZONTAL)

        hsizer.Add(dos_button, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
        hsizer.Add(self.replot_checkbox, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL,
                   5)

        main_sizer.Add(hsizer, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, 5)

        panel.SetSizerAndFit(main_sizer)