Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_squiggly.py
- SCREENSAVER_BACKGROUND_COLOR="black"
- TRANSPARENCY_LEVEL = 0.75
- COLOR_CHOICE = ['blue',"red","yellow","white","skyblue","green"]
- PIPE_WIDTH = 10
- WAITING_TIME_LAP = 0.09
- RESTARTING_POINT = 100
- LOOK_LIKE_THREAD = True
- import tkinter as Tkinter
- import random
- import time
- 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()
- 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
- 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="# Tk_squiggly.py")
- 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.attributes('-fullscreen', True)
- go=[1]
- def out(event):
- go[0]=0
- root.bind_all('<Any-KeyPress>', out)
- while go[0]:
- root.update()
- root.update_idletasks()
- screen.update_screen()
- root.destroy()
- if __name__=='__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement