Reputation: 181
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"
Upvotes: 8
Views: 11215
Reputation: 16031
There are two methods to making label's text bold. They are as follow:
Use bold: True
Label:
bold: True
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
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()
Upvotes: 12
Reputation: 66
You may refer to the API here
Label:
text: 'blah blah'
bold: True
You may try adding color with the following tag:
color: [0.941, 0, 0,1]
That should show in red color. It uses the format as RGBA (A for Alpha/Opacity). You can use this tool to choose your color.
Upvotes: 1