本文整理汇总了Python中table.Table.add方法的典型用法代码示例。如果您正苦于以下问题:Python Table.add方法的具体用法?Python Table.add怎么用?Python Table.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类table.Table
的用法示例。
在下文中一共展示了Table.add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: transfer
# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import add [as 别名]
def transfer(self):
doc = ElementTree.parse(self.filepath)
root = doc.getroot()
database = root.getchildren()
for table in database:
datatable = Table(table.attrib['tablename'])
columns = table.getchildren()
for column in columns:
datatable.add(column.attrib['columnname'], column.attrib['columntype'],column.attrib['columnwidth'])
self.datatables.append(datatable)
示例2: __init__
# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import add [as 别名]
def __init__(self,value=None,**params):
params.setdefault('cls','select')
Table.__init__(self,**params)
label = Label(" ",cls=self.cls+".option.label")
self.top_selected = Button(label, cls=self.cls+".selected")
Table.add(self,self.top_selected) #,hexpand=1,vexpand=1)#,0,0)
self.top_arrow = Button(Image(self.style.arrow), cls=self.cls+".arrow")
Table.add(self,self.top_arrow) #,hexpand=1,vexpand=1) #,1,0)
self.options = Table(cls=self.cls+".options")
self.options.connect(BLUR,self._close,None)
self.options.name = "pulldown-table"
self.values = []
self.value = value
示例3: Select
# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import add [as 别名]
class Select(Table):
"""A combo dropdown box widget.
Example:
w = Select(value="goats")
w.add("Cats","cats")
w.add("Goats","goats")
w.add("Dogs","Dogs")
w.value = 'dogs' #changes the value from goats to dogs
"""
# The drop-down arrow button for the selection widget
top_arrow = None
# A button displaying the currently selected item
top_selection = None
# The first option added to the selector
firstOption = None
# The PGU table of options
options = None
def __init__(self,value=None,**params):
params.setdefault('cls','select')
Table.__init__(self,**params)
label = Label(" ",cls=self.cls+".option.label")
self.top_selected = Button(label, cls=self.cls+".selected")
Table.add(self,self.top_selected) #,hexpand=1,vexpand=1)#,0,0)
self.top_arrow = Button(Image(self.style.arrow), cls=self.cls+".arrow")
Table.add(self,self.top_arrow) #,hexpand=1,vexpand=1) #,1,0)
self.options = Table(cls=self.cls+".options")
self.options.connect(BLUR,self._close,None)
self.options.name = "pulldown-table"
self.values = []
self.value = value
def resize(self,width=None,height=None):
max_w,max_h = 0,0
for w in self.options.widgets:
w.rect.w,w.rect.h = w.resize()
max_w,max_h = max(max_w,w.rect.w),max(max_h,w.rect.h)
#xt,xr,xb,xl = self.top_selected.getspacing()
self.top_selected.style.width = max_w #+ xl + xr
self.top_selected.style.height = max_h #+ xt + xb
self.top_arrow.connect(CLICK,self._open,None)
self.top_selected.connect(CLICK,self._open,None)
w,h = Table.resize(self,width,height)
self.options.style.width = w
#HACK: sort of, but not a big one..
self.options.resize()
return w,h
def _open(self,value):
opts = self.options
opts.rect.w, opts.rect.h = opts.resize()
# y = self.rect.y
# c = self.container
# while hasattr(c, 'container'):
# y += c.rect.y
# if (not c.container):
# break
# c = c.container
# if y + self.rect.h + opts.rect.h <= c.rect.h: #down
# dy = self.rect.y + self.rect.h
# else: #up
# dy = self.rect.y - self.rect.h
opts.rect.w, opts.rect.h = opts.resize()
# TODO - make sure there is enough space to open down
# ...
yp = self.rect.bottom-1
self.container.open(opts, self.rect.x, yp)
self.firstOption.focus()
# TODO - this is a hack
for opt in self.options.widgets:
opt.repaint()
def _close(self,value):
self.options.close()
self.top_selected.focus()
def _setvalue(self,value):
self.value = value._value
if self.container:
#self.chsize()
#HACK: improper use of resize()
#.........这里部分代码省略.........