Create Watermark Splash Screen in Real Time using Python Tkinter

Source Code:

# pip install Pillow

from tkinter import *
from PIL import ImageTk,Image


def size():     
     root = Tk()
     # Detect your screen width x height
     ws = root.winfo_screenwidth()
     hs = root.winfo_screenheight()
     print(ws,'x', hs) #1360 x 768

def img_size():
     im = Image.open('pyimageg.png')
     width, height = im.size
     print(im.size) #300 x 300

print('1920 x 1080')
print('1920 / 2 ='+str(1360 / 2))
print('1080 / 2 ='+str(768 / 2))
print()
print('300 x 300')
print('300 / 2 ='+str(300 / 2))
print()
print(int(1920 / 2) - int(300 / 2),int(1080 / 2) - int(300 / 2))

#####################################################################################################
def wd(text):
     return str(text)

def ht(text):
     return str(text)

def run(t_1,t_2):
     root = Tk()
     canvas = Canvas(root, width = 300, height =300, bg = 'white', highlightthickness = 0)  
     canvas.pack()
     canvas.master.overrideredirect(True)
     canvas.master.geometry('+'+wd(t_1)+'+'+ht(t_2)+'')
     canvas.master.wm_attributes("-transparentcolor","white")
     canvas.master.wm_attributes("-alpha",0.4)
     canvas.master.wm_attributes("-topmost",True)
     canvas.master.lift()
     img = ImageTk.PhotoImage(Image.open("pyimageg.png"))  
     canvas.create_image(10, 10, anchor=NW, image=img)
     root.mainloop()

def center():
     w = int(1920 / 2) - int(300 / 2)
     h = int(1080 / 2) - int(300 / 2)
     run(w,h)

Download Image Source
https://drive.google.com/file/d/1XSXTrCPPz4Vt7jQnvNWBanYHl9fHQxci/view?usp=sharing

Note: Install Pillow module to make this code work.
Run ⇢ CMD ⇢ “pip install Pillow”

#python #programming #developer

Create Watermark Splash Screen in Real Time using Python Tkinter
17.15 GEEK