
A port of the GTK+3 Hello World to Bash - regitwo
https://github.com/taviso/ctypes.sh/blob/master/test/gtk.sh
======
unwind
This seems to basically showcase the ctypes.sh Bash plug-in, which is what is
doing the magic calling into a native library. See
[https://github.com/taviso/ctypes.sh/wiki](https://github.com/taviso/ctypes.sh/wiki),
that was very interesting.

~~~
seba_dos1
Previous discussion on ctypes.sh:
[https://news.ycombinator.com/item?id=10184940](https://news.ycombinator.com/item?id=10184940)

------
nitrogen
As someone who has written quite large projects in both C and Bash, I find it
amusing that it's now even easier to use two of our biggest footguns together.
Still, I can see this being very useful for writing test scripts for
libraries.

------
hansen
I don't know if this is awesome or just sick.

~~~
nix0n
Here are the reactions from the parent project's readme:
[https://github.com/taviso/ctypes.sh#here-is-what-people-
have...](https://github.com/taviso/ctypes.sh#here-is-what-people-have-been-
saying-about-ctypessh)

------
marssaxman
I don't know whether to be delighted or appalled, and I love the brain-twist.

------
shmerl
I've never heard of ctypes.sh, but it sounds pretty interesting:
[https://github.com/taviso/ctypes.sh/wiki](https://github.com/taviso/ctypes.sh/wiki)

------
chriswarbo
Whilst it's a fun proof of concept, the real solution would be zenity:
[https://help.gnome.org/users/zenity/stable/info.html.en](https://help.gnome.org/users/zenity/stable/info.html.en)

------
lmm
I have long been annoyed that this wasn't possible. Seems like you could use
this as a kind of "C REPL".

------
guard-of-terra
Why not use Tk/wish? Result is basically the same but means are much, much
more conventional.

------
julie1
tightly packed portable version of this code

\--------------------------------------------------------

#!/usr/bin/env bash

cat <<EOF | /usr/local/bin/wish

package require Tk

pack [button .b -text {Push Me} -command {

    
    
        tk_messageBox -message {hello, world}
    

}]

EOF

\--------------------------------------------------------

Of course doing it directly in Tk Tcl would be even more portable, readable,
simple and smarter and easier to deploy/maintain.

And at the opposite of gtk team tk team does not breaks API for the pleasure
of being more right than the users.

So it would be a win-win-win situation to use Tk/Tcl instead of gtk3.

~~~
tcler
You can simplify it by starting your program like this:

    
    
      #!/bin/sh
      # \
      exec wish "$0" ${1+"$@"}
    

( You wouldn't need the cat pipe. )

------
ericfrederich
I hate that something like this is possible.

This gives people who know only bash the ability to create a mess rather than
learn a real scripting language like Python.

~~~
rhinoceraptor
I've tried writing a GTK 3 app in python, it was pretty horrible. The GTK XML
format is very annoying to work with, and writing interfaces programmatically
requires using an automatically generated C->python API, which has essentially
no documentation.

~~~
dekhn
I didn't find GTK2 with Glade all that difficult.

But eventually I dropped GTK and switched to Qt. I thought they worked through
all the common issues with better solutions.

