I've just started learning a bit of Python and I'm currently trying to implement a Python UI through HTML. Is there anything in vanilla Python that would allow for this, similar to how you can create UI's with Java and XML with JFX or will I have to use a framework such as Django?
I'm reluctant to use Django as there are many features that I do not need
Thanks,
Michael
In vanilla python wsgiref is very helpful for building the server-side of web-applications (possibly with str.format or string.Template and/or json) but if you want it more direct communication I would suggest XML-RPC (there are good js-clients out there).
It is also possible to execute Python Scripts right in your Website with Brython or (with strong constraints) Ironpython
For Windows you can build HTML Applications with Ironpython (have not tried but in theory it should work) or Brython (if you dont want to require the user to have ironpython installed)
You can also use Pyjs to build applications but while it uses html and javascript, i think it you dont see much of it.
There are HTML things in some ui-libraries like in wxpython (I am quite sure you will find them in many libraries)
Related
I am wondering if there is a way to to navigate Python(Django) code in Emacs similar to how one can M-. for Common Lisp code when using SLIME.
I have installed ELPY and a mode called python-django. However, they do not seem to provide this functionality.
I am particularly interested in doing this why developing using Django. However, even navigation for standalone Python projects would be nice.
I will give dumb-jump a chance.
It is not as fancy as other go-to-definition methods, as it only searchs for some predefined regex in your project. But it simply works most of the time, and you can add your own regex if you need them.
We have a tool written in C# where we write vb.net scripts. Now, I need to integrate python in it so that we can run python scripts in same tool. All, the tool does is send string command and capture the string response.
My question: do I need to write interpreter for this?How can I talk to python engine. Is there any other way I can implement this? Links to get it going would be helpful. Just started with python today!
Thanks!
Look into IronPython to fill your scripting needs. IronPython will provide you all of the features of Python but from within the .Net framework. Here is a previous question concerning embedding IronPython in C#
Michael Foord has an post on embeddeding IronPython into C#. There are several methods to achieve this goal. The simplest being to create a hosting engine from within C# and embed a string of Python code that will be executed.
What are good python libraries for the following needs:
MVC
Domain Abstraction
Database Abstraction
Video library (just to create thumbnails)
I already know that SQLAlchemy is really good for Database Abstraction so don't bother with it unless you want to suggest a better one.
Edit: This might seem stupid to mention but I'm talking about MVC for GUI and not for web, just mentioning for clarification
Edit: Also does the MVC part contain GUI part or can I use a separate library for GUI like PyQt
Have you tried wxWidgets (well, wxPython in fact)?
It has nice documentation (which is always a good thing), and allows creating code in MVC manner. It's just the GUI library, but allows some simple image manipulation (if it's not good enough for you try using Python version of ImageMagick). It uses native controls, so the application looks native on the OS it's being ran.
PyQt on the other hand has even better docs than wxWidgets or wxPython, but I could never get used to the look&feel of its GUI (it's custom, so it doesn't look native on any OS). Because riverbankcomputing couldn't agree with nokia on a license nokia started a project called PySide which is a LGPL version of the Qt-bindings. It's supposed to be finished in early 2010.
django is a pretty good mvc framework with an orm
You could go with http://turbogears.org/ . Its like Django, but uses "of the shelves" existing modules.
TurboGears 2 is the built on top of the experience of several next generation web frameworks including TurboGears 1 (of course), Django, and Rails. All of these frameworks had limitations which were frustrating in various ways, and TG2 is an answer to that frustration. We wanted something that had:
Real multi-database support
Horizontal data partitioning (sharding)
Support for a variety of JavaScript toolkits, and new widget system to make building ajax heavy apps easier
Support for multiple data-exchange formats.
Built in extensibility via standard WSGI components
Is there a way to execute python code in a browser, other than using Jython and an applet?
The execution does not have to deal with anything related to graphics. For example, just sum all the digits of a binary 1Gb file (chosen by the browser user) and then return the result to the server.
I am aware that python can be executed remotely outside a browser, but my requirement is to be done inside a browser.
For sure, I take for granted the user will keep the right to execute or not, and will be asked to do so, and all this security stuff... but that is not my question.
The Pyjamas project has a compiler called pyjs which turns Python code into Javascript.
nosklo's answer is wrong: pyxpcomext for firefox adds language="python" support to script tags. yes it's a whopping 10mb plugin, but that's life. i think it's best if you refer to http://wiki.python.org/moin/WebBrowserProgramming because that is where all known documented links between python and web browser technology are recorded: you can take your pick, there.
I put together a table comparing many Python-In-Browser technologies not long ago:
http://stromberg.dnsalias.org/~strombrg/pybrowser/python-browser.html
On my travels, I came across Skulpt, a project which seems to offer Python directly in the browser without plugins. It's licensed under MIT.
Skulpt Homepage
Skulpt # Github
No, you can't.
Modern browsers only run javascript or plugins. You can develop your own python plugin and convince people to download and run it, but I guess that falls to the "not inside the browser" category.
You mean client-side?
Sure you can! But you need to have python installed on the client first.
The linked book describes that in order to use client-side Active Scripting, you can test it with the a simple html file.
<html><body>
<script language='Python'>alert("Hello, Python!")</script>
</body></html>
In the old version refered in that book (Python programming on Win32
By Mark Hammond, Andy Robinson)
it says that you need to install the Python Win32 extensions, and it will automatically register Python Active Scripting. Should you do it manually, you have to run the script python\win32comext\axscript\client\pyscript.py.
http://repl.it/ - Python interpreter in JavaScript running on client side. There are many other languages too. Source is available under MIT license, which is awesome.
You can now (2016) also use:
http://www.transcrypt.org
It compiles Python 3.6 (incl. multiple inheritance, operator overloading, all types of comprehensions, generators & iterators) to lean and fast JS, supports source level debugging with sourcemaps and optional static typechecking using mypy.
Disclaimer: I am the initiator of the project.
By accident I was listening to Hanselminutes where he mentioned about Gestalt project. This is a solution to integrate a languages as IronRuby and IronPython in browser via Silverlight.
So I think the answer is no if you don't have any special plugins.
Brython - "A Python 3 implementation for client-side web programming"
http://www.brython.info/
https://bitbucket.org/olemis/brython/src
I'm planning on using an embedded browser in my pygtk application and I'm debating between gtkmozembed and pywebkitgtk. Is there any compelling difference between the two? Are there any third options that I don't know about?
It should be noted that I won't be using this to access content on the web. I'm mainly using it for UI purposes.
My priorities are:
It needs to be stable.
It needs to be cross-platform.
It should be easy to use.
It should be actively maintained.
It should be extensible.
It should be fast.
gtkmozembed is not available on Windows, although you can use the gecko embedding interface directly. This would require you to write some C++ code.
As far as I know, the gtk webkit port is not available on Windows yet, and still appears to be undergoing a lot of change.
For an example of a cross-platform gecko embedding solution, check out Miro.
Miro is python, and they've written just a couple of C++ classes to embed gecko on Windows, while using gtkmozembed on linux.
if you judge by the web pages then definitely pywebkitgtk
pygtkmoz from this page
"Note: this project is no longer maintained. Please use gnome-python-extras (http://www.pygtk.org) instead. I apologize for any trouble this might cause, but this is better in the long run. Python bindings for GtkEmbedMozilla."
and pywebkitgtk looks like active project changes