コード例 #1
0
ファイル: browser.py プロジェクト: gmatteo/abipy
    def BuildUi(self):
        self.file_list = file_list = MyListCtrl(self)

        file_list.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.OnRightClick)
        file_list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated)

        self.columns = columns = ["filename", "type", "reldirpath"]

        # Used to store the Max width in pixels for the data in the column.
        column_widths = [awx.get_width_height(self, s)[0] for s in columns]

        self.id2filedata = {}
        for (index, colname) in enumerate(columns):
            file_list.InsertColumn(index, colname)

        for filepath in self.filepaths:
            entry = self.AppendFilepath(filepath)

            w = [awx.get_width_height(self, s)[0] for s in entry]
            column_widths = map(max, zip(w, column_widths))

        for (index, colname) in enumerate(columns):
            #file_list.SetColumnWidth(index, wx.LIST_AUTOSIZE)
            file_list.SetColumnWidth(index, column_widths[index])

        # Now that the list exists we can init the other base class, see wx/lib/mixins/listctrl.py
        self.itemDataMap = self.id2filedata
        listmix.ColumnSorterMixin.__init__(self, len(columns))
        self.Bind(wx.EVT_LIST_COL_CLICK, self.OnColClick, self.file_list)

        # Pack
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(file_list, 1, wx.ALL | wx.EXPAND, 5)

        self.SetSizerAndFit(sizer)
コード例 #2
0
    def BuildUi(self):
        self.file_list = file_list = MyListCtrl(self)

        file_list.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.OnRightClick)
        file_list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated)

        self.columns = columns = ["filename", "type", "reldirpath"]

        # Used to store the Max width in pixels for the data in the column.
        column_widths = [awx.get_width_height(self, s)[0] for s in columns]

        self.id2filedata = {}
        for (index, colname) in enumerate(columns):
            file_list.InsertColumn(index, colname)

        for filepath in self.filepaths:
            entry = self.AppendFilepath(filepath)

            w = [awx.get_width_height(self, s)[0] for s in entry]
            column_widths = map(max, zip(w, column_widths))

        for (index, colname) in enumerate(columns):
            #file_list.SetColumnWidth(index, wx.LIST_AUTOSIZE)
            file_list.SetColumnWidth(index, column_widths[index])

        # Now that the list exists we can init the other base class, see wx/lib/mixins/listctrl.py
        self.itemDataMap = self.id2filedata
        listmix.ColumnSorterMixin.__init__(self, len(columns))
        self.Bind(wx.EVT_LIST_COL_CLICK, self.OnColClick, self.file_list)

        # Pack
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(file_list, 1, wx.ALL | wx.EXPAND, 5)

        self.SetSizerAndFit(sizer)
コード例 #3
0
ファイル: pseudos.py プロジェクト: zbwang/abipy
    def BuildUi(self):
        self.pseudo_list = pseudo_list = MyListCtrl(self)

        pseudo_list.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.OnRightClick)
        pseudo_list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated)

        self.id2pseudo = {}
        columns = self.columns = ["basename", "symbol", "Z_val", "l_max", "rcore", "type"]

        # Used to store the Max width in pixels for the data in the column.
        column_widths = [awx.get_width_height(self, s)[0] for s in columns]

        for (index, colname) in enumerate(columns):
            pseudo_list.InsertColumn(index, colname)

        for pseudo in self.pseudos:
            entry = self.AppendPseudo(pseudo)
            w = [awx.get_width_height(self, s)[0] for s in entry]
            column_widths = map(max, zip(w, column_widths))

        for (index, colname) in enumerate(columns):
            pseudo_list.SetColumnWidth(index, column_widths[index])

        # Now that the list exists we can init the other base class, see wx/lib/mixins/listctrl.py
        self.itemDataMap = {pid: [getattr(pseudo, attr) for attr in self.columns] for pid, pseudo in self.id2pseudo.items()}
        listmix.ColumnSorterMixin.__init__(self, len(columns))
        self.Bind(wx.EVT_LIST_COL_CLICK, self.OnColClick, self.pseudo_list)

        # Pack
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(pseudo_list, 1, wx.ALL | wx.EXPAND, 5)

        self.SetSizerAndFit(sizer)
