Created
March 11, 2019 13:54
-
-
Save angeloped/42c56295154816bc335262f3548f4d73 to your computer and use it in GitHub Desktop.
This is the basic screen blocker with a background image.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image, ImageTk | |
try: | |
import Tkinter as tk | |
except ImportError: | |
import tkinter as tk | |
try: | |
import ttk | |
except ImportError: | |
import tkinter.ttk as ttk | |
class FullScreenBlocker(tk.Tk): | |
def __init__(self): | |
tk.Tk.__init__(self) | |
self.top=self | |
# no border; full screen | |
self.top.attributes('-fullscreen', 'true') | |
# always on top | |
self.top.attributes('-topmost', 'true') | |
self.geometry("{0}x{1}+0+0".format(self.winfo_screenwidth(), self.winfo_screenheight())) | |
w,h = self.winfo_screenwidth(),self.winfo_screenheight() | |
cv = tk.Canvas(self, width=w, height=h) | |
cv.pack(fill='both', expand='yes') | |
pil_image = Image.open("this_is_my_background.gif")# you can use .gif, .png, .jpg.. | |
pil_image2 = pil_image.resize((w,h), Image.ANTIALIAS) | |
tk_image = ImageTk.PhotoImage(pil_image2) | |
cv.create_image(w//2, h//2, image=tk_image, anchor='center') | |
tk.Button(cv, text="kill me!", command=self.destroy).pack() | |
self.mainloop() | |
def _show_clnt_confg(self): | |
clnt_top = tk.Toplevel(self.top) | |
# always on top | |
clnt_top.attributes('-topmost', 'true') | |
top_ClntLogin = ClntLogin(clnt_top) | |
fscrnblcker = FullScreenBlocker() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment