Screenshot using Construct

For questions about using Classic.

Post » Fri Apr 23, 2010 12:55 pm

See my post before your. I just uploaded a new version with the vcredist and some new Dlls.

Please remove Python26 and try the new version out first without installing the vcredist. If that doesn't work then try installing the redistributable. It is only 2mb so much better than installing Python.

Ok, I duplicated your error message after I uninstalled Visual C++ on my XP system. I then installed the vcredist and that solved the error message.

As far as releasing new instructions, that isn't necessary. Just follow everything in the tutorial and the only addition is to install the vcredist. If you don't want to install the vcredist then read the Part 1 tutorial where I discuss packaging your own msvcr90.dll and manifest file.

Good luck!
B
8
S
3
G
7
Posts: 835
Reputation: 5,313

Post » Fri Apr 23, 2010 1:55 pm

I downloaded your new package and uninstalled Python 2.6 from my WindowsXP. IT'S WORKING CORRECTLY! Thank you, man!!!

Now, I want to create my own application in Construct. I'm reading an article "python_library_tutorial_part2", I installed all nessesary programs - Python 2.6, GTK+ All In One, PyCairo, PyGObject and cx_Freeze... But... I don't understand this:

"Go ahead and build an executable using cx_freeze. Now copy the library.zip file that was
produced and paste it into the Construct/Data/Python directory. Finally, unzip this file into the
directory."

I don't know how to build an executable using cx_freeze and how to get "library.zip".
B
2
G
2
Posts: 24
Reputation: 698

Post » Fri Apr 23, 2010 2:26 pm

Uh... isn't using python library solely for taking screenshots a bit excessive? :?
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Fri Apr 23, 2010 2:35 pm

Sounds like you are close to getting the build to work. Here are the steps from where you are at.

1. On page 3 of the Part 2 tutorial there is a Python script. You need to create a file called "test.py" and copy the import lines of the script into that file. Read the Python_quickguide if you have not already.

The file should have the imports:

import sys
import pygtk
import gtk

2. Once you have the script, you need to build a cx_freeze build script called "setup.py" like below in the same directory as the script you just created. This is shown in the Python_quickguide.

from cx_Freeze import setup, Executable

setup(
name = "screenshot",
version = "0.1",
description = "Basic screenshot example",
executables = [Executable("test.py")])


3. Once you have done that, open up a command prompt, cd to your directory and run the tool:
"setup.py build"

4. This step produces the library.zip file and all of the other dependencies that you see I copied with the executable. You unzip the library.zip file into your Construct\Data\Python directory. The other dependencies you bundle with your executable. You might also have to bundle the vcredistributable as I was explaining earlier.

Give the quickguide a short review and hopefully this all works!
B
8
S
3
G
7
Posts: 835
Reputation: 5,313

Post » Fri Apr 23, 2010 2:36 pm

[quote="Mipey":3f9jr5z2]Uh... isn't using python library solely for taking screenshots a bit excessive?[/quote:3f9jr5z2]
Of course it is. :-) but how else would you have him accomplish this? Write his own plugin in C++??
B
8
S
3
G
7
Posts: 835
Reputation: 5,313

Post » Fri Apr 23, 2010 2:38 pm

OK, THANK YOU!!! I created "build" directory and library.zip inside with cx_Freeze. I copied library.zip to Construct/Data/Python directory... But, when I'm running example (pygtk_screenshot.cap) I have error:

[quote:2lf4woae]Traceback (most recent call last):
File "<string>", line 9, in <module>
File "C:\Python26\lib\site-packages\gtk-2.0\gtk\__init__.py", line 30, in <module>
import gobject as _gobject
File"C:\Python26\lib\site-packages\gtk-2.0\gobject\__init__.py", line 26, in <module>
from glib import spawn _async, idle _add, timeout _add, timeout _add_seconds, \
File"C:\Python26\lib\site-packages\gtk-2.0\glib\__init__.py", line 22, in <module>
grom glib._glib import *
ImportError: DLL load failed[/quote:2lf4woae]

