
PapaGeek
User
Feb 18, 2014, 7:25 AM
Post #7 of 14
(37105 views)
|
Re: [FishMonger] Class or Package?
[In reply to]
|
Can't Post
|
|
FishMonger, You have been a major help and I thank you for that. Based on what you have said so far, I have experimented with a possible coding scheme. As stated, I want each menu to be contained in its own file, per your advice, a PL file. You mentioned a do loop of sorts, couldn’t get that working, but individual do’s for each menu file works great. Here are three files that seem to work and I’d appreciate your critique of what was done so far. TestGUI.pl contains a commented list of the basic menu structure, only two of the menus are in the test so far and each menu has a prefix letter to insure that there is no code interference. I load each menu with a do statement and then create each menu. Each menu has a local variable that hold the handle to the menu. I use the main menu handle to show the main menu and then start the dialog. The M or main menu contains a set of buttons to call the other menus. Only the first one does anything and the list is not correct or complete yet. The open accounts event at the end of the file uses the main handle to hide that menu and the account handle to show the next menu. The A or accounts menu only has one button so far to close it. There are two events at the end of the code. The first is to terminate the menu when the bottom is clicked which links to the code to terminate the menu when the X is hit. In either case I merely hide the pop up menu and restore the main menu. I realize the code is very primitive and is missing large chunks, but how do you feel about the basic approach? Thanks again for all your help so far PapaGeek
use Modern::Perl '2013'; use Win32::GUI(); main(); # Menus used by GUI: # M Main: # A Accounts: # S Sectors: # E Exist: E_Set('Sector'); Show() => Sector already exists / . . . # T Tickers: # E Exist: E_Set('Ticker'); Show() => Ticker already exists / . . . # S Sectors: Tickers can call Sectors if it doesn't exist yet! # I Investments: # T Tickers: Investments can call Tickers if it doesn't exist yet! # U Update: # C Crystal Ball: Can't request a date in the future # P Progress: sub main { do 'MenuA.pl'; do 'MenuM.pl'; A_Create(); # It only creates the menu M_Create(); # It only creates the menu M_Handle()->Show(); # Displays top menu Win32::GUI::Dialog(); # And starts the dialog } use Modern::Perl '2013'; use Win32::GUI(); my $M_Menu; # always call this menu sub M_Create { my $TopMenuWidth = 335; my $TopMenuHeight = 250; my $screen_width = Win32::GUI::GetSystemMetrics(0); my $screen_height = Win32::GUI::GetSystemMetrics(1); my $TimesRoman20 = Win32::GUI::Font->new( -name => "Times New Roman", -size => 20, -bold => 1, ); $M_Menu = new Win32::GUI::Window( -name => "TheTopMenu", -title => "Main Window", -pos => [ ($screen_width - $TopMenuWidth)/2, ($screen_height - $TopMenuHeight)/2 ], -size => [ $TopMenuWidth, $TopMenuHeight ], -background => [128,255,128], ); # $M_Menu->AddButton( # -name => "OpenMonthly", # -text => "Run Monthly Reports", # -pos => [ 10, 10 ], # -align => "center", # -valign => "center", # -size => [ 300, 40], # -font => $TimesRoman20, # ); $M_Menu->AddButton( -name => "M_OpenAccounts", -text => "Personal Accounts", -pos => [ 10, 10 ], -align => "center", -valign => "center", -size => [ 300, 40], -font => $TimesRoman20, ); $M_Menu->AddButton( -name => "M_OpenView", -text => "View Monthly Reports", -pos => [ 10, 60 ], -align => "center", -valign => "center", -size => [ 300, 40], -font => $TimesRoman20, ); $M_Menu->AddButton( -name => "M_OpenInvestments", -text => "Manage Investments", -pos => [ 10, 110 ], -align => "center", -valign => "center", -size => [ 300, 40], -font => $TimesRoman20, ); $M_Menu->AddButton( -name => "M_OpenFunds", -text => "Manage Funds", -pos => [ 10, 160 ], -align => "center", -valign => "center", -size => [ 300, 40], -font => $TimesRoman20, ); return; } sub M_Handle { return $M_Menu; } # This code is not call by the dialog process # It calls the parallel code in the Perl file that started the dialog sub M_OpenAccounts_Click { print "Accounts Button Hit\n"; M_Handle()->Hide(); A_Handle()->Show(); } use Modern::Perl '2013'; use Win32::GUI(); my $A_Menu; # always call this menu sub A_Create { my $TopMenuWidth = 200; my $TopMenuHeight = 100; my $screen_width = Win32::GUI::GetSystemMetrics(0); my $screen_height = Win32::GUI::GetSystemMetrics(1); $A_Menu = new Win32::GUI::Window( -name => "A_AccountsMenu", -title => "Accounts Window", -pos => [ ($screen_width - $TopMenuWidth)/2, ($screen_height - $TopMenuHeight)/2 ], -size => [ $TopMenuWidth, $TopMenuHeight ], ); $A_Menu->AddButton( -name => "A_CloseAccounts", -text => "Close Menu", -pos => [ 10, 10 ], ); return; } sub A_Handle { return $A_Menu; } # This code is not call by the dialog process # It calls the parallel code in the Perl file that started the dialog sub A_CloseAccounts_Click { print ("Click Button\n"); return A_AccountsMenu_Terminate(); } sub A_AccountsMenu_Terminate { print ("Click Menu X\n"); A_Handle()->Hide(); M_Handle()->Show(); return 0; # Don't do standard terminate }
|