embedding plot within Qt gui - python

How do you embed a vpython plot (animated) within your Qt GUI? so that it has its own display area and would not need to created a new window anymore.

vpython's FAQs claim that vpython's architecture make any embedding a problem...:
Q: Is there a way to embed VPython in another environment?
This is difficult because VPython has
two threads, your computational thread
and a rendering thread which about 25
times per second paints the scene
using the current attributes of the
graphics objects. However, Stef
Mientki has managed to embed VPython
in a wxPython window on Windows; see
the contributed section.
So if with wxPython it takes heroic efforts ("has managed to" doesn't sound like a trivial achievement;-) AND only works on a single platform, I fear it won't be any easier with Qt... one hard, uphill slog separately on each and every single platform.
If you're up for a SERIOUS challenge, deeply familiar with vpython, reasonably familiar with Qt, and acquainted with the underlying window-level architecture on all platforms you care about (and with a minor in wxPython), the place to start is Mientki's amazing contribution. He's actually working well below wxPython's level of abstraction, and in terms of win32gui calls, win32con constants, plus "a finite state-machine, clocked by a wx.Timer" at 100 milliseconds (though he does admit that the result from the latter Frankenstein surgery is... "not perfect";-). Extremely similar approaches should see you home (in a similarly "not perfect" way) on any other framework on Windows, including Qt.
However, nobody's yet offered any ports of this to Mac OS X, nor to any window manager of the many that are popular on Linux and Unix-like architectures (I'm not sure whether the feat could be achieved just at xlib level -- window decoration aspects do seem to be involved, and in the X11 world those DO tend to need window manager cooperation).
So, the literal answer to your question is, "with a huge amount of work requiring lots of skills and/or incredible perseverance, and probably in a platform-dependent way that will require redoing on each and every platform of interest"... sorry to be the bearer of pretty bad news, but I prefer to call them as I see them.

I contacted maintainer of VPython and he confirmed, that he is not aware of any working solution where Visual is embedded into QT window.
That turned me to try VTK and so far I'm pretty happy, no problem with using VTK within PyQT framework.

Related

how can ensure that a Python qt application is screen readable on all operating systems

I am developing a text with Python and Qt that can be used by blind and visually impaired people.
The text editor should be suitable for screen readers.
I do tests with the screen readers NVDA (Windows) and
Orca (Ubuntu).
Texts for screen readers should actually be saved in the "AccessibleDescription" property. The NVDA screen reader does not read the "AccessibleDescription" property. AccessibleName property only. The Orca screen reader reads the "AccessibleDescription" property.
Question:
What can I do so that my application is screen-readable on all operating systems?
Short answer
Sadly, there's probably no magic solution here.
The only reasonnable answer is just trying and testing a maximum of different combinations of OS, screen readers, GUI toolkits and components, as much as you can. That's the only way to discover what works well for your particular scope, and what doesn't.
There is no uniformity at all between OS, screen readers and GUI toolkits, and probably no combination working everywhere in all cases.
Longer answer
This isn't a peasure to give this answer but in fact, if you want to make sure your app is 100% screen reader accessible, your only way is basicly to stop using GUI toolkits and exclusively use the native components offered by the OS for which accessibility is well documented; and therefore of course develop as many different apps as OS you intent to support.
As soon as you are using a GUI toolkit, you are adding a layer, and may lose some accessibility (and often more than less) in the process.
The gap between the features offered by the native OS components and those proposed in the toolkit is often closed by emulation, and some of the emulations aren't made accessible, or simply can't be made accessible for various (more or less excusable) reasons.
That's why some components are accessible while some others aren't; why a given component can be accessible under one OS but not at all under another; and why a component can be accessible in version N of the toolkit but not the same component in version N+1.
In short, you have understood, accessibility is extremely fragile.
Sadly, GUI toolkits rarely well document accessibility of their components under the different OS they support.
That's really a shame. It has to be addressed.
Additionally, accessibility is often presented as being expert compicated features. It shouldn't be so. It should be easy for app developers to make accessible apps.
So, wwell, since there is often no documentation about accessibility, your only way is to try and test.
That's a lot of work, and there is no alternative. Try and test. That's all.
Digging deeper
There's generally two foundamental ways to design a GUI toolkit, and depending on which has been chosen, this has a dramatic impact on natural accessibility, and what kind of accessibility the toolkit can hope to achieve.
The first way is to start from a blank page as far as the OS permits, and from there, decide literally everything: what components to provide, and how they should look and behave.
By doing so, you make sure that your app will look and behave exactly the same everywhere. An user might be surprised or confused the first time because look and behavior is often not 100% conform to OS conventions or user preferences, but in the long run, he/she will always feel at home with your app regardless of the OS used.
However, more importantly, create everything from a blank page also means that everything must be defined from scratch for accessibility. It requires of course a lot of work, whether for the GUI implementers, or the app developer. Different toolkits place the responsibility cursor at different places.
Some toolkits perform better and/or go further than others, but in general they are nowhere near what the native components of the OS can provide.
The second way is to use as much as possible the components proposed by the OS, and emulate only missing features when they are really needed.
This is excellent for accessibility, since almost all native OS components are naturally accessible or only require little effort. Users will have an app that conforms to the general look of their OS, and so won't be confused or surprised by the interface and its behavior.
However, the app isn't going to look exactly the same in all computers. Sadly, for many designers and developers, this is a definitive stopper.
As the vaste majority of GUI toolkits I know of, QT is part of the first group, but isn't playing that bad in accessibility (at least under windows) if the app developer is also aware of accessibility.
In the second group, you have WXWidgets for example.

What are good libraries for creating a python program for (visually appealing) 3D physics simulations/visualizations?

What are good libraries for creating a python program for (visually appealing) 3D physics simulations/visualizations?
I've looked at Vpython but the simulations I have seen look ugly, I want them to be visually appealing. It also looks like an old library. For 3D programming I've seen suggestions of using Panda3D and python-ogre but I'm not sure if it is really suited for exact simulations. Also, I would prefer a library that combines well with other libraries (E.g. pygame does not combine so well with other libraries).
3D support for python is fairly weak compared to other languages, but with the way that most of them are built, the appearance of the program is far more mutable than you might think. For instance, you talked about Vpython, while many of their examples are not visually appealing, most of them are also from previous releases, the most recent release includes both extrusions, materials, and skins, which allow you to customize your appearance much moreso than before.
It is probably worth noting also, that it is simply not possible to make render-quality images in real time (cycles is a huge step in that direction, but it's still not quite there). I believe that most of your issue here is you are looking for something that technology is simply not capable of now, however if you are willing to take on the burden for making your simulation look visually appealing, Vpython (which is a gussied up version of PyOpenGL) is probably your best bet. Below is a run down of different technologies though, in case you are looking for anything more general:
Blender: The most powerful python graphics program available, however it is made for graphic design and special effects, though it has very complex physics running underneath it, Blender is not made for physics simulations. Self contained.
Panda3D: A program very often compared to Blender, however mostly useful for games. The game engine is nicer to work with than Blender's, but the render quality is far lower, as is the feature-richness. Self contained
Ogre: A library that was very popular for game development back in the day, with a lot of powerful functionality, especially for creating game environments. Event handling is also very well implemented. Can be made to integrate with other libraries, but with difficulty.
VPython: A library intended for physics simulations that removes a lot of the texture mapping and rendering power compared to the other methods, however this capability is still there, as VPython is largely built from OpenGL, which is one of the most versatile graphics libraries around. As such, VPython also is very easy to integrate with other libraries.
PyOpenGL: OpenGL for Python. OpenGL is one of the most widely use graphics libraries, and is without a doubt capable of producing some of the nicest visuals on this list (Except for Blender, which is a class of its own), however it will not be easy to do so. PyOpenGL is very bare bones, and while the functionality is there, it will be harder to implement than anything else. Plays very will with other libraries, but only if you know what you're doing.
Try PyOpenGL. It is a library that provides Python bindings to OpenGL through the Python ctypes library.
Heres a demo of this:
If I needed a visualization package for python, I would start with Processing.py:
https://github.com/jdf/processing.py
This is a python binding for the java-based Processing.org codes. A quick comparison can be found here:
http://wiki.processing.org/w/Python_Comparison
Of course, if you are not constrained to python, then Processing itself would also be a good starting point:
http://processing.org
There are also python bindings out there for Visualization Toolkit (VTK), but most of their examples are either C++ or Tk.
If all you're looking for is scene graph to move geometries around, not native vis, then I have seen some python binding for Open Scene Graph out there, eg: http://code.google.com/p/osgswig/
Good Luck!
From your question, it is not clear what you want to achieve. Do you want to create a standalone application that can be used to control the simulation at runtime, or, create a simulation using Python that can then be viewed offline?
For the latter, you could look at Blender, an open source 3D content creation suite which includes a python scripting interface giving access to most (if not all) of the internals of the application. Blender comes with some physics and particle libraries which might be of use and as an application is indicative of the type of software used to make visual effects for films etc.
If you want to make a standalone application to control the simulation at runtime, this is most likely not a suitable option. However if you want to produce a series of viewable images it might be worth a look.

Framework for paint program

I've decided to start working on a personal project, attempting to develop a cross platform, MSPaint like app. Oddly enough, I find mspaint is one of the applications I miss the most on Linux or OS X, so I want to try to make something similar. Tuxpaint, mtpaint, gpaint, etc. are all old and inactive and ugly. I don't want to make GIMP, just the basics, similar in features to MS Paint.
I'm thinking of doing it in python with the pygtk toolkit, but I was interested to hear your suggestions. Would C/C++ be a better choice, or even C# (gasp!) with mono? How about using Qt as opposed to GTK, or maybe some other fancy library I don't know about (Please, not FLTK!). I'd be curious to hear your thoughts.
Thanks!
Qt's canvas object (or its newer replacement QGraphicsView) can do pretty cool things. Whether you choose C++ or python is a matter of personal choice, as Qt is supported in both languages. For a simple project like this I'd choose python because killer performance is not much of an issue, and it will be much easier to write.
Another thing to look into is making this app web based with HTML5's canvas object and Javascript. It can be surprisingly robust, and anything that can be put on the cloud is a win in most cases.
If you decide to go with Python (which would be my choice because it's such a simple language), then TkInter is considered the de-facto standard GUI package. That link should send you to some excellent starting references for TkInter, although I also really like Not_a_Golfer's suggestion of an HTML5 web-app.
Short: You can use both, no third party library is guaranteed to be distributed with all major distributions.
Long:
Gtk+ vs. Qt
What do you want incorporate into your application. If it is just selecting a brush, selecting color you could pretty much use any gui toolkit.
If you are going to run it as a web-based tool, Gtk+ has an html5 backend renderer (I don't know about Qt)
A sidenote:
I recommend to use the toolkit's native programming language (gtk+ C, Qt C++) - if you don't, you will suffer from delays with bugfixes, generally more bugs and delayed releases, though for that case it shouldn't really matter.
Everything else boils down to personal preferences and there already exist some questions to tackling that issue.
if you are using qt,you can use QtitanRibbon

How to use python to create a GUI application which have cool animation/effects under Linux (like 3D wall in Cooliris, compiz effects etc...)

I am not sure if my question title makes sense to you or not. I am seeing many cool applications which have cool animations/effects. I would like to learn how to use python to create this kind of GUI applications under Linux.
"cool animation/effects" like 3D wall in Cooliris which is written in flash and compiz effects with opengl.
I also heard of some python GUI library like wxPython and pyQT. Since I am completely new to python GUI programming, can anyone suggest me where to start and what I should learn to achieve and create such application? maybe learn pyQT with openGL feature? pyopengl binding? I have no clue on where to start. thank you very much for your time and suggestion.
By the way, in case if someone need to know which kind of application I am going to create, well, just any kind of applications. maybe photo explorer with 3D wall, maybe IM client, maybe facebook client etc...
http://techbase.kde.org/Development/Languages/Python
Many KDE styles use SVG and plenty of animation. The user can always change themes. I think you should be more specific about what kind of animations you want to do. I don't think 3D wall type affects really fall into the widget category that QT is. It sounds to me like you want to make a 3D interface for an application. If that is the case, you may want to look more into 3D engine type libraries used mainly in games. I know that some have excellent GUI widgets for programming game menus and the like. I guess you'd decide on your engine and the see if there are python language bindings. One of my favorite engines: http://irrlicht.sourceforge.net/links.html
Another thing you would want to consider is how you want to handle the window management. Do you want to make a full screen interface? Or is to to be windowed? Also how would such an application integrate into a 3D window manager or rather a window manager with compositing.
Edit:
In that case the qtopengl module is probably something to look into: http://doc.qt.nokia.com/4.6/qtopengl.html
I do recommend QT. It's clean and easy to use and cross platform. So your app could run on windows as well.
One thing you'd want to think about before hand is the type of FX you want to perform. For example, if you want to create a page curl type effect when renaming the image, you'd have to think about how to program that, or look for libraries/code snipets that do that math. 3D engines that are used in games often have a lot of support for those kind of typical FX or animations that you'd see in a game. If you use something like qtopengl, you'd need to think about this as well. qtopengl can pretty much only render. Think of it as a viewport. However, it is the correct approach to making a 3D application for the desktop.
Programming 3D applications is really interesting and fun. I enjoyed it a lot. However, don't get discouraged be the math. I recommend getting a book about it if you are serious. I liked this one: http://www.amazon.com/Primer-Graphics-Development-Wordware-Library/dp/1556229119
However, IIRC the examples are C++ which you may not be comfortable with. When you understand such mathematical concepts, it easier to think about how you would make a page curl type affect. Of course, if you find libraries or code that shows you how to do the math, that may be fine.
May be, just create a GUI and all effects will make compiz?
Anyway, as I know QT have ability to use openGL.
http://doc.qt.nokia.com/4.1/examples.html#opengl-examples

Which GUI framework to learn when you know scripting and HCI

I have some knowledge about Human computer interaction and some basic knowledge programming scripts (Python) that run from start to finish and automate some tasks I want to do or calculations. In the past I built interfaces in HTML with PHP behind it.
I would like my python scripts to evolve from the command line and build some applications with GUIs that would allow the user to drag files and push buttons to initiate operations and check progress graphically.
Since I write my scripts in Python I looked at some of the options (Tkinter, wxPython, PyQt) but I can't make a decision between them to invest my time learn one and not the other. My criteria:
Has a introduction for programmers for GUI (what are the differences from a script, examples of some simple interfaces)
A framework that would allow me to run my programs on the platforms I use most (Windows) but that can also run on Mac and maybe Linux, without too much modification.
Very shallow learning curve (easy to make first interfaces) but flexibility later on to customize the interface beyond what the typical OS allows (different colors, size and shapes of buttons, for example)
If not the same, similar to how you program GUI for Android and/or Nokia smartphones. I'm planning to write some programs for these platforms in the near future so I would like to carry over some of the lessons here onto those platforms, if possible.
I did find this previous question but none of the answers are satisfactory.
Does any of the frameworks fit these requirements better than the others or are they essentially similar and I would be happy with any of them?
Note: If you think I should consider other language rather than Python to achieve this, which one? I really like Python whitespace syntax and have grown used to it so I would prefer to stick with it.
PyQt and/or the very similar Nokia-sponsored PySide (with a more "relaxed" license, LGPL instead of GPL, and the same underlying toolkit, Qt) do offer the advantage of similarity with Nokia's smartphones GUI toolkit (your fourth point) -- Nokia purchased Trolltech, the makers of Qt, exactly because Qt was the fundamental GUI toolkit for their mobile offerings.
All the toolkits you mention satisfy the conditions you pose about operating systems (Windows, Mac, Linux), your second point.
Your first and to some extend third points depend in good part of what learning materials you have available for each of the toolkits. To my tastes, it seems that wxPython's tutorial (the new one in wiki form is what I'm pointing to and recommending) is really good, and PyQt's not bad at all; PySide's docs don't include a good tutorial (that I know of), I believe PySide's intention is that you first learn PyQt (with the reasonable available materials), then apply these few differences to be programming in PySide instead of PyQt;-). Tkinter's tutorials that I can find are either very old or focused on the underlying toolkit's multi-language nature, which I think makes them inferior.
If you can afford a book, PyQt has a good one (also applies to PySide, as above) -- this excellent and free one is unfortunately very old, so I don't think it helps. wxPython's own book is also quite good; tkinter's, again, is very dated.
Personally I recommend PyQt / PySide: overall power A+, ease to get started (with the above tutorial and book) A-, Nokia-phone programmer similarity A. For wxPython I'd say power A, ease A, Nokia-similarity B. Tkinter's dated tutorials and book are important negatives.
You also mention Android, but I don't see how anything could be similar to both Android and Nokia's phone-GUI programming at the same time. Maybe I'm not familiar enough with Android GUI programming, but it seems to me that it differs from every one of the toolkits you've mentioned.
PyGTK fufills at least the first three points. I'm not sure on the fourth. It has a nice tutorial here: http://www.pygtk.org/pygtk2tutorial/index.html
I guess you are looking for Glade.
The site says:
Glade is a RAD tool to enable quick & easy development of user
interfaces for the GTK+ toolkit and the GNOME desktop environment.
The user interfaces designed in Glade are saved as XML, and by using
the GtkBuilder GTK+ object these can be loaded by applications
dynamically as needed.
By using GtkBuilder, Glade XML files can be used in numerous
programming languages including C, C++, C#, Vala, Java, Perl,
Python,and others.
I am a pretty noob programmer yet, but I am having just a few issues to get things started with C and Glade. So I guess you will run smoothly here with your snake. Take a look.

Categories

Resources