473,788 Members | 2,854 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Closing a menu window dynamically.

40 New Member
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 1566
cnsabar
40 New Member
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
2146
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 the window is not created by a script, the onclick command does not work. These files are simply meant to be clicked on by the user and displayed in their browser of choice. Any suggestions? Kevin Partin <!DOCTYPE HTML PUBLIC "-//W3C//DTD...
4
5192
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 the menu content in the same part of the page where the menu goes (BODY). The content of the page is generated dynamically so I can't put the menu content it on the headers.
3
2325
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 on it and choose Open from the context menu, I want the form to reappear. For that, I got the point covered. Even when the form is minimize, the behavior is like MSN Messenger. But one problem arose. When I close the form (the first time), it...
5
3052
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", acViewPreview AC.Visible = True AC.DoCmd.ShowToolbar "Print Preview", acToolbarNo AC.DoCmd.ShowToolbar "Menu Bar", acToolbarNo
10
4030
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 application. What should happen, is that the main MDI form should close, taking the child forms with it. There is code to loop through the child forms, remove the controls on each of them, and then close the form, but this code should execute only...
2
3023
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 and then attempts to close the window (either via my custom 'Close' box or by clicking the close 'X' in the upper right window corner), the validation event still triggers and it tells the user that they have invalid data. Which of course means...
1
1087
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 dynamically add some querystring value to that URL. So I need the menu item to do something like window.open("http://newurl/page.aspx?value=5");
5
14812
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 is the link ,or you can see the attachment with of the screen grab. HERE IS THE CODE FOR THAT MENU .suckerdiv ul{ font-family: Arial, Helvetica, sans-serif; font-size: 11px; margin-left: 0px; margin-right:0px; margin-top:0px;
1
3808
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 disappears can any one help in this here is the link you can watch the left menu here link here is the code var menuids= //Enter id(s) of SuckerTree UL menus, separated by commas function buildsubmenus(){ for (var i=0; i<menuids.length;...
0
10364
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9967
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4069
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.