Back to News
Advertisement
Advertisement

⚑ Community Insights

Discussion Sentiment

71% Positive

Analyzed from 1284 words in the discussion.

Trending Topics

#tcl#python#gui#something#apps#tkinter#native#don#language#article

Discussion (25 Comments)Read Original on HackerNews

drdexebtjlβ€’about 2 hours ago
> Those GUI apps look native on Windows, Linux and macOS

I don’t see how the author can write this with a straight face.

The apps look like what native apps looked like in 2003.

fitsumbelayβ€’27 minutes ago
> The apps look like what native apps looked like in 2003

you make that sound more like a bug than the feature it truly is

ronsorβ€’about 1 hour ago
Coincidentally the last time native apps were good.
tnelsond4β€’about 1 hour ago
Pretty sure tcl apps look ugly as sin... Python's tkinter is all tcl underneath.
vincent-manisβ€’about 2 hours ago
I use Tk routinely in Scheme; there is no Tcl in my code, but Tk is a very nice (though basic) GUI kit, and my programs work on Linux, BSD, MacOS, and Windows. Other commenters have mentioned that Python ships with Tkinter, a library module that interfaces to Tk. I believe Ruby does the same. Hell, if you're programming in Cobol, you can have Tk (as long as your Cobol allows you to call C). You do not have to love Tcl to love Tcl/Tk.
ofalkaedβ€’about 1 hour ago
>you can have Tk (as long as your Cobol allows you to call C).

No C required, you can just connect to the UI through a socket and often skip the FFI completely. This is my preferred way to use Tk and I don't even consider anything else unless there is a reason. Working this way also has the nice side effect of making the application UI agnostic.

WalterGRβ€’19 minutes ago
But then you have an entire front end written in Tcl or some other non-COBOL language (to continue the above example,) right?

Or is there a way to run Tk as a daemon?

ofalkaedβ€’2 minutes ago
Believe you have to do that anyways unless you are going to create full language bindings as tkinter and the like do. I don't know the Tk API in full but I don't believe it provides ways to create widgets, just interact with them more directly. Perhaps someone more knowledgeable will fill in the gaps here, I learned what I needed of the Tk API and called it good.
em-beeβ€’17 minutes ago
that sounds interesting. can you give an example please?
forintiβ€’about 1 hour ago
When I first found out about Tcl/Tk, it was used to give a GUI to programs written in C. I've used Tk with Tcl and many times with Perl too.
em-beeβ€’about 2 hours ago
in what way is Tk basic? can you elaborate? also what are your thoughts on the issues with python as mentioned in the article? how do the scheme bindings compare?
piloto_ciegoβ€’about 1 hour ago
This is a fun idea! Are you using Guile-tk?
fitsumbelayβ€’6 minutes ago
I appreciate this reminder that boring old tech is pretty fucking good tech; especially to your non-ReactJS-not-anti-ReactJS dev, here.

The comments are also a helpful reminder of the various sw and visual design/GUI values folks hold.

I personally never gotten past exploring Tkinter but like everything else I played with until I found reason to depend on it, that'll probably change since it's as available as vim and python and _that's_ the kind of thing I value. Limitations/constrains are the engineer's problem, not the tool's (unless they are the tool's problem (but even then, just be your natural creative self and roll with it))

piloto_ciegoβ€’about 2 hours ago
Tkinter or other Tk based GUI interfaces are the immediate tool I reach for whenever I build something that's not in the CLI or in the browser.

My general "daily driver" is python and I love that I can just spin up a cross-platform tool immediately with it. Tcl/Tk rule and are insanely useful.

em-beeβ€’about 2 hours ago
how is your experience with the problems with Tk and python as described in the article?
piloto_ciegoβ€’about 1 hour ago
Well, they talk about the "barebones" Tcl version - tbh, I didn't even really know that was an issue in Python, and he is right that you have to remember to install it, and basically whenever I get a new computer I screw it up the first time until I remember the right incantations to spew at pip install or apt install to get it to work? So, "sure," there are some issues there. And to be fair, trying to do modern kind of interfaces with Tkinter in python and ttk can be kind of tricky/impossible? The part about it being "awkward" is definitely true.

But it's "good enough" like 99% of the time? And going from 0 to "something with a button a user can click" is crazy easy. At my old job, before I started working for myself, I built some painfully sprawling python script to:

