/ Published in: Perl
Generates a crappy menu from some text files.
Expand |
Embed | Plain Text
#!/usr/bin/perl use warnings; use strict; use Tk; #Open the menu file with the formatted menu name + filename list #file format: #Menu Name,TextFileName.txt my @menu = <MENULIST>; my $mw =MainWindow->new; my $frame = $mw->Frame->pack; mainmenu(); #Generate the main menu sub mainmenu { $frame->destroy; $frame = $mw->Frame->pack; foreach(@menu) { chomp $_; $frame->Button(-text => "$menuname", -width => 15, -command => sub { genlist("$listfile") } )->pack; } $frame->Button(-text => "Big List", -width => 15, -command => sub { genbiglist() } )->pack; } #Generate the submenu list based on the file passed to the sub #file formate: #Button Name,http://ButtonAddress sub genlist { $frame->destroy; $frame = $mw->Frame->pack; my ($listfile) = (@_); #Open the file my @addlist = <LIST>; foreach(@addlist) { chomp $_; $frame->Button(-text => "$aname", -width => 15, -command => sub { openbrowser("$aurl") }, )->pack; } $frame->Button(-text => "Menu", -command => sub { mainmenu() })->pack; } sub genbiglist { my @bigflist; my @bigfitems; $frame->destroy; $frame = $mw->Frame->pack; foreach(@menu) { chomp $_; } foreach(@bigflist) { } foreach (@bigfitems) { chomp $_; $frame->Button(-text => "$aname", -width => 15, -command => sub { openbrowser("$aurl") }, )->pack; } $frame->Button(-text => "Menu", -command => sub { mainmenu() })->pack; } sub openbrowser { my ($url) = (@_); #Actually open the webrowser, this method causes lag - to update to an API module at a later stage. ShellExecute("$url"); } MainLoop;
You need to login to post a comment.
