I know this question has been asked before (Underline text in a Label in Kivy?) and it is quite an old question but I was really wondering if there is a way to underline text in label's in Kivy?
The only suggested solution I've found online is using a python script extended_markup.py. But this does not work and is riddled with problems due to updates in Kivy.
I've tried messing around myself but underline even seems to be removed from markup in the kivy source code...even though the documentation talks about underline!
Any help would be appreciated.
This functionality has been added in the development version of Kivy 1.9.2-dev. The instructions to update to the development version vary by platform: https://kivy.org/docs/installation/installation.html
You can set underline on a Label widget to underline the text:
Label:
text: 'underline this!'
underline: True
You can also use markup:
Label:
text: 'underline [u]this![/u]'
markup: True
However, underline is not supported by all text providers. In particular, the SDL2 text provider does support it while the pygame and PIL providers do not.
Related
Currently I am Working on a Kivy desktop application but I am facing a problem while trying to display unicode characters in Bengali in my application's Label and Button Text. Every time I'm getting output like the image below. I have tried different fonts such as SolaimanLipi.ttf, kalpurush.ttf, NikoshBAN.ttf but still no luck. I am using a Windows PC. The same text in the same font displays correctly outside of Kivy; it works fine in all text editors and to make sure I have tested in a Java Swing desktop application, too.
Can any one please describe what is the problem? What can i do to solve it?
Expected Output:
Program Output:
#-- coding: utf-8 --
from kivy.base import runTouchApp
from kivy.lang import Builder
runTouchApp(Builder.load_string("""
#:import sp kivy.metrics.sp
Label:
text: 'সকালে'
font_size: sp(50)
font_name: "SolaimanLipi.ttf"
"""))
There is a bug in Kivy which has been open since 2014 (!) - https://github.com/kivy/kivy/issues/2669
To the extent that I can understand the discussion and the current status, the developer is looking for a solution still.
Languages such as Tamil require reshaping, a process which is not supported in our current providers. I'm working on a new text provider using Pango as an option to provide this support on Linux (and probably OSX).
-- kived in 2014
This (from 2017) seems relevant, too, but also vaguely stale: https://github.com/kivy/kivy/issues/4902
Unicode text can be converted to Bijoy (ANSI) text and can be used easily in Kivy with the use of [font] tag like this:
text = "[font=font/SutonnyMJ]Avwg evsjvq K_v ewj[/font] means I speak Bangla"
This repo provides code and instructions related to Unicode to Bijoy (ANSI) conversion in Kivy. Not a perfect solution, but most of the apps will meet their need.
I've beeing coding applications for years using C# and Delphi. And one of the greatest things of those languages, in my opinion, was how easy it was to code the interface - you could grab the buttons, make the rectangles and etc, all using the mouse, dragging the squares.
Now I'm interested in Kivy, using Python. Can I construct the desktop interface just like Delphi, using the mouse and making the layout easily, or is the interface made only through coding?
Thanks for the patience, guys.
If you want to use kivy I suggest that you learn Kv Language which is a simple language to design the UI for kivy.
.kv file example:
<MyWidget>:
label_widget: label_widget
Button:
text: 'Add Button'
on_press: root.add_widget(label_widget)
Button:
text: 'Remove Button'
on_press: root.remove_widget(label_widget)
Label:
id: label_widget
text: 'widget'
There is however a Kivy Designer which you can use to design the UI but it is still at alpha stage and not perfect yet.
WARNING: This project is at an unstable alpha stage and is not yet
suitable for general use. Contributions are welcome.
Kivy Designer is Kivy's tool for designing graphical user interfaces
(GUIs) from Kivy Widgets. You can compose and customize widgets, and
test them. It is completely written in Python using Kivy.
So if it doesn't do what you want, you can create a simple UI and have a look at the generated code so you get an idea of how the UI is written in python.
I want to be able to open the bubble with a button click.
I am kind of new to kivy.
Here's the code in the kivy file:
Button:
bubble:bubble.__self__
text:"Home"
on_release:self.show_bubble
Bubble:
id:bubble
size_hint: (None, None)
size: (150, 50)
pos_hint: {'x': 1, 'y': 1.7}
arrow_pos: 'bottom_mid'
orientation: 'horizontal'
BubbleButton:
text: "This is"
BubbleButton:
text: "a"
BubbleButton:
text: "Bubble"
Could anyone help?
Thanks.
You should follow the example shown here:
https://kivy.org/docs/api-kivy.uix.bubble.html
i.e. put the Bubble in a separate FloatLayout (for example) instead of inside the triggering Button
I have worked in KIVY for mobile-based application development. But let me tell you its quite a pain. If you just want to make interactive python programs that are not mobile based I think you should start with the Tkinter module.
KIVY is really ugly. I suggest porting to JAVA for mobile application development simply because it was born to do that.
We have a long way till everyone starts using python for mobile apps.
I'm just learning Python and the Kivy framework. I can't seem to find any specific complete examples of being able to gracefully exit a Kivy app using code linked to a button.
I have found Kivy code snippets like this
Button:
id:btnExit
text:"Exit"
on_press: app.Exit()
But not any matching code that implements the app.Exit() call. Everything I've tried stops code execution but doesn't clean up the program window.
I've read that Android and iOS style guides state that a program is not to programmatically exit and let the OS handle it but I am developing fullscreen borderless Desktop app and need a way to exit the program with a button press.
Use App.stop(*largs):
Button:
id: btnExit
text: "Exit"
on_press: app.stop()
Try using App.get_running_app().stop().
For more details, read the Kivy documentation article for the function.
Try using self.root_window.close().
There is bug in new android toolchain.
I used
on_press : app.stop()
in Button's property in Kivy Layout File and it worked well for me.
Hej
I like to customize the On/Off Switch in kivy. For a Button I know how to do it. The kv code looks like this:
Button:
background_normal: 'gfx/offButton.png'
background_down: 'gfx/onButton.png'
Now I whant to know it for the Switch widget. Any Ideas?
The switch does not have properties to control this. Maybe it should, but it also has more behaviour than just on/off since you can drag the slider.
If you just want an active/inactive choice, you could use a CheckBox (which does have background image properties).