How can I enhance the look of the Perl/TK GUI under Perl 5.004?
Asked Answered
L

5

8

I have an application that is built to work on Windows, Linux, and Solaris that uses the Perl/TK GUI. Due to constraints, we are limited to Perl/TK only. Moreover, we are limited to an old Perl/Tk version, 5.00404.

I'd like to work within these limitations to make the GUI look as nice and modern as possible.

Are there any web-resources that have TK design schemes (for buttons, frames, colors, etc) that could assist me in this endeavor?


I am also looking for modernization advices like the one that I found here:

If you're finding that your Tk apps look a little ugly on X-based systems, try adding the following lines to the top of your script:

$mw->optionAdd("*font", "-*-arial-normal-r-*-*-*-120-*-*-*-*-*-*");
$mw->optionAdd("*borderWidth", 1);
Leone answered 4/3, 2009 at 15:39 Comment(4)
can you give us a screenshot of the app? In my experience making a GUI nice is more about design than about the widget set (depending on your definition of "nice", of course". Maybe if we see what you presently have we can make some suggestions.Sorrells
Let me guess, Igor, you work for Intel?Rath
Artem: Yes, I remember you from a project were you optimized the existing perl codeLeone
Heheh, the world is so small.Rath
C
5

Try using images instead of button elements, then you can have whatever style you like and the fonts can be baked in. This will work for pretty much any element where the contents are not dynamic - including backgrounds on panes and such. Granted it's more work but it does solve your problem, especially if you have a competent artist in your project group.

Chinchin answered 23/5, 2009 at 6:43 Comment(1)
this may not be the most 'elegant code' solution, but it's nicely pragmatic. one thing to look out for is resizing.Moore
B
5

You could use the Tk theme engine to give your app better looks.

Brechtel answered 4/3, 2009 at 16:55 Comment(3)
Downvoted because you can't access the ttk stuff from Perl 5.004. AFAICT you need at least 5.6 to access the newer bindings (Tkx or Tcl::Tk) that allow use of the theme support in recent versions of Tk.Aery
That's not strictly true. There is a compatibility library (named "tile") that works with 8.5 (and has worked with 8.5 for a couple years now). I have no idea if that can be used with Python or how easy that would be.Sorrells
Not sure how relevant whether it can be used with Python or not is?Ilyse
C
5

Try using images instead of button elements, then you can have whatever style you like and the fonts can be baked in. This will work for pretty much any element where the contents are not dynamic - including backgrounds on panes and such. Granted it's more work but it does solve your problem, especially if you have a competent artist in your project group.

Chinchin answered 23/5, 2009 at 6:43 Comment(1)
this may not be the most 'elegant code' solution, but it's nicely pragmatic. one thing to look out for is resizing.Moore
S
2

Using optionAdd to tweak defaults through the option database is a reasonable start. A thread about this can be found at:

http://tcl.projectforum.com/tk/221

Download griffin.kit from there, use the sdx tool to unwrap it and locate griffin.tcl to get a good set of option settings.

http://wiki.tcl.tk/3411 for the sdx tool.

Scrappy answered 11/3, 2009 at 19:51 Comment(1)
It is written for Tcl but should be trivially translatable to Perl.Scrappy
D
1

The Tile themeable engine for Tk makes it look much prettier. However, Perl/Tk has lagged far behind Tk's development, and can't take advantage of Tile and other advancements.

You should investigate whether Tkx is an option for you. It's not completely compatible with Perl/Tk, but the API is pretty close. It's a bridge between Perl and Tcl/Tk, so it can use all of the modern Tcl/Tk features (like Tile) while still having application logic coded in Perl. Quite a few of ActiveState's own graphical utilities use Tkx, with fairly good-looking results.
ActiveState PPM
(source: activestate.com)

Perl 5.00404 is incredibly ancient, though. The Tkx dist claims to depend on Perl≥5.008... I don't have an old enough Perl to see how accurate that is.

Derick answered 24/5, 2009 at 4:8 Comment(0)
H
1

Since in Linux the background of Tk::Entry and Tk::Text is grey i would also use the following two lines.

$mw->optionAdd( '*Entry.background',   'snow1' );
$mw->optionAdd( '*Text.background',    'snow1' );

Replace 'snow1' with a color of your choice. You can also use the hex representation(RGB) of the colors like '#ff9696'.

Howbeit answered 25/5, 2011 at 0:13 Comment(1)
Never worry about the age of a question!. 2 Years later and here I am reading your answer and finding it very useful!Eventually

© 2022 - 2024 — McMap. All rights reserved.