f



Perl/Tk problem with pack() - option: '-in'

Hello.
I want to give a widget a new master!
What are my possibilities on this?

I tried to do this with the in-option from the packer pack() like this
way:

#!perl -w

use strict;
use Tk;

my $mw = new MainWindow;
my $f1 = $mw->Frame;
my $f2 = $f1->Frame;
$f2->pack(-in => $mw);

MainLoop;

I get the error:

can't pack .frame.frame inside . at ...

Please help me!
Erik

0
tschinke
8/16/2005 11:10:52 AM
comp.lang.perl.tk 4721 articles. 0 followers. pharrendorf (19) is leader. Post Follow

5 Replies
435 Views

Similar Articles

[PageSpeed] 52

tschinke <e.tschi@web.de> writes in article %:
> Hello.
> I want to give a widget a new master!
> What are my possibilities on this?
> 
> I tried to do this with the in-option from the packer pack() like this
> way:
> 
> #!perl -w
> 
> use strict;
> use Tk;
> 
> my $mw = new MainWindow;
> my $f1 = $mw->Frame;
> my $f2 = $f1->Frame;
> $f2->pack(-in => $mw);
> 
> MainLoop;
> 
> I get the error:
> 
> can't pack .frame.frame inside . at ...
> 
> Please help me!

From the Tk::pack pod:

    RESTRICTIONS ON MASTER WINDOWS
    The master for each slave must either be the slave's parent (the
    default) or a descendant of the slave's parent. This restriction
    is necessary to guarantee that the slave can be placed over any
    part of its master that is visible without danger of the slave
    being clipped by its parent.

$mw is not a descendant of $f1.

