gpt4 book ai didi

python - TKinter 中的阿拉伯语文本

转载 作者:行者123 更新时间:2023-11-28 16:24:09 25 4
gpt4 key购买 nike

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

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()

我想用阿拉伯语句子替换消息“主界面已关闭,请联系您的管理员”。

有人可以帮忙吗?

最佳答案

您只需将编码设置为 UTF-8,方法是将此行设置为 Python 文件中的第一行(在您的代码之前):# - *- 编码: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()

关于python - TKinter 中的阿拉伯语文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37964605/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com