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

When I try to do the following example:
#http://habrahabr.ru/blogs/perl/65774/ use Tkx; my $mw = Tkx::widget->new('.'); #Main Window #buttons my @btns = ( $mw->new_ttk__button(-text=>'button 1'), $mw->new_ttk__button(-text=>'button 2'), $mw->new_ttk__button(-text=>'button 3') ); #Place elements (buttons) in table grid #column x row coordinates $btns[0]->g_grid(-row=>0, -column=>0); $btns[1]->g_grid(-row=>0, -column=>1); $btns[2]->g_grid(-row=>1, -column=>1); #Event Loop Tkx::MainLoop();
It gives me an error:
invalid command name "ttk::button" at "script.pl" line ##
When I add after
use Tkx;
the following:
Tkx::package_require('ttk');
It gives me an error that it cannot find the "ttk" package:
can't find package ttk at "script.pl" line ##
Either way, I tried to capitalize "Ttk". Same thing happens.
So, I had to do:
use Tkx; my $mw = Tkx::widget->new('.'); #Main Window #buttons #used to be: #$mw->new_ttk__button(-text=>'button 1') #now: #$mw-> new_button(-text=>'button 1') my @btns = ( $mw->new_button(-text=>'button 1'), $mw->new_button(-text=>'button 2'), $mw->new_button(-text=>'button 3') ); #Place elements (buttons) in table grid #column x row coordinates $btns[0]->g_grid(-row=>0, -column=>0); $btns[1]->g_grid(-row=>0, -column=>1); $btns[2]->g_grid(-row=>1, -column=>1); #Event Loop Tkx::MainLoop();
And it works that way, but I figure that ttk is the package that allows for themed widgets, but when I use regular button, as I did in the last code above, it is a standard blocky widget.

Does anybody know how the person that made the example with ttk, managed it to work?

I have:
ActiveState perl, v5.10.0 built for MSWin32-x86-multi-thread

Replies are listed 'Best First'.
Re: Tkx ttk problem
by Anonymous Monk on Dec 23, 2009 at 20:09 UTC
    I think it depends on your version of Tcl, http://wiki.tcl.tk/11075
    The following instructions are for the Tile package, not for the ttk included in Tk 8.5. There are subtle differences, such as tile::setTheme becoming ttk::setTheme and others.
    So for Tcl 8.5 I usually needed
    use Tkx; $Tkx::TRACE=64; Tkx::package_require('tile'); Tkx::ttk__setTheme('xpnative');#Tkx::tile__setTheme('xpnative');
    Your code however works fine with Tcl 8.5
      Your code however works fine with Tcl 8.5

      Are you talking about the code that doesn't work for me (the first one, or the second one that works for me?

      are you talking about the one with ttk or without?
        Both version of your code work with 8.5
      By version of TCL, do you mean I need to update the TCL module in Perl or do I need to install the new version of TCL itself (I use ActiveState TCL)
Re: Tkx ttk problem
by Gangabass (Vicar) on Dec 24, 2009 at 01:32 UTC

    I'm sure this is your Tk version issue. So just update it.

    By the way here your can find excellent Tkx tutorial.

      He isn't using Tk :)