python类grid()的实例源码

main.py 文件源码 项目:wxpythoncookbookcode 作者: driscollis 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def __init__(self, parent):
        """Constructor"""
        wx.Panel.__init__(self, parent=parent)

        grid = gridlib.Grid(self)
        grid.CreateGrid(25,12)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(grid, 0, wx.EXPAND)
        self.SetSizer(sizer)
main.py 文件源码 项目:wxpythoncookbookcode 作者: driscollis 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self, panel1, panel2):
        self.panel1 = panel1
        self.panel2 = panel2
        self.panel1.grid.Bind(wx.EVT_SCROLLWIN, self.onScrollWin1)
        self.panel2.grid.Bind(wx.EVT_SCROLLWIN, self.onScrollWin2)
main.py 文件源码 项目:wxpythoncookbookcode 作者: driscollis 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def onScrollWin2(self, event):
        if event.Orientation == wx.SB_HORIZONTAL:
            self.panel1.grid.Scroll(event.Position, -1)
        else:
            self.panel1.grid.Scroll(-1, event.Position)
        event.Skip()
main.py 文件源码 项目:wxpythoncookbookcode 作者: driscollis 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self, parent):
        """Constructor"""
        wx.Panel.__init__(self, parent)
        self.grid = gridlib.Grid(self, style=wx.BORDER_SUNKEN)
        self.grid.CreateGrid(25,8)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.grid, 1, wx.EXPAND)
        self.SetSizer(sizer)
padherder_proxy.py 文件源码 项目:padherder_proxy 作者: jgoldshlag 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def GetNumberCols(self):
        """Return the number of columns in the grid"""
        return 3
padherder_proxy.py 文件源码 项目:padherder_proxy 作者: jgoldshlag 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def GetAttr(self, row, col, someExtraParameter ):
        if col != 2:
            attr = wx.grid.wxGridCellAttr()
            attr.SetReadOnly( 1 )
            return attr
        return None
padherder_proxy.py 文件源码 项目:padherder_proxy 作者: jgoldshlag 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def __init__(self, mails, main_tab):
        wx.grid.PyGridTableBase.__init__(self)
        self.mails = mails
        self.main_tab = main_tab
padherder_proxy.py 文件源码 项目:padherder_proxy 作者: jgoldshlag 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def GetNumberCols(self):
        """Return the number of columns in the grid"""
        return 6
padherder_proxy.py 文件源码 项目:padherder_proxy 作者: jgoldshlag 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def GetAttr(self, row, col, someExtraParameter ):
        attr = wx.grid.GridCellAttr()
        attr.SetReadOnly(True)
        return attr
padherder_proxy.py 文件源码 项目:padherder_proxy 作者: jgoldshlag 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def __init__(self, parent, main_tab):
        wx.Panel.__init__(self, parent)
        self.Bind(custom_events.EVT_MAIL_EVENT, self.onMailEvent)
        self.grid = wx.grid.Grid(self, wx.ID_ANY, size=(-1,-1))
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.grid, 0, wx.EXPAND)
        self.SetSizer(self.sizer)
        self.SetAutoLayout(1)
        self.sizer.Fit(self)
        self.main_tab = main_tab
        self.grid.Bind(wx.EVT_KEY_DOWN, self.onKeyDown)
padherder_proxy.py 文件源码 项目:padherder_proxy 作者: jgoldshlag 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def copy(self):
        if self.grid.GetSelectionBlockTopLeft() == []:
            rows = 1
            cols = 1
            iscell = True
        else:
            rows = self.grid.GetSelectionBlockBottomRight()[0][0] - self.grid.GetSelectionBlockTopLeft()[0][0] + 1
            cols = self.grid.GetSelectionBlockBottomRight()[0][1] - self.grid.GetSelectionBlockTopLeft()[0][1] + 1
            iscell = False
        # data variable contain text that must be set in the clipboard
        data = ''
        # For each cell in selected range append the cell value in the data variable
        # Tabs '\t' for cols and '\r' for rows
        for r in range(rows):
            for c in range(cols):
                if iscell:
                    data += str(self.grid.GetCellValue(self.grid.GetGridCursorRow() + r, self.grid.GetGridCursorCol() + c))
                else:
                    data += str(self.grid.GetCellValue(self.grid.GetSelectionBlockTopLeft()[0][0] + r, self.grid.GetSelectionBlockTopLeft()[0][1] + c))
                if c < cols - 1:
                    data += '\t'
            data += '\n'
        # Create text data object
        clipboard = wx.TextDataObject()
        # Set data object value
        clipboard.SetText(data)
        # Put the data in the clipboard
        if wx.TheClipboard.Open():
            wx.TheClipboard.SetData(clipboard)
            wx.TheClipboard.Close()
        else:
            wx.MessageBox("Can't open the clipboard", "Error")
