特金特。当我输入非英语时,文本小部件有点奇怪

2024-09-24 00:25:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在申请聊天。制造了这么多零件

当我做输入文本的一部分时,我遇到了一个问题

enter image description here

你能看出区别吗?此问题仅出现在非英语字母中。这个问题不妨碍聊天。但为了完善程序,我想解决这个问题

代码在这里

class chat(tk.Toplevel):
    def __init__(self,parent,*args,**kw):
        tk.Toplevel.__init__(self,parent,*args,**kw)
        self.iconbitmap(default=r"./img/favicon.ico")
        self.parent = parent
        self.title("TEMP")
        self.geometry("400x500+%s+%s"%(str(int(int(self.winfo_screenwidth())/2)+rd.randrange(1,200)),str(int(int(self.winfo_screenmmheight() )/2)+rd.randrange(1,200))))

        self.top = tk.Frame(self,bg=ToRGB((220,220,220)),height = 80,bd=0)
        self.top.pack(side='top',fill='x')

        self.chatFrame = List(self)
        self.chatFrame.pack(side='top',fill='both',expand = True)
        self.chatFrame.canvas.configure(bg = ToRGB((220,220,220)))
        self.chatFrame.interior.config(bg = ToRGB((220,220,220)))

        self.inputFrame = tk.Frame(self,bg='white')
        self.inputFrame.pack(fill='x',side= 'top')

        self.inputText = tk.Text(self.inputFrame,height = 5,bd = 0,font=("맑은 고딕",11))
        self.inputText.pack(fill='both',anchor='c',padx = 5, pady = 5)

root = tk.Tk()
root.iconify()
app = chat(root)
root.mainloop()

[问题2]

enter image description here


Tags: selftopchatrootfillsidepacktk
1条回答
网友
1楼 · 发布于 2024-09-24 00:25:38

我解决了这个问题。捕获系统默认字体

您可以在Tkinter中使用多种字体。它可以检查下面的代码

# Python 3.8
from tkinter import Tk, font
root = Tk()
a = font.families()
print(a)

并检查您的计算机默认字体

这个问题只发生在韩国。我查不到其他语言。但也许会发生

谢谢你的帖子人评论

但[问题2]并没有得到解决。如果我解决了问题。我也发帖

相关问题 更多 >