示例#1
0
 def __init__(self, parent, num_rows, num_cols, popup_creator=None):
     grid.Grid.__init__(self, parent)
     self._bind_to_events()
     self.selection = _GridSelection(self)
     self.SetDefaultRenderer(grid.GridCellAutoWrapStringRenderer())
     self._clipboard_handler = ClipboardHandler(self)
     self._history = _GridState()
     self.CreateGrid(num_rows, num_cols)
     self._popup_creator = popup_creator or PopupCreator()
示例#2
0
    def __init__(self, parent):
        gridlib.Grid.__init__(self, parent)
        self.moveTo = None

        self.CreateGrid(5, 7)

        self.SetColLabelValue(0, "1")
        self.SetColLabelValue(1, "2")
        self.SetColLabelValue(2, "3")
        self.SetColLabelValue(3, "ACTION")
        self.SetColLabelValue(4, "4")
        self.SetColLabelValue(5, "5")
        self.SetColLabelValue(6, "6")

        self.SetColLabelAlignment(wx.ALIGN_CENTER, wx.ALIGN_BOTTOM)

        self.SetDefaultCellOverflow(False)
        r = gridlib.GridCellAutoWrapStringRenderer()
        self.SetCellRenderer(9, 1, r)
示例#3
0
    def __init__(self, parent, log):
        gridlib.Grid.__init__(self, parent, -1)
        ##mixins.GridAutoEditMixin.__init__(self)
        #打印log信息
        self.log = log
        self.moveTo = None

        self.Bind(wx.EVT_IDLE, self.OnIdle)
        #创建一个25X25的电子表格
        self.CreateGrid(25, 25)  #, gridlib.Grid.SelectRows)
        ##self.EnableEditing(False)

        #simple cell formatting
        #设置第index=3列的宽度大小,像素=200
        self.SetColSize(col=3, width=200)
        #设置第index=4行的高度大小,像素=45
        self.SetRowSize(4, 45)
        #设置 row=0,col=0,value="First cell"
        self.SetCellValue(0, 0, "First cell")
        #设置 row=1,col=1,value="Another cell"
        self.SetCellValue(1, 1, "Another cell")
        #设置 row=2,col=2,value="Yet another cell"
        self.SetCellValue(2, 2, "Yet another cell")
        #设置 row=3,col=3,value="This cell is read-only"
        self.SetCellValue(3, 3, "This cell is read-only")
        #设置字体格式
        self.SetCellFont(
            0, 0,
            wx.Font(12, wx.FONTFAMILY_ROMAN, wx.FONTSTYLE_ITALIC,
                    wx.FONTWEIGHT_NORMAL))
        #设置字体颜色
        self.SetCellTextColour(1, 1, wx.RED)
        #设置cell背景颜色
        self.SetCellBackgroundColour(2, 2, wx.CYAN)
        #设置只读属性
        self.SetReadOnly(3, 3, True)
        #设置 row=5,col=0,数字编辑器
        self.SetCellEditor(5, 0, gridlib.GridCellNumberEditor(1, 1000))
        #设置 row=5,col=0,value="123"
        self.SetCellValue(5, 0, "123")
        #设置 row=6,col=0,浮点数
        self.SetCellEditor(6, 0, gridlib.GridCellFloatEditor())
        #设置 row=6,col=0,value="123.34"
        self.SetCellValue(6, 0, "123.34")
        #设置
        self.SetCellEditor(7, 0, gridlib.GridCellNumberEditor())
        #设置 row=6,col=3,value="You can veto editing this cell"
        self.SetCellValue(6, 3, "You can veto editing this cell")

        #self.SetRowLabelSize(0)
        #self.SetColLabelSize(0)

        # attribute objects let you keep a set of formatting values
        # in one spot, and reuse them if needed
        #wx.grid.GridCellAttr

        #这个类可以用来通过改变它们的默认属性来改变网格在网格中的外观。
        attr = gridlib.GridCellAttr()
        #字体颜色:黑色
        attr.SetTextColour(wx.BLACK)
        #设置背景颜色:红色
        attr.SetBackgroundColour(wx.RED)
        #设置字体格式
        attr.SetFont(
            wx.Font(10, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL,
                    wx.FONTWEIGHT_BOLD))

        # you can set cell attributes for the whole row (or column)
        #设置Row=5,attr
        self.SetRowAttr(5, attr)

        #设置Col=0,LableValue =Custom
        self.SetColLabelValue(0, "Custom")
        self.SetRowLabelValue(0, "日期")

        #设置Col=1,LabelValue = "column"
        self.SetColLabelValue(1, "column")
        #设置Col=2,LabelValue = labels
        self.SetColLabelValue(2, "labels")
        #设置列表标签左右以及上下对齐方式:左对齐,下沉
        self.SetColLabelAlignment(wx.ALIGN_LEFT, wx.ALIGN_BOTTOM)

        #self.SetDefaultCellOverflow(False)
        #r = gridlib.GridCellAutoWrapStringRenderer()
        #self.SetCellRenderer(9, 1, r)

        #overflow cells
        self.SetCellValue(
            9, 1,
            "This default cell will overflow into neighboring cells, but not if you turn overflow off."
        )
        #单元格合并处理:3x3
        self.SetCellSize(11, 1, 3, 3)
        #设置单元格对齐方式:中间,中间
        self.SetCellAlignment(11, 1, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
        #设置单元格值
        self.SetCellValue(11, 1,
                          "This cell is set to span 3 rows and 3 columns")

        #设置
        editor = gridlib.GridCellTextEditor()
        #值长度
        editor.SetParameters('10')
        #设置格式
        self.SetCellEditor(0, 4, editor)
        #设置值
        self.SetCellValue(0, 4, "Limited text")

        #可以用来格式化单元格中的字符串数据。
        renderer = gridlib.GridCellAutoWrapStringRenderer()
        self.SetCellRenderer(15, 0, renderer)
        self.SetCellValue(
            15, 0, "The text in this cell will be rendered with word-wrapping")

        # test all the events
        #左单击
        self.Bind(gridlib.EVT_GRID_CELL_LEFT_CLICK, self.OnCellLeftClick)
        #右单击
        self.Bind(gridlib.EVT_GRID_CELL_RIGHT_CLICK, self.OnCellRightClick)
        #左双击
        self.Bind(gridlib.EVT_GRID_CELL_LEFT_DCLICK, self.OnCellLeftDClick)
        #右双击
        self.Bind(gridlib.EVT_GRID_CELL_RIGHT_DCLICK, self.OnCellRightDClick)

        #label 左单击
        self.Bind(gridlib.EVT_GRID_LABEL_LEFT_CLICK, self.OnLabelLeftClick)
        #label 右单击
        self.Bind(gridlib.EVT_GRID_LABEL_RIGHT_CLICK, self.OnLabelRightClick)
        #label 左双击
        self.Bind(gridlib.EVT_GRID_LABEL_LEFT_DCLICK, self.OnLabelLeftDClick)
        #label 右双击
        self.Bind(gridlib.EVT_GRID_LABEL_RIGHT_DCLICK, self.OnLabelRightDClick)

        self.Bind(gridlib.EVT_GRID_COL_SORT, self.OnGridColSort)

        #拖动Row大小
        self.Bind(gridlib.EVT_GRID_ROW_SIZE, self.OnRowSize)
        #拖动Col大小
        self.Bind(gridlib.EVT_GRID_COL_SIZE, self.OnColSize)

        self.Bind(gridlib.EVT_GRID_RANGE_SELECT, self.OnRangeSelect)
        self.Bind(gridlib.EVT_GRID_CELL_CHANGED, self.OnCellChange)
        self.Bind(gridlib.EVT_GRID_SELECT_CELL, self.OnSelectCell)

        self.Bind(gridlib.EVT_GRID_EDITOR_SHOWN, self.OnEditorShown)
        self.Bind(gridlib.EVT_GRID_EDITOR_HIDDEN, self.OnEditorHidden)
        self.Bind(gridlib.EVT_GRID_EDITOR_CREATED, self.OnEditorCreated)
示例#4
0
    def __init__(self, parent, log):
        gridlib.Grid.__init__(self, parent, -1)
        ##mixins.GridAutoEditMixin.__init__(self)
        self.log = log
        self.moveTo = None

        self.Bind(wx.EVT_IDLE, self.OnIdle)

        self.CreateGrid(25, 25)#, gridlib.Grid.SelectRows)
        ##self.EnableEditing(False)

        # simple cell formatting
        self.SetColSize(3, 200)
        self.SetRowSize(4, 45)
        self.SetCellValue(0, 0, "First cell")
        self.SetCellValue(1, 1, "Another cell")
        self.SetCellValue(2, 2, "Yet another cell")
        self.SetCellValue(3, 3, "This cell is read-only")
        self.SetCellFont(0, 0, wx.Font(12, wx.ROMAN, wx.ITALIC, wx.NORMAL))
        self.SetCellTextColour(1, 1, wx.RED)
        self.SetCellBackgroundColour(2, 2, wx.CYAN)
        self.SetReadOnly(3, 3, True)

        self.SetCellEditor(5, 0, gridlib.GridCellNumberEditor(1,1000))
        self.SetCellValue(5, 0, "123")
        self.SetCellEditor(6, 0, gridlib.GridCellFloatEditor())
        self.SetCellValue(6, 0, "123.34")
        self.SetCellEditor(7, 0, gridlib.GridCellNumberEditor())

        self.SetCellValue(6, 3, "You can veto editing this cell")

        #self.SetRowLabelSize(0)
        #self.SetColLabelSize(0)

        # attribute objects let you keep a set of formatting values
        # in one spot, and reuse them if needed
        attr = gridlib.GridCellAttr()
        attr.SetTextColour(wx.BLACK)
        attr.SetBackgroundColour(wx.RED)
        attr.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD))

        # you can set cell attributes for the whole row (or column)
        self.SetRowAttr(5, attr)

        self.SetColLabelValue(0, "Custom")
        self.SetColLabelValue(1, "column")
        self.SetColLabelValue(2, "labels")

        self.SetColLabelAlignment(wx.ALIGN_LEFT, wx.ALIGN_BOTTOM)

        #self.SetDefaultCellOverflow(False)
        #r = gridlib.GridCellAutoWrapStringRenderer()
        #self.SetCellRenderer(9, 1, r)

        # overflow cells
        self.SetCellValue( 9, 1, "This default cell will overflow into neighboring cells, but not if you turn overflow off.");
        self.SetCellSize(11, 1, 3, 3);
        self.SetCellAlignment(11, 1, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE);
        self.SetCellValue(11, 1, "This cell is set to span 3 rows and 3 columns");


        editor = gridlib.GridCellTextEditor()
        editor.SetParameters('10')
        self.SetCellEditor(0, 4, editor)
        self.SetCellValue(0, 4, "Limited text")

        renderer = gridlib.GridCellAutoWrapStringRenderer()
        self.SetCellRenderer(15,0, renderer)
        self.SetCellValue(15,0, "The text in this cell will be rendered with word-wrapping")

        
        # test all the events
        self.Bind(gridlib.EVT_GRID_CELL_LEFT_CLICK, self.OnCellLeftClick)
        self.Bind(gridlib.EVT_GRID_CELL_RIGHT_CLICK, self.OnCellRightClick)
        self.Bind(gridlib.EVT_GRID_CELL_LEFT_DCLICK, self.OnCellLeftDClick)
        self.Bind(gridlib.EVT_GRID_CELL_RIGHT_DCLICK, self.OnCellRightDClick)

        self.Bind(gridlib.EVT_GRID_LABEL_LEFT_CLICK, self.OnLabelLeftClick)
        self.Bind(gridlib.EVT_GRID_LABEL_RIGHT_CLICK, self.OnLabelRightClick)
        self.Bind(gridlib.EVT_GRID_LABEL_LEFT_DCLICK, self.OnLabelLeftDClick)
        self.Bind(gridlib.EVT_GRID_LABEL_RIGHT_DCLICK, self.OnLabelRightDClick)

        self.Bind(gridlib.EVT_GRID_ROW_SIZE, self.OnRowSize)
        self.Bind(gridlib.EVT_GRID_COL_SIZE, self.OnColSize)

        self.Bind(gridlib.EVT_GRID_RANGE_SELECT, self.OnRangeSelect)
        self.Bind(gridlib.EVT_GRID_CELL_CHANGE, self.OnCellChange)
        self.Bind(gridlib.EVT_GRID_SELECT_CELL, self.OnSelectCell)

        self.Bind(gridlib.EVT_GRID_EDITOR_SHOWN, self.OnEditorShown)
        self.Bind(gridlib.EVT_GRID_EDITOR_HIDDEN, self.OnEditorHidden)
        self.Bind(gridlib.EVT_GRID_EDITOR_CREATED, self.OnEditorCreated)
