I am using Popup
widgets in python-2.7
and kivy
.Can someone help me?
1. How to make label bold ? (ex. text: "make label bold"
)
2. How to change color of title ? (ex. title : "change title color"
)
from kivy.app import App
from kivy.core.window import Window
from kivy.uix.popup import Popup
class abc(Popup):
def __init__(self, **kwargs):
super(abc, self).__init__(**kwargs)
self.open()
class TestApp(App):
def build(self):
return abc()
TestApp().run()
<abc>
title : "change title color"
BoxLayout:
orientation: "vertical"
GridLayout:
Label:
text: "make label bold"
There are two methods to making label's text bold. They are as follow:
Use bold: True
Label:
bold: True
Label » bold
bold
Indicates use of the bold version of your font.
Note
Depending of your font, the bold attribute may have no impact on your text rendering.
bold is a BooleanProperty and defaults to False.
Use Markup text, markup: True
Label:
markup: True
text: '[b]make label bold[/b]
Use title_color
<abc>
title : "change title color"
title_color: [1, 0, 0, 1] # red title
Popup » title_color
title_color
Color used by the Title.
title_color is a ListProperty and defaults to [1, 1, 1, 1].
from kivy.app import App
from kivy.uix.popup import Popup
from kivy.uix.button import Button
from kivy.lang import Builder
Builder.load_string('''
#:kivy 1.11.0
<abc>
title : "change title color"
title_color: 1, 0, 0, 1 # red title
BoxLayout:
orientation: "vertical"
GridLayout:
cols: 1
Label:
bold: True
text: "make label bold"
Label:
markup: True
text: "[b]make label bold[/b]"
''')
class abc(Popup):
pass
class PopupApp(App):
title = 'Popup Demo'
def build(self):
self._popup = abc()
return Button(text="press me", on_press=self._popup.open)
PopupApp().run()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With