TKinter 中的阿拉伯语文本 [英] Arabic text in TKinter

查看:45
本文介绍了TKinter 中的阿拉伯语文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个带有文本的窗口.我想在文本中使用阿拉伯语:

I am creating a window with text. I would like to use Arabic language in the text:

root = Tk()
root.title('Alram')
root.geometry("1500x600")
msg = Message(root, bg="red", text='The main interface is down, please contact your administrator')
msg.config(font=('times', 72, 'bold'))
exit_button = Button(root, width=10, text='Exit', command=root.destroy)
exit_button.pack()
msg.pack(fill=X)
root.mainloop()

我想将消息主界面关闭,请与您的管理员联系"替换为阿拉伯语.

I would like to replace the message "The main interface is down, please contact your administrator" with Arabic sentence.

有人可以帮忙吗?

推荐答案

您只需将此行设置为第一行,将编码设置为 UTF-8 (在你的代码之前)在你的 Python 文件中:# -*- coding: UTF-8 -*-

You simply need to set your encoding to UTF-8 by making this line the first one (before your code) in your Python file: # -*- coding: UTF-8 -*-

这是一个代码示例:

# -*- coding: UTF-8 -*-
from Tkinter import *
root = Tk()
root.title('Alram')
root.geometry("1500x600")
mytext= 'ذكرت تقارير' #Arabic text
msg = Message(root, bg="red", text= mytext, justify='right')
msg.config(font=('times', 72, 'bold'))
exit_button = Button(root, width=10, text='Exit', command=root.destroy)
exit_button.pack()
msg.pack(fill=X)
root.mainloop()

这篇关于TKinter 中的阿拉伯语文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