Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Can't Erase Previous Menu Button

by socrtwo (Sexton)
on Nov 13, 2010 at 23:12 UTC ( [id://871261]=perlquestion: print w/replies, xml ) Need Help??

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

I'm writing a simple GUI Perl Tk converter of corrupt Open Office files into salvaged text and an attempt at a recovered version of the files. I have a Tk text area which displays the text and a menu bar that shows a button which when pushed launches the attempts at a recovered version of the file using whatever program is set to open the Open Office file format in question.

These all work fine. The problem is, after the first file recovery, with all subsequent files opened, the menubuttons keep piling up, and I can't erase the old ones. The menu buttons all try to launch the newest recovered file when pushed, not even pointing to the previous files recovered. I have tried to use "unpost", "destroy" and "forget" combined with "pack" with all sorts of arrows and double arrow with no luck. Of course I have no idea what I'm doing but the fun part is over now and frustration is seeping in.

I'm just a hacker newbie, and I'm not even sure if the button is a Tk::Menubutton or a Tk::Menu::Button as I have both modules referenced in the beginning, from borrowing from other scripts I hacked out before.

Anyway here is my button code which is part of the "Main Loop"/"sub menuopenClicked" section of my script which is launched when a user chooses a file from the Open choice on the simple File menu:

$but = $mbar -> Button(-label=>"Launch $ruslcbasename", -command =>\&recovered);

Replies are listed 'Best First'.
Re: Can't Erase Previous Menu Button
by PeterPeiGuo (Hermit) on Nov 14, 2010 at 01:56 UTC

    Hope this simple example helps you:

    use Tk; use strict; use warnings; my $mw = MainWindow->new; my $button = $mw->Button()->pack(); $button->configure( -text => 'delete me', -command => sub {$button->destroy();} ); MainLoop;

    Peter (Guo) Pei

Re: Can't Erase Previous Menu Button
by zentara (Archbishop) on Nov 14, 2010 at 22:25 UTC
    We need to see an example of your full working code. You probably are making some dumb mistake in the variable scope... like declaring each new menubutton with a my. Show code which displays the problem, so we can run it.

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
Re: Can't Erase Previous Menu Button
by Anonymous Monk on Nov 13, 2010 at 23:31 UTC
    Why are you creating new buttons?

      I'm trying to give a place where the user can launch the recovered version of the file. The salvaged text is right in front of them in the text area. The button is to launch the recovered version which might have the formatting too.

      The recovery process is different from the text salvaging. The text salvaging is done by a command line app. The recovery version is created by unzipping the Open Office File and replacing one of the XML files with a simplified version and then rezipping all the XML files back into an Open Office file again. Sometimes this allows for recovery after file corruption.

      Here's a screenshot.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (1)
As of 2024-04-25 01:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found