本文整理汇总了Python中wx.LIST_AUTOSIZE属性的典型用法代码示例。如果您正苦于以下问题:Python wx.LIST_AUTOSIZE属性的具体用法?Python wx.LIST_AUTOSIZE怎么用?Python wx.LIST_AUTOSIZE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类wx
的用法示例。
在下文中一共展示了wx.LIST_AUTOSIZE属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import LIST_AUTOSIZE [as 别名]
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)
示例2: set_default_widths
# 需要导入模块: import wx [as 别名]
# 或者: from wx import LIST_AUTOSIZE [as 别名]
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)
示例3: CreateColumns
# 需要导入模块: import wx [as 别名]
# 或者: from wx import LIST_AUTOSIZE [as 别名]
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)
示例4: AddColumn
# 需要导入模块: import wx [as 别名]
# 或者: from wx import LIST_AUTOSIZE [as 别名]
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);
示例5: AutoSizeColumns
# 需要导入模块: import wx [as 别名]
# 或者: from wx import LIST_AUTOSIZE [as 别名]
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()