示例#5
0
    def OnIdle(self, event):
        """ Update the contents of this DataWindow tab during IDLE time, as it could be slow, especially during
            the editing of a document """

        # NOTE:  When there are a large number of Quotes, this routine can, not surprisingly, be pretty
        #        slow.  In order to avoid this being disruptive to program activity, I've taken a couple
        #        of steps.  First, this is getting called in the OnIdle event, so will only happen when
        #        there's time.  Second, I've added "wx.YieldIfNeeded()" calls at several places so that
        #        Transana won't lock up while this is being processed.  Third, this processing will only
        #        occur while the page is showing.  Fourth, there are a number of places where this routine
        #        will bail out if another call to redraw it is made before the last redraw is complete.

        try:
            # If the DocumentQuotes tab needs to be re-drawn AND it is currently showing ...
            if self.redraw and self.IsShown():
                # Signal that the Redraw has begun.  Do it here so we can detect if ANOTHER redraw is
                # requested even before this one is complete.
                self.redraw = False
                self.redrawComplete = False

                # Get quote data from the CONTROL OBJECT.  This way, we will get the LIVE data if this
                # document is currently loaded, and will get the data from the database otherwise
                quoteData = self.ControlObject.GetQuoteDataForDocument(
                    self.documentObj.number, self.textPos, self.textSel)
                ##        if TransanaConstants.proVersion:
                ##            # Get the snapshot data from the database
                ##            snapshotData = DBInterface.list_of_snapshots_by_episode(self.documentObj.number, TimeCode)
                ##

                # Combine the two lists
                cellData = {}
                # For each Quote ...
                for quote in quoteData:
                    # load the Quote
                    tmpObj = Quote.Quote(quote['QuoteNum'])
                    # Update the Quote's Start and End times based on editing changes
                    tmpObj.start_char = quote['StartChar']
                    tmpObj.end_char = quote['EndChar']
                    # add the Quote to the cellData
                    cellData[(quote['StartChar'], quote['EndChar'],
                              tmpObj.GetNodeString(True).upper())] = tmpObj

                    # See if other Transana actions that take priority should be allowed
                    wx.YieldIfNeeded()
                    if self.redraw:
                        break

        ##        if TransanaConstants.proVersion:
        ##            # for each Snapshot ...
        ##            for snapshot in snapshotData:
        ##                # load the Snapshot
        ##                tmpObj = Snapshot.Snapshot(snapshot['SnapshotNum'])
        ##                # add the Snapshot to the cellData
        ##                cellData[(snapshot['SnapshotStart'], snapshot['SnapshotStop'], tmpObj.GetNodeString(True).upper())] = tmpObj

        # See if other Transana actions that take priority should be allowed
                wx.YieldIfNeeded()

                if self.redraw:
                    return

                # Get the Keys for the cellData
                sortedKeys = cellData.keys()
                # Sort the keys for the cellData into the right order
                sortedKeys.sort()

                # Add rows to the Grid to accomodate the amount of data returned, or delete rows if we have too many
                if len(cellData) > self.gridQuotes.GetNumberRows():
                    self.gridQuotes.AppendRows(
                        len(cellData) - self.gridQuotes.GetNumberRows(), False)
                elif len(cellData) < self.gridQuotes.GetNumberRows():
                    self.gridQuotes.DeleteRows(
                        numRows=self.gridQuotes.GetNumberRows() -
                        len(cellData))

                # Initialize the Row Counter
                loop = 0
                # Add the data to the Grid
                for keyVals in sortedKeys:
                    # If we have a Quote ...
                    if isinstance(cellData[keyVals], Quote.Quote):
                        # ... get the start, end characters and the object type
                        startChar = cellData[keyVals].start_char
                        endChar = cellData[keyVals].end_char
                        objType = 'Quote'
                        # Initialize the string for all the Keywords to blank
                        kwString = unicode('', 'utf8')
                        # Initialize the prompt for building the keyword string
                        kwPrompt = '%s'
        ##            # If we have a Snapshot ...
        ##            elif isinstance(cellData[keyVals], Snapshot.Snapshot):
        ##                # ... get the start, stop times and the object type
        ##                startTime = cellData[keyVals].episode_start
        ##                stopTime = cellData[keyVals].episode_start + cellData[keyVals].episode_duration
        ##                objType = 'Snapshot'
        ##                # if there are whole snapshot keywords ...
        ##                if len(cellData[keyVals].keyword_list) > 0:
        ##                    # ... initialize the string for all the Keywords to indicate this
        ##                    kwString = unicode(_('Whole:'), 'utf8') + '\n'
        ##                # If there are NOT whole snapshot keywords ...
        ##                else:
        ##                    # ... initialize the string for all the Keywords to blank
        ##                    kwString = unicode('', 'utf8')
        ##                # Initialize the prompt for building the keyword string
        ##                kwPrompt = '  %s'

        # See if other Transana actions that take priority should be allowed
                    wx.YieldIfNeeded()

                    if self.redraw:
                        break

                    # For each Keyword in the Keyword List ...
                    for kws in cellData[keyVals].keyword_list:
                        # ... add the Keyword to the Keyword List
                        kwString += kwPrompt % kws.keywordPair
                        # If we have a Quote ...
                        if isinstance(cellData[keyVals], Quote.Quote):
                            # After the first keyword, we need a NewLine in front of the Keywords.  This accompishes that!
                            kwPrompt = '\n%s'
        ##                # If we have a Snapshot ...
        ##                elif isinstance(cellData[keyVals], Snapshot.Snapshot):
        ##                    # After the first keyword, we need a NewLine in front of the Keywords.  This accompishes that!
        ##                    kwPrompt = '\n  %s'

        ##            # If we have a Snapshot, we also want to display CODED Keywords in addition to the WHOLE Snapshot keywords
        ##            # we've already included
        ##            if isinstance(cellData[keyVals], Snapshot.Snapshot):
        ##                # Keep a list of the coded keywords we've already displayed
        ##                codedKeywords = []
        ##                # Modify the template for additional keywords
        ##                kwPrompt = '\n  %s : %s'
        ##                # For each of the Snapshot's Coding Objects ...
        ##                for x in range(len(cellData[keyVals].codingObjects)):
        ##                    # ... if the Coding Object is visible and if it is not already in the codedKeywords list ...
        ##                    if (cellData[keyVals].codingObjects[x]['visible']) and \
        ##                      (not (cellData[keyVals].codingObjects[x]['keywordGroup'], cellData[keyVals].codingObjects[x]['keyword']) in codedKeywords):
        ##                        # ... if this is the FIRST Coded Keyword ...
        ##                        if len(codedKeywords) == 0:
        ##                            # ... and if there WERE Whole Snapshot Keywords ...
        ##                            if len(kwString) > 0:
        ##                                # ... then add a line break to the Keywords String ...
        ##                                kwString += '\n'
        ##                            # ... add the indicator to the Keywords String that we're starting to show Coded Keywords
        ##                            kwString += unicode(_('Coded:'), 'utf8')
        ##                        # ... add the coded keyword to the Keywords String ...
        ##                        kwString += kwPrompt % (cellData[keyVals].codingObjects[x]['keywordGroup'], cellData[keyVals].codingObjects[x]['keyword'])
        ##                        # ... add the keyword to the Coded Keywords list
        ##                        codedKeywords.append((cellData[keyVals].codingObjects[x]['keywordGroup'], cellData[keyVals].codingObjects[x]['keyword']))

        # Insert the data values into the Grid Row
        # Start and End Characters  in column 0
                    self.gridQuotes.SetCellValue(
                        loop, 0, "%s -\n %s" % (startChar, endChar))
                    # Node String (including Item name) in column 1
                    self.gridQuotes.SetCellValue(
                        loop, 1, cellData[keyVals].GetNodeString(True))
                    # make the Collection / Item ID line auto-word-wrap
                    self.gridQuotes.SetCellRenderer(
                        loop, 1, grid.GridCellAutoWrapStringRenderer())
                    # Keywords in column 2
                    self.gridQuotes.SetCellValue(loop, 2, kwString)
                    # Item Number (hidden) in column 3.  Convert value to a string
                    self.gridQuotes.SetCellValue(
                        loop, 3, "%s" % cellData[keyVals].number)
                    # Item Type (hidden) in column 4
                    self.gridQuotes.SetCellValue(loop, 4, "%s" % objType)
                    # Auto-size THIS row
                    self.gridQuotes.AutoSizeRow(loop, True)
                    # Increment the Row Counter
                    loop += 1

                # See if other Transana actions that take priority should be allowed
                wx.YieldIfNeeded()

                if not self.redraw:
                    # Select the first cell
                    self.gridQuotes.SetGridCursor(0, 0)
                    self.gridQuotes.Refresh()
                    self.redrawComplete = True

        # We get PyDeadObjectError exceptions when a tab has been deleted because we're changing Objects.
        except wx._core.PyDeadObjectError, e:
            # We can safely ignore this!
            pass
