Python wx.LIST_AUTOSIZE Examples

The following are 5 code examples of wx.LIST_AUTOSIZE(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module wx , or try the search function .
Example #1
Source File: namesdlg.py    From trelby with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, parent):
        wx.ListCtrl.__init__(self, parent, -1,
            style = wx.LC_REPORT | wx.LC_VIRTUAL | wx.LC_SINGLE_SEL |
                    wx.LC_HRULES | wx.LC_VRULES)

        self.sex = ["Female", "Male"]

        self.InsertColumn(0, "Name")
        self.InsertColumn(1, "Type")
        self.InsertColumn(2, "Sex")
        self.SetColumnWidth(0, 120)
        self.SetColumnWidth(1, 120)

        # we can't use wx.LIST_AUTOSIZE since this is a virtual control,
        # so calculate the size ourselves since we know the longest string
        # possible.
        w = util.getTextExtent(self.GetFont(), "Female")[0] + 15
        self.SetColumnWidth(2, w)

        util.setWH(self, w = 120*2 + w + 25) 
Example #2
Source File: ListCtrl.py    From BitTorrent with GNU General Public License v3.0 6 votes vote down vote up
def set_default_widths(self):
        # must be called before *any* data is put into the control.
        sample_data = {}
        for name in self.column_order:
            sample_data[name] = self.columns[name].sample_data
        sample_row = BTListRow(None, sample_data)

        self.InsertRow(-1, sample_row)
        for name in self.column_order:
            column = self.columns[name]
            if name in self.enabled_columns:
                self.SetColumnWidth(column.GetColumn(), wx.LIST_AUTOSIZE)
                column.width = self.GetColumnWidth(column.GetColumn())
            dc = wx.ClientDC(self)
            header_width = dc.GetTextExtent(column.GetText())[0]
            header_width += 4 # arbitrary allowance for header decorations
            column.width = max(column.width, header_width)
            if name in self.enabled_columns:
                self.SetColumnWidth(column.GetColumn(), column.width)
        self.default_rect = self.GetItemRect(0)
        self.DeleteRow(-1) 
Example #3
Source File: listviews.py    From pyFileFixity with MIT License 5 votes vote down vote up
def CreateColumns( self ):
        """Create/recreate our column definitions from current self.columns"""
        self.SetItemCount(0)
        # clear any current columns...
        for i in range( self.GetColumnCount())[::-1]:
            self.DeleteColumn( i )
        # now create
        for i, column in enumerate(self.columns):
            column.index = i
            self.InsertColumn(i, column.name)
            if not windows or column.targetWidth is None:
                self.SetColumnWidth(i, wx.LIST_AUTOSIZE)
            else:
                self.SetColumnWidth(i, column.targetWidth) 
Example #4
Source File: ctl_adm.py    From admin4 with Apache License 2.0 5 votes vote down vote up
def AddColumn(self, text, size=-1, format=wx.LIST_FORMAT_LEFT):
    if size in [None, -1, wx.LIST_AUTOSIZE]:
#      size=wx.LIST_AUTOSIZE
      size=self.GetClientSize().GetWidth();
      for i in range(self.GetColumnCount()):
        size -= self.GetColumnWidth(i)
    elif size > 0:
      size=self.convert(size) + self.MARGIN
      if not self.GetColumnCount():
        size += self.ICONWITDH
    return self.InsertColumn(self.GetColumnCount(), text, format, size); 
Example #5
Source File: ObjectListView.py    From bookhub with MIT License 5 votes vote down vote up
def AutoSizeColumns(self):
        """
        Resize our auto sizing columns to match the data
        """
        for (iCol, col) in enumerate(self.columns):
            if col.width == wx.LIST_AUTOSIZE:
                self.SetColumnWidth(iCol, wx.LIST_AUTOSIZE)

                # The new width must be within our minimum and maximum
                colWidth = self.GetColumnWidth(iCol)
                boundedWidth = col.CalcBoundedWidth(colWidth)
                if colWidth != boundedWidth:
                    self.SetColumnWidth(iCol, boundedWidth)

        self._ResizeSpaceFillingColumns()