コード例 #4
0
ファイル: pseudos.py プロジェクト: GkAntonius/abipy
    def BuildUi(self):
        self.pseudo_list = pseudo_list = MyListCtrl(self)

        pseudo_list.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.OnRightClick)
        pseudo_list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated)

        self.id2pseudo = {}
        columns = self.columns = ["name", "symbol", "Z_val", "l_max", "rcore", "type"]

        # Used to store the Max width in pixels for the data in the column.
        column_widths = [awx.get_width_height(self, s)[0] for s in columns]

        for (index, colname) in enumerate(columns):
            pseudo_list.InsertColumn(index, colname)

        for pseudo in self.pseudos:
            entry = self.AppendPseudo(pseudo)
            w = [awx.get_width_height(self, s)[0] for s in entry]
            column_widths = map(max, zip(w, column_widths))

        for (index, colname) in enumerate(columns):
            pseudo_list.SetColumnWidth(index, column_widths[index])

        # Now that the list exists we can init the other base class, see wx/lib/mixins/listctrl.py
        self.itemDataMap = {pid: [getattr(pseudo, attr) for attr in self.columns] for pid, pseudo in self.id2pseudo.items()}
        listmix.ColumnSorterMixin.__init__(self, len(columns))
        self.Bind(wx.EVT_LIST_COL_CLICK, self.OnColClick, self.pseudo_list)

        # Pack
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(pseudo_list, 1, wx.ALL | wx.EXPAND, 5)

        self.SetSizerAndFit(sizer)
コード例 #5
0
    def __init__(self, parent, dataset, **kwargs):
        """
        Args:
            parent:
                Parent window.
            dataset:
                Netcdf4 `Dataset`.
        """
        super(VarsPanel, self).__init__(parent, -1, **kwargs)

        self.dataset = dataset

        text = wx.StaticText(
            self, -1, "Number of variables: %d" % len(dataset.variables))

        columns = ["name", "dtype", "shape", "value", "dimensions"]
        self.list = wx.ListCtrl(self,
                                -1,
                                style=wx.LC_REPORT | wx.SUNKEN_BORDER)

        for col, name in enumerate(columns):
            self.list.InsertColumn(col, name)

        # Used to store the Max width in pixels for the data in the column.
        column_widths = [awx.get_width_height(self, s)[0] for s in columns]

        self.id2entry = {}
        for idx, (name, var) in enumerate(dataset.variables.items()):
            # Show the value of scalars.
            if not var.shape:
                value = str(var[:]).replace("[", "").replace("]", "").strip()
            else:
                value = "[...]"

            entry = map(str,
                        [name, var.dtype, var.shape, value, var.dimensions])
            self.list.Append(entry)
            self.list.SetItemData(idx, idx)
            self.id2entry[idx] = entry

            w = [awx.get_width_height(self, s)[0] for s in entry]
            column_widths = map(max, zip(w, column_widths))

        for index, col in enumerate(columns):
            self.list.SetColumnWidth(index, column_widths[index])

        # Now that the list exists we can init the other base class, see wx/lib/mixins/listctrl.py
        self.itemDataMap = self.id2entry
        listmix.ColumnSorterMixin.__init__(self, len(columns))
        self.Bind(wx.EVT_LIST_COL_CLICK, self.OnColClick, self.list)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(text, 0, wx.EXPAND, 5)
        sizer.Add(self.list, 1, wx.EXPAND, 5)
        self.SetSizerAndFit(sizer)

        # Connect the events whose callback will be set by the client code.
        self.list.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.OnRightClick)
        self.list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated)
コード例 #6
0
ファイル: wxncview.py プロジェクト: GkAntonius/abipy
    def __init__(self, parent, dataset, **kwargs):
        """
        Args:
            parent:
                Parent window.
            dataset:
                Netcdf4 `Dataset`.
        """
        super(VarsPanel, self).__init__(parent, -1, **kwargs)

        self.dataset = dataset

        text = wx.StaticText(self, -1, "Number of variables: %d" % len(dataset.variables))

        columns = ["name", "dtype", "shape", "value", "dimensions"]
        self.list = wx.ListCtrl(self, -1, style=wx.LC_REPORT | wx.SUNKEN_BORDER)

        for col, name in enumerate(columns):
            self.list.InsertColumn(col, name)

        # Used to store the Max width in pixels for the data in the column.
        column_widths = [awx.get_width_height(self, s)[0] for s in columns]

        self.id2entry = {}
        for idx, (name, var) in enumerate(dataset.variables.items()):
            # Show the value of scalars.
            if not var.shape:
                value = str(var[:]).replace("[", "").replace("]", "").strip()
            else:
                value = "[...]"

            entry = map(str, [name, var.dtype, var.shape, value, var.dimensions])
            self.list.Append(entry)
            self.list.SetItemData(idx, idx)
            self.id2entry[idx] = entry
                                                                                      
            w = [awx.get_width_height(self, s)[0] for s in entry]
            column_widths = map(max, zip(w, column_widths))
                                                                                      
        for index, col in enumerate(columns):
            self.list.SetColumnWidth(index, column_widths[index])

        # Now that the list exists we can init the other base class, see wx/lib/mixins/listctrl.py
        self.itemDataMap = self.id2entry
        listmix.ColumnSorterMixin.__init__(self, len(columns))
        self.Bind(wx.EVT_LIST_COL_CLICK, self.OnColClick, self.list)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(text, 0, wx.EXPAND, 5)
        sizer.Add(self.list, 1, wx.EXPAND, 5)
        self.SetSizerAndFit(sizer)

        # Connect the events whose callback will be set by the client code.
        self.list.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.OnRightClick)
        self.list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated)               
