Advertisement
here2share

# Tk_screencopy.py

Aug 31st, 2020
1,365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. # Tk_screencopy.py
  2.  
  3. from Tkinter import *
  4. from PIL import ImageTk, ImageGrab
  5.  
  6. root = Tk()
  7.  
  8. ww = 500
  9. hh = 500
  10. def screenshot():
  11.     im1 = ImageGrab.grab((0, 0, ww, hh)) # bbox =  (x1, y1, x2, y2)  
  12.  
  13.     New = Toplevel(root, width=ww, height=hh)
  14.     im1 = ImageTk.PhotoImage(im1)
  15.     image1 = Label(New, image = im1)
  16.     image1.image = im1
  17.     image1.place(x=0, y=0)
  18.  
  19. Button(root, text='ScreenShot', padx=1, command=screenshot).pack(padx=1, pady=1)
  20.  
  21. mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement