Kivy isn't showing (Bengali) Unicode character properly - python

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.

Related

When converting kivy file (.py) to apk, widgets are not automatically adjusting to device's window size

I am trying to develop an andriod app using Kivy. I have used floatLayout to place the widgets. The output, when I run it on my linux is:
Output in linux
Then after converting it to apk, the widgets are getting compresed and texts flow out of widget and looking shabby :
output on android
my code :
code
code
how can I make the widgets get adjusted automatically to the size of device(in my case Andriod). So that the texts doesnt flow outside the buttons and looks systamatic as it is in linux.
First of all, you have to check your kivy app in correct resolutions.So run in cmd : python main.py --size=1440x2960 (phone device screensize opt.You can scale input sizes for your computer screen. Divide by 2/3/4/5..) So you can reedit your code after check in correct resolution.
Also you need to use metrics for your font sizes.Example: font_size: '20sp' . Use sp metrics for scale your fonts for all devices automaticly. Check here for Kivy Metrics Docu.

Robotframework RIDE: text in Edit panel is not markable

Settings:
Windows 10. Python 2.7
different versions of RIDE: from 1.1 up to 1.5.2.1.
wxpython different versions from 2.8 up to latest.
When I double click any text in "Edit" panel and try to mark it by holding the left mouse key and moving mouse, nothing happens: the cursor does move but the color of text doesn't change.
In the 'text edit' panel everything's fine, any text can be selected/marked properly, the problem is only with the 'Edit' panel.
I have the same version of python, ride, wxpython on Windows 7 and text marking
is normal there.
Has anybody encountered such problem?
Maybe it's some kind of incompatibility with Windows 10?
I've had the same issue back when I was using RIDE. One thing you should know is, even though you don't actually see the text being selected, it is selected. In other words, if you do a CTRL+C, it will effectively copy the text you selected, you just don't visually see it being selected.
As for what causes this exactly, I'm not sure but I wouldn't bother searching too much either. RIDE really has a lot of annoying bugs like this one, and with last commit being 2 years ago, I'd say it's not maintained anymore.
You might wanna switch to raw test data editing (equivalent of text edit in RIDE) using a modern IDE like Pycharm or any other good IDE you like that offers Robot Framework test data editing, or perhaps you could try out RED, which is kind of an upgraded RIDE.

Python Kivy - underline not working in label

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.

Kivy execution error

Iam trying to run a simple sample code of Hello World which is as follows:
import kivy
kivy.require('1.8.0') # replace with your current kivy version !
from kivy.app import App
from kivy.uix.button import Button
class MyApp(App):
def build(self):
return Button(text='Hello World')
if __name__ == '__main__':
MyApp().run()
and i have saved this as hello.py which then i run by using kivy-1.8.0 which in turn gives me an error message titled Kivy Fatal Error and the rest of the description is in Chinese,Japanese or Korean language.
Is there a problem of graphics card? or
Is there any other way to a Kivy application
please help.
Please post the full terminal output from when the app is run.
I don't remember what the funny character message means (it's nonsense, not real text), but I think it indicates a too-low opengl version. The appearance of the garbled message is itself a bug that I think is fixed in kivy master.
Possible issues with kivy (and python):
Indentation issues: make doubly sure that your indents are consistent: they should all be the same. If you are using a tab, make sure it is a tab everywhere. If you are using multiple spaces make sure they are the same number everywhere.
A more kivy specific issue: try to comment out line 2 (kivy.require('1.8.0')). You may not have the correct version of kivy installed. Alternatively, decrease that number (1.0.6 should be more than enough for what you are doing in this simple application).
I don't know what the issue could be with the language you get the message in. Perhaps you installed some weird distribution, or selected some language pack that it is defaulting to.

Python widget/cursor detection?

Beginner python learner here. I have a question that I have tried to Google but I just can't come up with the proper way to ask in just a few words (partly because I don't know the right terminology.)
How do I get python to detect other widgets? For example, if I wanted a script to check and see when I click my mouse if that click put focus on an entry widget on a (for example) website. I've been trying to get it to work in Tkinter and I can't figure out even where to begin.
I've seen this:
focus_displayof(self)
Return the widget which has currently the focus on the
display where this widget is located.
But the return value for that function seems to be some ambiguous long number I can't decipher, plus it only works in its own application.
Any direction would be much appreciated. :)
Do you mean inside your own GUI code, or some other application's/website's?
Sounds like you're looking for a GUI driver, or GUI test/automation driver. There are tons of these, some great, some awful, many abandoned. If you tell us more about what you want that will help narrow down the choices.
Is this for testing, or automation, or are you going to drive the mouse and button yourself and just want something to observe what is going on under the hood in the GUI?
>How do I get Python to detect other widgets?
On a machine, or in a browser? If in a machine, which platform: Linux/Windows (which)/Mac?
If in a browser, which browser (and major version)?
> But the return value for that function seems to be some ambiguous long number I can't decipher
Using longs as resource handles is par for the course, although good GUI drivers also work with string/regex matching on window and button names.
> plus it only works in its own application.
What do you mean, and what are you expecting it to return you? You should be able to look up that GUI object and access its title. Look for a GUI driver that works with window and button names.
Here is one list, read it through and see what sounds useful. I have used AutoIt under Win32, it's great, widely-used and actively-maintained; it can be called from Python (via subprocess).
Here are comparisons by the author of PyWinAuto on his and similar tools. Give a read to his criticisms of its structure from 2010. If none of these is what you want, at least you now have the vocabulary to tell us what would be...

Categories

Resources