473,326 Members | 2,104 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Closing a menu window dynamically.

40
Hi

I am having a problem in closing a menu window using TK module dynamically.

I use the following program.
Expand|Select|Wrap|Line Numbers
  1. use Tk;
  2.  
  3. $mw = MainWindow->new;
  4. $mw->geometry("1024x768");
  5. $mw->title("Menu Test");
  6.  
  7. $main_menu = $mw->Menu();
  8. $mw->configure(-menu => $main_menu);
  9. $file_menu = $main_menu->cascade(-label=>"File", -underline => 0, -tearoff=>0);
  10. $file_menu->command(-label=>"Exit", -underline=>0, -command=>sub{exit});
  11. $settings_menu = $main_menu->cascade(-label=>"Settings", -underline => 0, -tearoff=>0);
  12. $settings_menu->command(-label=>"Sub Menu1", -underline=>0, -command=>sub{&sub_func1});
  13. MainLoop;
  14. sub sub_func1
  15. {
  16.     $s_mw = MainWindow->new;
  17.     $s_mw->geometry("800x550+150+100");
  18.     $s_mw->title("Sub Menu");
  19.     $sub_menu1 = $s_mw->Menu();
  20.     $s_mw->configure(-menu => $sub_menu1);
  21.     $label1 = $s_mw->Label(-anchor => "w", -text => "Perl Path:", -background => "#D4D0C8", -cursor => "");
  22.     $txt1 = $s_mw->Entry(-borderwidth => 1, -cursor => "", -font => "Tahoma 8 normal", -foreground => "#000000", -relief => "sunken");
  23.  
  24.     $closeParent = $s_mw->Button(-background => "#FFFFFF", -borderwidth => 1, -text => "Close Main Window",-command => sub {&parent_close}, -cursor => "");
  25.     $cmdClear = $s_mw->Button(-background => "#FFFFFF", -borderwidth => 1, -text => "CLEAR",-command =>  sub{Clear()}, -cursor => "");
  26.     $cmdCancel = $s_mw->Button(-background => "#FFFFFF", -borderwidth => 1, -text => "EXIT",-command => [$s_mw => 'destroy'], -cursor => "");
  27.     $label1->place(-width => 96, -height => 24, -x => 25, -y => 25 );
  28.     $txt1->place(-width => 180, -height => 20, -x => 130, -y => 25);                
  29.  
  30.     $closeParent->place(-width => 100, -height => 20, -x => 200, -y => 500);
  31.     $cmdClear->place(-width => 60, -height => 20, -x => 350, -y => 500);
  32.     $cmdCancel->place(-width => 60, -height => 20, -x => 500, -y => 500);
  33.  
  34.     MainLoop;
  35. }
  36.  
  37. sub Clear 
  38. {
  39.     $txt1->delete(0, 'end');    $txt2->delete(0, 'end');
  40. }
  41.  
  42. sub parent_close
  43. {
  44. #Invoking close a window..
  45.     $mw => 'destroy'; 
  46. }
  47.  
I do know how to close a window dynamically in other menu...
looking any help regarding this.
Thanks
Jan 17 '08 #1
1 1543
cnsabar
40
Hi.,

I found one the method to close a window..
Expand|Select|Wrap|Line Numbers
  1. $mw ->withdraw();
  2.  
Let me know if anyother method available.
Thanks,
Sabarish
Jan 17 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Kevin Partin | last post by:
I am creating HTML documents that have the same structure as shown below. As a convenience to the user, I wanted to simply put a button on the bottom of the page to close the window. However, since...
4
by: Stromboli | last post by:
hi people, My problem is that I need to build a dynamic menu (preferably that works in all the browsers) that appears when I mouseover a certain link. The problem is that I have to declare...
3
by: ThunderMusic | last post by:
Hi, I'm trying to have a MSN Messenger like form/app closing behavior. When I click on the X button, I only want the form to disappear and when I double-click on the notify icon or right-click...
5
by: nick_faye | last post by:
Hi, I am still a newbie to VB and using MS Access 2000. I am currently trying to provide a preview of reports before printing them. My program is simple: AC.DoCmd.OpenReport "MyReport",...
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
2
by: Tom | last post by:
How is the best way to avoid validation when closing a window? For instance, I have a Windows Forms window which has a validation event for a text box. However, if one enters invalid data in then...
1
by: lstuyck73 | last post by:
Hi there, I use a menu control that is bound to a sitemap to display menu items, no problems there. I now have one menu item that needs to open an url in a new window, and I have to...
5
omerbutt
by: omerbutt | last post by:
hi all, i have a menu based on <ul> and <li> it is working fine on mozilla all versions IE 6 and 7 all versions and google chrome ver 2.0.172.31 , the only problem is occuring is with the IE8 here...
1
omerbutt
by: omerbutt | last post by:
hi every one i have a menu li and ul based the problem is when any specific category in the li is hovered the li or the sub-cat items appear but as i move my mouse over the sub-cat or level two li it...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.