D:\python\lib\tkinter\__init__.py:839: UserWarning: Glyph 25439 (\N{CJK UNIFIED IDEOGRAPH-635F}) missing from current font. func(*args)
时间: 2023-09-18 21:14:28 浏览: 149
这个 UserWarning 是因为当前字体中缺少一个中文字符 \N{CJK UNIFIED IDEOGRAPH-635F},它的 Unicode 编码为 25439。你可以忽略这个警告,也可以尝试更换一个包含该字符的字体来解决警告。你可以使用以下代码来更换字体:
```python
import tkinter as tk
from tkinter import font
root = tk.Tk()
# 使用系统字体
default_font = font.nametofont("TkDefaultFont")
default_font.configure(family="Arial", size=12)
# 新建一个 Label 来测试字体是否更换成功
label = tk.Label(root, text="测试字体")
label.pack()
root.mainloop()
```
在上面的代码中,我们使用 `font.nametofont()` 方法获取默认字体,然后使用 `configure()` 方法更改字体的属性。最后,我们新建了一个 Label 来测试字体是否更换成功。你可以更改 `family` 和 `size` 属性来更换不同的字体和大小。
相关问题
/usr/lib/python3.10/tkinter/__init__.py:839: UserWarning: Glyph 20154 (\N{CJK UNIFIED IDEOGRAPH-4EBA}) missing from current font. func(*args) /usr/lib/python3.10/tkinter/__init__.py:839: UserWarning: Glyph 35780 (\N{CJK UNIFIED IDEOGRAPH-8BC4}) missing from current font. func(*args) /usr/lib/python3.10/tkinter/__init__.py:839: UserWarning: Glyph 20215 (\N{CJK UNIFIED IDEOGRAPH-4EF7}) missing from current font. func(*args)
这个警告是因为在当前字体中找不到指定的中文字符,分别是“人”、“评”和“货”字。这可能会导致在使用这些字符时无法正确显示,但一般情况下不会影响程序的功能。
你可以尝试更换字体,或者在代码中指定字体来解决这个问题。比如,在创建应用程序的时候,可以通过设置`font`参数来指定字体:
```python
import tkinter as tk
root = tk.Tk()
label = tk.Label(root, text="你好,世界!", font=("Arial", 12))
label.pack()
root.mainloop()
```
这里将标签的字体设置为Arial,大小为12。你可以根据需要选择其他字体和大小。
/usr/lib/python3.10/tkinter/__init__.py:839: UserWarning: Glyph 35780 (\N{CJK UNIFIED IDEOGRAPH-8BC4}) missing from current font. func(*args) /usr/lib/python3.10/tkinter/__init__.py:839: UserWarning: Glyph 20215 (\N{CJK UNIFIED IDEOGRAPH-4EF7}) missing from current font. func(*args)
这个警告是因为在当前字体中找不到指定的中文字符,分别是“评”和“货”字。这可能会导致在使用这些字符时无法正确显示,但一般情况下不会影响程序的功能。
你可以尝试更换字体,或者在代码中指定字体来解决这个问题。比如,在创建应用程序的时候,可以通过设置`font`参数来指定字体:
```python
import tkinter as tk
root = tk.Tk()
label = tk.Label(root, text="你好,世界!", font=("Arial", 12))
label.pack()
root.mainloop()
```
这里将标签的字体设置为Arial,大小为12。你可以根据需要选择其他字体和大小。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)