-2

Here is the full code

import tkinter as tk
from PIL import ImageTk, Image

def hide_screen():
    window.overrideredirect(0)
    window.iconify()

def screen_appear(event):
    window.overrideredirect(1)

def callback(event):
    window.geometry("+{0}+{1}".format(event.x_root,event.y_root))

window = tk.Tk()
window.geometry("400x200")
window.overrideredirect(True)

title_bar = tk.Frame(window, bg="#2c2c2c", bd=0)

title_bar_logo = ImageTk.PhotoImage(Image.open("title_bar_logo.png"))
title_bar_logo = ImageTk.resize((250, 250), Image.ANTIALIAS)
panel = tk.Label(title_bar, image=title_bar_logo)
label1 = tk.Label(title_bar, text="Title Bar", fg="gold2", bg="#2c2c2c", font="Times")
close_button = tk.Button(title_bar, text="X", bg="red", command=window.destroy, bd=0)
minimise_button = tk.Button(title_bar, text="-", bg="red", command=hide_screen, bd=0)

window2 = tk.Canvas(window, bg="#1b1b1b", highlightthickness=0)

title_bar.pack(fill="x")
panel.pack(side=tk.LEFT)
close_button.pack(side=tk.RIGHT)
minimise_button.pack(side=tk.RIGHT)
window2.pack(expand=1, fill="x")
label1.pack(anchor=tk.CENTER)

title_bar.bind("<Map>", screen_appear)
title_bar.bind("<B1-Motion>", callback)
window.mainloop()

And here are the image lines

title_bar_logo = ImageTk.PhotoImage(Image.open("title_bar_logo.png"))
title_bar_logo = ImageTk.resize((250, 250), Image.ANTIALIAS)
panel = tk.Label(title_bar, image=title_bar_logo)
panel.pack(side=tk.LEFT)

i have tried soo many things but i can't get it to work and i really hope you can find an answer for me

thank you in advance

jizhihaoSAMA
  • 12,336
  • 9
  • 27
  • 49
Lualt
  • 1
  • `title_bar_logo = ImageTk.PhotoImage(Image.open("title_bar_logo.png").resize((250, 250), Image.ANTIALIAS))`,The `PIL.ImageTk` instance has no attribute `.resize`, but the `PIL.Image` has. – jizhihaoSAMA May 29 '20 at 09:15
  • ***The PIL.ImageTk instance***: The OP don't use a **instance**, it's a **class**: Read [TypeError: Missing one required positional argument](https://stackoverflow.com/a/50594457/7414759) – stovfl May 29 '20 at 10:04

1 Answers1

0

I use it as example it working well:

logo = Image.open("title_bar_logo.png")
logo = logo.resize((20,15), Image.ANTIALIAS)
title_bar_logo=ImageTk.PhotoImage(logo)

use :

title_bar_logo

in your code

Alchimie
  • 426
  • 4
  • 12