1) Spin up a selenium browser to access something in servicenow that they wouldn't let us query the API for but required we access 2) Control the downloading of a bunch of files from a tk interface from python 3) toggle various settings and parse through a bunch of downloaded spreadsheets from there and another website that had some data on 4) python and matplotlib then drew pretty pictures for management 5) python then spit out documents and charts in various formats 6) then a button click triggered it all to process in parallel and opened an email to the appropriate managers that I fire off

This turned something like 10-40 hours of manual work (depending on how well you knew how to do it) where you were clicking and reading into like a 15 min job that I could do on the first of the month while I drank my coffee.

I'm sure it would probably be "better" to write the whole program in Tcl/tk, but sometimes I am lazy. Also, if I'm doing something with pandas or AI and the tk gui is just something slapped over the underlying logic and code. I guess it's a matter of preference? But tkinter is "pretty good" and often "pretty good" is way better than perfect.

They say in the article something like, "if you don't need to call python libraries just use tcl/tk" or whatever. And that's fair, but honestly, being able to throw pandas at something or matplotlib or whatever is super valuable. I think in the future maybe it'll be easy to do something like, "claude please port matplotlib into tcl" and then you can do it natively, that would make sense? Or maybe even like they say it might be cool to make a python script then call it from tcl like they say? but multiple scripts in different languages seems like a bit of a maintenance headache? Though that also might be just a skill issue on my part lol. It might be lazy of me but staying in one language has some advantages, namely, I don't need all the boilerplate argparse code for each thing in python I might want to write.

When I wrote the monstrosity above, I didn't really know anything about tcl/tk other than "isn't that that archaic ui thing?" I actually played around with raw tcl during the process of writing that beast, but that was mostly just for fun.

I guess my real response is, if I end up in a knife fight with a GUI layer over python again, the way they describe in there might be what I do? Calling the python from the tcl might be the optimal choice? It'd be fine to stretch the brain in a slightly different direction anyway.

em-beeβ€’about 1 hour ago
trying to do modern kind of interfaces with Tkinter in python and ttk can be kind of tricky/impossible? The part about it being "awkward" is definitely true.

that sounds a bit worrying. can you give some examples?

from the article i was specifically wondering about this:

And yet still, even with ttk, Python doesn't automatically pick the best theme for the OS! It often defaults to "clam", "alt", or the dreaded "classic" on Linux, which look dated. It's a mess of a Tk bridge! ... the provided bridge to it is clunky

so is it just the perception? sounds like i should just have to remember to pick a better theme. (and use ttk)

and what you say about using pandas supports my point. i usually want to add a gui to something that is written in a particular language for a reason.

tehologistβ€’about 2 hours ago
I take issue with the only 100 MB footprint, that is still pretty big when consider fasm, tcc and rebol are all closer to 1 meg.
tnelsond4β€’about 1 hour ago
Yeah, 100mb is not a bragging point. That's the size of a full web browser engine
edoceoβ€’about 1 hour ago
On Linux there is also this windowing shell `wish` which I've used for some very quick (and very very dirty) UIs
ashenkeβ€’32 minutes ago
Do you have more information? It looks interesting
edoceoβ€’10 minutes ago
I don't, but it was easy even before AI code.

It's this one https://en.wikipedia.org/wiki/Wish_(Unix_shell) - which turns out is Tcl.

I used it to wrap up some socat and curl. Ugly stuff. Reading values from a serial device, show on screen until a button press when a value was sent over HTTP. The kind of code you hate but the management thinks is production ready.

I found it because someone on Gentoo IRC was like: ?"if you hate yourself try this"?. Would have preferred to do the whole thing in Perl.

em-beeβ€’about 2 hours ago
the problem with Tcl/Tk is Tcl. the author does write about the quirks and problems, so this is a good article, but the end of it is that Tcl is simply not a language that i am interested in mastering. just like shell scripting. i'll use it if i have to, but it is not my preference.

and as the article also mentions what makes the apps cross platform is the native or near-native GUI. and apparently Tk is good for that.

but i'd rather use a nicer language with it. again, the article does talk about python, and points out that the Tk bindings in python are simply not good enough. that was very insightful, and i am glad to know.

however i would like to know if any other languages do better here. what about go for example? has anyone tried Tk with other languages and can share some experience?

mbirthβ€’11 minutes ago
I wonder whether Delphi/Lazarus would be better suited for a native GUI on each platform. But you’d have to compile your app for each separately.
mbirthβ€’about 3 hours ago
Fun fact: macOS hex editor "Hex Fiend" uses Tcl for its templating language:

https://github.com/HexFiend/HexFiend/tree/master/templates