Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

creating skinable Perl/Tk apps

by gri6507 (Deacon)
on Feb 09, 2005 at 12:42 UTC ( [id://429375]=perlquestion: print w/replies, xml ) Need Help??

gri6507 has asked for the wisdom of the Perl Monks concerning the following question:

Fellow monks,

I have recently took a look at creating KDE apps in C++ using KDeveloper and QT Designer. One of the tasks that is made very easy when using those tools is applying different skins to your program. I would like to know if anyone has implemented, or has thought about implementing skinable Tk applications. Any pointers? (searching the monastery was fruitless) I was hoping to create a simple app just for practice. Also, just for my personal enrichment, can Tk create apps that don't have the default Window Manager titlebar with buttons (i.e. winamp, gkrellm, etc)?

Thanks in advance.

Replies are listed 'Best First'.
Re: creating skinable Perl/Tk apps
by PodMaster (Abbot) on Feb 09, 2005 at 13:00 UTC
    Yes. I've thought about it, I've even written a small tutorial, though I haven't published it (machine trouble ...).

    The easiest way to implement a winamp type app is using Tk::Canvas. All you've got to do is load a bunch of pictures, determine their size (width/height), and place them at a certain location(x/y) on your canvas. You can also associate events with each canvas item, and once you do that, you're done.

    One limitation is that you can't have a free-form window, or a transparent canvas, so whatever you create has to be square. update: I should say it may be possible using platform specific hacks and maybe some extensions (Tk::Zinc), but as a general rule, not portably.

    update: See the overrideredirect docmentation in Tk::Wm.

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

      Actually overrideredirect(1) does not do the same thing as Winamp. Let me be more specific: overrideredirect(1) does remove the window decorations, but it also removes the abilities to move the window and resize the window. How can that be done?
        How can that be done?
        Through platform specific hacks (diddling the decorative window), or by managing it yourself.

        MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
        I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
        ** The third rule of perl club is a statement of fact: pod is sexy.

Re: creating skinable Perl/Tk apps
by zentara (Archbishop) on Feb 09, 2005 at 13:32 UTC
    There was a discussion of this recently in comp.lang.perl.tk. Go to groups.google.com and search for "Tk vs Anythign Else?". There are some code samples in the thread. The problem is portability. It's easier to make skins if confined to 1 window manager, like KDE, but Tk is designed to run under any window manager.

    For what it's worth, some of the guru's there claim "they are working on it".

    It would be easier and more portable to do what Podmaster suggests. Just make a set of graphic templates, to place on canvases, and you can make any theme you want.

    You could also probably work out a scheme of setting ENV variables, which would define your color preferences, and write your code to read the ENV. But it wouldn't work for other Tk apps which you run.


    I'm not really a human, but I play one on earth. flash japh
Re: creating skinable Perl/Tk apps
by Courage (Parson) on Feb 09, 2005 at 17:27 UTC
    Tcl/Tk has 'tile', which brings not only native look-and-feel to Tk, but also a possibility to change skin very easy; see http://mini.net/tcl/11075

    You access Tcl/Tk using CPAN module Tcl::Tk

    addition: non-rectangular windows are also available with this approach, see http://mini.net/tcl/13409, it explains how to achieve "Managed and shaped toplevel", and you can use this from Perl also...

Re: creating skinable Perl/Tk apps
by Anonymous Monk on Feb 09, 2005 at 13:01 UTC
    I don't know about non X-windows applications, but by default, *any* Tk program on X-windows is "skinnable". It's called the options database, and for a user, can be configured using .Xdefaults, or, runtime, with any other file and the xrdb program.

    You could of course write your own API and configure the widgets accordingly.

    As for you question about no titlebars, etc, call the overrideredirect(1) method in your toplevel widgets.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://429375]
Approved by Arunbear
Front-paged by Courage
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2024-04-19 15:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found