Generic GUI Wrapper For Python 114
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."
Re:Mmm (Score:1)
(Creator of Perl), 14 Oct 1998
source:
http://www.mindview.net/Books/Python/ThinkingIn
Re:Mmm (Score:2)
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.
Re:Mmm (Score:2)
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.
Defective O'reilly literature (Score:2)
Re:Mmm (Score:1)
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.
WxPython (Score:2, Informative)
David
Re:WxPython (Score:1)
Python itself is available for many many platforms: linux, win32, solaris, os/2, amiga, beos, qnx, vms, psion, acorn vxworks, ibm as/400, playstation, palm, winCE
and you could write a program once and it would use the native GUI on the respective machine.
cheers
Re:WxPython (Score:1)
What about MacOS X? (Score:1)
Anybody know anything about future Python support for the X as well as this anygui?
Re:What about MacOS X? (Score:1)
When they say "passable MacOS version", do they mean Classic or MOSX?
Re:What about MacOS X? (Score:1)
They mean classic Mac OS. I got TiK [sourceforge.net] to run on it once; here's a screen shot [brad-x.com]. There seemed to be no support for the menubar, or right-click contextual menus, or of course sound (since I believe TiK cats
Re:What about MacOS X? (Score:1)
Re:What about MacOS X? (Score:2, Informative)
If MacOS X has Jython (swing), PyGTK, Tkinter or wxPython it should work out of the box anyway. If not, we would of course welcome a developer of a MacOS X backend!
Regards,
Kalle Svensson, PyGTK backend developer.
Re:What about MacOS X? (Score:1)
Anybody know anything about future Python support for the X as well as this anygui?
Tk in 8.4 has a native Aqua port [apple.com] (Oct 16 news) in beta, from the guys at Apple. All languages binding to Tk can take advantage of OS X now.
In any case, this has been said, but the idea of anygui being the lowest common denominator of toolkits seems like a bad idea being repeated. Tk has been inflicted by this sometimes, but more and more pressure is on Tk development to add more single-platform support bits in the core.
I like this idea. (Score:1)
random Java flaming again (Score:4, Insightful)
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.
Re:random Java flaming again (Score:1)
As far as I see they just want to create an abstraction layer for the different gui toolkits in python. Even for text and html.
I think this is very neat and definatly not NIH.
Re:random Java flaming again (Score:1)
You could argue this, and propose to use a 'common widget set' with 'common behaviour' across all platforms, but this will alienate your software's GUI from the rest of the system. As a Windows user, I resent anything that behave's like a Mac or like a Sun, how subtle the differences may be.
IMHO, true cross-platform development means separating your GUI from your internals, and keeping the functionality platform independent. Ansi C++ for this (including STL) is maybe a good choice, but I'm not a C++ developer.
Just my 0.02 Euro
Dave
Re:random Java flaming again (Score:2)
The portability problems did come from AWT but not from the use of native widgets.
The problems arose because SUN kept the Java Development Kit proprietary and refused to fix any bugs in the system.
I mean AWT still uses Motif on UNIX machines (even to this day)? Motif is very different from the Win32 API so you could easily see why applications written on Windows/UNIX had different "issues".
These issues will be fixed in GCJ (GNU Compiler for Java). GCJ will provide a modern AWT implementation which should eventually support both GTK and QT.
Java is back baby! And this time it is Free and GNU powered!
Kevin
it's not an IBM project (Score:2)
My faith in Anonymous Coward is broken forever! (Score:1)
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.
Re:In short, IBM says "Screw you guys, we'll do it (Score:2)
Or... (Score:2)
Sometimes we do write stuff just to learn. If what we've written also turns out to actually be useful so much the better.
awt ? (Score:1, Interesting)
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.
Reminds me of my comp sci professor (Score:1)
Someone should try this with perl, it could use a good abstraction layer like this.
Not IBM... (Score:5, Informative)
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.
seems very naive (Score:3)
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.
Re:seems very naive (Score:1)
they aren't ignoring qt,gtk,swing and others. they are using them!!
they are making on unified way to access them from python,so that the user can choose which one he want to use.
Re:seems very naive (Score:2)
Precisely. There is a reason GTK doesn't work like anygui, and a reason Qt/Swing/Mozilla/etc. also don't work like anygui, and a reason the AWT approach was dumped.
You can do cross-toolkit abstraction if you do it like AbiWord, where they often add features and hooks to punch through to platform-native if required. But that doesn't work in a generic XP toolkit.
Wrapper toolkits are very limited in power, there's just no way around it.
Python needs to bite the bullet, suck it up, pick one of the existing actively-maintained modern toolkits despite the possible flamewar, and then simply address its limitations (e.g. porting to platforms as required). Until then it won't have a standard GUI. Sometimes there is no silver bullet. ;-)
Re:seems very naive (Score:1)
It's views like yours that hinder learning and research. It's those same views that stop people from making vast breakthroughs that may alter the landscape of their specific field.
"It can't be done!""It's been tried, and that failed. If they couldn't do it, you can't".
"That impossible to do."
Things like what you just said, were said for a multitude of things, (i.e. Nukes, lasers, space flight, UNIX, X, Linux). But guess what, they all happened.
Will this project change the landscape? No. Will this project alter history? No. Does the possibility exist that this project will force developers to look at their code differently? Yes. That's all that needs to exist to make this project worth while to the developers who choose to develop for it.
I don't care if you're a "well-known hacker". I don't care that you're the "Chairman for the Gnome Foundation", and, right now, I couldn't care less if AnyGUI went away. For you to completely blow off the whole project just shows me how short-sighted you are.
This is open-source. You don't like the project, don't use it. Let them do their thing, you go do your thing, and everyone is happy. Maybe within a year or two they, or some other project, will show you up and prove that it can be done.
And yes, AWT was dumped.. by a corporation who failed to see enough profits to come from their investment. This is not a corporation, they are not driven by their bottom line. You, of all people, should recognize that.
--seaRe:seems very naive (Score:1)
Nonsense. No-ones trashing "anygui" for being new and challenging conventional wisdom. It's being criticised because it's a rehash of old designs. If there were some evidence that the authors better understood the pitfalls of similar projects (AWT being a good example), and had some plan to address these issues, perhaps the posters here would be less cynical.
The article trashes java, while failing to point out how "anygui" will avoid the same pitfalls.
And yes, AWT was dumped.. by a corporation who failed to see enough profits to come from their investment.
And a corporation who realised that a complete redesign would be a more effective use of limited resources than trying to fix AWT. Or are you trying to argue that Swing was a triumph of marketting over good design ? I think you'd find anyone who'd used both toolkits would find that laughable.
alternative approach (Score:2)
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).
Re:alternative approach (Score:2)
I don't think that this is a particularly good idea. Python is a scripting language, any GUI that relies too much on Python code is bound to be sluggish. That's the real beautty of wxPython (IMHO). It is a very nice wrapper around wxWindows, with a definite Python "feel." The fact that wxWindows is compiled means that WxPython GUIs are amazingly responsive. I ported some test apps from Java/Swing and was amazed at how much faster they ran and how much easier they were to write. WxWindows also uses the native toolkit, so your application appears to fit in with the rest of your environment.
Of course, I am more than a little biased, I personally think that a mixture of Python + C (or in this case C++) is about the perfect development blend. Prototyping is fast and easy, and Python is so easy to extend in C that making the application fast enough is very straightforward.
Anygui sounds like a nice idea, but any abstraction layer generic enough to include ncurses isn't likely to be capable of creating very complex GUIs.
Of course, if they prove me wrong, well I will be pleasantly surprised. I have wrong once or twice before :).
Re: (Score:1)
Re:seems very naive (Score:1)
Minimal: The goal is to have a *minimal* set of widgets that allow the most common types of input and output. The idea is to make a toolkit that anyone can use to create a *simple* gui on any platform that Python runs on.
Universal: Which one of the "other perfectly good solutions" you mention (qt, gtk, XUL, Kylix, Swing) does *everybody* have? Which of them is available on all the platforms that Python runs on? None of them, of course. The whole point is that no single toolkit is going to satisfy this requirement, so more than one toolkit needs to be supported.
What most of the posts I've seen so far lack is an understanding of the current situation in Python. The language is great for programming almost any kind of non-realtime project in a cross-platform way, but it lacks a way to write cross-platform guis without asking the user to download a 5 to 10 MB window toolkit on one or more of Python's platforms. This is simply unacceptible when you're distributing a 150 kB Python program! Hell, it's hard enough to get people to download the python interpreter!
There is a real need for this project in the Python community, and I wish them great success.
-DA
Re:seems very naive (Score:2)
I agree however that there is a need for a crossplatform GUI kit. I only think that it should be a full featured one rather than some arbitrary subset. More importantly, I think it should be object oriented and language independent. Otherwise we'll see duplicated efforts for perl, ruby, whatever. Most of the existing GUI kits are language dependent or at least assume a great deal about the language used to work with them. This limits their usefulness. A good example is the GTK - QT debate. C programmers will likely favour GTK whereas C++ programmers will likely prefer QT. Swing is great when you use Java, but using it from another language is usually hard (unless it has an implementation ontop of the JVM).
Re:seems very naive (Score:2)
First, I admit that XUL isn't exactly ideal for the kind of work he wants to do.
But, as far as platform availability, XUL already works under seven different GUIs (Win32, BeOS, MacOS, WPS [OS/2], X, Photon, and NanoGUI) and at least nineteen operating systems (Windows 9x/Me, Windows NT/2000/XP, MacOS, MacOS X, Linux, AIX, BeOS, Irix, OpenVMS, OS/2, HPUX, BSD/OS, Solaris, Tru64 Unix, FreeBSD, NetBSD, DG/UX, and QNX).
Okay, admittedly the DG/UX binaries are rather old, and the Photon/QNX ones might be (I can't find any data on whether recent milestones are available for it). But everything else on my list has a Mozilla 0.9.4 or 0.9.5 version.
This is not a new GUI toolkit (Score:4, Informative)
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/
tkinter (Score:1)
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.
Won't work (Score:1)
Java tried it, failed.
Netscape tried, failed.
I agree (Score:1)
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
Re:I agree (Score:1)
No, it's an example of a very real world thing called an engineering trade-off. They are trading-off feature richness for universality.
If someone needs a universal GUI library, and can live with the lack of features, then this could be a good solution. They are attempting to provide one solution to a particular problem. For free. That is commendable.
Re:Won't work (Score:1)
hmm, that sounds familiar... where have I heard that statement before? Oh yeah, from Microsoft(about Linux), for C++ developers(about Java), and from just about every other nay-sayer who thinks that a tool can't be made, or won't work. Television, radio, electricity, and the telephone come to mind.
Let them try. You don't like the project, don't use it. Much like if you don't like KDE, don't use it.
I'm tired of people like you. If a developer chooses to develop for a project, then that developer thinks it can be done. And the opinions from the likes of you shouldn't stop them. God knows where the world would be if everyone listens to opinions like that.
--sea
Re:Won't work (Score:1)
Just said it won't work.
PS - WTF is this:
Slashdot requires you to wait 20 seconds between hitting 'reply' and submitting a comment.
It's been 15 seconds since you hit 'reply'!
Re:Won't work (Score:1)
Good luck, slashdot!
Woot! (Score:1)
Pythons big advantage over Java.... (Score:1)
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.
Re:Pythons big advantage over Java.... (Score:1)
Re:Pythons big advantage over Java.... (Score:1)
Python is NOT GPLd, it is more free than that.
It ist *GPL-compatible*, though.
I'm for it (Score:1)
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!
Listing of available Python GUIs (Score:1)
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.
Not an IBM project (Score:1)
anygui [sourceforge.net] 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 [python.org]
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.
anydbm isn't for MySQL and Postgres (Score:1)
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
wxWindows (Score:2)
I am rapidly becoming a wxWindows [wxwindows.org] 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.
Re:wxWindows (Score:1)
Thanks for pointing this project out. I was in the midst of doing something very similar to this (exactly this actually). Now, I'll just throw my small weight behind this since they're a ways ahead of me.
Now.. I have to go read their source.. go about your business..
--seaRe:wxWindows (Score:2)
Perhaps an interesting project would be a wxWindows target for an MFC reimplementation.
Re:wxWindows (Score:1)
Don't forget about QT! (Score:1)
The only book on Python and QT programming
Not impressed (Score:2)
Anyway, I find it hard to get excited about this toolkit, because it looks to me like a solution waiting for a problem.
Clarifications from the Author (Score:1)
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.
anygui is precisely the AWT (Score:2)
On top of that, the callback/event-look API described surely went out with the ark.
Python is great... (Score:2)
It's like the XML parser model (Score:1)
The idea of a API which provides a way to hook into whatever provider exists on a platform reminds me of the SAX [megginson.com] 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.