Hey monks

I have a weird thing going on for a few days now, and I can't seem to find the solution.

I have made a program on unix, using the Tk module. I will gave you the basic code you need to compile it and test it on your own.

This program is just 2 pages of a notebook widget. on the first page there are 2 big entry boxes with buttons aside. These I use to browse for files and save files. This is no problem.

but the entry "cell" gives me throubles. this is the smaller entry on the right of the screen.

When you click the button next, which i placed below the screen, I want to continue to page 2. Butt I only want to continue if the entry widget "cell" is not empty!

I have created a subroutine to check the state of the entry widget, but it always says the widget is empty...

So the mssgbox keeps popping up, eventhoug the entry "cell" is not empty.

I have tryd checking with "" as " " to be sure. nothing works.. I have been looking on it for days now.. Hope someone can help me! beneath is my code

use Tk; use Tk::LabFrame; use Tk::Dialog; $mw = MainWindow->new; $mw->geometry("1300x800"); $mw->title("Main window"); $nb = $mw->NoteBook( )->pack(-expand => 1, -fill => 'both'); ####### Create page 1 ########## $p1 = $nb->add('page1', -label => 'Input / Output'); $p1->Button(-text => 'Next', -width => '15', -height => '2', -command +=> \&go_page2,)->place( -x => 1100, -y =>620); $btBrowse = $p1->Button( -text => "Browse", -command => \&browse_file, )->place( -x => 450, -y => 105); $btSave = $p1->Button( -text => "Browse", -command => \&save_file, )->place( -x => 1180, -y => 105); $entrybrowse = $p1->Entry(-width => 60)->place( -x => 20, -y => 110); $entrysave = $p1->Entry(-width => 60)->place( -x => 750, -y => 110); $entry_cell = $p1->Entry(-width => 20)->place( -x => 850, -y => 200); ####### Create page 2 ########## $p2 = $nb->add('page2', -label => 'page2', -state=>'disabled'); MainLoop; sub go_page2 { $name_topcell = $entry_cell->get(); print $name_topcell, "\n"; if ($name_topcell == ""){ print "yes \n"; $mssg_empty = $p1->Dialog(-title => 'Fill in Values', -text => 'Please fill in all the values', -default_button => 'oke', -buttons => [ 'oke'], -bitmap => 'info' )->Show(); } else { $nb->pageconfigure('page2', -state => 'normal'); $nb->raise('page2'); } }

Many Thanks in advance


In reply to Checking state entry widget?! by jerre_111

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.