Given that openbox does not include the capability of obtaining a screenshot, 
I've written a little routine in python to accomplish that task. I'm running 
Fedora 13, and am trying to strip down my installation while still making it as 
complete (for my needs) as possible. The code (shown below) seems to work 
properly, but when I run the program from a terminal and select the --screen 
option, I get the following error:
  (screenshooter2.py:4787): Gtk-WARNING **: Missing argument for --screen
Can anyone explain why the error occurs?
TIA

#!/usr/bin/env python
"""
    Screenshooter2.py
    A simple screenshooter, modified from mirage
    Copyright 2010 Rockdoctor <[email protected]>
    Version 2.05 20090317
            Minor cleanup from 2.04

    Mirage Citation
    Mirage, a fast GTK+ Image Viewer
    Copyright 2007 Scott Horowitz <[email protected]>
    # $HeadURL: http://svn.berlios.de/svnroot/repos/mirageiv/trunk/mirage.py $
    # $Id: mirage.py 239 2008-03-27 04:08:59Z stonecrest $
"""
import os
import sys
import gtk.gdk

shoot_window=False
myfilename=""

# Display usage info and exit
def no_argument():
    my_cmd = 'zenity --info --text="<b>Usage:</b>\n\n'
    my_cmd += 'screenshooter.py &lt;--screen&gt; shoot whole screen\n'
    my_cmd += 'screenshooter.py &lt;--window&gt; shoot window under cursor"'
    rtn = os.popen(my_cmd)
    sys.exit()

# Get window position and dimensions
def xwininfo():
    rtn = os.popen('xwininfo')
    count=0
    for line in rtn:
        if count==7:
            l = line.split(' ')
            ulx=l[6].strip()
        if count==8:
            l = line.split(' ')
            uly=l[6].strip()
        if count==11:
            l = line.split(' ')
            width=l[3].strip()
        if count==12:
            l = line.split(' ')
            height=l[3].strip()
        count += 1
    h = gtk.gdk.screen_height()
    if int(height)+int(uly) > h:
        height = h - int(uly)
    return int(ulx), int(uly), int(width), int(height)

# Main Routine

# There should only be one parameter; --screen or --window
# Display usage info (and exit) if this is not the case
l = len(sys.argv)
if l==2:
    if sys.argv[1]=='--window':
        shoot_window=True
    elif sys.argv[1]=='--screen':
        shoot_window=False
    else:
        no_argument()
else:
    no_argument()

# Get info for screen/window as appropriate
root_win = gtk.gdk.get_default_root_window()
if not shoot_window:
    x = 0
    y = 0
    width = gtk.gdk.screen_width()
    height = gtk.gdk.screen_height()
else:
    (x, y, width, height) = xwininfo()

# Grab the screen/window
pix = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, width, height)
pix = pix.get_from_drawable(root_win, gtk.gdk.colormap_get_system(), x, y, 0, 
0, width, height)

# Request filename and save file
my_cmd = 'zenity --entry --text="Save image as: "'
rtn = os.popen('zenity --entry --text="Save image as: "','r')
filename = rtn.read()
filename = filename.strip()
if filename:
    pix.save(filename+".png", 'png')


      

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Lxde-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/lxde-list

Reply via email to