Screenshot using Construct

This forum is currently in read-only mode.
From the Asset Store
Casino? money? who knows? but the target is the same!
  • 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

    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"})

    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")])

  • 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).

  • 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

    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!

  • 2. I installed GTK+ and added directory "C:\gtk\bin" to my system variables and named it "gtk"

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

    <img src="http://i43.tinypic.com/256dwyb.jpg">

    For example, I installed mine to C:\opt\gtk\bin and this is how my path looks.

  • 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!!! !

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Awesome!! Way to go. You've helped me out as well identify how I can make the instructions better.

    Nice work!

  • Nice to hear it . I have the last question... What a python libraries should I select when I'm creating *.exe file from Construct? My exe application doesn't work correctly when I'm trying to launch it on a other machine without python26. I think, I have all nessesary files in my app directory (copied from "build" folder and from ur simple screenshot example directory), but I see this same error message.

    [quote:3rzolbb6]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

    Your application is working very good, mine's not . Maybe I'm copying wrong dll files to my app directory?

    Sorry for my strange questions and bad level of english language, and thank you for all .

  • Unfortunately, this is a somewhat tedious step.. but hopefully the next update to Construct will make this easier. Make sure you select the .pyc libraries when you are creating the executable.

    You must select all of the .pyc libraries (except the encodings directory entries.. don't check those) when you get to the portion in the export wizard on python settings.

    This should be in page 4 of the quickguide on creating the .exe. You probably have around 25 .pyc files that you need to check.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)