▶ Watch CustomTkinter Playlist ✅ FREE Tkinter Widget Book bit.ly/45iO4OP bit.ly/3K4qlZC ▶ See More At: ✅ Subscribe To My RU-vid Channel: Tkinter.com bit.ly/3Pk1By4 ▶ MASSIVE TKINTER.COM DISCOUNT ✅ Join My Facebook Group: 30% off with coupon code: youtube bit.ly/2GFmOBz ▶ Get The Code For This Video bit.ly/3dCzz2K
Great vídeo, as usual! I was wondering, the reason to have a dark image might be so you can have two different versions of the image that go best with each mode (like different logo versions, or diagram versions).
When I enter my_image configured as you say, the image does not open in either light mode or dark mode, however, when I enter it in the label it does appear. I´m using python 3.12.2 , pillow 10.2.0, and VsCode
@@TkinterPython import customtkinter from PIL import Image customtkinter.set_appearance_mode('dark') customtkinter.set_default_color_theme("dark-blue") root=customtkinter.CTk() root.title('Nirvana') root.iconbitmap("C:/Users/arkai/Desktop/Python/11-Interfaces/2-Custom_Tkinter/Nirvana.ico") root.geometry('800x500') my_image=ctk.CTkImage(light_image=Image.open('nirvana.png')) root.mainloop() I have it exactly the same. The root window opens but does not show anything, however, when I complete the code with the resizing and the label, then it works correctly. The terminal path is exactly where both the file and the image are. It's very strange
I have it exactly the same. The path of the terminal is set in the folder where both the python file and the image are located. When you run the program, root opens, but it does not show any image. However, when I complete the video code with the label, the image appears wonderfully well. Is very strange This works great: import customtkinter as ctk from PIL import Image ctk.set_appearance_mode('dark') ctk.set_default_color_theme("dark-blue") root=ctk.CTk() root.title('Nirvana') root.iconbitmap("Nirvana.ico") root.geometry('800x500') my_image=ctk.CTkImage(light_image=Image.open('nirvana.png'), dark_image=Image.open('nirvana.png'),size=(520,380)) my_label=ctk.CTkLabel(root,text='',image=my_image) my_label.pack(pady=10) root.mainloop() This other one doesn't work: import customtkinter as ctk from PIL import Image ctk.set_appearance_mode('dark') ctk.set_default_color_theme("dark-blue") root=ctk.CTk() root.title('Nirvana') root.iconbitmap("Nirvana.ico") root.geometry('800x500') my_image=ctk.CTkImage(light_image=Image.open('nirvana.png')) root.mainloop() @@TkinterPython
Is there any possibility to play a video in the customTkinter label, just as it is done in tkinter. The images would come from the acquisition of frames in opencv. cap=cv2.VideoCapture(0,cv2.CAP_DSHOW) def visualize(): global cap ret, frame = cap.read() if ret: frame=imutils.resize(frame,width=350) frame=cv2.flip(frame,1) frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) im = Image.fromarray(frame) img = ImageTk.PhotoImage(image=im) lblVideo.configure(image=img) lblVideo.image = img lblVideo.after(10, visualize)
Just found this video of yours, and it is very helpful, only problem is in the resizing it does not keep the aspect ratio, I created this shorty that may just help anyone else needing to do this.. img = f"./pix/origpicture.png" # path to pic im = Image.open(img) nw = 640 # enter your new width nh = int(nw/im.width * im.height) # calculates your new height my_image = ct.CTkImage(dark_image=Image.open(img), size=(nw, nh)) # creates new image my_label = ct.CTkLabel(window, text = "", image = my_image) my_label.grid(column = 0, row = 0) Again thank you for all your videos, I have been learning from you for years !!
It is impossible for me to put a background image and a label on top of it, it always comes out with the square of the label, even if it is transparent it still leaves a gap with the shape of the label on top of the image, and they are not assimilated to the floating text.
I get this error message Traceback (most recent call last): File "/home/david/PythonCodes/Energieffizienzklassenrechner3.py", line 7, in from PIL import Image, ImageTk File "/home/david/PythonCodes/PIL/Image.py", line 84, in from . import _imaging as core ImportError: cannot import name '_imaging' from 'PIL' (/home/david/PythonCodes/PIL/__init__.py) [Finished in 102ms with exit code 1] [cmd: ['python3', '-u', '/home/david/PythonCodes/Energieffizienzklassenrechner3.py']] [dir: /home/david/PythonCodes] [path: /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/snap/bin] Could you help me ?