Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

perl Tk help

by ansh batra (Friar)
on Jun 24, 2012 at 20:31 UTC ( #978083=perlquestion: print w/replies, xml ) Need Help??

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

hi monks
i have seen the tutorials for perl Tk but still looking for more
can you guyz suggest me the something from where i can get to know more about perl Tk
are there any other modules for GUI in perl?
does perl Tk supports things like radio buttons,dropdown list,etc?

Replies are listed 'Best First'.
Re: perl Tk help
by cavac (Curate) on Jun 24, 2012 at 21:43 UTC

    Well, Tk has it's good and bad sided. The big, big BIG bonus is: It works on every operating system i ever tested it without any major obstacles. But of course, it looks old fashioned (because it is) and it's quite clumsy to program a more complex interface.

    If you want to design UIs with Tk, you can try ZooZ. It's a few years since i used it last, but it worked back then.

    As for other user interfaces: There are modules for Gtk2 and Gtk3. I wrote a simple example 944371 that uses GTK3 plus WebKit to make a simple one-purpose webbrowser. (Most of the article actually deals with fixing MakeMaker to work correctly in 64bit Linux).

    In theory there are also some Qt bindings, but as far as i know, they haven't been updated for quite a while.

    "You have reached the Monastery. All our helpdesk monks are busy at the moment. Please press "1" to instantly donate 10 currency units for a good cause or press "2" to hang up. Or you can dial "12" to get connected directly to second level support."
Re: perl Tk help
by zentara (Archbishop) on Jun 25, 2012 at 09:47 UTC
    does perl Tk supports things like radio buttons,dropdown list,

    Have you looked at the widget demo that comes with Tk? It contains radio button and dropdown list examples. Just type "widget" at a command prompt if you have Tk installed, or look in the Tk source/demos directory for the widget demo.

    Other than Tk, I also like Gtk2 for GUI's.

    Just in case you have a hard time wrangling the code out of the demo's, here are a couple of simple examples.

    Radiobuttons:

    #!/usr/bin/perl use warnings; use strict; use Tk; my $mw = MainWindow->new; my $rb = 'first button'; my $rb1 = $mw->Radiobutton(-text => "Button One", -value => 'button1', -variable => \$rb)->pack; my $rb2 = $mw->Radiobutton(-text => "Button Two", -value => 'button2', -variable => \$rb)->pack; my $b1 = $mw->Button(-text => 'Show', -command => [ \&showRB, \$rb ])- +>pack; MainLoop; sub showRB { print "Arg list is @_ \n"; my $state_ref = shift; my $state = $$state_ref; print "$state\n"; $mw->messageBox(-title => 'Status', -type => 'OK', -message => "Status is :$state:."); }
    and a drop down menu
    #!/usr/bin/perl use warnings; use strict; use Tk; my $top = MainWindow->new; $top->geometry('200x200+100+100'); # Menubar my $menu = $top->Frame(-relief => 'raised', -bd => 2); my $menu_pulldown = $menu->Menubutton(-text => "Test", -underline => 0); $menu_pulldown->command(-label => "Exit", -command => sub { exit 0 }); # Cascade Menu $menu_pulldown->cascade(-label => "Cascade", -underline => 1,); my $newmenu = $menu_pulldown->cget(-menu)->Menu; $menu_pulldown->entryconfigure('last', -menu => $newmenu); $newmenu->command(-label => "CascadeCommand", -command => sub { exit 0 }); $menu->pack(-side => 'top', -fill => 'x'); $menu_pulldown->pack(-side, 'left'); MainLoop;

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
Re: perl Tk help
by linuxkid (Sexton) on Jun 24, 2012 at 21:54 UTC

    I use a lot of Perl/Tk, and my favorite resource is here and my second favorite is here. and yes, it does support dropdowns and radiobuttons. and it has several very nice extensions to it that I love to use.

    --linuxkid


    imrunningoutofideas.co.cc

      The first link you provide is to a site which illegally publishes ebooks from O'Reilly.

        I'm not so sure about that anymore. I recently heard a radio interview with the head of O'Reilly, still Tim O'Reilly I presume, and he said that the illegal content out there was actually helpful to them, by making people aware that such resources exist. So even though they may be technically illegal, I don't see much prosecution of these sites. Of course, this is just from my memory of what I heard, and may just be my wishful thinking. :-)

        There are quite a few sites with O'Reilly content on them, some with advertising for various things, so it would seem their lawyers are letting it slide, or are complicit with it.


        I'm not really a human, but I play one on earth.
        Old Perl Programmer Haiku ................... flash japh

        I have a legal copy of the ebook, and that is easier to search than the copy on my kindle, and i'm pretty sure that other countries have differeing copyright laws, and it my not be copyright there.

        --linuxkid


        imrunningoutofideas.co.cc
Re: perl Tk help
by bulk88 (Priest) on Jun 25, 2012 at 02:51 UTC
    Wx, Prima, Tkx. As mentioned earlier, GTK, QT. Some people call DHTML a GUI. WxGlade can generate Perl WX code for you. GUI Loft for Win32::GUI. SpecTCL for Perl TK or TKX I dont remember. GuiBuilder is more modern decendent of SPecTCL, it makes Perl TK and TKX code. Last I checked there is nothing that will produce perl GTK code for you. Glade doesn't do it.

      Last I checked there is nothing that will produce perl GTK code for you.

      But it is not difficult to translate the generated C code to Gtk2.pm. The APIs are similar.

        But it is not difficult to translate the generated C code to Gtk2.pm. The APIs are similar.

        The APIs are identical only the calling convention is different, but there is also no point in doing the translation yourself, it misses the point of using Glade, the idea behind Glade is for it to generate code for you
        Glade::PerlGenerate
        glade2perl - Builds Gtk-Perl sources from a Glade file
        glade2perl-2 - Builds Gtk2-Perl sources from a Glade-2 file
        Glade2::Widget - Creates a new widget from a .glade file. It accepts the following parameters.
        Gtk2::GladeXML - Create user interfaces directly from Glade XML files.
        Gtk2::GladeXML::Simple - A clean object-oriented interface to Gtk2::GladeXML

Re: perl Tk help
by Anonymous Monk on Jun 25, 2012 at 01:23 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://978083]
Approved by Old_Gray_Bear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2020-10-31 23:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (291 votes). Check out past polls.

    Notices?