I am working on some sort of animation maker with tkinter but I have run into a problem, i would want to save the current application window or canvas widget to a .png file for later use, is this possible? Thanks in advance.
Asked
Active
Viewed 88 times
0
-
Of course, just store the values with the variables somewhere and write a function to get them. – Thingamabobs Jul 01 '20 at 15:19
-
Not what i meant @Atlas435 – chboo1 Jul 01 '20 at 15:22
-
Take a canvas widget and store the visual representation (What you see) as a .png . – chboo1 Jul 01 '20 at 15:23
-
You cant do it with tkinter. You may find something here:https://stackoverflow.com/questions/2846947/get-screenshot-on-windows-with-python – Thingamabobs Jul 01 '20 at 15:31
-
@chboo1 It is a good practice to accept/upvote the answer, if it was helpful. – Roshin Raphel Jul 21 '20 at 17:32
1 Answers
1
import pyautogui
myScreenshot = pyautogui.screenshot()
myScreenshot.save(r'Path to save screenshot\filename.png')
And there it is ! ^^
And if you don't want everything else on your screen, you can try to crop it with pil

Quantum Sushi
- 504
- 7
- 23
-
1
-
3@Atlas435 Related to your comment: https://stackoverflow.com/questions/40938868/taking-screenshots-with-pil – shreyasm-dev Jul 01 '20 at 15:36
-
That's right haha, I took the first method but why make it complicated when you can do simple ? – Quantum Sushi Jul 01 '20 at 15:38
-
@TheMachinist Python says this: Traceback (most recent call last): File "screenshot.py", line 1, in
import pyautogui ModuleNotFoundError: No module named 'pyautogui' – chboo1 Jul 21 '20 at 19:20 -
-
thanks that works just fine for me `pip3 install pyautogui` made it install easy – chboo1 Jul 21 '20 at 19:33