in reply to Dynamically destroying a window in Tk?

Well, here's the error message(s):
Can't call method 'destroy' without a package or object reference at * +.pl line *. Uncaught exception from user code: Can't call method 'destroy' without a package or object reference at * +.pl line *. main::quit('windowname') called at *.pl line *.

Replies are listed 'Best First'.
Re^2: Dynamically destroying a window in Tk?
by Koosemose (Pilgrim) on Dec 06, 2004 at 00:17 UTC

    Yep, A reference allows you to pass the actual variable (contents and all, which is what you need) With the single quotes, you're basically passing an indirect reference (though not quite in the way that more or less works) and that's generally considered a Bad Thing. Try passing a real refernce as I mentioned in my last post, and let us know how/if that works.

    I believe the sub will need altered a touch to, this should do it:

    sub quit { $$_[0]->destroy; }
    Just Another Perl Alchemist
      Alright, I've messed around with it a bit, and managed to get it down to this:
      MainWindow=HASH(0x164a81c) is not a widget at *.pl line **.


      Any more ideas?
        What is $windowname? Where does it come from/get created? Can you show the code that creates it? Also the result of ref($windowname) which should tell us what it is (widget or no).

        I suspect it's getting unblessed somewheres..

        C.