示例#6
0
    def DisplayCells(self, TimeCode):
        """ Get data from the database and populate the Episode Clips / Selected Clips Grid """
        # Get clip data from the database
        clipData = DBInterface.list_of_clips_by_episode(self.episodeObj.number, TimeCode)
        if TransanaConstants.proVersion:
            # Get the snapshot data from the database
            snapshotData = DBInterface.list_of_snapshots_by_episode(self.episodeObj.number, TimeCode)

        # Combine the two lists
        cellData = {}
        # For each Clip ...
        for clip in clipData:
            # load the Clip
            tmpObj = Clip.Clip(clip['ClipNum'])
            # add the Clip to the cellData
            cellData[(clip['ClipStart'], clip['ClipStop'], tmpObj.GetNodeString(True).upper())] = tmpObj
        if TransanaConstants.proVersion:
            # for each Snapshot ...
            for snapshot in snapshotData:
                # load the Snapshot
                tmpObj = Snapshot.Snapshot(snapshot['SnapshotNum'])
                # add the Snapshot to the cellData
                cellData[(snapshot['SnapshotStart'], snapshot['SnapshotStop'], tmpObj.GetNodeString(True).upper())] = tmpObj

        # Get the Keys for the cellData
        sortedKeys = cellData.keys()
        # Sort the keys for the cellData into the right order
        sortedKeys.sort()
        
        # Add rows to the Grid to accomodate the amount of data returned, or delete rows if we have too many
        if len(cellData) > self.gridClips.GetNumberRows():
            self.gridClips.AppendRows(len(cellData) - self.gridClips.GetNumberRows(), False)
        elif len(cellData) < self.gridClips.GetNumberRows():
            self.gridClips.DeleteRows(numRows = self.gridClips.GetNumberRows() - len(cellData))

        # Initialize the Row Counter
        loop = 0
        # Add the data to the Grid
        for keyVals in sortedKeys:
            # If we have a Clip ...
            if isinstance(cellData[keyVals], Clip.Clip):
                # ... get the start, stop times and the object type
                startTime = cellData[keyVals].clip_start
                stopTime = cellData[keyVals].clip_stop
                objType = 'Clip'
                # Initialize the string for all the Keywords to blank
                kwString = unicode('', 'utf8')
                # Initialize the prompt for building the keyword string
                kwPrompt = '%s'
            # If we have a Snapshot ...
            elif isinstance(cellData[keyVals], Snapshot.Snapshot):
                # ... get the start, stop times and the object type
                startTime = cellData[keyVals].episode_start
                stopTime = cellData[keyVals].episode_start + cellData[keyVals].episode_duration
                objType = 'Snapshot'
                # if there are whole snapshot keywords ...
                if len(cellData[keyVals].keyword_list) > 0:
                    # ... initialize the string for all the Keywords to indicate this
                    kwString = unicode(_('Whole:'), 'utf8') + '\n'
                # If there are NOT whole snapshot keywords ...
                else:
                    # ... initialize the string for all the Keywords to blank
                    kwString = unicode('', 'utf8')
                # Initialize the prompt for building the keyword string
                kwPrompt = '  %s'
            # For each Keyword in the Keyword List ...
            for kws in cellData[keyVals].keyword_list:
                # ... add the Keyword to the Keyword List
                kwString += kwPrompt % kws.keywordPair
                # If we have a Clip ...
                if isinstance(cellData[keyVals], Clip.Clip):
                    # After the first keyword, we need a NewLine in front of the Keywords.  This accompishes that!
                    kwPrompt = '\n%s'
                # If we have a Snapshot ...
                elif isinstance(cellData[keyVals], Snapshot.Snapshot):
                    # After the first keyword, we need a NewLine in front of the Keywords.  This accompishes that!
                    kwPrompt = '\n  %s'

            # If we have a Snapshot, we also want to display CODED Keywords in addition to the WHOLE Snapshot keywords
            # we've already included
            if isinstance(cellData[keyVals], Snapshot.Snapshot):
                # Keep a list of the coded keywords we've already displayed
                codedKeywords = []
                # Modify the template for additional keywords
                kwPrompt = '\n  %s : %s'
                # For each of the Snapshot's Coding Objects ...
                for x in range(len(cellData[keyVals].codingObjects)):
                    # ... if the Coding Object is visible and if it is not already in the codedKeywords list ...
                    if (cellData[keyVals].codingObjects[x]['visible']) and \
                      (not (cellData[keyVals].codingObjects[x]['keywordGroup'], cellData[keyVals].codingObjects[x]['keyword']) in codedKeywords):
                        # ... if this is the FIRST Coded Keyword ...
                        if len(codedKeywords) == 0:
                            # ... and if there WERE Whole Snapshot Keywords ...
                            if len(kwString) > 0:
                                # ... then add a line break to the Keywords String ...
                                kwString += '\n'
                            # ... add the indicator to the Keywords String that we're starting to show Coded Keywords
                            kwString += unicode(_('Coded:'), 'utf8')
                        # ... add the coded keyword to the Keywords String ...
                        kwString += kwPrompt % (cellData[keyVals].codingObjects[x]['keywordGroup'], cellData[keyVals].codingObjects[x]['keyword'])
                        # ... add the keyword to the Coded Keywords list
                        codedKeywords.append((cellData[keyVals].codingObjects[x]['keywordGroup'], cellData[keyVals].codingObjects[x]['keyword']))

            # Insert the data values into the Grid Row
            # Start and Stop time in column 0
            self.gridClips.SetCellValue(loop, 0, "%s -\n %s" % (Misc.time_in_ms_to_str(startTime), Misc.time_in_ms_to_str(stopTime)))
            # Node String (including Item name) in column 1
            self.gridClips.SetCellValue(loop, 1, cellData[keyVals].GetNodeString(True))
            # make the Collection / Item ID line auto-word-wrap
            self.gridClips.SetCellRenderer(loop, 1, grid.GridCellAutoWrapStringRenderer())
            # Keywords in column 2
            self.gridClips.SetCellValue(loop, 2, kwString)
            # Item Number (hidden) in column 3.  Convert value to a string
            self.gridClips.SetCellValue(loop, 3, "%s" % cellData[keyVals].number)
            # Item Type (hidden) in column 4
            self.gridClips.SetCellValue(loop, 4, "%s" % objType)
            # Auto-size THIS row
            self.gridClips.AutoSizeRow(loop, True)
            # Increment the Row Counter
            loop += 1
        # Select the first cell
        self.gridClips.SetGridCursor(0, 0)
示例#7
0
    def addRow(self, index=None):
        if index == None:
            self.AppendRows(1, True)
            row = len(self.objects)
        else:
            self.InsertRows(index, 1, True)
            row = index

        # Filename
        attr = gridlib.GridCellAttr()
        attr.SetReadOnly(True)
        self.SetAttr(row, ID_COL_FILENAME, attr)
        renderer = gridlib.GridCellAutoWrapStringRenderer()
        self.SetCellRenderer(row, ID_COL_FILENAME, renderer)
        self.SetCellValue(row, ID_COL_FILENAME, "Click to choose a sound")
        self.SetCellTextColour(row, ID_COL_FILENAME, "#888888")
        # Loop Mode
        attr = gridlib.GridCellAttr()
        attr.SetReadOnly(True)
        self.SetAttr(row, ID_COL_LOOPMODE, attr)
        # Transpo
        attr = gridlib.GridCellAttr()
        attr.SetReadOnly(True)
        self.SetAttr(row, ID_COL_TRANSPO, attr)
        rd = gridlib.GridCellFloatRenderer()
        rd.SetPrecision(4)
        self.SetCellRenderer(row, ID_COL_TRANSPO, rd)
        # Gain
        attr = gridlib.GridCellAttr()
        attr.SetReadOnly(True)
        self.SetAttr(row, ID_COL_GAIN, attr)
        rd = gridlib.GridCellFloatRenderer()
        rd.SetPrecision(4)
        self.SetCellRenderer(row, ID_COL_GAIN, rd)
        # Playing
        attr = gridlib.GridCellAttr()
        attr.SetReadOnly(True)
        self.SetAttr(row, ID_COL_PLAYING, attr)
        # Direct Out
        attr = gridlib.GridCellAttr()
        attr.SetReadOnly(True)
        self.SetAttr(row, ID_COL_DIRECTOUT, attr)
        # Start Point
        attr = gridlib.GridCellAttr()
        attr.SetReadOnly(True)
        self.SetAttr(row, ID_COL_STARTPOINT, attr)
        rd = gridlib.GridCellFloatRenderer()
        rd.SetPrecision(4)
        self.SetCellRenderer(row, ID_COL_STARTPOINT, rd)
        # End Point
        attr = gridlib.GridCellAttr()
        attr.SetReadOnly(True)
        self.SetAttr(row, ID_COL_ENDPOINT, attr)
        rd = gridlib.GridCellFloatRenderer()
        rd.SetPrecision(4)
        self.SetCellRenderer(row, ID_COL_ENDPOINT, rd)
        # Crossfade
        attr = gridlib.GridCellAttr()
        attr.SetReadOnly(True)
        self.SetAttr(row, ID_COL_CROSSFADE, attr)
        rd = gridlib.GridCellFloatRenderer()
        rd.SetPrecision(1)
        self.SetCellRenderer(row, ID_COL_CROSSFADE, rd)
        # Channel
        attr = gridlib.GridCellAttr()
        attr.SetReadOnly(True)
        self.SetAttr(row, ID_COL_CHANNEL, attr)
        rd = gridlib.GridCellNumberRenderer()
        self.SetCellRenderer(row, ID_COL_CHANNEL, rd)

        self.SetCellAlignment(row, 0, wx.ALIGN_LEFT, wx.ALIGN_CENTER)
        for i in range(1, len(LABELS)):
            self.SetCellAlignment(row, i, wx.ALIGN_CENTER, wx.ALIGN_CENTER)
示例#8
0
 def renderer(self):
     return gridlib.GridCellAutoWrapStringRenderer()