Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8015

Raspberry Pi OS • Re: GUI screenshot/snip on rpi5/bookworm

$
0
0
can some one test this
the problem i'm having is the app would be caught in the screen shot, i moved it over to my desktop to fix

i'm on gnome and grim don't work
i think i have it, but can only confirm the parts work

Code:

#!/usr/bin/env python3from tkinter import simpledialog, messageboximport tkinter as tkimport subprocessimport timedef take_screenshot(option, root):    root.withdraw()    try:        if option == "Desktop":            subprocess.run(["grim"], check=False)        elif option == "Select":            area = subprocess.run(["slurp"], capture_output=True, text=True, check=False).stdout.strip()            subprocess.run(["grim", "-g", area], check=False)        elif option == "Time":            delay = simpledialog.askinteger("Screenshot Delay", "Enter delay in seconds:", minvalue=1)            if delay:                time.sleep(delay)                subprocess.run(["grim"], check=False)                messagebox.showinfo("Screenshot Captured", f"Screenshot taken after {delay} seconds.")    except Exception:        pass    root.deiconify()    root.quit()def create_window():    root = tk.Tk()    root.title("Raspberry Screenshot   ")    try:        img = tk.PhotoImage(file="/usr/share/icons/PiXflat/128x128/places/folder-pictures.png")        img_label = tk.Label(root, image=img)        img_label.image = img        img_label.pack(pady=10)    except Exception:        pass    frame = tk.Frame(root, padx=20, pady=20)    frame.pack(padx=10, pady=10)    button_width = 20    btn_Desktop = tk.Button(frame, text="Desktop", width=button_width, command=lambda: take_screenshot("Desktop", root))    btn_Desktop.grid(row=0, column=0, padx=5, pady=5)    btn_select = tk.Button(frame, text="Select", width=button_width, command=lambda: take_screenshot("Select", root))    btn_select.grid(row=1, column=0, padx=5, pady=5)    btn_time = tk.Button(frame, text="Time", width=button_width, command=lambda: take_screenshot("Time", root))    btn_time.grid(row=2, column=0, padx=5, pady=5)    root.mainloop()create_window()
Screenshot from 2025-03-01 19-36-12.png

Statistics: Posted by kerry_s — Sun Mar 02, 2025 5:38 am



Viewing all articles
Browse latest Browse all 8015

Trending Articles