示例#1
0
文件: label.py 项目: obspy/branches
 def _allocate(self, width, height):
     Widget._allocate(self, width, height)
     if self._deleted:
         return
     label = self._label
     style = self._style
     p = style.padding
     halign = style.halign
     valign = style.valign
     content_width = self.width-p[2]-p[3]
     content_height = self.height-p[0]-p[1]
     label.x = int(self.x+p[2]+(content_width-label.content_width)*halign)
     label.y = int(self.y-p[0]-(content_height-label.content_height)*valign)
示例#2
0
 def _allocate(self, width, height):
     Widget._allocate(self, width, height)
     if self._deleted:
         return
     label = self._label
     style = self._style
     p = style.padding
     halign = style.halign
     valign = style.valign
     content_width = self.width - p[2] - p[3]
     content_height = self.height - p[0] - p[1]
     label.x = int(self.x + p[2] +
                   (content_width - label.content_width) * halign)
     label.y = int(self.y - p[0] -
                   (content_height - label.content_height) * valign)
示例#3
0
    def _allocate(self, width, height):
        ''' Set size allocation.

        **Parameters**
            `width` : int
                Width in pixels
            `height` : int
                Height  in pixels
        '''
        if self._deleted:
            return
        Widget._allocate(self, width, height)
        text = self._text
        style = self._style
        padding = style.padding
        content_width = self.width - padding[2] - padding[3]
        content_height = self.height - padding[0] - padding[1]
        label = self._label
        layout = self._layout

        if label:
            # Ellipsize text if necessary
            # Dear Glydget, I do not want you to f**k up my content strings. Sincerely, Steve.
            if label.content_width > content_width and False:
                n, m = 1, len(text)
                while (m - n) > 1:
                    i = (n + m) // 2
                    if i < (len(text) - 1):
                        label.text = text[:i] + u'…'
                    else:
                        label.text = text
                    if label.content_width < content_width:
                        n = i
                    else:
                        m = i
                if n < (len(text) - 2):
                    label.text = text[:n] + u'…'
                else:
                    label.text = text
            label.x = int(self.x + padding[2])
            label.y = int(self.y - padding[0])
        elif layout:
            layout.width = content_width
            layout.height = self._minimum_size[1]
            layout.x = int(self.x + padding[2])
            layout.y = int(self.y - padding[0])
示例#4
0
    def _allocate(self, width, height):
        ''' Set size allocation.

        **Parameters**
            `width` : int
                Width in pixels
            `height` : int
                Height  in pixels
        '''
        if self._deleted:
            return
        Widget._allocate(self, width, height)
        text = self._text
        style = self._style
        padding = style.padding
        content_width = self.width-padding[2]-padding[3]
        content_height = self.height-padding[0]-padding[1]
        label = self._label
        layout = self._layout
        
        if label:
            # Ellipsize text if necessary
            # Dear Glydget, I do not want you to f**k up my content strings. Sincerely, Steve.
            if label.content_width > content_width and False:
                n,m = 1, len(text)
                while (m-n) > 1:
                    i = (n+m)//2
                    if i < (len(text)-1):
                        label.text = text[:i]+u'…'
                    else:
                        label.text = text
                    if label.content_width < content_width:
                        n = i
                    else:
                        m = i
                if n < (len(text)-2):
                    label.text = text[:n]+u'…'
                else:
                    label.text = text
            label.x = int(self.x+padding[2])
            label.y = int(self.y-padding[0])
        elif layout:
            layout.width = content_width
            layout.height = self._minimum_size[1]
            layout.x = int(self.x+padding[2])
            layout.y = int(self.y-padding[0])
示例#5
0
    def _allocate(self, width, height):
        ''' Set size allocation.

        **Parameters**
            `width` : int
                Width in pixels
            `height` : int
                Height  in pixels
        '''
        Widget._allocate(self, width, height)
        if self._deleted:
            return
        label = self._label
        style = self._style
        p = style.padding
        halign = style.halign
        valign = style.valign
        content_width = self.width-p[2]-p[3]
        content_height = self.height-p[0]-p[1]
        label.x = int(self.x+p[2]+(content_width-label.content_width)*halign)
        label.y = int(self.y-p[0]-(content_height-label.content_height)*valign)
示例#6
0
    def _allocate(self, width, height):
        ''' Set size allocation.

        **Parameters**
            `width` : int
                Width in pixels
            `height` : int
                Height  in pixels
        '''
        Widget._allocate(self, width, height)
        if self._deleted:
            return
        label = self._label
        style = self._style
        p = style.padding
        halign = style.halign
        valign = style.valign
        content_width = self.width - p[2] - p[3]
        content_height = self.height - p[0] - p[1]
        label.x = int(self.x + p[2] +
                      (content_width - label.content_width) * halign)
        label.y = int(self.y - p[0] -
                      (content_height - label.content_height) * valign)
示例#7
0
 def _allocate(self, width, height):
     if self._deleted:
         return
     Widget._allocate(self, width, height)
     text = self._text
     style = self._style
     padding = style.padding
     content_width = self.width-padding[2]-padding[3]
     content_height = self.height-padding[0]-padding[1]
     label = self._label
     layout = self._layout
     if label:
         # Ellipsize text if necessary
         if label.content_width > content_width:
             n,m = 1, len(text)
             while (m-n) > 1:
                 i = (n+m)//2
                 if i < (len(text)-1):
                     label.text = text[:i]+u'…'
                 else:
                     label.text = text
                 if label.content_width < content_width:
                     n = i
                 else:
                     m = i
             if n < (len(text)-2):
                 label.text = text[:n]+u'…'
             else:
                 label.text = text
         label.x = int(self.x+padding[2])
         label.y = int(self.y-padding[0])
     elif layout:
         layout.width = content_width
         layout.height = self._minimum_size[1]
         layout.x = int(self.x+padding[2])
         layout.y = int(self.y-padding[0])
示例#8
0
文件: entry.py 项目: obspy/branches
 def _allocate(self, width, height):
     if self._deleted:
         return
     Widget._allocate(self, width, height)
     text = self._text
     style = self._style
     padding = style.padding
     content_width = self.width - padding[2] - padding[3]
     content_height = self.height - padding[0] - padding[1]
     label = self._label
     layout = self._layout
     if label:
         # Ellipsize text if necessary
         if label.content_width > content_width:
             n, m = 1, len(text)
             while (m - n) > 1:
                 i = (n + m) // 2
                 if i < (len(text) - 1):
                     label.text = text[:i] + u"…"
                 else:
                     label.text = text
                 if label.content_width < content_width:
                     n = i
                 else:
                     m = i
             if n < (len(text) - 2):
                 label.text = text[:n] + u"…"
             else:
                 label.text = text
         label.x = int(self.x + padding[2])
         label.y = int(self.y - padding[0])
     elif layout:
         layout.width = content_width
         layout.height = self._minimum_size[1]
         layout.x = int(self.x + padding[2])
         layout.y = int(self.y - padding[0])