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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |