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

Troubleshooting • Re: Invalid geometry using grim

$
0
0
you need slurp

Code:

apt install slurp

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()

Statistics: Posted by kerry_s — Mon Mar 10, 2025 5:53 pm



Viewing all articles
Browse latest Browse all 8082

Trending Articles