Python in Windows Store apps
Asked Answered
G

3

9

The Windows Store app Python 3 For Metro claims that it allows users to edit and run Python files (I can't get it to work). How is this possible from within the sandbox? Can I run a file (say test.py on the desktop) from my JavaScript app?

Gerbold answered 8/1, 2013 at 9:34 Comment(2)
You mean this one? If not, please provide a link.Ehr
Yes, that's the app I was talking about. Thanks for the link.Gerbold
C
15

How is this possible from within the sandbox?

I have ported the Python interpreter to WinRT to achieve that. Instead of using Win32 API, it now uses WinRT API (in particular for reading files from the user's Documents folder).

Can I run a file (say test.py on the desktop) from my JavaScript app?

In principle, yes. You need to take the python33.dll from my app, wrap it as a WinRT component, and then call it. It actually is a WinRT component already, but doesn't expose any of the Python API. See

http://hg.python.org/sandbox/loewis/file/ee9f8c546ddd/win8app/python33

Condemn answered 13/1, 2013 at 2:12 Comment(0)
C
1

Basically, what you need to do is write a C++ "shell" app according to the Metro rules, then host the Python interpreter inside that C++ app. And again, scrub the Python codebase so that it runs within the Metro sandbox.

You can then go a step further, and have the C++ shell expose WinRT libraries to the Python environment. There's probably a way to get Python to expose WinRT objects, but that would be a LOT of work.

You won't be able to call directly from JavaScript into Python - you'll need a WinRT component in the middle.

This is a lot of work, and requires some fairly low level work in C.

Catnap answered 11/1, 2013 at 19:48 Comment(0)
G
-2

You have two options:

  • add python.exe to your PATH and, from within a terminal, enter the folder that contains your test.py and run python.exe test.py, using your current installation

  • you can follow step1 and step2 of this post and install a brand new python from scratch

If you can provide some more informations, we can help you better.

Can I run a file (say test.py on the desktop) from my JavaScript app?

This can be your real problem, what do you mean with this statement? generally the answer would be "no, you can't"

Gerhan answered 8/1, 2013 at 10:0 Comment(1)
I have no problem running python files from the desktop. I am a python developer. What I want to do is call python files from a Metro app. I initially thought this would be impossible, but "Python 3 For Metro" is doing it somehow.Gerbold

© 2022 - 2024 — McMap. All rights reserved.