I want to use unicode symbols for text in buttons, but kivy does'not want to show it.
Like this:
self.add_widget(KeyboardButtonOthers(text = u'\u232B', size_hint = (1/7, 0.2)))
#Here I use Sans font
Or this:
<MainButton@Button>:
text: '⌂ Exit'
#Here I use default Roboto kivy font
In both cases nothing works. Instead normal symbols I getting this: Sans font
And this: Roboto font
I work under Windows, but I plan to install the project on Linux. Maybe they will work on Linux and this is a Windows problem? Thanks for help.
#########################
I found a good solution for my case without using unicode symbols. If you need something like this you can try this:
Builder.load_string("""
<KeyboardButtonBackspace@Button>:
background_color: (0, 0, 0, 0)
canvas.before:
Color:
rgba: (166/255, 166/255, 166/255, 1) if self.state == 'normal' else (80/255, 80/255, 80/255, 1)
RoundedRectangle:
pos: self.pos
size: self.size
radius: [5]
Image:
source: 'images/clear2.png'
size: self.parent.size
y: self.parent.y
x: self.parent.x
allow_stretch: True
""")
Clear2 is vector icon from here https://icons8.com/icons/set/clear
Unicode text can only display characters that are available in the font.
from kivy.app import App
from kivy.lang.builder import Builder
KV = """
Screen:
BoxLayout:
Label:
text: u'\u00A9 ' + chr(97)
Button:
text: u'\u00B6 ' + chr(100)
"""
class MyApp(App):
def build(self):
return Builder.load_string(KV)
if __name__ == '__main__':
MyApp().run()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.