tkinter 条目和从右到左光标

use*_*054 5 python tkinter python-2.7 python-3.x

我正在尝试使用 tkinter 创建一个使用阿拉伯语的应用程序。问题是光标的方向总是从左到右,这让用户在选择(突出显示)条目内的阿拉伯文本时感到困惑(所选文本的字母位置颠倒了)。

在此处输入图片说明

小智 1

我认为你必须检查Tkinter.py的代码,看看是否可以调整它(但就像创建扩展而不是覆盖代码),也许如果你看到你可以对这些行做一些事情:

def get(self):
    """Return the text."""
    return self.tk.call(self._w, 'get')
def icursor(self, index):
    """Insert cursor at INDEX."""
    self.tk.call(self._w, 'icursor', index)
def index(self, index):
    """Return position of cursor."""
    return getint(self.tk.call(
        self._w, 'index', index))
def insert(self, index, string):
    """Insert STRING at INDEX."""
    self.tk.call(self._w, 'insert', index, string)
def scan_mark(self, x):
    """Remember the current X, Y coordinates."""
    self.tk.call(self._w, 'scan', 'mark', x)
Run Code Online (Sandbox Code Playgroud)

前面的所有行都在 Entry 类中:

class Entry(Widget, XView):
    """Entry widget which allows to display simple text."""
Run Code Online (Sandbox Code Playgroud)

我没有关于用 Python 编写阿拉伯语的支持的参考资料,但这并不意味着它不存在,也许有一些 dll 或插件等待被发现。