What's wrong? I'm sorry for my questions ;/...

EDIT:

My "test.py" file was:

[quote:2lf4woae]import sys
import pygtk
if not sys.platform == 'win32':
pygtk.require('2.0')
import gtk


# Either "png" or "jpeg"
format = "jpeg"

width = gtk.gdk.screen_width()
height = gtk.gdk.screen_height()
screenshot = gtk.gdk.Pixbuf.get_from_drawable(
gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, width, height),
gtk.gdk.get_default_root_window(),
gtk.gdk.colormap_get_system(),
0, 0, 0, 0, width, height)
screenshot.save("screenshot." + format, format, {"quality": "70"})[/quote:2lf4woae]

And my setup.py file was:
[quote:2lf4woae]
from cx_Freeze import setup, Executable

setup(
name = "scr",
version = "0.1",
description = "scr",
executables = [Executable("test.py")])[/quote:2lf4woae]
B
2
G
2
Posts: 24
Reputation: 698

Post » Fri Apr 23, 2010 2:49 pm

You should never have any problems running the code inside of Construct. The part with using cx_freeze and the library.zip is only when packaging for others.

If it fails inside of Construct, that means that your pyGtk, or other library install is somehow wrong. Are you able to run this Python script from the command line?

http://www.box.net/shared/bsiqeevoi6

Does it correctly produce a screenshot? If it fails then go back and make sure you followed all the steps in the tutorial (especially the steps in page 3 about setting your system path).
B
8
S
3
G
7
Posts: 835
Reputation: 5,313

Post » Fri Apr 23, 2010 3:02 pm

Yours script "gtk_screenshot.py" doesn't produce screenshot... Maybe I done something wrong?

1. I installed Python 2.6
2. I installed GTK+ and added directory "C:\gtk\bin" to my system variables and named it "gtk"
3. I installed PyCairo, PyGobject, and PyGTK.
4. I installed cx_Freeze and created "build" directory with "library.zip" and other files in it.
5. I copied library.zip to Construct\Data\Python.
6. I unpacked.
7. I opened "pygtk_screenshot.cap" and when I want to run it, I have:

[quote:2qqwgy7j]Traceback (most recent call last):
File "<string>", line 9, in <module>
File "C:\Python26\lib\site-packages\gtk-2.0\gtk\__init__.py", line 30, in <module>
import gobject as _gobject
File"C:\Python26\lib\site-packages\gtk-2.0\gobject\__init__.py", line 26, in <module>
from glib import spawn _async, idle _add, timeout _add, timeout _add_seconds, \
File"C:\Python26\lib\site-packages\gtk-2.0\glib\__init__.py", line 22, in <module>
grom glib._glib import *
ImportError: DLL load failed[/quote:2qqwgy7j]

and yours "gtk_screenshot.py" doesn't produce any screenshot. Should I reinstall all software? Or I missed something nesseary?

EDIT:

When I tried to run your script from Command Line, I got this same error messages what in Construct!
B
2
G
2
Posts: 24
Reputation: 698

Post » Fri Apr 23, 2010 3:15 pm

[quote="mfadier":2l1sms9u]2. I installed GTK+ and added directory "C:\gtk\bin" to my system variables and named it "gtk"[/quote:2l1sms9u]

You need to add "C:\gtk\bin" to the "Path" system variable. Remove the "gtk" variable and add the directory to your path.



For example, I installed mine to C:\opt\gtk\bin and this is how my path looks.
B
8
S
3
G
7
Posts: 835
Reputation: 5,313

Post » Fri Apr 23, 2010 3:25 pm

YEAH! It's working! Your script is creating screenshot from CommandLine and pygtk_screenshot.cap is working corectly from Construct!!! I don't know how to thank you!!!

T H A N K Y O U very much!!! :D !
B
2
G
2
Posts: 24
Reputation: 698

PreviousNext

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests