I am looking for a Python GUI library that I can rewrite the rendering / drawing.
It has to support basic widgets (buttons, combo boxes, list boxes, text editors, scrolls,), layout management, event handling
The thing that I am looking for is to use my custom Direct3D and OpenGL renderer for all of the GUI's drawing / rendering.
edit suggested by S.Lott: I need to use this GUI for a 3D editor, since I have to drag and drop a lot of things from the GUI elements to the 3d render area, I wanted to use a GUI system that renders with Direct3D (preffered) or OpenGL. It also has to have a nice look. It is difficult to achieve this with GUI's like WPF, since WPF does not have a handle. Also it needs to be absolutly free for commercial use.
edit: I would also like to use the rendering context I initialized for the 3d part in my application
I don't know what are you working at, so maybe this is not what you're looking for, but:
Have you considered using Blender + its Game Engine?
It supports Python scripting, and provides some APIs to create "standard" GUIs too, while allowing you to do a lot of cool stuff with 3d models. This could be especially useful if your application does a lot of 3d models manipulation..
Then you can "compile" it (it just builds the all-in-one package containing all the dependencies, in a way similar to what py2exe does) for any platform you need.
You can use Qt Scene Framework with OpenGL rendering. There are many examples on Nokia site.
The best Python GUI toolkit is wxPython (also known as wxWidgets).
This is not merely my opinion, see also: wxPython quotes
wxPython is the best and most mature
cross-platform GUI toolkit, given a
number of constraints. The only reason
wxPython isn't the standard Python GUI
toolkit is that Tkinter was there
first. -- Guido van Rossum
I can't say how easy or hard it would be to add your own renderer.
There are OpenGL bindings in Python that will get you 3D rendering. Personally, I'd use wxpython as your 'gui' manager and use the bindings to do opengl for the rest. Wx has the necessary demos (check the wxpython demos installation) and information in their GLCanvas demos.
Another sample code is here too.
You might find PyClutter useful.
Related
I work a lot with HTML & CSS for Web Development, and I've only recently transitioned to Python for software development. I've done some of the basics with Python, my proudest moment being I programmed a calculator through Python using the TKinter, but I'm going to be honest with you it's quite ugly. I know how to change the foreground and background color, but that's about it. I was sort of hoping there was a way to style Python like you would style HTML with CSS. Is something like this possible?
I don't know if this is too broad of a question, but I really just need some sort of answer. Even a link to some sort of YouTube video to get me down the right path would be nice. I would also like to learn how to do other GUI style's like transitions, hover effects, and keyframes, but that's for another question.
Inside of python your options are quite less, but never none. You have options starting from ttk from tkinter, which kind of gives a windows 7 theme and with ttkthemes you get more themes for tkinter. But if your planning to go on for a more modern GUI, using HTML and CSS and JS, then you do have Eel for python. There is also a python wrapper for Qt called PyQt which also provides not so bad design. And also Kivy which can also gives you some kind of modern looks. Using tkinter is mainly for simple projects and it has its own limitations. But one of the limitation is your imagination and designing skill, for example here is a GUI I made with tkinter:
It does not look top of the mark or something, but it kind of looks better than traditional looks with tkinter.
First off, Web Design with CSS is a lot prettier, in Python you have less options.
But there is an editor called QT Designer, it lets you create GUIs and use them in your C++ or Python script. You may give it a try.
Keith Galli made a youtube tutorial on a Python GUI with TKinter which doesn't look that bad, regarding it's made with Python.
i have a small application. I want my target users(windows,linux) to be able to start and exit the application from the system tray. I intend to use Tkinter because of its low footprint but, i dont know how to implement it.
Can tkinter do this or are there better alternatives. I need a GUI library that won't change my 1MB program to a 5MB program.
Please sample codes will be appreciated
Thanks
I don't know any direct examples but I found a TCL/Tk extension to use the systray over here http://wiki.tcl.tk/4090 and a page on the wiki giving information on how to use TCL/Tk extensions from Tkinter.
On a more general note, you might want to consider using a more "advanced" toolkit (like wx) that provides things like systray usage etc. natively.
I've got a Python/GTK project I've been working on for a while, and some of the functionality I want already exists in Gnome panel applets. Based on my reading, panel applets are already in a subclass of the standard GTK Bin, so I would think there'd be a way that I can use the C-based GTK objects in my Python-based application.
For instance, I've got the fish applet in /usr/lib/gnome-panel/fish-applet-2 as a binary
Can I do some GTK magic to get that object so it can be embedded into my Python/GTK gui?
I'm not expecting a step-by-step walkthrough, but if anyone can point me in the right direction, I'd appreciate it.
The code for applets in gnome panel is quite complex. It's based on the gnome Bonobo framework (which in turn is based on CORBA). But now the whole thing is in a bit of a flux because gnome is moving away from Bonobo to a new dbus-based design. So if it's loading existing gnome panel applets you want you should absolutely use the code from gnome panel to do it. There is (or at least was) an example program included that does nothing but load an applet into a window.
If you want to display a widget from one of your own programs (a custom applet) inside another of your programs it's much easier. There are a set of widgets called GtkSocket and GtkPlug for this purpose. Of course the to programs doesn't need to run on the same machine. But there is always the delicate problem of getting them together in the first place.
I am writing a small diagram drawing application (similar to Graphviz in spirit), and need a GUI library that would allow me to embed a canvas capable of drawing anti-aliased lines and text. I want to have a text editor in one half of the window to edit the diagram code and a (perhaps live) preview pane in the other.
Right now I have the text editor in a tkinter window and the rendered diagram in a separate pygame one. This technically works, but it's messy (e.g. having two event loops), and in general I would much prefer having both parts in one window. I have searched for ways of integrating the two, but haven't been able to find anything cross-platform, and pygame explicitly suggests not trying to do it.
An alternative would be to have pygame export the image into a file and load it back into tkinter, but tkinter can read only GIF/PPM without PIL (and I use Python 3, which PIL doesn't support) and pygame can't write GIF/PPM. I could backport to Python 2, since it's a tiny app, but even then, having a large extra library for a simple image conversion doesn't seem right, and the round-trip to a file will probably be too slow for live preview (not to mention ugly).
Finally, a simple tkinter canvas is almost what I want, except it can't draw anti-aliased lines, and for a program whose main purpose is to draw line figures, that is not acceptable.
I'm using Python 3 so libraries that support it are preferred, but if there's no way to do that whatsoever Python 2 libs are Ok as well. The library needs to be cross-platform, and of course, the fewer external packages are required, the better.
If you don't mind the way GTK looks, pygtk has an option for antialising in their canvas widget (see this) and is considered by many to be as powerful as Tkinter, though it is not included in standard Python installs.
Also, it's Python 3.x compatible, which can't be said of most non-standard library modules and packages.
Screwing around with Tkinter+pygame is silly. I would use wxPython. In fact, I've done a diagramming widget using wxPython, and it has anti-aliasing:
Unfortunately it was for work, so I can't distribute the code.
The wxPython classes you want to look at for anti-aliasing are wx.GCDC and/or wx.GraphicsContext.
After a thorough search I ended up using PyQt4. It does fit all my requirements (Python 3, cross-platform, anti-aliasing), and now that I've gotten through the basics, it's also quite intuitive and easy to use.
Posting this as an answer to my own question and accepting it for future reference.
I'm writing a simulator in Python, and am curious about options and opinions regarding basic 2D animations. By animation, I'm referring to rendering on the fly, not displaying prerendered images.
I'm currently using matplotlib (Wxagg backend), and it's possible that I'll be able to continue using it, but I suspect it won't be able to sufficiently scale in terms of performance or capabilities.
Requirements are:
Cross-platform (Linux, MacOS X,
Windows)
Low complexity overhead
Plays well with wxpython (at least won't step on each other's toes unduly)
Interactivity. Detect when objects are clicked on, moused over, etc.
Note that high performance isn't on the list, but the ability to handle ~100 bitmap objects on the screen would be good.
Your thoughts?
I am a fan of pyglet which is a completely self contained library for doing graphical work under win32, linux, and OS X.
It has very low overhead, and you can see this for yourself from the tutorial on the website. It should play well with wxpython, or at least I seem to recall posts to the mailing list about wxpython and pyglet being used together.
It however does not offer selection of objects via mouse clicks - this you will have to handle yourself. Generally speaking for a 2D application this is not too difficult to do.
mactorii is an OS X application of mine written in pure python+pyglet, and has some basic animation (scrolling) and click detection. It doesn't use wxpython, but perhaps it will give you an idea of what is involved. Note however mactorii is using the old pyglet api, so the run loop I have in there is obsolete. I will get around to updating it one day... :P
You can try pygame, its very easy to handle and similar to SDL under c++
Arcade works on any platform with OpenGL 3.3+ (i.e. not the Raspberry Pi, but most other platforms). Although it's intended for simple games, Arcade offers great bitmap and sprite handling, as well as simple graphics primitives such as rectangles, arcs and circles.