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


Python text.Label类代码示例

本文整理汇总了Python中kivy.core.text.Label的典型用法代码示例。如果您正苦于以下问题:Python Label类的具体用法?Python Label怎么用?Python Label使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: CounterNum

class CounterNum(Widget):
	
	label = ObjectProperty(None)
	texture_size = None
	label_texture = ObjectProperty(None)
	
	def __init__(self, num, **kwargs):
		super(CounterNum, self).__init__(**kwargs)
		
		# generate texture containing the desired label
		self.label = CoreLabel(text=str(num), font_size=500, color=(1,1,1,1))
		self.label.refresh()		
		self.texture_size = list(self.label.texture.size)
		self.label_texture = self.label.texture
		
		pass
		
	def animate(self):
		
		# animate widget
		size_old = self.texture_size
		size_new = (size_old[0] * 1.5, size_old[1] * 1.5)
		pos = self.pos
		anim = Animation(size=size_new, pos=(pos[0] - (size_new[0] - size_old[0])/2, pos[1] - (size_new[1] - size_old[1])/2), duration=0.5)
		#anim = Animation(scale=1.5, pos=(pos[0] - (size_new[0] - size_old[0])/2, pos[1] - (size_new[1] - size_old[1])/2), duration=0.25)
		anim.start(self)

		pass
开发者ID:cgart,项目名称:photobooth,代码行数:28,代码来源:counter.py

示例2: _calculate_optimum_font_size

    def _calculate_optimum_font_size(self):
        #cw = self._calculate_widths()
        words = list(self._iterate_words())
        text = ' '.join([x.text for x in words])
        font_size = WORD_FONTSIZE
        corelabel = CoreLabel(text=text, font_name=words[0].font_name)
        padding = words[0].padding * len(words)

        # too many words ?
        if padding > self.width / 2:
            padding = int(self.width / 2 / len(words))
            for word in words:
                word.padding = padding
        else:
            for word in words:
                word.padding = Word.padding.defaultvalue

        while True:
            corelabel.options['font_size'] = sp(font_size)
            w, h = corelabel.render()
            if w < self.width - padding:
                break
            font_size -= 1

        font_size = sp(font_size)
        if font_size != words[0].font_size:
            for word in words:
                word.font_size = font_size
                word.texture_update()
开发者ID:urbanlab,项目名称:logotouch2,代码行数:29,代码来源:game.py

示例3: update_layout

	def update_layout(self):
		if not self._corelabel:
			# create new label
			corelabel = CoreLabel(text=self.text, font_size=self.font_size, color=self.font_color)
			corelabel.refresh();
			self._corelabel = corelabel
		labeltexture = self._corelabel.texture
		self.canvas.add(Rectangle(texture=labeltexture, size=(self.width, self.height)))
开发者ID:herrschr,项目名称:pocket-throne,代码行数:8,代码来源:gamelabel.py

示例4: build_canvas

    def build_canvas(self, dt):

        # get 3 textures
        curdir = dirname(__file__)
        arrow_left = CoreImage(join(curdir, 'arrow_left.png')).texture
        arrow_middle = CoreImage(join(curdir, 'arrow_middle.png')).texture
        arrow_right = CoreImage(join(curdir, 'arrow_right.png')).texture

        self.canvas.before.clear()
        with self.canvas.before:
            cmax = ((self.date_end - self.date_start) / float(self.date_step))
            x, y = self.pos
            w, h = self.size
            fh = 100
            bh = 10
            cy = y + h / 2
            h = fh * 2
            r = range(self.date_start, self.date_end, self.date_step)
            for index, cx in enumerate(r):
                alpha = (cx - self.date_start) / (float(self.date_end) -
                        float(self.date_start))
                
                # create background of arrow (part of)
                c = 0.9 - (0.4 * alpha)
                a = 1.0 - 0.4 * alpha
                Color(c, c, c, a)

                if index == 0:
                    texture = arrow_left
                    border = (2, 2, 2, 8)
                elif index == len(r) - 1:
                    texture = arrow_right
                    border = (2, 126, 2, 2)
                else:
                    texture = arrow_middle
                    border = (2, 0, 2, 0)
                BorderImage(pos=(x, cy - fh), size=(w/cmax, h), texture=texture,
                        border=border)

                # create lines
                x = int(x)
                if index > 0:
                    Color(1, 1, 1, .8)
                    Line(points=[x, cy - fh - bh, x, cy + fh + bh])

                # create label (333f43)
                label = CoreLabel(text=str(cx),
                        font_size=14, font_name='fonts/DroidSans.ttf')
                label.refresh()
                Color(0x33/255., 0x3f/255., 0x43/255.)

                # trick to invert the label orientation
                tc = label.texture.tex_coords
                th, tw = label.texture.size
                tc = tc[-2:] + tc[0:-2]
                Rectangle(pos=(x + 5, cy - th / 2), size=(tw, th),
                        texture=label.texture, tex_coords=tc)
                x += w / cmax
