3

Is there any way to make widgets with Python on Android?

I mean, that I know only Python, HTML, DOM, JS, maybe jQuery and nothing more (not C, Java or something).

Maybe it's simple?

I honestly searched stackoverflow but search returned no answers :(

Help me, please. Give me a hope.

Крайст
  • 776
  • 1
  • 9
  • 22

4 Answers4

2

Personally I wrote a google app engine app in python to collect and display the data, and then used an app called "meta widget" that allows you to turn a website's content into a widget. The app pulls the content from my GAE website and shows it in a widget on the android homescreen.

You might be able to do something completely local if you can make something to serve HTTP requests in sl4a python, then have meta widget go to a local http address.

python412524
  • 266
  • 2
  • 4
  • Hmm, I think that's the best solution at this time. Thank you! Also I've found that Py4A now supports generic ui layouts. – Крайст Dec 03 '12 at 14:22
2

I don't think this could be done.

I've done a quick search in SL4A documentation and there is no API to register broadcast receiver. And Android widgets are just a bunch of Views and code in BroadcastReceiver.

And as far as I know, SL4A is the only way to use Python on Android with UI interaction.

uaraven
  • 1,097
  • 10
  • 16
2

Please check this links:

Remember that there is a Python implementation on the JVM called Jython.

Edit: In terms of Android development i should say Jythonroid.

DarkByte
  • 192
  • 5
  • As I understand Jython works by compiling Python source to JVM byte-code on the fly. But Android does not have JVM, it has different VM implementation called Dalvik (http://www.dalvikvm.com/). And Dalvik is not byte-code compatible with JVM, so this generated code could not be executed. – uaraven Oct 03 '11 at 15:26
  • 1
    You are right. There are some things that the Dalvik cant do, or cant do equally. But just like you say Jython is converted to Java bytecodes, and this can be then converted to Dalvik. See this [link](http://android-dls.com/wiki/index.php?title=Android_FAQ#Q:_Is_Python_available_for_Android.3F) – DarkByte Oct 03 '11 at 15:43
  • okay, I understand. But how it can looks like in practice? Maybe, simple widget's code example? please.. – Крайст Oct 05 '11 at 05:35
0

Pyjamas perhaps? Maybe not exactly what you're looking for but it would allow you to at least write some of your code in Python (and compile to JavaScript).

ChrisC
  • 1,282
  • 9
  • 9
  • I can use JS to make desktop widgets on Android?! – Крайст Oct 05 '11 at 05:36
  • @Крайст - sorry, missed the part about wanting to do desktop widgets; I thought you were looking for a way to get a Python-based app going. – ChrisC Oct 05 '11 at 16:16
  • ammm... I want to know, how can I make/write home screen widgets for android. In Python or maybe in js (Opera makes this possible, as I know) – Крайст Oct 05 '11 at 17:28