Generic GUI Wrapper For Python
An Anonymous Coward writes "IBM is working on a generic GUI wrapper to allow Python developers to write cross-platform GUIs. The anygui project will expose a common set of functions to the programmer and choose which backend gui toolkit to use for the given platform: TK, WIN32, GTK, Bethon, etc. Currently the software is in an alpha stage. The article also has some example code." Update: 10/27 23:53 GMT by T : Magnus Lie Hetland wrote to point out that though this article is hosted at IBM, "Anygui has nothing to do with IBM. It is,
in fact, an independent Open Source project currently
hosted at SourceForge."
What's wrong with WxPython? I've seen software on Linux and Windows that uses that. What is the difference between WxPython and IBM's one?
David
a Python story about a generic GUI wrapper.
-Mr. Redundant
Well, what about MacOS X?
Anybody know anything about future Python support for the X as well as this anygui?
I have been working with Python sience this summer Ranging from Web Apps to console apps. I find it real nice because I dont usually have to annoy the administer to add more modules on to the system (like in perl), Pluse my code comes out really clean and most of the time the programs are cross platform so it makes distribution a lot simpler. And the main reason I usually avoided using graphics in Python is because the GUI interface needed a tcl/tk program and that becomes more of a hasel for distribution. If they can come up for more of a common graphical interface that can be imbedded into the Python source and works platform independent I am all for it.
If something is so important that you feel the need to post it on the internet... It probably isn't that important.
Pretty much all the portability problems with AWT came from the use of native widgets. So, why is Mertz going to repeat the same mistake in his implementation? In fact, it looks like he is going to work hard to make things worse by exposing different APIs on different platforms.
There are a couple of good cross-platform GUIs for Python: FLTK with Python bindings, Fox with Python bindings, and wxWindows (universal or native) with Python bindings. Mertz's project seems like it recreates something whose functionality already exists--a typical case of N.I.H.
The problem: existing cross-platform libraries are not ported everywhere.
The solution, according to IBM: port an existing cross-platform library everywhere? No! Make an entirely brand new cross-platform library interface, that runs no previously-written code. Also, instead of wrapping the few unsupported low-level GUI interfaces not yet supported, and deal with all the quirks of each system, they will wrap every existing Python GUI, and deal with the quirks of each system. Naturally this will result in a far superior, much more portable product. Why? Because We're IBM and We say so! (it's their company motto, slogan, and vision statement, look it up)
So all Python programmers should immediately embrace this new standard, which, despite being alpha at best, will surely soon be much better than any existing toolkit.
Sure, they could just clean up the TK ports, but where's the fun (or branding) in that?
"...The emphasis of anygui is to provide a usable set of interface elements that will work with every backend; particular backends might themselves be capable of more advanced interfaces, but anygui sticks to what is common to them all. ..."
it looks like awt.
awt was replaced by swing because by sticking with
lowest common denominator, you end up with just
very simple (and not very useful) widgets.
Someone should try this with perl, it could use a good abstraction layer like this.
Mertz's affiliation is given as "Gnosis, Inc.", not IBM. The article is simply published in IBM's DeveloperWorks for Linux.
"Perl is worse than Python because people wanted it worse". Larry Wall
P yt hon.html
(Creator of Perl), 14 Oct 1998
source:
http://www.mindview.net/Books/Python/ThinkingIn
Python is used for twenty-seven open source AI projects on SourceForge, and therefore a Mind-to-Python liaison page has been established at http://mind.sourceforge.net/python.html -- along with fifteen other Open Source AI languages.
Artificial Intelligence in Python at http://www.strout.net/python/ai/ is one instance of how important Python is for AI.
What most open source AI projects lack is a Theory of Mind well-grounded in neuroscience. The http://mind.sourceforge.net/theory5.html page with ample co-references provides not only the fundamental AI theory but also its albeit primitive implementation in both Win32Forth and MSIE JavaScript -- which any AI enthusiast may easily save-to-disk and begin hosting on a personal Web site, as the AI Mind pervades the 'Net and leads us upwards and onwards to Technological Singularity!
You might be interested to know that this project has nothing to do with IBM. There is an article about it on IBM developerWorks, but that's it.
Also, it's not David Mertz's project, the project leader is Magnus Lie Hetland.
More info: http://anygui.sf.net/
Regards,
Kalle Svensson, PyGTK backend developer.
'worse' in this particular case means braindead object design, that's because no perl code ever uses objects that they were implemented in such a bad way, but since no one uses them it doesn't matter, that's where perl is worse. Of course in perl you can put as many spaces as you want without the interpreter complaining about it. On the other hand, most object oriented designs fail, take Gnome as the best example, circular library dependencies anyone? Even with that it has made progress, so much that next Mandrake release will provide in-kernel gnome support. Sure the kernel size will grow to 25MB, but memory is so cheap these days that it won't matter. Now talk about bloated :)
Someone then please explain why pygtk is unsuitable...?
A strange game. The only winning move is not to play. How about a nice game of chess? - Joshua (Wargames)
SUN has been working for years to create a cross platform application framework. It is called swing. Swing is very complex and heavy on resources but it does the job. It supports printing, drag & drop, integration with the native clipboard, key bindings, skinning, all sorts of graphical stuff and lots of other stuff.
...). Swing integration is easy if you use jython. I think there are also python bindings for Mozilla so you should be able to create XUL applications in python. Presumably integration with GTK or QT is also easy.
While you might disagree that Swing is a good solution, the fact remains that Sun realized that all of the above is needed if you want to create competitive GUI apps.
The solution suggested for python seems to make the same design mistakes sun made early on (AWT) and seems to be based on the same naive view on what comprises a good GUI. In addition it seems to ignore a whole lot of other perfectly good solutions (qt, gtk, XUL, Kylix, Swing,
Wrapping is no good solution for anything but the most trivial applications. As soon as you make things more complex, you will have more and more trouble keeping things crossplatform since each platform works slightly different, has its own bugs to work around and may or may not support what you need.
Jilles
Most of the posts so far seem to have missed the point.
This is not a new GUI toolkit. It is a wrapper API for a large number of underlying graphic toolkits. You write code for AnyGUI and don't have to worry what GUI toolkit is used. "On Windows, the Win32 API might be used (or wxWindows); on MacOS, native calls; on BeOS, Bethon; on Linux, TKinter or GTK"
Also, as far as I know this is not an IBM project. The article is just published on an IBM site.
If this works as well as the AnyDBM module which allows basic database access from Python without having to worry about what actual database you are using it will be great.
Check out http://anygui.sourceforge.net/
Because GTK sucks ass.
If it did work, somebody would have done it by now.
Java tried it, failed.
Netscape tried, failed.
That's... a good point. I read it as a somewhat odd press release, and skimmed right over the header material to read the body.
It changes the tone of the article completely, from giant nonsensical arrogant corporate initiative to just another cross-platform GUI library for Python.
Wow, I'm dumb.
More justification to love python. I use it for everything. Unfortunatly the apache mod_python interface sucks badly if you want to use it the 'proper' way. But this anygui sounds great. I wrote an app in tkinter and made it into a stand alone windows program, but it had to include so much crap to make sure it ran, the simple program turned into a 3meg bloat. I wrote another program in pygame (SDL interface,) and it came out a lil smaller, ~1.5megs. But I think the main goal with anygui would be ubiquitousness. The GUI you need is already there, so if I were to make stand-alone windows programs, it wouldn't be bloated including the GUI libraries. This is great!
--Roy
According to Mentifex, all topics are relevant to Mind, which is a shitty AI which does nothing, based on a shitty theory which he dreamt up alone and nobody else respects.
Was a word mentioned that could be fit into the same sentence as Mind? Well, clearly Mind is not off-topic!
Who am I kidding? Alex Chiu doesn't even come close to this level of goofiness. At least he sells some magnets to suckers.
Though Java rox as a language and was the first to implement the VM principle and has a huge set of APIs (which make for it's biggest advantage but often are written very haphazardly), it has one big downside in comparsion to Python.
Python is GPLd. Java is not.
If the other-way-around aproach IBM is taking now is crappy, there be no one stopped from enhancing it or writing a better one. Everyone can go by and rewrite any part of the Standard library if he thinks it's to slow. If IBM wants to bug SUN a little in the "nifty new language concept" dept., this is not the stupidest thing to do.
We suffer more in our imagination than in reality. - Seneca
Gotta admit that Python is probably the only computing environment I've encountered, which is both easy to learn and powerful in the long run.
The downside is, of course, Python's more restricted syntax. I'd say Python and Perl codes compare like technical manuals and poetry. But when programming I'll rather take the tech (TeX :) route.
Escher was the first MC and Giger invented the HR department.
I understand not wanting to make pike or forth topics, but you have done so many articles on python at this point, it's getting ridiculous! I know slashdot is perl-centric, but for the love of god!
Having dabbled in Python programming, I see this as a Very Good Thing (TM). I read the article, and as others have pointed out, this is not a new GUI toolkit, but a wrapper for all of them. So now I can write Python programs that use both PyQT (Linux) and Tk (Windows) without having to learn two different toolkits.
Now if only PyKDE2 would come out soon, so that I can start making a couple of kicker applets for KDE2. Of course, by the time PyKDE2 is out, KDE3 will have come out, and the whole cycle will start over again!
How is the parent post a troll? The guy *does* have a point. I mean, we have the gall to be discussing a Generic GUI Wrapper for Python?
Python, quite frankly, fucking sucks. (Not as badly as Perl, but I digress). Python developers are morons who couldn't learn C++ properly. (And anyone who says C++ sucks is an uninformed moron. Pick up a copy of C++ Faqs, 2nd edition and read it cover to cover before you shoot your mouth off with uninformed gibberish and come off like an asshole.
So yes, let's put this topic to bed where it belongs. (The number of comments attached to this story seems to prove my point that nobody gives a fuck about Python anyway.)
I love choice, but part of me wishes that more effort would go into getting wxPython/wxWindows polished (and more fully cross-platform) to knock Tkinter from its status as defacto Python GUI.
Sometimes we do write stuff just to learn. If what we've written also turns out to actually be useful so much the better.
I'm trying to teach myself to set people on fire with my mind... Is it hot in here?
anygui is not an IBM project -- it was just reported on in IBM developer works. If they write an article on java, does it mean they invented java? Sheesh.
From the website:
The purpose of the anygui project is to create an easy-to-use, simple, and generic module for making graphical user interfaces in Python. It's main feature is that it will work transparently with many different GUI packages on most platforms.
You can use it to write a generic GUI app and it will scan the gui toolkits on your box and choose the best one to use for your app.
A successful project with analogous goals is anydbm
You can make generic operations on databases, and it will work on mysql and postgresql. It's already a part of the standard python distribution.
I am rapidly becoming a wxWindows fan. I've spent the last week or so learning this toolkit and implementing something like Gamespy or The All Seeing Eye.
I admit this is the first GUI toolkit that I've used (for the desktop), but it seems to be very clear to use. I've got most of the standard functionality down now - events, windows/frames, window sizing, encapsulated string handling, etc, and I've only had to consult the mailing list for a single issue.
I'm using it with C++, but there are some rather popular bindings for Python called wxPython, as well as Perl and an assortment of other languages.
And the thing that gives me wood is that it looks native in each environment. GTK+ with themes under Linux, and Win32 GUI widgets under windows. And yes, it manages to do this without taking the lowest common denominator route: Sometime features like traybar iconifing under Win32 get plainly ignored under other OSes.
Learned a new API this year? (If you are a coder...) If you have not, you're due.
It's a great example of how an idea that seems good when discussing it in a CS class, falls apart where the rubber meets the road.
- adam
Perl isn't an OOP language? Guess I need to tear out chapters 12-13 of my Camel Book.
http://stage.linuxports.com/projects/pyqt/book1.ht m
The only book on Python and QT programming
Get your PostgreSQL here: http://www.commandprompt.com/
This is demonstrably false. The majority of the perl toolkits that I've used do make use of perl objects. Sure, in your 100 line web program or sysadmin script, it might not matter, but when you want to write scalable modular software, it does.
On the other hand, most object oriented designs fail, take Gnome as the best example, circular library dependencies anyone?
GNOME is not a good example of "object oriented design", because very few OO projects use C as the implementation language. As for circular dependencies, that is simply indicative of poor design.
Anyway, I find it hard to get excited about this toolkit, because it looks to me like a solution waiting for a problem.
I don't think it will come close to wxWindows. wxWindows already runs on OS9 and OS X, and a Mac port of wxPython is actively being worked on.
While all the current ports of wxWindows use native widgets (when available), the wxUniversal port will provide an emulated set of widgets that will make it easy to port to other platforms until native support is available.
Among other platforms, wxUniversal will run on Sci Tech's MGL library, which supports Windows, Linux, DOS, OS/2, QNX, SMX, RT-Target and other embedded operating systems. Other platforms (such as OS/2) are also being developed.
I am David Mertz, the author of the referenced (but somewhat mis-described) article on IBM developerWorks about anygui. Some other folks have posted several clarifications, but let me try putting them together in one place.
1. I am not the lead developer of Anygui. That honor belongs to Magnus Lie Hetland, who has been doing a wonderful job. As indicated in the article, or on the project page, I -did- volunteer to lead one tiny aspect (but have not yet done any work, for which I apologize).
2. Anygui is not sponsored by IBM. I just write columns for IBM, and found the project interesting enough to devote an installment to.
3. Anygui does not "repeat the mistakes of AWT", nor does it aim to replace another toolkit like GTK or Fox. Anygui is a *wrapper* around lower-end toolkits. The idea is that you can distribute *identical* source code to different users, on different platforms, and have it run with *some* available backend.
4. Anygui will never be as feature-rich as many of its backend toolkits. It is not trying to be. The aim of Anygui is to provide a minimal, but -universal-, GUI API. If you want the full sophistication of, e.g. Swing, don't use Anygui. If you want users of Jython, MacOS native, Win32, and PyGTK (and others) to all be able to receive and run (without modification) your common Python code, Anygui is a brilliant project.
Buy Text Processing in Python
A successful project with analogous goals is anydbm. You can make generic operations on databases, and it will work on mysql and postgresql.
anydbm is a generic interface to variants of the DBM database, not relational databases like MySQL and Postgres. For relational databases the generic interface is DB-API.
Hamish Lawson
What the article describes - a common interface to the lowest common denominator of a wide range of GUI toolkits - is exactly what the Java AWT did. Unfortunately the intersection of all common toolkits is quite small: many don't support graphics on buttons, or sliders. There are also significant differences in the behaviour of the widgets between platforms that create problems. It looks to me as if you haven't examined the AWT and the reasons for its failure in enough detail, so you're going to make the same naive mistake again.
On top of that, the callback/event-look API described surely went out with the ark.
Alternatively, Python should mature to the point that people can write a toolkit in Python itself, relying only on drawing primitives from the platform (the same could be said about Perl).
This is what people who have never truly grasped OOP always say. It seams to be 'I don't know how to use it so it must be bad!'. This is, of course, utterly false. OOP projects take a bit longer to create but maintainability and extensablity more then make up for it.
As for the speed issue, that argument was made when programmers moved from C to Assembler. I am sure there are still a few assembler programmers out there saying
'What's this shit with Procedural Programming? PP is a sinking ship, it's been already demonstrated a hundred times that it shows no advantages (except for morons who don't know what they're doing) and is always 5-500 times slower, take C for example.'
So your argument is worthless. I would say pick up and OOP book and spend the next six months or so tring to come up to speed. When the 'Aha' moment strikes you may take back your post.
I'm a programmer, I don't have to spell correctly; I just have to spell consistently
I especially think PyGTK is an example of somewhat relatively well-done work. In my experience with Perl and Python, Python tends to lend itself better than Perl for maintenance. However, the way in which data members of a class can be declared *anywhere* could create problems on larger projects. Also, having to have self as an argument to your class functions is a bit strange, and having to reference all class methods and members explicitly through self is a bit strange too, strange way of distinguishing between local and class methods and variables. And the way private vs. public is a bit strange. Other than this, I really like Python, a really impressive interpreted language, with a really excellent way to interface with C code, more impressive to me than any other non-C language, espeically makes JNI of Java look like complete crap.
XML is like violence. If it doesn't solve the problem, use more.
Why does a different cross-platform interface need to be built for each language? Wouldn't it make more sense to have a set of API's that works for all languages (or at least the common ones)?
Table-ized A.I.
Actually, tkinter works cross-platform. I use Python a lot, and I have used tkinter on Macintosh (an old 68040, not a modern Mac) as well as UNIX. I am told that tkinter works in Windows, but I have never used it there myself. As far as I know, you don't need to change your code either, or at least I have never had to. If you are using Python to do something GUI-style, tkinter is an excellent choice, especially because of the easy cross-platform support.
Best Slashdot comment ever
>> This is what people who have never truly grasped OOP always say. <<
And people who claim to grasp it cannot provide evidence that it is objectively better. OO has become an Anecdote Club.
>> PP is a sinking ship, it's been already demonstrated a hundred times that it shows no advantages.....OOP projects take a bit longer to create but maintainability and extensablity more then make up for it.
<<
If precedural and OO are the same, but OO has a longer learning curve, then doesn't it make sense to stick with procedural?
The biggest problem with OO is that its assumptions about the patterns of change are pretty much wrong. However, people believe them because those patterns are the only ones people are trained to recognize due to inundation by OO texts. IOW, OO is the right solution to the wrong problem.
oop.ismad.com
Table-ized A.I.
The idea of a API which provides a way to hook into whatever provider exists on a platform reminds me of the SAX XML event-driven interface. Right now it does not seem to provide much that an effort to port Tkinter to the "minor" platforms might give you, but maybe in the future it might be able to let a GUI app query the underlying provider whether certain capabilities (e.g. bitmaps on buttons) are supported and make intelligent choices based on that information.
Inventor of the LOLbalrog meme.
I'm a Delphi and Python developer. I consider both to be RAD (Rapid Application Development) tools.
If Python had a good GUI builder similar to Delphi or VB, I belive it would be a revolution in software development.
Python stands in a class by itself. I consider it not a RAD tool, but a VRAD tool (Very Rapid Application Development). Unfortunately this qualificative does not apply to the GUI building, where Delphi or even VB are a lot better than it.
I have tried several available libraries, including wxWindows. It simply does not compare to Delphi.