当前位置: 首页>>代码示例>>Python>>正文


Python Table.add方法代码示例

本文整理汇总了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)
开发者ID:cntimothy,项目名称:toolbox,代码行数:12,代码来源:xmltocs.py

示例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
开发者ID:JonahBrooks,项目名称:Portfolio,代码行数:19,代码来源:select.py

示例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()
#.........这里部分代码省略.........
开发者ID:JonahBrooks,项目名称:Portfolio,代码行数:103,代码来源:select.py


注:本文中的table.Table.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。