1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | #!/usr/bin/python
# ---------------- READ ME --------------------------------------------- # This Script is Created Only For Practise And Educational Purpose Only # This is an Example Of Tkinter Canvas Graphics # This Script Is Created For http://www.bitforestinfo.com # This Script is Written By # # ################################################## ######## Please Don't Remove Author Name ######### ############### Thanks ########################### ################################################## # # __author__='''
###################################################### By ######################################################
Suraj Singh surajsinghbisht054@gmail.com http://www.bitforestinfo.com/
###################################################### ''' print __author__ # ============ CONFIGURATIONS ===================== SCREENSAVER_BACKGROUND_COLOR="black" TRANSPARENCY_LEVEL = 0.75 COLOR_CHOICE = ['blue',"red","yellow","white","skyblue","green"] SCREEN_SAVER_CLOSING_EVENTS = ['<Any-KeyPress>', '<Any-Button>', '<Motion>'] PIPE_WIDTH = 10 WAITING_TIME_LAP = 0.09 RESTARTING_POINT = 100 LOOK_LIKE_THREAD = True # =================================================
# *************** Importing Module **************** try: import Tkinter import random import time except: import tkinter as Tkinter import random import time
# Create Canvas Class class Pipes(Tkinter.Canvas): def __init__(self, *args, **kwargs): Tkinter.Canvas.__init__(self, *args, **kwargs) # Starting Coordinates self.coordinates=[0,0,0,0] # Create Line Function self.create_pipe()
# Create A Line def create_pipe(self): self.p = self.create_line(0,0,0,0, fill=random.choice(COLOR_CHOICE),smooth=LOOK_LIKE_THREAD ,width=PIPE_WIDTH) return
# update Canvas Configurations def update_screen(self): self.coordinates.append(random.randint(0,self.winfo_screenwidth())) self.coordinates.append(random.randint(0,self.winfo_screenheight())) self.coords(self.p, *self.coordinates) time.sleep(WAITING_TIME_LAP) if len(self.coordinates)>RESTARTING_POINT: self.coordinates=[0,0,0,0] color = random.choice(COLOR_CHOICE) self.itemconfigure(self.p, fill=color) return
# Main Functions def main(): root=Tkinter.Tk(className="Pipes screenSaver By Bitforestinfo") screen = Pipes(root, bg=SCREENSAVER_BACKGROUND_COLOR) screen.pack(expand="yes",fill="both") # Tkinter Window Configurations root.wait_visibility(screen) root.wm_attributes('-alpha',TRANSPARENCY_LEVEL) root.wm_attributes("-topmost", True) root.overrideredirect(1) root.attributes('-fullscreen', True) # Window Exit Functions def out(event): root.destroy() return # Event Bindings for seq in SCREEN_SAVER_CLOSING_EVENTS: root.bind_all(seq, out)
# Update Loop while True: root.update() root.update_idletasks() screen.update_screen() return
#============ Trigger ======================== if __name__=='__main__': main()
|