简体   繁体   中英

Why are all the tk examples in a Python distribution written in TCL?

Now don't get me wrong, I'm not exactly a Python fan, but when you see a Tk directory inside of the python directory you kinda expect... Well Python. And yeah, I get that Tk came from TCL, but if I had to write a TCL to use Tk, I'd forget TK existed and use a completely different tool box. (The popularity of this combination completely eludes me.)

Expecting to see a relatively readable language like Python, and finding TCL is like walking in on your grandma naked. It's just visually painful.

I haven't drank the cool-aid when it comes to Python, but I use for simple task that I don't want to bother with C or C++ on and maybe if I want some for quick and dirty text processing. It just seems like a cruel joke to put TCL examples in the Python distribution.

Is there an equivalent package that includes those examples written in Python?

Edit: I guess this also kinda begs the question is Tk the best option for GUI dev in Python?

There are no Tcl examples in Python's official distribution; whatever distro you're using must have bundled them on its own volition.

IMHO, Tk's only real advantage by now is the convenience that comes from having it bundled with Python. I was criticized for covering it in "Python in a Nutshell", but I stand by that decision because it is still "the" bundled toolkit, after all. But if you want something better and don't mind taking a tiny amount of inconvenience to procure it (and possibly to bundle it with apps you distribute), there are other excellent choices.

PyQt (if you can stand the GPL license or pay for the commercial one) and wxPython are IMHO currently superior offerings for cross-platform GUI apps (though you'll have to work to bundle them with py2exe or PyInstaller if you want to distribute a stand-alone app) and other packages are excellent if you don't care about cross-platform distribution or have specialized needs (eg pyui -- while now a general-purpose UI toolkit -- for simple UIs for games if you're using PyGame or PyOpenGL anyway).

Perhaps you should start by looking at the Python Tkinter documentation here and the Tkinter wiki here .

And where are you seeing Tcl examples? Are you looking at a Tcl library supplied with Python perhaps?

TCL / TK is a simple language to understand with which the applications are made very simple, very quickly occupying very few resources and hardware platform to be run on all platforms.

In TCL / TK exist there is also starkits or freewrap allowing wrap libraries, code and other files into a single package easier to carry around, to other platforms and run and install, without being necessary to bring all the libraries brings language.

While the evaluator of TCL / TK requires 3MB, the python requires much more, and uses many more that unused libraries.

When these applications grow, it is logical to migrate first to python and share the GUI using Tkinter, then they can move on to other GUI as QT or Wxwidgets, to work faster.

Who want to program with Tkinter, you must know how it works TCL and TK GUI with which are made tkinter.

Today is not here another library module GUI that there be a versatile as tkinter into a single file that allows cross-platform applications remain to be small and modular for all basic python project.

While tkinter is 2 MB, wxwidget are 80 MB and if you take a calculator, a notepad or a drawing application, you'll want a small GUI easy to incorporate into your projects.

Besides that today made Tkinter applications run faster and better in small devices with limited hardware, ARM or raspberry o smartphones but wxwidgets becomes slow.

If your application is basic and small and you platform is not robust chooses Tkinter, but if is big and heavy and platform of very much resources chooses wxwidget o QT.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM