python中能够修改主窗口标题的属性是_python – 我可以更改Tkinter中的标题栏吗?...

是的,这是可能的.您可以在根窗口上使用

overrideredirect()方法来终止标题栏和默认几何设置.之后,您需要从头开始重建所有这些方法,以便按需要重新设置它们.这是一个功能最少的小工作示例:

root = Tk()

def move_window(event):

root.geometry('+{0}+{1}'.format(event.x_root, event.y_root))

root.overrideredirect(True) # turns off title bar, geometry

root.geometry('400x100+200+200') # set new geometry

# make a frame for the title bar

title_bar = Frame(root, bg='white', relief='raised', bd=2)

# put a close button on the title bar

close_button = Button(title_bar, text='X', command=root.destroy)

# a canvas for the main area of the window

window = Canvas(root, bg='black')

# pack the widgets

title_bar.pack(expand=1, fill=X)

close_button.pack(side=RIGHT)

window.pack(expand=1, fill=BOTH)

# bind title bar motion to the move window function

title_bar.bind('', move_window)

root.mainloop()

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值