コード例 #7
0
ファイル: flowviewer.py プロジェクト: davidwaroquiers/abipy
    def __init__(self, parent, work, **kwargs):
        """
        Args:
            parent:
                Parent window.
            work:
                `Workflow` containig the List of `Task` instances.
        """
        super(TaskListCtrl, self).__init__(parent, id=-1, style=wx.LC_REPORT | wx.BORDER_SUNKEN, **kwargs)

        self.work = work

        columns = ["Task", "Status", "Queue_id", 
                   "Errors", "Warnings", "Comments", 
                   "MPI", "OMP", 
                   "num_restarts", "Task Class",
                   ]

        for index, col in enumerate(columns):
            self.InsertColumn(index, col)

        # Used to store the Max width in pixels for the data in the column.
        column_widths = [awx.get_width_height(self, s)[0] for s in columns]

        for task in work:
            events = map(str, 3*["N/A"])

            try:
                report = task.get_event_report()
                if report is not None: 
                    events = map(str, [report.num_errors, report.num_warnings, report.num_comments])
            except:
                pass

            cpu_info = [task.mpi_procs, task.omp_threads]
            entry = map(str, [task.name, str(task.status), task.queue_id] + 
                              events + 
                              cpu_info + 
                              [task.num_restarts, task.__class__.__name__]
                        )
            w = [awx.get_width_height(self, s)[0] for s in entry]
            column_widths = map(max, zip(w, column_widths))

            self.Append(entry)

        # Set the width in pixel for each column.
        for index, col in enumerate(columns):
            self.SetColumnWidth(index, column_widths[index])

        self.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.OnRightClick)
        self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated)
コード例 #8
0
ファイル: flowviewer.py プロジェクト: gmrigna/abipy
    def __init__(self, parent, work, **kwargs):
        """
        Args:
            parent:
                Parent window.
            work:
                `Workflow` containig the List of `Task` instances.
        """
        super(TaskListCtrl, self).__init__(parent, id=-1, style=wx.LC_REPORT | wx.BORDER_SUNKEN, **kwargs)

        self.work = work

        columns = ["Task", "Status", "Queue_id", 
                   "Errors", "Warnings", "Comments", 
                   "MPI", "OMP", 
                   "num_restarts", "Task Class",
                   ]

        for index, col in enumerate(columns):
            self.InsertColumn(index, col)

        # Used to store the Max width in pixels for the data in the column.
        column_widths = [awx.get_width_height(self, s)[0] for s in columns]

        for task in work:
            events = map(str, 3*["N/A"])

            try:
                report = task.get_event_report()
                if report is not None: 
                    events = map(str, [report.num_errors, report.num_warnings, report.num_comments])
            except:
                pass

            cpu_info = [task.mpi_procs, task.omp_threads]
            entry = map(str, [task.name, str(task.status), task.queue_id] + 
                              events + 
                              cpu_info + 
                              [task.num_restarts, task.__class__.__name__]
                        )
            w = [awx.get_width_height(self, s)[0] for s in entry]
            column_widths = map(max, zip(w, column_widths))

            self.Append(entry)

        # Set the width in pixel for each column.
        for index, col in enumerate(columns):
            self.SetColumnWidth(index, column_widths[index])

        self.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.OnRightClick)
        self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated)
