元豪 发表于 2022-10-5 17:15:28

tk库将文本字体变成白色

本帖最后由 元豪 于 2022-10-5 20:38 编辑

如题

l = tk.Label(window, text='退出', bg='black', width=6, height=2)
l.pack()

将文本文字变成白色

而且我的tkinter库没有messagebox弹窗, 为什么?
代码:

def TuiChu():
    tk.messagebox.askquesion(title='退出', message='你确定要退出吗?')

b = tk.Button(window, text='退出', bg='black', fg='white', width=3, height=1, command=TuiChu())

临时号 发表于 2022-10-5 17:18:38

l = tk.Label(window, text='退出', bg='black', fg='white', width=6, height=2)
l.pack()

Twilight6 发表于 2022-10-5 17:19:37



fg 设置为 white 即可

zhangjinxuan 发表于 2022-10-5 18:03:36

#2 #3正解

元豪 发表于 2022-10-5 19:20:09

临时号 发表于 2022-10-5 17:18


那设置大小呢?

元豪 发表于 2022-10-5 19:20:53

zhangjinxuan 发表于 2022-10-5 18:03
#2 #3正解

你的头像
什么叫WA了此题?

柿子饼同学 发表于 2022-10-5 20:13:11

元豪 发表于 2022-10-5 19:20
你的头像
什么叫WA了此题?

WA 是 Wonderful Answer 的意思
即优美的答案

元豪 发表于 2022-10-5 20:40:06

Twilight6 发表于 2022-10-5 17:19
fg 设置为 white 即可

修改了一下, 接着问, 求大佬回答{:10_254:}

Twilight6 发表于 2022-10-5 20:47:01

元豪 发表于 2022-10-5 20:40
修改了一下, 接着问, 求大佬回答



加上这个参数 font=("微软雅黑", 25) 字体名称和大小可以自己设置

你可以来这篇文章看详细的参数:https://fishc.com.cn/forum.php?mod=viewthread&tid=59087&extra=page%3D1%26filter%3Dtypeid%26typeid%3D604

元豪 发表于 2022-10-6 07:21:17

Twilight6 发表于 2022-10-5 20:47
加上这个参数 font=("微软雅黑", 25) 字体名称和大小可以自己设置

你可以来这篇文章看详细的参数 ...

tkinter库有没有弹窗方法呢?

Twilight6 发表于 2022-10-6 07:47:56

元豪 发表于 2022-10-6 07:21
tkinter库有没有弹窗方法呢?



tkinter 的 messagebox 就是弹窗类的,参考帖子:https://fishc.com.cn/forum.php?mod=viewthread&tid=61678&extra=page%3D1%26filter%3Dtypeid%26typeid%3D604

zhangjinxuan 发表于 2022-10-6 08:06:29

元豪 发表于 2022-10-5 19:20
你的头像
什么叫WA了此题?

好玩吖{:10_256:}

zhangjinxuan 发表于 2022-10-6 08:07:19

柿子饼同学 发表于 2022-10-5 20:13
WA 是 Wonderful Answer 的意思
即优美的答案

我很赞同!【哭笑不得】

zhangjinxuan 发表于 2022-10-6 08:15:34

元豪 发表于 2022-10-5 19:20
你的头像
什么叫WA了此题?

WA其实是Wrong Answer,(柿子同学要把我笑死),意思是错误答案

对应的是AC,是Accepted,意思是通过、正确

OJ中经常遇到的除了WA,AC还有TLE(超时),MLE(内存超了),RE(运行时错误),CE(编译错误),
OLE(输出超过上限,不常见),PE(格式错误,输出格式不对),SE(系统错误,遇到请和老师说一声)....

原本我的头像是 你通过了此题,恭喜! 但是我这个人有点手欠,就.....

你WA了此题!
   恭喜!
页: [1]
查看完整版本: tk库将文本字体变成白色