Text Input Box with Xlib

Robert Heller heller at deepsoft.com
Sat Feb 2 15:36:40 PST 2013

At Sat, 02 Feb 2013 14:02:04 -0800 Alan Coopersmith <alan.coopersmith at oracle.com> wrote:

> On 02/ 2/13 01:56 PM, Gabriel Duarte wrote:
> > I already got window and button widgets working, and now I would like
> > to write a text input box, but I have no idea how to start. If someone out
> > there have advices, example code, etc etc, I would be very glad.
> The best advice we can give you is to use an existing toolkit.
> Correctly handling all the different languages, writing systems,
> accessibility helpers, etc. is a multi-year project to write, debug,
> and make useful, and one that people have already done for you.

And if you are too impatient for that, just use Tcl/Tk.  Tcl is a basic
scripting language that comes with a basic GUI toolkit.  One that you
can play with *interactively*.  Once you have Tcl/Tk installed (under
Linux it is just a matter of

# Red Hat flavored (RHEL, CentOS, Scientific Linux, Fedora)
yum install tcl tk
# Debian flavored (Debian, Ubuntu, Mint, etc.)
apt-get install tcl tk

), you can do this ('%'=shell prompt):

% wish
pack [entry .e]

and presto, a text input box.

A slightly more exciting example:

% wish
pack [entry .e] -side left
pack [buttom .b \
	-text "Hit me" \
	-command {puts "You entered: '[.e cget -text]'"}] -side right

The packages *should* come with man pages.  Also: visit
http://wiki.tcl.tk/ for lots of fun stuff.


Robert Heller             -- 978-544-6933 / heller at deepsoft.com
Deepwoods Software        -- http://www.deepsoft.com/
()  ascii ribbon campaign -- against html e-mail
/\  www.asciiribbon.org   -- against proprietary attachments


More information about the xorg mailing list