Python Scripting - Extension

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • Hi, i'm trying to have wxpython with the python extension, basically I would like to access a gui toolkit for python, but no sucess. I followed the steps on the thread but can't get it to work.

    would it work though? or any other that would work?
    If so how can it be done?

    Regards.....

    Excellent work by the way

  • Since I can't post in the other thread, I'll just say thanks to Mathias here !

    This python extension is just an awesome project and will expand MMF2 capabilities way further. I couldn't test it yet but I'll do as soon as possible. From what you did with pylacewing, i'm sure this extension was very cleverly planned and i guess it will be a pleasure to use it.

    Thank you very much Mathias !

  • me again,

    It has been a while since my last experience with python, but i think there was a gui lib included in the standard distribution tkinter, i belive... looking at the zip i can't find it...was it left behind?

    refering again to my first post.

    thanks

  • Unfortunately, I decided to leave out the tkinter modules, since MMF2 already provides GUI features. You can still include it with your executable, though ;)

    And by the way, you can probably include wxPython in the same directory as your executable (even though I still suggest you use MMF2 for you GUI, since wxPython is a pretty big library unless you cut away unneeded modules).

  • ok, i'm having problems in adding modules, i zip them with the files in the python26.zip, copy them unzipped into all the folders data/runtime, extensions, mmf root, and application folder, nothing.

    I'm trying to get opencv for python to work, see Please login to see this link., this requires numpy, and i get an error saying that numpy isn't installed,

    could someone try it and see if it's possible, and if it is write a small idiot proof tutorial on how to do it (yep, i'm the idiot)

    thanks for your time

  • I was just going to suggest making a python forum as i just downloaded the new object but it is already done. This should be great :)

    Offtopic -

    We need a OpenGL forum also :)

  • Quote from cel

    I'm trying to get opencv for python to work, see Please login to see this link., this requires numpy, and i get an error saying that numpy isn't installed.


    I managed to use opencv by installing it with my Python installation, and then adding the site-packages directory to sys.path in the extension. You should only have to place numpy and the pyopencv folders (from site-packages) in the same directory as your MFA file.

  • I'm sorry Mathias, I don't fully understand the bit to add the site packages directory to the sys.path in the extension. Do I script that in the extension? Could you give me an example?

    Thanks for your time, great news that opencv can be used trouhg python object

  • Basically, you install pyopencv (and Python 2.6.5 beforehand if you haven't already), and then you do this in your code:

    Code
    import sys
    # or whatever the path to your Python installation is
    sys.path.append('C:\\Program Files\\Python26\\Lib\\site-packages')
    import pyopencv

    This is a bit hack-ish, but it works. When distributing your application, you should include the site-packages\pyopencv (and site-packages\numpy if it's a dependency) directories in the same directory as the EXE.

  • I've tried asa you said,

    My code:

    import sys

    sys.path.append('C:\\Python26\\Lib\\site-packages')
    import numpy
    import pyopencv


    img = imread('people.jpg')
    hog = HOGDescriptor()
    hog.setSVMDetector(HOGDescriptor.getDefaultPeopleDetector())
    for r in hog.detectMultiScale(img, 0, Size(8,8), Size(24,16), 1.05, 2).to_list_of_Rect():
    r.x += round(r.width*0.1)
    r.y += round(r.height*0.1)
    r.width = round(r.width*0.8)
    r.height = round(r.height*0.8)
    rectangle(img, r.tl(), r.br(), Scalar(0,255,0), 1)

    namedWindow("people detector", 1)
    imshow("people detector", img)
    waitKey(0)

    I still get no module named multiarray as an error

  • I've run into the same kind of problems (trying to run pylacewing from the extension), and ended up adding this to my project :
    sys.path.append('C:\\Python26')
    sys.path.append('C:\\Python26\\DLLs')
    sys.path.append('C:\\Python26\\lib')
    sys.path.append('C:\\Python26\\lib\\lib-tk')
    sys.path.append('C:\\Python26\\lib\\plat-win')
    sys.path.append('C:\\Python26\\lib\\site-packages')
    sys.path.append('C:\\Python26\\lib\\site-packages\\Pythonwin')
    sys.path.append('C:\\Python26\\lib\\site-packages\\win32')
    sys.path.append('C:\\Python26\\lib\\site-packages\\win32\\lib')

    everything runs ok now :D

  • Im new to python so im slightly confused about adding the extensions/packages. What im wondering is what do you download/need?

    Would i get the exe like -

    Box2D-2.0.2b1.win32-py2.6.exe

    Then install, i do this and can get it working with the main python but im not sure what to do in regards to making it work with MMF still yet. Also when it says put the package into the python26.zip does that mean you unzip it add the exe or install it then copy some files to some location and re-zip it again?

    I know that python is highly documented off site just like Lua is but all scripting extensions should definitely have a few tutorials with this type of stuff and other things where it links to MMF. Starting a new code language with no help docs and searching the web to find possibly the wrong answers or non MMF based answers is kind of annoying so a links/MMF reference here or on the wiki would also be nice :)

  • Box2D uses binary modules, so you'll have to install it, and then copy the Box2D package from your site-packages directory and include it with your executable when you distribute it (when you're merely developing, you can add site-packages to sys.path) ;)

  • Thanks i will try this, i think some other packages had a few other files in other folders also so maybe it would be better to just copy and zip the whole python folder?

    Also im curious, when a exe that uses python is built how does it use the zip would it use the whole thing somewhere? If that is the case is it worth optimizing it by removing any un-needed examples and extra things from packages etc? or would it only use what gets used. Python seems very powerful, this is like having 10000+ new extensions if i can get the packages working ok, it is great :D

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!