开发者ID:Iknewton,项目名称:kaleidoscope,代码行数:58,代码来源:fresco_common.py

示例5: set_caption

 def set_caption(t):
     print(t.content.text)
     mylabel = CoreLabel(text=t.content.text, font_size=25, color=self.color, position=(touch.x, touch.y))
     # Force refresh to compute things and generate the texture
     mylabel.refresh()
     texture = mylabel.texture
     texture_size = list(texture.size)
     with self.canvas:
         self.history.append(Rectangle(pos=(touch.x, touch.y), texture=texture, size=texture_size))
开发者ID:sshivaji,项目名称:kivynote,代码行数:9,代码来源:main.py

示例6: update_label

	def update_label(self):
		'''update buttons text'''
		if self.label == None:
			# create new label
			label = CoreLabel(text=self.get_text(), font_size=12, color=(0, 0, 1))
			label.refresh();
			self.label = label
		labeltexture= self.label.texture
		labelsize = list(labeltexture.size)
开发者ID:herrschr,项目名称:pocket-throne,代码行数:9,代码来源:gamebutton.py

示例7: render

 def render(self):
     self.rect = Rectangle(size=self.size, pos=self.pos)
     self.canvas.add(self.rect)
     label = CoreLabel(text="Text Lable here", font_size=20)
     label.refresh()
     text = label.texture
     #self.canvas.add(Color(self.colour, 1-self.colour,0, 1))
     pos = [150,150]#self.pos[i] + (self.size[i] - text.size[i]) / 2 for i in range(2))
     self.canvas.add(Rectangle(size=text.size, pos=pos, texture=text))
     self.canvas.ask_update()
开发者ID:MartinLidy,项目名称:LSTM-GA-StockTrader,代码行数:10,代码来源:StockTrader_UI.py

示例8: draw_step

    def draw_step(self, x, y, c):
        self.canvas.add(Color(c[0], c[1], c[2]))
        self.canvas.add(Ellipse(pos = [self.cx[x] - self.d/2, self.cy[y] - self.d/2], size = [self.d, self.d]))
        self.canvas.add(Color(0., 0., 0.))
        self.canvas.add(Line(circle = (self.cx[x], self.cy[y], self.d/2)))

        label = CoreLabel(text="{0}".format(self.app.qsteps), font_size=14)
        label.refresh()
        text = label.texture
        self.canvas.add(Color(1 - c[0], 1- c[1], 1- c[2]))
        self.canvas.add(Rectangle(size=text.size, pos = [self.cx[x] - text.size[0]/2, self.cy[y] - text.size[1]/2], texture=text))
开发者ID:youryharchenko,项目名称:kivy-gomoku,代码行数:11,代码来源:gomoku.py

示例9: draw_text

def draw_text(wid, pos_x, pos_y, font_size, text):

    pos_y = invert_y(wid, pos_y)

    label = CoreLabel(text=text, font_size=font_size)
    label.refresh()
    texture = label.texture
    Color(1, 1, 1)
    Rectangle(pos=(pos_x, pos_y - texture.size[1]/2), size=texture.size)
    Color(0, 0, 0)
    Rectangle(texture=texture, pos=(pos_x, pos_y - texture.size[1]/2), size=texture.size)
开发者ID:mik403,项目名称:GTPTabViewer,代码行数:11,代码来源:core_draw_tool.py

示例10: _create_line_label

 def _create_line_label(self, text):
     # Create a label from a text, using line options
     ntext = text.replace('\n', '').replace('\t', ' ' * self.tab_width)
     kw = self._get_line_options()
     cid = '%s\0%s' % (ntext, str(kw))
     texture = Cache.get('textinput.label', cid)
     if not texture:
         label = Label(text=ntext, **kw)
         label.refresh()
         texture = label.texture
         Cache.append('textinput.label', cid, texture)
     return texture
开发者ID:jon1012,项目名称:kivy,代码行数:12,代码来源:textinput.py

示例11: _create_line_label

 def _create_line_label(self, text):
     # Create a label from a text, using line options
     ntext = text.replace("\n", "").replace("\t", " " * self.tab_width)
     kw = self._get_line_options()
     cid = "%s\0%s" % (ntext, str(kw))
     texture = Cache.get("textinput.label", cid)
     if not texture:
         label = Label(text=ntext, **kw)
         label.refresh()
         texture = label.texture
         Cache.append("textinput.label", cid, texture)
     return texture
开发者ID:alexleighton,项目名称:kivy,代码行数:12,代码来源:textinput.py

示例12: _get_texture_pos

 def _get_texture_pos(self, tick, index, succinct=True, which='time',
                      texture=None):
     tl = self.tickline
     # tick_info should be (x, y, width, height) of tick
     tick_info = self.registrar[tick][index]
     if not texture:
         label_kw = tick.get_label_texture(index, succinct, return_kw=True)
         if not label_kw:
             return
         label_kw['font_size'] = self.time_font_size if which == 'time' else \
                                   self.date_font_size
         label_kw['halign'] = 'left' if tl.is_vertical() else 'center'
         label = CoreLabel(**label_kw)
         label.refresh()
         texture = label.texture
     if tl.is_vertical():
         y = tick_info[1] + tick_info[3] / 2 - texture.height / 2
         if which == 'time':
             dist = self.time_dist_from_edge
         else:
             dist = self.date_dist_from_edge            
         dist = max(dist, tick.tick_size[1] + tl.tick_label_padding)
         halign = tick.halign
         if halign == 'left':
             x = tl.x + dist
         elif halign == 'line_left':
             x = tl.line_pos - dist - texture.width
         elif halign == 'line_right':
             x = tl.line_pos + dist
         else:
             x = tl.right - dist - texture.width
     else:
         # TODO horizontal is gonna get crowded with text
         x = tick_info[0] + tick_info[2] / 2 - texture.width / 2
         if which == 'time':
             dist = self.time_dist_from_edge
         else:
             dist = self.date_dist_from_edge
         dist = max(dist, tick.tick_size[1] + tl.tick_label_padding)
         valign = tick.valign
         if valign == 'top':
             y = tl.top - dist - texture.height
         elif valign == 'line_top':
             y = tl.line_pos + dist
         elif valign == 'line_bottom':
             y = tl.line_pos - dist - texture.height
         else:
             y = tl.y + dist       
     return (texture, [x, y])
开发者ID:kivy-garden,项目名称:garden.timeline,代码行数:49,代码来源:__init__.py

示例13: _create_label

 def _create_label(self):
     # create the core label class according to markup value
     if self._label is not None:
         cls = self._label.__class__
     else:
         cls = None
     markup = self.markup
     if (markup and cls is not CoreMarkupLabel) or (not markup and cls is not CoreLabel):
         # markup have change, we need to change our rendering method.
         d = Label._font_properties
         dkw = dict(list(zip(d, [getattr(self, x) for x in d])))
         if markup:
             self._label = CoreMarkupLabel(**dkw)
         else:
             self._label = CoreLabel(**dkw)
开发者ID:zeeMonkeez,项目名称:kivy,代码行数:15,代码来源:label.py

示例14: on_start

    def on_start(self):
        """ This is the start point of the kivy ui
        """
        win = Window
        win.bind(size=self.on_size, on_keyboard=self.on_keyboard)
        win.bind(on_key_down=self.on_key_down)

        # Register fonts without this you won't be able to use bold/italic...
        # inside markup.
        from kivy.core.text import Label

        Label.register(
            "Roboto",
            "data/fonts/Roboto.ttf",
            "data/fonts/Roboto.ttf",
            "data/fonts/Roboto-Bold.ttf",
            "data/fonts/Roboto-Bold.ttf",
        )

        if platform == "android":
            # bind to keyboard height so we can get the window contents to
            # behave the way we want when the keyboard appears.
            win.bind(keyboard_height=self.on_keyboard_height)

        self.on_size(win, win.size)
        config = self.electrum_config
        storage = WalletStorage(config.get_wallet_path())

        Logger.info("Electrum: Check for existing wallet")

        if storage.file_exists:
            wallet = Wallet(storage)
            action = wallet.get_action()
        else:
            action = "new"

        if action is not None:
            # start installation wizard
            Logger.debug("Electrum: Wallet not found. Launching install wizard")
            wizard = Factory.InstallWizard(config, self.network, storage)
            wizard.bind(on_wizard_complete=self.on_wizard_complete)
            wizard.run(action)
        else:
            wallet.start_threads(self.network)
            self.on_wizard_complete(None, wallet)

        self.on_resume()
开发者ID:gjhiggins,项目名称:electrum,代码行数:47,代码来源:main_window.py

示例15: _create_label

 def _create_label(self):
     # create the core label class according to markup value
     if self._label is not None:
         cls = self._label.__class__
     else:
         cls = None
     markup = self.markup
     if (markup and cls is not CoreMarkupLabel) or \
        (not markup and cls is not CoreLabel):
         # markup have change, we need to change our rendering method.
         d = Label._font_properties
         dkw = dict(zip(d, [getattr(self, x) for x in d]))
         # XXX font_size core provider compatibility
         if Label.font_size.get_format(self) == 'px':
             dkw['font_size'] *= 1.333
         if markup:
             self._label = CoreMarkupLabel(**dkw)
         else:
             self._label = CoreLabel(**dkw)
开发者ID:Ghopper21,项目名称:kivy,代码行数:19,代码来源:label.py


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