|

楼主 |
发表于 2021-6-18 16:17:38
|
显示全部楼层
网上搜了一个不显示原有标题栏,然后重新写了一个frame做标题栏的....
- from tkinter import *
- root = Tk()
- def motion(event):
- print(event.x, event.y, event.x_root, event.y_root)
- 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
- root.update()
- # make a frame for the title bar
- title_bar = Frame(root, bg='gray', relief='raised', bd=2)
- # put a close button on the title bar
- close_button = Button(title_bar, text='X', bg='gray', command=root.destroy)
- # a canvas for the main area of the window
- window = Canvas(root)
- # 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('<B1-Motion>', move_window)
- root.bind('<Motion>', motion)
- root.mainloop()
复制代码 |
|