コード例 #9
0
ファイル: kpoints.py プロジェクト: zbwang/abipy
    def __init__(self, parent, kpoints, **kwargs):
        """
        Args:
            parent:
                Parent window.
            kpoints:
                List of `Kpoint` instances.
        """
        super(KpointsListCtrl,
              self).__init__(parent,
                             id=-1,
                             style=wx.LC_REPORT | wx.BORDER_SUNKEN,
                             **kwargs)

        self.kpoints = kpoints

        columns = ["#", 'Reduced coordinates', 'Weight', 'Name']

        for (index, col) in enumerate(columns):
            self.InsertColumn(index, col)

        # Used to store the Max width in pixels for the data in the column.
        column_widths = [awx.get_width_height(self, s)[0] for s in columns]

        # Used by the ColumnSorterMixin, see wx/lib/mixins/listctrl.py
        self.itemDataMap = {}

        for (index, kpt) in enumerate(self.kpoints):
            entry = [
                "%d\t\t" % index,
                "[%.5f,  %.5f,  %.5f]\t\t" % tuple(c for c in kpt.frac_coords),
                "%.3f\t\t" % kpt.weight,
                "%s" % kpt.name,
            ]
            self.Append(entry)
            self.itemDataMap[index] = entry
            self.SetItemData(index, index)

            w = [awx.get_width_height(self, s)[0] for s in entry]
            column_widths = map(max, zip(w, column_widths))

        for (index, col) in enumerate(columns):
            self.SetColumnWidth(index, column_widths[index])

        # Now that the list exists we can init the other base class, see wx/lib/mixins/listctrl.py
        listmix.ColumnSorterMixin.__init__(self, len(columns))
コード例 #10
0
ファイル: kpoints.py プロジェクト: GkAntonius/abipy
    def __init__(self, parent, kpoints, **kwargs):
        """
        Args:
            parent:
                Parent window.
            kpoints:
                List of `Kpoint` instances.
        """
        super(KpointsListCtrl, self).__init__(parent, id=-1, style=wx.LC_REPORT | wx.BORDER_SUNKEN, **kwargs)

        self.kpoints = kpoints

        columns = ["#", 'Reduced coordinates', 'Weight', 'Name']

        for (index, col) in enumerate(columns):
            self.InsertColumn(index, col)

        # Used to store the Max width in pixels for the data in the column.
        column_widths = [awx.get_width_height(self, s)[0] for s in columns]

        # Used by the ColumnSorterMixin, see wx/lib/mixins/listctrl.py
        self.itemDataMap = {}

        for (index, kpt) in enumerate(self.kpoints):
            entry = ["%d\t\t" % index, 
                     "[%.5f,  %.5f,  %.5f]\t\t" % tuple(c for c in kpt.frac_coords), 
                     "%.3f\t\t" % kpt.weight, 
                     "%s" % kpt.name,
                     ]
            self.Append(entry)
            self.itemDataMap[index] = entry
            self.SetItemData(index, index)

            w = [awx.get_width_height(self, s)[0] for s in entry]
            column_widths = map(max, zip(w, column_widths))

        for (index, col) in enumerate(columns):
            self.SetColumnWidth(index, column_widths[index])

        # Now that the list exists we can init the other base class, see wx/lib/mixins/listctrl.py
        listmix.ColumnSorterMixin.__init__(self, len(columns))
コード例 #11
0
ファイル: flowsdb.py プロジェクト: GkAntonius/abipy
    def __init__(self, parent, flows, cluster, flows_db, **kwargs):
        """
        Args:
            parent:
                Parent window.
            flows:
                List of flows info.
            cluster:
                The cluster where the flows are executed.
            flows_db:
                The database of flows.
        """
        super(FlowsListCtrl, self).__init__(parent, id=-1, style=wx.LC_REPORT | wx.BORDER_SUNKEN, **kwargs)

        self.flows, self.cluster, self.flows_db = flows, cluster, flows_db

        columns = ["Workdir", "Status", "Start Date"]

        for (index, col) in enumerate(columns):
            self.InsertColumn(index, col)

        # Used to store the Max width in pixels for the data in the column.
        column_widths = [awx.get_width_height(self, s)[0] for s in columns]

        for flow in flows:
            entry = map(str, [flow.workdir, flow.status, flow.start_date])
            self.Append(entry)

            w = [awx.get_width_height(self, s)[0] for s in entry]
            column_widths = map(max, zip(w, column_widths))

        # Set the width in pixel for each column.
        for (index, col) in enumerate(columns):
            self.SetColumnWidth(index, column_widths[index])

        self.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.OnRightClick)
        self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated)