PySimpleGUI / PySimpleGUI

Python GUIs for Humans! PySimpleGUI is the top-rated Python application development environment. Launched in 2018 and actively developed, maintained, and supported in 2024. Transforms tkinter, Qt, WxPython, and Remi into a simple, intuitive, and fun experience for both hobbyists and expert users.
https://www.PySimpleGUI.com
Other
13.37k stars 1.84k forks source link

[ Enhancement ] Support for Unicode Bi-Directional (BiDi) Languages #4026

Open mguttman opened 3 years ago

mguttman commented 3 years ago

Type of Issues (Enhancement)

Operating System (all)

Python version (any)

PySimpleGUI Port and Version Next one :-) ???

Ports = tkinter, Qt, WxPython, Web (all)

PySimpleGUI Version: Next???

tkinter version: (Not sure)

You can get these by adding this to the top of your file and running it:

import PySimpleGUI as sg

print(sg)             # Location of your PySimpleGUI.py file
print(sg.version)     # PySimpleGUI version number
print(sg.tclversion_detailed)   # tkinter detailed version number (in PySimpleGUI version 4.29.0+)
print(sg.sys.version) # Python version number

The tkinter version number can be obtained using above code in version 4.29.0+. If your code is prior:

print(sg.tkinter.Tcl().eval('info patchlevel'))

Your Experience Levels In Months or Years

2 years of Python programming experience 30+ years of Programming experience overall One GUI Have used another Python GUI Framework (tkinter, Qt, etc) previously (yes/no is fine)?

You have completed these steps:

Description of Problem / Question / Details

Unicode Right-To-Left (RTL) languages such as Arabic and Hebrew are not supported. Hebrew text for example is displayed LTR and is unreadable. Please compare the Hebrew text in the demo code (It is displayed correctly, at least in the Firefox browser!) to the resulting display in the tiny GUI.

Code To Duplicate

import PySimpleGUI as sg

layout = [[sg.Text('זה טקסט בעברית:',size=(40,1))],]

window = sg.Window('Hebrew Text entered RTL', layout, grab_anywhere=False)

while True:
    action, values = window.read()
    print (action, '\n', values)
    if action in (None, 'Exit'):
        break

window.close()
PySimpleGUI commented 3 years ago

Can this not be done by the user? It would be helpful to understand at a detailed level what this means, on an element by element basis. I have no idea what it means and if there are workarounds available. I assume that a user can create any text they want in any dirrection they want. It may not flow the same way, but it should be possible to create the desired window.

mguttman commented 3 years ago

The problem is not in the sg.Text fields. There one (the programmer) could enter it in reverse, from the end to the beginning of the string. The problem is in the text entry fields. I will never convince the user to enter text in reverse. Try it in English... The Unicode consortium does provide a BiDi algorithm, see Unicode® Standard Annex #9 . The Microsoft Visual Studio Code editor supports BiDi quite decently. Isn't this editor open source? Also the firefox browser support BiDi. This one is also open source, isn't it?

PySimpleGUI commented 3 years ago

OK. Leave things as they are then. Sounds like a bigger thing than can be described by you in a request.

PySimpleGUI commented 3 years ago

This is a duplicate by the way. It was asked for a number of times. I'll eventually go find them and list them here or close it and list it there.

mguttman commented 3 years ago

Yes you are right! And one of the requests was by me two years ago and I completely forgot about it... :-(

PySimpleGUI commented 3 years ago

It's great you're advocating for a feature that will benefit a lot of people. It's a good thing. I appreciate you taking the time to fill in an Enhancement request, twice, for it. Means it really means a lot to you... also means that the PySimpleGUI project has not yet been able to take action.

The reason I was asking for specifics was to see if there can be a phased approach. Can it be one or two things at a time, or does it have to be a massive feature done all at once?

Like everything submitted as an Issue, It goes through a prioritization process and put onto a roadmap. At the moment, resources are scarce, to say the least. When I look at Enhancement Request in particular, these are some of the questions I ask as I look at a request:

Out of those comes a basic priority or category. Is it going to happen this week, month, year? How does it fit into the rest of the development happening with PySimpleGUI?

I don't know if making that process more transparent is helpful or not. Hopefully it's helpful to explicitly state my process for all Issues, bugs and enhancements.

mguttman commented 3 years ago

Dear PySimpleGUI,

Well, I can't answer all but may be one of the questions you listed. The one is "How many are impacted?"

Arabic speaking people count about 400 millions, but GUI users might not be many of them. Hebrew speaking people are a meager 6 or at most 10 millions. However, many of them are potential GUI users.

Another question is do the underlying GUI elements, tkinter and the like, support Bi-Di languages? If these do not, is there any hope that BiDi support could be added on top of it, at the PySimpleGUI layer?

PySimpleGUI commented 3 years ago

I would like to support screen readers and a whole host of features like bi-directional language that makes the tent larger.

I'm suggesting that rather than wait for PySimpleGUI to do this, that you look at how to use what's available to you today to achieve the desired result. It's why I asked about individual elements and the basic requirements. You're going to find success in this approach much quicker than waiting for me to add it to PySimpleGUI.

Jason did a series of demos that showed how to do some of these operations using a Graph Element from what I can recall.

It could be that WxPython or Qt provides support for this and so that's the better route than the tkinter port of PySimpleGUI.

mguttman commented 3 years ago

Doing something like BiDi support on my own is way over my skill level I am afraid... However, to nudge BiDi a little up the priority ladder, here are some resources that might make the job a little easier:

The author of the Python-BiDi package is an acquaintance of mine and both of us will be more than happy to serve as alpha testers

Food for thought!

PySimpleGUI commented 3 years ago

Thank you for the additional information. When this feature makes its way towards the top of the list, then I'll certainly look through this information to see how much can be leveraged.

mguttman commented 3 years ago

I hate to discourage you, but here is a funny and easy to understand article on the intricacies of the BiDi issue: The twisted road through right-to-left language support

and BTW, on Windows 10, BiDi is supported "right out-of-the-box" without changing anything in PySimpleGUI! Meir

PySimpleGUI commented 3 years ago

You're not disappointing me. I need to leave this issue alone for a while. As I've explained, when it gets near the top of the priority list, then I'll be able to give it attention. I appreciate you're passionate about this feature. I think I've done what I can to explain where we are at the moment. Maybe look at working with some other GUI packages in the meantime if it's a pressing issue for you.

PySimpleGUI commented 3 years ago

Hi there! I'm looking into support for bi-directional in Qt. We may be able to do it much sooner than I thought.

I need to get the PySimpleGUIQt port completed since it's being heavily reworked right now. After it's released, the reword version, which will be soon, it maybe be very quickly that we can do this bi-directional text :-)

mguttman commented 3 years ago

Hi there Thank you! Glad to hear that and very much appreciated! And of course, you can count on me for Alpha and Beta testing Meir Guttman Cell. +972-54-526 2264

On Fri, Mar 26, 2021 at 4:23 PM PySimpleGUI @.***> wrote:

Hi there! I'm looking into support for bi-directional in Qt. We may be able to do it much sooner than I thought.

I need to get the PySimpleGUIQt port completed since it's being heavily reworked right now. After it's released, the reword version, which will be soon, it maybe be very quickly that we can do this bi-directional text :-)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/PySimpleGUI/PySimpleGUI/issues/4026#issuecomment-808211975, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKAHTLAKX2BUO3QB45JHTLTFSDGZANCNFSM4Y4HA2SQ .

PySimpleGUI commented 3 years ago

https://github.com/PySimpleGUI/PySimpleGUI/issues/4136

I don't know if the techniques that are being discussed in this issue may be of help to you, but it seems like what they are suggesting may apply and lead to results you are after.

mguttman commented 3 years ago

See my comment on that Issue

zamantech commented 1 year ago

any update? photo_5377484546095825948_x https://stackoverflow.com/questions/47249474/hebrew-with-tkinter-bidi https://stackoverflow.com/questions/4150053/python-tkinter-using-tkinter-for-rtl-right-to-left-languages-like-arabic-hebr https://forums.raspberrypi.com/viewtopic.php?t=266671 https://stackoverflow.com/questions/41905458/tkinter-label-with-arabic-text/41922710#41922710 https://stackoverflow.com/questions/37964605/arabic-text-in-tkinter https://stackoverflow.com/questions/66283291/use-arabic-text-with-tkinter https://stackoverflow.com/questions/41905458/tkinter-label-with-arabic-text

zamantech commented 1 year ago

https://github.com/biblepix/TkBidi

zamantech commented 1 year ago

https://github.com/mpcabd/python-arabic-reshaper

jul commented 5 months ago

I guess everyone pinpointed TkInter => Tk as the culprit.

Then I guess it should be nice to make python core team aware that Tk9.0 that should solve the issue (beta release).

I would put the ticket on hold until tk9 is integrated in tkinter :D

https://www.tcl.tk/software/tcltk/9.0.html