1 2 ..N:: 1 2 ..Npackage require BWidgetTkx::package_require('BWidget');ttk::button .b -text "Hello World" -command exitmy $b = $main_window->new_ttk__button( -text => 'Hello World', -command => sub { exit; } );tk_messageBox -message "Press OK"Tkx::tk___messageBox( -message => 'Press OK' );wm title . "Main Window"Tkx::wm_title( '.', 'Main Window' );$main_window->g_wm_title( 'Main Window' );Tkx::MainLoop();
  #! / usr / bin / perl
 use strict;
 use Tkx;
 our $ PROGNAME = 'MyProgram';
 our $ VERSION = '0.1';
 # create the main window
 my $ main_window = Tkx :: widget-> new ('.');
 # set the title
 $ main_window-> g_wm_title ('Main Window');
 # create and attach menu
 $ main_window-> configure (-menu => make_menu ($ main_window));
 # routine to create the main menu
 sub make_menu {
     my $ mw = shift;
    
     # disable the menu release mode (similar to GIMP)
     Tkx :: option_add ('* tearOff', 0);
    
     # depending on the OS, the Ctrl / Control button identifier may change
     my $ control = ($ ^ O eq "darwin")?  "Command": "Control";
     my $ ctrl = ($ ^ O eq "darwin")?  "Command-": "Ctrl +";
    
     # upper levels
     my $ menu = $ mw-> new_menu ();
     my $ menu_file = $ menu-> new_menu ();
     my $ menu_help = $ menu-> new_menu ();
    
     $ menu-> add_cascade (
         -label => 'File',
         -menu => $ menu_file,
     );
    
     $ menu-> add_cascade (
         -label => 'Help',
         -menu => $ menu_help,
     );
    
     # Add items to the File menu
     $ menu_file-> add_command (
         -label => 'Quit',
         -command => sub {$ mw-> g_destroy ();  },
     );
    
     # Help menu
     $ menu_help-> add_command (
         -label => 'About ...',
         -command => sub {
             Tkx :: tk ___ messageBox (
                 -title => 'About ...',
                 -message => "$ PROGNAME $ VERSION",
             );
         },
     );
    
     # return menu
     return $ menu;    
 }
 # run the main loop
 Tkx :: MainLoop (); Source: https://habr.com/ru/post/65466/
All Articles