1、首先在PyCharm软件中,打开一个Python项目。
2、在Python项目中,新建并打开一个空白的python文件(比如:test.py)。
3、在python文件编辑区中,输入:“import tkinter as tk”,导入 tkinter 模块。
4、输入:“overstrikeButton_win = tk.Tk()”,创建一个 tkinter 窗口。
5、插入语句:“overstrikeButton = tk.Button(overstrikeButton_win, text="overstrikeButton")”,放置一个tkinter按钮。
6、插入语句:“overstrikeButton.config(font=("宋体", 18, "overstrike"))”,使用属性“overstrike”为tkinter按钮文本添加删除线。
7、插入语句:“overstrikeButton.pack(side=tk.LEFT)”,设置按钮的布局。
8、继续输入:“overstrikeButton_win.mainloop()”,显示窗口。
9、在编辑区域点击鼠标右键,在弹出菜单中选择“运行”选项。
10、程序运行完毕后,可以看到已经成功地为tkinter按钮文本添加删除线。