I have some data in an SQLite database and serve it through JSON objects to an HTML app via AJAX calls and chart it using D3.js. I would like to replicate the same functionality locally (MS Windows is fine) in a self-contained application. It would be a super simple app, just a few form controls, a chart and a table, querying a local file-based database. As for it being self-contained - I'd like to ship an .exe file and an .sqlite file to someone with no need to install python, numpy, matplotlib, sqlite or anything on the target computer.
I'd like to it to be quite future-proof, so I'd rather stay away from experimental/alpha libraries and build it using more proven technologies that have had longer term support. It seems that PyInstaller is the way to go in terms of self-containing, but developers seem to be quite divided when it comes to GUI options.
The question is then: What's the industry standard to build future self-contained GUI apps in Python? One which would include SQLite access and charting. Thanks!
Python itself includes the sqlite module since version 2.5:
https://docs.python.org/2/library/sqlite3.html
So regardless of which Python GUI Toolkit you go with, you already have that functionality built in to Python. There are several options to choose from when it comes to Python GUI toolkits. If you want a toolkit that can handle theming / skinning, then you may want to look at PyQt or even Kivy. The only GUI toolkit that uses the actual widgets of each major OS that I know of is wxPython. All the others draw their own widgets, albeit some of them do it so well that you'd be hard-pressed to tell the difference (i.e. PyQt).
All three of these projects are stable and are currently being developed, although wxPython's development is much slower than the others mentioned here. wxPython and PyQt both have widgets that allow you to load web pages.
However if all you want to do is serve web pages locally, then you might be better served using a Python web framework such as Django or Flask. You could run these locally pretty easily and view your content via the user's browser. The exe could launch them locally and call Python's webbrowser module to launch the default browser to a local URL.
Related
I am new with Django. I need to quickly develop a sophisticated GUI for a Django project. My underlying database is resource description framework (RDF). Is there any Eclipse IDE available for quick Django GUI development? Or is there any other GUI development tool (provides widgets) available for Django based project?
JetBrains has a Product for Python developers with Django support.
Its not for free but you can try it for 30 days.
https://www.jetbrains.com/pycharm/
Django is a web framework. It doesn't have a GUI. Though there are many IDEs that support Django template syntax, none of them will provide any kind of GUI functionality.
As far as IDEs go, Jetbrains is good, Eclipse has pretty decent python support, though I'm a big fan of sublime texts smart simplicity.
As for GUI stuff, perhaps rethink a little here. Django is a web framework that deals best with transactional interaction. It fires you a web page, you fire it a response. The system isn't really a good fit to GUI stuff. Thats not to say it can't play a part. Instead consider splitting it into a client/server product. Both TastyPie and Django Rest Framework are good options for building a RESTful API that can be interrogated by a remote client. You can then build the client using either one of the visual studio suites, or delphi, or if your looking to stay within the python mothership, perhaps PyQT/PySide (Which include a visual form designer) would be more up your alley. I guess you could build djangos ORM into an app (Although personally I'd use SQLAlchemy for that as its more decoupled than djangos ORM), but I'd warn that direct network access to databases isn't generally held to be wise for obvious security reasons, and you need to have a have a hard think about the threading implications if your gui toolkit is multithreaded, because Djangos ORM isn't built with the assumption it'll need to deal with multiple threads over single objects. My 0.02c is use Django to build an API and PyQT (or whateer your comfortable with) for the front end.
GUI is a term more for desktops, frontend is for web, for more see https://en.wikipedia.org/wiki/Graphical_user_interface.
Try any HTML5 WISWYG editor to make frontend (probably responsive) design.
More no this look in https://softwareengineering.stackexchange.com/questions/148489/how-to-develop-front-end-ui-for-my-django-website
In essence I want to run existing python scripts through a web browser, display the text and plots(if any) and also keeping the ability to run them through the command line.
I am wondering is there any toolkit that can help me with the development.Also it would be nice if the toolkit does or allows JavaScript based interactive plots.
Thanks!
-Abhi
WSGI is designed for just this purpose - it provides an interface for a web server to initiate python scripts.
You probably don't want to work with WSGI in the raw. Flask is a straightforward, simple framework you might use for this.
The details of how to actually build a WSGI web server are well beyond the scope of a stackoverflow answer - you can find plenty of tutorial docs on Flask's website.
I am used to PHP having applications. For example,
c:\xampp\htdocs\app1
c:\xampp\htdocs\app2
can be accessed as
localhost://app1/page.php
localhost://app2/page.php
Things to be noticed:
a directory placed inside the www-root directory maps directly with the URL
when a file/directory is added/removed/changed, the worker processes seamlessly reflect that change (new files are hot-deployed).
I am on the lookout for a mature python web framework. Its for a web API which will be deployed for multiple clients, and each copy will diverge on customization. And our workflow has frequent interaction/revision cycles between us and our clients. Hence the "drag and drop" deployment is a must.
Which python framework enables this? I prefer a lightweight solution (which doesnt impose MVC, ORMs etc)
Related
How to build Twisted servers which are able to do hot code swap in Python?
Python web hosting: Why are server restarts necessary?
fastcgi, cherrypy, and python
No mature python framework that I'm aware of allows you to map urls to python modules, and frankly, for good reason. You can do this with CGI, but it's definitely not the recommended way to deploy python apps. Setting that requirement aside, flask and bottle are both lightweight micro web-frameworks with similar approaches, both allow you to reload automatically when changes are detected (this is only wise during development).
There is no web framework in Python that I know of that lets you do that out of the box, but if you need it it's not to hard to add with a bit of convention over configuration.
Simply pick your web framework of choice in Python and then write a wrapper to the main application that walks a directory or set of directory and auto-registers routes from the modules inside of them. Have your modules do the same thing in their __init__.py files to the other files located with them. Then just set up your WSGI code to autoreload when the WSGI script is updated and your deployment during development simply becomes a two step process - add file then touch dev_app.wsgi. You could even add a real deployment option to this wrapper that walks a set up dev environment like this and generates hard-coded URL-to-function mappings for deployment.
However, all of this work isn't really necessary. Python is not PHP and the way you develop in one doesn't necessarily translate to the other well. If the client wants variable routes, use dynamic routes and give them (or you) an admin interface to control the mapping of content to URL. Use flat files, SQLite, a NoSQL datastore, or the ether to store these mappings and the content. Use a template engine like Jinja2, Mako, Cheetah or Genshi to maintain your general layout. Wrap this all up with an object oriented structure to make extending it easy (or use a functional paradigm if that comes more naturally to you). Or, drop the whole dynamic in production portion and generate flat HTML files a la Jekyll.
CherryPy is a mature web framework that redeploys automatically when changes are detected. The file structure - URL isn't there, but it is a lightweight framework that doesn't impose ORM, MVC, or even a templating engine.
If you are used to PHP, you might want to take a look at the Apache modules mod_python or mod_wsgi (and WSGI in general if you do web development -- which is the Pythonic way).
With those two modules, the Python interpreter gets started every time a request comes in (similar to PHP). Needless to say, this slows things down but you'll always get the result based on your newest code. Depending on your expected traffic numbers, this might or might not be okay for you.
BUT: If you decide to write your own framework, you most probably do not want to write a system that supports "hot-deploying". Even though the reload() command is built-in, it takes more than just that and will get you into a world full of pain.
i am new in python.before this i done some work in php with codeigniter framework.
now i want to develop website using python and sqlite3.
so which framework will you suggest me.
i also want to know IDE for sqlite.
Do you mean something similar to sqliteman or dbeaver? These are not not IDEs for SQLite, but instead, are GUI interfaces. There are more here: http://www.google.com/search?&q=sqlite+gui
3rd link down is another stack overflow question: What are good open source GUI SQLite database managers?
For Python web frameworks, a very popular full-stack framework is the Django Project
Check out web2py. It's a feature-rich full-stack framework, but it's also very easy to set up, learn, and use. It requires no installation or configuration, has no dependencies, and includes its own web server and web-based IDE/administrative interface (see demo). If you download the binary version for Windows or Mac, it even includes its own Python interpreter (so you don't need to have Python installed).
The database abstraction layer (DAL) works with 10 different database backends, including SQLite. It doesn't include its own SQLite IDE, though it does include a database administrative interface called appadmin, which allows you to view all database tables; view, insert, update, and delete records within each table; and import/export tables to CSV. You can also import and export the entire database to CSV. (Note, these features work for all database backends, not just SQLite.)
You will probably also find that you don't really need an IDE for SQLite when using web2py because the DAL takes care of everything for you. You specify all of your data models using the DAL syntax, and then the DAL automatically creates the SQLite database, creates all tables, and handles migrations when you changes your models.
If you have any questions, there's a friendly and responsive mailing list that will provide lots of help.
I am in the planning stages of rewriting an Access db I wrote several years ago in a full fledged program. I have very slight experience coding, but not enough to call myself a programmer by far. I'll definitely be learning as I go, so I'd like to keep everything as simple as possible. I've decided on Python and SQLite for my program, but I need help on my next decision.
Here is my situation
1) It'll be run locally on each machine, all Windows computers
2) I would really like a nice looking GUI with colors, nice screens, menus, lists, etc,
3) I'm thinking about using a browser interface because (a) from what I've read, browser apps
can look really great, and (b) I understand there are lots of free tools to assist in setting up the GUI/GUI code with drag and drop tools, so that helps my "keep it simple" goal.
4) I want the program to be totally portable so it runs completely from one single folder on a user's PC, with no installation(s) needed for it to run
(If I did it as a browser app, isn't there the possibility that a user's browser settings could affect or break the app. How likely is this?)
For my situation, should/could I make it a browser app? What would be the pros and cons for my situation?
Writing a desktop application as a locally-hosted web application isn't typically a good idea. Although it's possible to create great user interfaces with HTML, CSS, and Javascript, it's far easier to create interfaces with conventional GUI frameworks.
Using web technologies to create your desktop GUI would introduce a great deal of unnecessary complexity to your application.
Creating user interfaces with HTML and CSS is difficult and time-consuming. HTML is a document markup language and CSS is a document formatting language; neither is well-suited to creating GUIs.
Using web technologies makes your application depend on the user's web browser. Far too many people are still using old, crippled browsers such as IE 6 and 7 that don't follow modern standards. You'll spend hours if not days trying to track down interface bugs that only happen on certain browsers.
You'll need to serve your application with a web server, introducing another layer of complexity. Your application will have to communicate with your interface through restricted web technologies without any of the benefits of a true web application.
I recommend using a desktop GUI framework, instead. In particular, I think wxPython would be the best GUI framework for you to use; it's stable, widely used, well documented, and highly portable. In addition, you can use a GUI-based interface builder such as Boa Constructor or possibly wxGlade to design your application's user interface. In summary, creating an application with almost any desktop GUI framework would be easier than using web technologies.
I've done a desktop app running on windows and I think that it is a great way to develop app.
I would recommend to have a look at bottle. It is a lightweight web framework. It is less capabale than Django for example but it does well. It can be packed with py2exe if you want to deploy on machines without Python.
There is a lot of javascript libs on the web to help you. I like jquery and jquery-ui, raphaeljs ... but there are some others.
My app is running into a small browser based on the mshtml component of Pyjama-Desktop. This way, the user doesn't know that it is a web app. But you could let the app running into the favorite browser, webbrowser python module might be interesting for you.
If your app needs to access your filesystem, a browser-based app may be tricky. For security reasons, a browser doesn't have full access to your filesystem. However, you can mimick file open with ajaxupload and file save with an iframe.
If it only deals with a sqllite database, i think that it is a very good choice.
I hope it helps
Pyjamas-Desktop
You did not mention if you are on windows or linux or any other OS.
If you are writing a browser app the first thing you are going to need is a web server, if each user is running the app on his local machine => means each user has to have a webserver running locally.
Also there are a lot of Rapid Development GUI toolkits such as wxPython and Glade which make design of GUI apps simple and easier.
I would suggest that if you are building a network app -> Take the browser route.
If you are building standalone app then go with a native application.
Here is an almost exhaustive list of all the frameworks. you can choose whatever suits your needs.
http://wiki.python.org/moin/GuiProgramming
I personally favor PyGtk, however it has a little learning curve associated with it if you havent done any GUI programming before.
I think it should work. What are you afraid of? Proxy settings, firewall?
I think running web server locally isn't hard for power user but it could be a problem for average user (even integrated with your app).
Probably You should run your app as service because forcing user to start server before entering web page, could be frustrating.
I would prefer other solutions. I would probably use Java (Swing) or C++ with QT. But I like Your approach, especially that it allows easy prototyping. If You prefer web style development you could try http://www.appcelerator.com/products/titanium-desktop-application-development/ it creates desktop apps using html+java script +webkit. But I didn't tried it my self (but I would like to).
Also Adobe Air could be probably good option for You.
I would suggest a browser application. This eliminates the need for installation on client computers (and as such, as OS agnostic), and is accessible from anywhere in the world if the DNS is set up correctly for the server.
Using a web interface allows you to make use of some of the more powerful User Interface tools, such as:
The ability to use CSS for spectacular design
The availability of JavaScript Utilities (jQuery, ExtJS, etc.)
Easily modified compared to Desktop applications
Higher accessibility
Consistent UI (e.g. Users already know how "back" works, etc)
Centralized updates (Just update the server, not each client)
Your choice of application type will be related both to the technology constraints and the type of user experience you plan to deliver.
Rich Client Application:
Usually developed as a stand-alone application.
Can support disconnected or occasionally connected scenarios.
Uses the processing and storage resources of the local machine.
Web Application:
Can support multiple platforms and browsers.
Supports only connected scenarios.
Uses the processing and storage resources of the server.
I personally favor PyQt in your case for a portable application.
The homepage for PyQt is http://www.riverbankcomputing.com/software/pyqt/
PyQt supports the Windows, Linux, UNIX and MacOS/X platforms.
PyQt4 is a set of Python bindings for Qt 4 that are dual-licensed under the GPL (version 2 and 3, with additional license exceptions) and a commercial license. There is also PySide by Nokia - new alternative bindings (as of November 2009) with LGPL license that struggle to be API compatible (at least until Qt 4.6) with PyQt4.
Tools and docs
PyQt Reference Documentation.
PyQt4 book: http://www.qtrac.eu/pyqtbook.html
The pyuic4 utility is a command line interface to the uic module. Conver xml ui from Qt to python.
Qt Designer is a powerful cross-platform GUI layout and forms builder. It allows you to rapidly design and build widgets and dialogs using on-screen forms using the same widgets that will be used in your application.
PyQt4 exposes much of the functionality of Qt 4 (From Nokia) to Python, including:
A comprehensive set of widgets
Flexible layout managers
Standard GUI features for applications (menus, toolbars, dock windows)
Easy communication between application components (signals and slots)
A unified painting system with transparency, anti-aliasing, OpenGL integration and SVG support
Internationalization (i18n) support and integration with the Qt Linguist translation tool
Etc.
You question is a little broad. I'll try to cover as much as I can.
First, what I understood and my assumptions.
In your situation, the sqlite database is just a data store. Only one process (unless your application is multiprocess) will be accessing it so you won't need to worry about locking issues. The application doesn't need to communicate with other instances etc. over the network. It's a single desktop app. The platform is Windows.
Here are some thoughts that come to mind.
If you develop an application in Python (either web based or desktop), you will have to package it as a single executable and distribute it to your users. They might have to install the Python runtime as well as any extra modules that you might be using.
Guis are in my experience easier to develop using a standalone widget system than in a browser with Javascript. There are things like Pyjamas that make this better but it's still hard.
While it's not impossible to have local web applications running on each computer, your real benefits come if you centralise it. One place to update software. No need to "distribute" etc. This of course entails that you use a more powerful database system and you can actually manage multiple users. It will also require that you worry about browser specific quirks.
I'd go with a simple desktop app that uses a prepackaged toolkit (perhaps Tkinter which ships with Python). It's not the best of approaches but it will avoid problems for you. I'd also consider using a language that's more "first class" on windows like C# so that the runtimes and other things are already there. You requirement for a fancy GUI is secondary and I'd recommend that you get the functionality working fine before you focus on the bells and whistles.
Good luck.