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


Python Table.tr方法代码示例

本文整理汇总了Python中table.Table.tr方法的典型用法代码示例。如果您正苦于以下问题:Python Table.tr方法的具体用法?Python Table.tr怎么用?Python Table.tr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在table.Table的用法示例。


在下文中一共展示了Table.tr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Select

# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import tr [as 别名]

#.........这里部分代码省略.........
        #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()
            #self.resize() #to recenter the new value, etc.
            pass
        #    #self._resize()
        
        self._close(None)
        #self.repaint() #this will happen anyways
        
    
    
    def __setattr__(self,k,v):
        mywidget = None
        if k == 'value':
            for w in self.values:
                if w._value == v:
                    mywidget = w
        _v = self.__dict__.get(k,NOATTR)
        self.__dict__[k]=v
        if k == 'value' and _v != NOATTR and _v != v: 
            self.send(CHANGE)
            self.repaint()
        if k == 'value':
            if not mywidget:
                mywidget = Label(" ",cls=self.cls+".option.label")
            self.top_selected.value = mywidget
    
    def add(self,w,value=None):
        """Add a widget and associated value to the dropdown box."""
        
        if type(w) == str: w = Label(w,cls=self.cls+".option.label")
        
        w.style.align = -1
        btn = Button(w,cls=self.cls+".option")
        btn.connect(CLICK,self._setvalue,w)
        
        self.options.tr()
        self.options.add(btn)
        
        if (not self.firstOption):
            self.firstOption = btn
        
        if value != None: w._value = value
        else: w._value = w
        if self.value == w._value:
            self.top_selected.value = w
        self.values.append(w)
开发者ID:JonahBrooks,项目名称:Portfolio,代码行数:104,代码来源:select.py


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