-- 
  Go to http://MarcDashevsky.com to send me e-mail.
  (Reunion -- http://ClassicalHigh70.com)
0
Marc
8/16/2005 12:19:57 PM
Thanks for your Help, but this is not a solution for my problem.

Let me explain my problem mor exactly:

I have Tk::Notebook with 3 Tabs. In the 2nd tab, there is a complex
widget. (a panedwindow with some other frames/widgets inside). When the
3rd Tab is opened there schould be exactly the same complex widget. i
dont want to copy this widget and all depending sub-widget by hand.

So here comes my idea: when i already have a widget packed in the 2nd
notebook-tab, the simpliest way to pack the SAME in the 3rd notebook is
to set the master/parent of my complex widget to the 3rd notebook-tab.
but how ?

i have tried it with the pack()- option '-in' without success.

my second idea is to clone the comlex widget and all subwidgets.
If you know how to clone a widget with all children an set them a new
master, you're welcome!

let me know your thougths about this...
Thanx a lot!

0
tschinke
8/16/2005 12:45:27 PM
tschinke <e.tschi@web.de> writes in article %:
> Thanks for your Help, but this is not a solution for my problem.
> 
> Let me explain my problem mor exactly:
> 
> I have Tk::Notebook with 3 Tabs. In the 2nd tab, there is a complex
> widget. (a panedwindow with some other frames/widgets inside). When the
> 3rd Tab is opened there schould be exactly the same complex widget. i
> dont want to copy this widget and all depending sub-widget by hand.
> 
> So here comes my idea: when i already have a widget packed in the 2nd
> notebook-tab, the simpliest way to pack the SAME in the 3rd notebook is
> to set the master/parent of my complex widget to the 3rd notebook-tab.
> but how ?
> 
> i have tried it with the pack()- option '-in' without success.

Yes, because it violates the laws of nature.

> my second idea is to clone the comlex widget and all subwidgets.
> If you know how to clone a widget with all children an set them a new
> master, you're welcome!

My thought is that the code that you use to create the complex
widget should be subroutinized so you can call it as many times
as you need to create the widget again and again and again . . .

-- 
  Go to http://MarcDashevsky.com to send me e-mail.
  (Reunion -- http://ClassicalHigh70.com)
0
Marc
8/16/2005 2:39:10 PM
tschinke wrote:

> So here comes my idea: when i already have a widget packed in the 2nd
> notebook-tab, the simpliest way to pack the SAME in the 3rd notebook is
> to set the master/parent of my complex widget to the 3rd notebook-tab.
> but how ?

As Marc pointed out, the master can be a descendant of the slave's 
parent. So, one idea is to make the parent of your complex widget an 
ancestor (the parent) of your notebook. This way, you should be able to 
pack your widget inside any of the notebook tabs. I haven't tested it 
though ;)

--Ala
0
Ala
8/16/2005 9:44:53 PM
tschinke wrote:
> Thanks for your Help, but this is not a solution for my problem.
>
> Let me explain my problem mor exactly:
>
> I have Tk::Notebook with 3 Tabs. In the 2nd tab, there is a complex
> widget. (a panedwindow with some other frames/widgets inside). When the
> 3rd Tab is opened there schould be exactly the same complex widget. i
> dont want to copy this widget and all depending sub-widget by hand.
>
> So here comes my idea: when i already have a widget packed in the 2nd
> notebook-tab, the simpliest way to pack the SAME in the 3rd notebook is
> to set the master/parent of my complex widget to the 3rd notebook-tab.
> but how ?
>
> i have tried it with the pack()- option '-in' without success.
>
> my second idea is to clone the comlex widget and all subwidgets.
> If you know how to clone a widget with all children an set them a new
> master, you're welcome!
>
> let me know your thougths about this...
> Thanx a lot!

Just make it a composite and invoke a second instance of it. If there
is state information you'd like to share, ConfigSpec a 'PASSIVE' into
the composite and stick a reference in there to hook back to your state
data.

Optionally use a hash to contain multiple frames, write a function to
pack() and packforget() them by hashkey, and use buttons instead of
tabs. Same frame pack()'d and the packforget()'ed by two different
buttons makes no inheritance issues. 

-FWIW
-Matt

0
shrike
8/18/2005 1:43:30 AM
Reply:

Similar Artilces:

Can't get passed 'use tk;' in my 1st perl/tk program.
I'm trying to run my 1st perl/tk program and can't get passed the "use Tk;" command. I get error, "Can't locate Tk.pm" and if I add a "use lib" pointer to directory containing Tk.pm, I get error message "Can't locate loadable object for module Tk::Event". SEE BELOW for actual scripts and error messages. Environment: Mac OS x 10.3.8; perl version 5.8.1; Tk directory Tk-804.027. Experince level: Used to write lots of perl code, 15 years ago on Sun/unix. Just wrote my 1st perl code on MAC. This is my first try at pe...

w2ksp4 cygwin Perl/Tk 'cpan -i Tk' fails
Hello, world! I have a W2K SP4 box with a fresh install of Cygwin, and would like to use Perl/Tk. When I attempt to install the Tk module using cpan: dpchrist@w2k30g:~$ cpan -i Tk CPAN: Storable loaded ok Going to read /home/dpchrist/.cpan/Metadata Database was generated on Sat, 13 Sep 2003 12:45:46 GMT Running install for module Tk ... Failed Test Stat Wstat Total Fail Failed List of Failed -------------------------------------------------------------------- ----------- t/cursor.t 255 65280 1 1 100.00% 1 t/entry.t ...

Perl/Tk: can't get -command=> \&function to work 'on-the-fly'!!
Please Help! I am trying to define buttons 'on-the-fly' mostly because their number is determined in a config file - I don't know how many I will need. It's ROYALLY NOT WORKING. I think Tk.pm is having issues. And it's all driving me very... verrrryyy... batty. *** I WANT THIS TO WORK *** (pseudo-code) for i=1;i<100,i++ { $handle[i] = menubar->command(-label => "test_i", %somecolors, -command => Move2Folder(i)); *** IS THIS TOO MUCH TO ASK??? *** 1) If I 'unroll it' (see end of this message) AND wrap the Move2Folder function...

[Tk] grid manager with '-', 'x', '^'
Just curious about special char with grid manager: On Tcl/Tk: grid .a - - grid ^ .b x This first line of TCL could translate on Ruby/Tk as: Tk.grid a, '-', '-' # a.path == '.a' There is no way to tranlate the second line without using any :row, :column, :rowspan, coloumnspan. Because TkGrid.configure want the first parameter is *win*. So, grid manager with relative placement on Ruby/Tk works only when the "first" is *win*. Is this right or do we have other trick for it ? Thanks. Hi! email55555 email55555 wrote: > > Just curious about special...

[tk] Equivalent to Perl's Tk::Tiler?
Hi All: I making arbitrarily large forms and in doing similar in Perl, I've used Tk::Tiler, a scrollable frame. I'd just pack my various entries into the form, and set a max size, from which the form would automatically scroll if the contents were larger than the form size. I've found a scrollable canvas sample I could use, but worry about the of resources it might take up. Any pointers? Thanks. Forrest From: Forrest Chang <fkc_email-news@yahoo.com> Subject: [tk] Equivalent to Perl's Tk::Tiler? Date: Tue, 6 Dec 2005 02:17:33 +0900 Message-ID: <81lkyz79...

Function 'system' nasty behaviour in Cygwin Perl/Tk
Hi All, I've recently installed latest x-Cygwin on different PCs and suddenly discovered strange reaction on 'system' function inside Perl/Tk apps. Naturally, console applications running well with this function. Below you can see my snippet code and stuff it prints. FELIX-XP-~> cat test.pl #!/usr/bin/perl # Code automatically generated by VPTK_W use strict; use Tk; use Tk::Button; my $mw=MainWindow->new(-title=>'Bug demo'); my $w_Button_001 = $mw -> Button ( -background=>'green4', -foreground=>'Yellow', -text=>...

Re: What's new in Tk 8.4 for Perl/Tk
Revised: http://www.lehigh.edu/~sol0/ptk/whats-new.html -++**==--++**==--++**==--++**==--++**==--++**==--++**== This message was posted through the Stanford campus mailing list server. If you wish to unsubscribe from this mailing list, send the message body of "unsubscribe ptk" to majordomo@lists.stanford.edu ...

PERL to mean what 'perldoc perl' says is wrong? (was: Re: perl should be improved and perl6)
Jim Cochrane wrote: > On 2008-04-14, Chris Mattern <syscjm@sumire.gwu.edu> wrote: >> On 2008-04-14, Jim Cochrane <allergic-to-spam@no-spam-allowed.org> >> wrote: <snip> >>> >>> Actually, "I should of course said" is still wrong - missing a verb >>> component - should be: "I should of course have said". >>> >> I think that sentence is also better for a little appropriate >> punctuation: "I should, of course, have said". The commas also help >> guide you to the correct verb choic...

Problem when require 'tk'
Hi All, My OS is Fedora. I download Ruby source and comppiled. I download ActiveTcl and installed. But, when I do require 'tk', ruby say: LoadError:no such file to load -- tk. Please help me. Thanks. -- Posted via http://www.ruby-forum.com/. Liu Ming wrote: > Hi All, > > My OS is Fedora. I download Ruby source and comppiled. I download > ActiveTcl and installed. But, when I do require 'tk', ruby say: > LoadError:no such file to load -- tk. > > Please help me. > > Thanks. > It seems you may have installed Ruby then Tcl, so you may need to ...

'require'ing globals without 'used only once' complaints from 'perl -w'?
I'm trying to figure out a way to load global variables using 'require' with 'perl -w' enabled, but without getting "<varname> used only once" errors. The only "solution" I've seen is to make sure all globals are referenced more than once, but that gets hard to manage when you scale up the project. My situation is a project of cgi-bin scripts, where there are several scripts all wanting to load global settings from a single 'config.pl' file. My current way of doing things is to make a 'config.pl' file that has the glo...

Linux Perl-TK -> Win32 Perl-Tk
I've got an app that I wrote in Perl-Tk for Linux (Redhat) that I would like to run on my Win32 laptop. I am not interested in dual-booting this laptop but would like to get the app up an running. I'm a perl-Tk hack at best. What is the best/easiest way to port the application? thanks, Mike On Tue, 21 Dec 2004 03:01:21 +0000, Michael Seningen wrote: > I've got an app that I wrote in Perl-Tk for Linux (Redhat) that I would > like to run on my Win32 laptop. > > I am not interested in dual-booting this laptop but would like to get > the ap...

Perl/Tk: 'selection conversion left too many bytes unconverted' error on large text selection
Hi all, I've written about this before, but it's come back and I still haven't found what the problem is. Basically, in Perl/Tk if a textbox has a lot of text in it (no idea on the limit yet - all I know is that it has to be a _lot_ of text), and all the text is selected (and therefore copied to the clipboard) the entire perl process is halted, the gui disappears and the error: selection conversion left too many bytes unconverted appears on the command line. This appears to be a tcl panic error (hence the cross-post to comp.lang.tcl as I'm not sure where the problem i...

Solution [ Perl/Tk: 'selection conversion left too many bytes unconverted' error on large text selection ]
After I got bitten enough by this error and found no solution on the web I had to debug it myself. For me it looks like the following: - text get selected from Tk::Text - TkSelPropProc in ./pTk/mTk/unix/tkUnixSelect.c gets called to handle the selection which determines that the display supports utf-8 and thus gets Encoding::utf8 as the responsable encoder (see Encode::Encoding for the interface) - then it calls Tcl_UtfToExternal to convert the selection from internal format to utf8, this function is defined in encGlue.c and just calls CallEncode in the same fil...

Tcl/Tk to Perl/TK Translation Problem
Hello, I am having problems translating the following tcl/tk code to perl/tk: ============ tcl code ============ label .controls.sizel -text "Size:" grid .controls.quall .controls.quallo .controls.qual .controls.qualhi -sticky ew grid .controls.sizel .controls.sizesm .controls.size .controls.sizelg -sticky ew grid .controls.colorl .controls.color -sticky ew grid configure .controls.color -columnspan 3 grid configure .controls.quall .controls.sizel .controls.colorl -sticky e grid configure .controls.quallo .controls.sizesm -sticky e grid configure .controls.qualh...

'^=' and '~='?
Hello, What is the difference between '^=' and '~='? Thanks, Duckhye ...

Web resources about - Perl/Tk problem with pack() - option: '-in' - comp.lang.perl.tk

Resources last updated: 2/6/2016 8:57:59 AM