鱼C论坛

 找回密码
 立即注册
查看: 5725|回复: 6

tkinter怎么设置窗口标题颜色?

[复制链接]
发表于 2021-6-18 15:05:13 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 lengyue869 于 2021-6-21 21:03 编辑

RT....
20210618150317.png
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-6-18 15:54:28 | 显示全部楼层


Tkinter 不支持自定义标题栏吧,因为他是调用系统来绘制的

小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-6-18 16:02:06 | 显示全部楼层
Twilight6 发表于 2021-6-18 15:54
Tkinter 不支持自定义标题栏吧,因为他是调用系统来绘制的

小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-6-18 16:17:38 | 显示全部楼层
网上搜了一个不显示原有标题栏,然后重新写了一个frame做标题栏的....
  1. from tkinter import *

  2. root = Tk()


  3. def motion(event):
  4.     print(event.x, event.y, event.x_root, event.y_root)


  5. def move_window(event):
  6.     root.geometry('+{0}+{1}'.format(event.x_root, event.y_root))


  7. root.overrideredirect(True)  # turns off title bar, geometry
  8. root.geometry('400x100+200+200')  # set new geometry
  9. root.update()

  10. # make a frame for the title bar
  11. title_bar = Frame(root, bg='gray', relief='raised', bd=2)

  12. # put a close button on the title bar
  13. close_button = Button(title_bar, text='X', bg='gray', command=root.destroy)

  14. # a canvas for the main area of the window
  15. window = Canvas(root)

  16. # pack the widgets
  17. title_bar.pack(expand=1, fill=X)
  18. close_button.pack(side=RIGHT)
  19. window.pack(expand=1, fill=BOTH)

  20. # bind title bar motion to the move window function
  21. title_bar.bind('<B1-Motion>', move_window)
  22. root.bind('<Motion>', motion)

  23. root.mainloop()
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-6-18 16:31:40 | 显示全部楼层
lengyue869 发表于 2021-6-18 16:17
网上搜了一个不显示原有标题栏,然后重新写了一个frame做标题栏的....



嗯,这个当然可以,但是 Tkinter 没有直接自定义标题栏的,只能自己靠其他组件做

小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-6-18 17:14:31 | 显示全部楼层
真想改,那就改系统设置即可。这是属于系统GUI的事。

解决:设置 --> 颜色 --> 勾选“标题栏和窗口边框”

ps: 只是这样设置 整个系统的所有窗口,都会使用该颜色配置。  

well, 颜色这东西,你喜欢就好~

win_color_setting.rar

97.33 KB, 下载次数: 3

小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-6-18 17:25:24 | 显示全部楼层
按照上面的方法,重新弄了个标题栏

20210618172216.png
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-4-26 07:36

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表