Grab and save a scrollable canvas including the invisible part #8680
-
I've been trying to use canvas = tk.Canvas(canvasFrame, bg="lightgray", yscrollincrement=10, xscrollincrement=10)
# Create vertical and horizontal scrollbars for the canvas
verticalScrollbar = tk.Scrollbar(canvasFrame, orient="vertical", command=canvas.yview)
horizontalScrollbar = tk.Scrollbar(canvasFrame, orient="horizontal", command=canvas.xview)
canvas.config(yscrollcommand=verticalScrollbar.set, xscrollcommand=horizontalScrollbar.set)
# Place the scrollbars around the canvas
canvas.grid(row=0, column=0, sticky="nsew")
verticalScrollbar.grid(row=0, column=1, sticky="ns")
horizontalScrollbar.grid(row=1, column=0, sticky="ew")
# Configure the grid to expand the canvas as the window resizes
canvasFrame.grid_rowconfigure(0, weight=1)
canvasFrame.grid_columnconfigure(0, weight=1) While I was able to produce a .png file of the visible part of the screen I was not able to produce a capture of the full image. Thank you, Adrian |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
In order do what you're describing - capture content that isn't visible in the window, but comes from part of the canvas hidden by scrollbars - my suggestion would be to programmatically scroll to the different parts of the canvas, take screen grabs of each of them, and then combine the result using Pillow. |
Beta Was this translation helpful? Give feedback.
ImageGrab.grab()
is currently based on capturing what is visible on the screen, yes.In order do what you're describing - capture content that isn't visible in the window, but comes from part of the canvas hidden by scrollbars - my suggestion would be to programmatically scroll to the different parts of the canvas, take screen grabs of each of them, and then combine the result using Pillow.