コード例 #1
0
    def __init__(self, parent, widgetID, characterStyle, headerCharacterStyle,
                 *arguments, **keywords):
        if wx.Platform == "__WXMAC__":
            theStyle = wx.BORDER_SIMPLE
        else:
            theStyle = wx.BORDER_STATIC
        """
          Giant hack. Calling event.GetEventObject in OnShow of
          application, while the object is being created cause the
          object to get the wrong type because of a
          "feature" of SWIG. So we need to avoid OnShows in this case.
        """
        IgnoreSynchronizeWidget(True,
                                super(wxTable, self).__init__,
                                parent,
                                widgetID,
                                style=theStyle,
                                *arguments,
                                **keywords)

        self.SetDefaultCellFont(Styles.getFont(characterStyle))
        self.SetLabelFont(Styles.getFont(headerCharacterStyle))
        self.SetColLabelAlignment(wx.ALIGN_LEFT, wx.ALIGN_CENTRE)
        self.SetRowLabelSize(0)
        self.AutoSizeRows()
        self.EnableDragCell(True)
        self.DisableDragRowSize()
        self.SetDefaultCellBackgroundColour(wx.WHITE)
        self.EnableCursor(False)
        self.SetLightSelectionBackground()
        self.SetScrollLineY(self.GetDefaultRowSize())
        self.SetUseVisibleColHeaderSelection(True)
        self.SetUseColSortArrows(True)

        # wxSidebar is subclassed from wxTable and depends on the binding of
        # OnLoseFocus so it can override OnLoseFocus in wxTable
        self.Bind(wx.EVT_KILL_FOCUS, self.OnLoseFocus)
        self.Bind(wx.EVT_SET_FOCUS, self.OnGainFocus)
        self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
        self.Bind(wxGrid.EVT_GRID_CELL_BEGIN_DRAG, self.OnItemDrag)
        self.Bind(wxGrid.EVT_GRID_COL_SIZE, self.OnColumnDrag)
        self.Bind(wxGrid.EVT_GRID_RANGE_SELECT, self.OnRangeSelect)
        self.Bind(wxGrid.EVT_GRID_LABEL_LEFT_CLICK, self.OnLabelLeftClicked)
        self.Bind(wxGrid.EVT_GRID_EDITOR_HIDDEN, self.OnEditorHidden)
        self.Bind(wxGrid.EVT_GRID_EDITOR_SHOWN, self.OnEditorShown)

        gridWindow = self.GetGridWindow()
        gridWindow.Bind(wx.EVT_PAINT, self.OnPaint)
        # wxSidebar is subclassed from wxTable and depends on the binding of
        # OnMouseEvents so it can override OnMouseEvents in wxTable
        gridWindow.Bind(wx.EVT_MOUSE_EVENTS, self.OnMouseEvents)
        gridWindow.Bind(wx.EVT_MOUSE_CAPTURE_LOST, self.OnMouseCaptureLost)
        # It appears that wxGrid gobbles all the mouse events so we never get
        # context menu events. So bind right down to the context menu handler
        gridWindow.Bind(wx.EVT_RIGHT_DOWN, wx.GetApp().OnContextMenu)
コード例 #2
0
ファイル: Table.py プロジェクト: HackLinux/chandler
    def __init__(self, parent, widgetID, characterStyle, headerCharacterStyle, *arguments, **keywords):
        if wx.Platform == "__WXMAC__":
            theStyle=wx.BORDER_SIMPLE
        else:
            theStyle=wx.BORDER_STATIC
        """
          Giant hack. Calling event.GetEventObject in OnShow of
          application, while the object is being created cause the
          object to get the wrong type because of a
          "feature" of SWIG. So we need to avoid OnShows in this case.
        """
        IgnoreSynchronizeWidget(True, super(wxTable, self).__init__,
                                parent, widgetID, style=theStyle,
                                *arguments, **keywords)

        self.SetDefaultCellFont(Styles.getFont(characterStyle))
        self.SetLabelFont(Styles.getFont(headerCharacterStyle))
        self.SetColLabelAlignment(wx.ALIGN_LEFT, wx.ALIGN_CENTRE)
        self.SetRowLabelSize(0)
        self.AutoSizeRows()
        self.EnableDragCell(True)
        self.DisableDragRowSize()
        self.SetDefaultCellBackgroundColour(wx.WHITE)
        self.EnableCursor (False)
        self.SetLightSelectionBackground()
        self.SetScrollLineY (self.GetDefaultRowSize())
        self.SetUseVisibleColHeaderSelection(True)
        self.SetUseColSortArrows(True)

        # wxSidebar is subclassed from wxTable and depends on the binding of
        # OnLoseFocus so it can override OnLoseFocus in wxTable
        self.Bind(wx.EVT_KILL_FOCUS, self.OnLoseFocus)
        self.Bind(wx.EVT_SET_FOCUS, self.OnGainFocus)
        self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
        self.Bind(wxGrid.EVT_GRID_CELL_BEGIN_DRAG, self.OnItemDrag)
        self.Bind(wxGrid.EVT_GRID_COL_SIZE, self.OnColumnDrag)
        self.Bind(wxGrid.EVT_GRID_RANGE_SELECT, self.OnRangeSelect)
        self.Bind(wxGrid.EVT_GRID_LABEL_LEFT_CLICK, self.OnLabelLeftClicked)
        self.Bind(wxGrid.EVT_GRID_EDITOR_HIDDEN, self.OnEditorHidden)
        self.Bind(wxGrid.EVT_GRID_EDITOR_SHOWN, self.OnEditorShown)

        gridWindow = self.GetGridWindow()
        gridWindow.Bind(wx.EVT_PAINT, self.OnPaint)
        # wxSidebar is subclassed from wxTable and depends on the binding of
        # OnMouseEvents so it can override OnMouseEvents in wxTable
        gridWindow.Bind(wx.EVT_MOUSE_EVENTS, self.OnMouseEvents)
        gridWindow.Bind(wx.EVT_MOUSE_CAPTURE_LOST, self.OnMouseCaptureLost)
        # It appears that wxGrid gobbles all the mouse events so we never get
        # context menu events. So bind right down to the context menu handler
        gridWindow.Bind(wx.EVT_RIGHT_DOWN, wx.GetApp().OnContextMenu)