padherder_proxy.py 文件源码 项目:padherder_proxy 作者: jgoldshlag 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def onMailEvent(self,event):
        mails = event.mails
        self.grid_table = MailGridTable(mails, self.main_tab)
        self.grid.SetTable(self.grid_table)
        self.grid.AutoSize()
        self.grid.SetRowLabelSize(40)
        self.Layout()
        event.Skip()
PartitionEditor.py 文件源码 项目:GRIPy 作者: giruenf 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def DeleteCols(self, pos=0, numCols=1):
        if pos >= self.N_COLS:
            i = pos - self.N_COLS
            for j in range(numCols)[::-1]:
                self._OM.remove(self.propmap.pop(i + j))

            self.GetView().BeginBatch()
            msg = wx.grid.GridTableMessage(self, wx.grid.GRIDTABLE_NOTIFY_COLS_DELETED, pos, numCols)
            self.GetView().ProcessTableMessage(msg)
            self.GetView().EndBatch()

            return True
        else:
            return False
PartitionEditor.py 文件源码 项目:GRIPy 作者: giruenf 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def AppendRows(self, numRows=1):
        part = self._OM.new('part')
        part.defaultdata = np.nan
        self._OM.add(part, self.partitionuid)
        self.partmap.append(part.uid)
        color = self.get_color(0)
        self.set_color(-1,color)

        self.GetView().BeginBatch()
        msg = wx.grid.GridTableMessage(self, wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED, numRows)
        self.GetView().ProcessTableMessage(msg)
        self.GetView().EndBatch()

        return True
PartitionEditor.py 文件源码 项目:GRIPy 作者: giruenf 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def DeleteRows(self, pos=0, numRows=1):
        if pos >= self.N_ROWS:
            i = pos - self.N_ROWS
            for j in range(numRows)[::-1]:
                self._OM.remove(self.partmap.pop(i + j))

            self.GetView().BeginBatch()
            msg = wx.grid.GridTableMessage(self, wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED, pos, numRows)
            self.GetView().ProcessTableMessage(msg)
            self.GetView().EndBatch()

            return True
        else:
            return False
PartitionEditor.py 文件源码 项目:GRIPy 作者: giruenf 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def on_add(self, event):
        dlg = PropertyEntryDialog(self)
        if dlg.ShowModal() == wx.ID_OK:
            name, unit = dlg.get_value()
            label = name + NAME_UNIT_SEPARATOR + unit
            n = self.grid.GetNumberCols()

            self.grid.AppendCols()
            self.grid.SetColLabelValue(n, label)

            self.grid.ForceRefresh()
PartitionEditor.py 文件源码 项目:GRIPy 作者: giruenf 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def on_add_part(self, event):
#        to_remove = self.grid.GetSelectedRows()
#        to_add = self.grid.GetSelectedRows()
#        self.grid.ClearSelection()
        self.grid.AppendRows()
#        self.grid.SetFocus()
#        self.grid.SelectedRows()
        self.grid.ForceRefresh()
PartitionEditor.py 文件源码 项目:GRIPy 作者: giruenf 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def on_remove_part(self, event):
#        to_remove = self.grid.GetSelectedCols()
        to_remove = self.grid.GetSelectedRows()
        self.grid.ClearSelection()
        for i in to_remove[::-1]:
            self.grid.DeleteRows(i)

        self.grid.ForceRefresh()
PartitionEditor.py 文件源码 项目:GRIPy 作者: giruenf 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def on_remove(self, event):
        to_remove = self.grid.GetSelectedCols()
        self.grid.ClearSelection()
        for i in to_remove[::-1]:
            self.grid.DeleteCols(i)

        self.grid.ForceRefresh()
RockTableEditor.py 文件源码 项目:GRIPy 作者: giruenf 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def DeleteRows(self, pos=0, numRows=1):
        if pos >= self.N_ROWS:
            i = pos - self.N_ROWS
            for j in range(numRows)[::-1]:
                self._OM.remove(self.rocktypemap.pop(i + j))

            self.GetView().BeginBatch()
            msg = wx.grid.GridTableMessage(self, wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED, pos, numRows)
            self.GetView().ProcessTableMessage(msg)
            self.GetView().EndBatch()

            return True
        else:
            return False


问题


面经


文章

微信
公众号

扫码关注公众号