Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_change_titlebar.py
- from tkinter import *
- root = Tk()
- root.title('Change Titlebar')
- # root.iconbitmap('c:/your.ico')
- ww = 500
- hh = 300
- root.geometry(f'{ww}x{hh}+10+10')
- # remove title bar
- root.overrideredirect(True)
- def move_app(e):
- root.geometry(f'{ww}x{hh}+{e.x_root-int(ww/2)}+{e.y_root-10}')
- def quitter(e=None):
- root.destroy()
- # Create Fake Title Bar
- title_bar = Frame(root, bg="darkgreen", relief="raised", bd=0)
- title_bar.pack(expand=1, fill=X)
- # Bind the titlebar
- title_bar.bind("<B1-Motion>", move_app)
- # Create title text
- title_label = Label(title_bar, text=" My Awesome App!", bg="darkgreen", fg="white")
- title_label.pack(side=LEFT, pady=4)
- # Create close button on titlebar
- close_label = Label(title_bar, text=" X ", bg="yellow", fg="red", relief="sunken", bd=1)
- close_label.pack(side=RIGHT, padx=3, pady=1)
- close_label.bind("<Button-1>", quitter)
- my_button = Button(root, text="CLOSE!", font=("Helvetica, 32"), command=quitter)
- my_button.pack(pady=100)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement