lib.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:smartschool 作者: asifkodur 项目源码 文件源码
def Copy(self):
        #print "Copy method"
        # Number of rows and cols
        rows = self.grid_1.GetSelectionBlockBottomRight()[0][0] - self.grid_1.GetSelectionBlockTopLeft()[0][0] + 1
        cols = self.grid_1.GetSelectionBlockBottomRight()[0][1] - self.grid_1.GetSelectionBlockTopLeft()[0][1] + 1

        # 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):
                data = data + str(self.grid_1.GetCellValue(self.grid_1.GetSelectionBlockTopLeft()[0][0] + r, self.grid_1.GetSelectionBlockTopLeft()[0][1] + c))
                if c < cols - 1:
                    data = data + '\t'
            data = data + '\n'
            #print data
        # 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")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号