Beefy Boxes and Bandwidth Generously Provided by pair Networks Russ
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

lepetitalbert's scratchpad

by lepetitalbert (Monsignor)
on Nov 15, 2005 at 23:37 UTC ( #508845=scratchpad: print w/ replies, xml ) Need Help??

use strict; use warnings; use Tk; use Tk::Label; use Tk::DialogBox; my $blue = "#3366ff"; my @CLIENTS = ( "Dubout Paul" , "Lepetit Albert" , "Tronc Paul" , "Cha +rles-Appolon de la Qjpètpluôkmonqu" ); my @OBJECTS = ( "Maison de Cully" , "Manoir de Chailly" , "Domaine de +la Roturière"); my @CLIENT_DESC = ( 'Nom' , 'Prénom' , 'Adresse' , 'Ville' , 'Code Pos +tal' ); # # -- MAIN WINDOW ----------------------------------------------------- +--------- # my $main_window = MainWindow -> new( -background => '#ffffff' ); $main_window -> title(temp); $main_window -> geometry('800x600+100+80'); # # -- MENU ------------------------------------------------------------ +--------- # # -- Menubar -- my $menubar = $main_window->Frame( -pady => '1' )->pack( -side => 'top', -fill => 'x' , ); # -- File menu -- my $filemenu = $menubar->Menubutton( -width => '8' , -text => 'Fichier', -tearoff => 0 , -activebackground => $blue , -activeforeground => 'white' , -relief => 'ridge' , -bd => '1' , ) -> pack( -side => 'left' ); $filemenu->command( -label => 'Sauver' , -accelerator => "Ctrl+S" , -command => \&save , -activebackground => $blue , -activeforeground => 'white' , ); $filemenu->separator( -background => '#cccccc' , -foreground => 'black' , -activebackground => '#3366ff' , -activeforeground => 'white' , ); $filemenu->command( -label => 'Quitter' , -accelerator => "Ctrl-Q" , -activebackground => '#3366ff' , -activeforeground => 'white' , -command => sub{exit;} ); # -- Tool menu -- my $toolmenu = $menubar->Menubutton( -width => '8' , -text => 'Outils', -tearoff => 0 , -activebackground => '#3366ff' , -activeforeground => 'white' , -relief => 'ridge' , -bd => '1' , ) -> pack( -side => 'left' ); $toolmenu->command( -label => 'Ajouter un client' , -accelerator => "Ctrl+C" , -command => \&add_client ); $toolmenu->separator(); $toolmenu->command( -label => 'Ajouter un objet' , -accelerator => "Ctrl+O" , -command => \&add_objet ); # -- GLOBAL KEYBORAD SHORTCUT -- $main_window -> bind ( "<Control-Key-q>" , sub {exit;} ) ; # Ctrl q $main_window -> bind ( "<Control-Key-s>" , \&save ) ; # Ctrl s $main_window -> bind ( "<Control-Key-c>" , \&add_client ) ; # Ctrl c # # -- HEADERS --------------------------------------------------------- +--------- # my $headerbar = $main_window->Frame( # -background => '#333333' , -height => '20px' , )->pack( -side => 'top' , -fill => 'x' ); my $client_header = $headerbar -> Label( -text => 'CLIENTS' , -font => 'arial 11 bold' , -width => '31' , -height => '1' , -relief => 'ridge' , -bd => '1' , -background => '#3366FF' , -foreground => 'white' , -padx => '1' )->pack( -side => 'left' , ); my $object_header = $headerbar -> Label( -text => 'OBJECTS' , -font => 'arial 11 bold' , -width => '31' , -height => '1' , -relief => 'ridge' , -bd => '1' , -background => '#3366FF' , -foreground => 'white' , )->pack( -side => 'left' , ); my $desc_header = $headerbar -> Label( -text => 'DESCRIPTION' , -font => 'arial 11 bold' , -width => '120' , -height => '1' , -relief => 'ridge' , -bd => '1' , -background => '#3366FF' , -foreground => 'white' , )->pack( -side => 'left' , -expand => 'x' ); # # -- CLIENT LISTBOX -------------------------------------------------- +--------- # my $client_listbox = $main_window -> Listbox ( -width => '35' , -borderwidth => '1' , -font => 'Helvetica 11' , ) -> pack( -side => 'left' , -fill => 'y' ); foreach (@CLIENTS) { $client_listbox -> insert( 'end', $_ ); } $client_listbox -> bind ('<ButtonPress-1>', \&show_client); # # -- OBJECTS LISTBOX ------------------------------------------------- +---------- # my $object_listbox = $main_window -> Listbox ( -width => '35' , -borderwidth => '1' , -font => 'Helvetica 11' , ) -> pack( -side => 'left' , -fill => 'y' ); foreach (@OBJECTS) { $object_listbox -> insert( 'end', $_ ); } $object_listbox -> bind ('<ButtonPress-1>', \&show_object); # # -- DESCRIPTION AREA ------------------------------------------------ +--------- # my $desc_area = $main_window -> Canvas( ) -> pack( -fill => 'both', -expand => 'both' ); # NOM my $client_fname_line = $desc_area -> Canvas ( -height => '30' ) -> pack( -side => 'top' , -fill => 'x' ); my $client_fname_label = $client_fname_line -> Label( -text => 'Nom' , -font => 'Helvetica 11' , -height => '1' , -width => '10' , -padx => '15' , -pady => '5' ) -> pack( -side => 'left' ); my $client_fname_data = $client_fname_line -> Label( -text => 'data' , -font => 'Helvetica 11 bold' , -height => '1' , -background => 'white' ) -> pack( -side => 'left' , -padx => '50' ); # PRENOM my $client_sname_line = $desc_area -> Canvas ( -height => '30' ) -> pack( -side => 'top' , -fill => 'x' ); my $client_sname_label = $client_sname_line -> Label( -text => 'Prénom' , -font => 'Helvetica 11' , -height => '1' , -width => '10' , -padx => '15' , -pady => '5' ) -> pack( -side => 'left' ); my $client_sname_data = $client_sname_line -> Label( -text => 'Prénom' , -font => 'Helvetica 11 bold' , -height => '1' , -background => 'white' ) -> pack( -side => 'left' , -padx => '50' ); # ADRESSE my $client_address_line = $desc_area -> Canvas ( -background => 'red' , -height => '30' ) -> pack( -side => 'top' , -fill => 'x' ); my $client_adress_label = $client_address_line -> Label( -text => 'Adresse' , -font => 'Helvetica 11' , -height => '1' , -width => '10' , -padx => '15' , -pady => '5' ) -> pack( -side => 'left' ); # VILLE my $client_city_line = $desc_area -> Canvas ( -background => 'red' , -height => '30' ) -> pack( -side => 'top' , -fill => 'x' ); my $client_city_label = $client_city_line -> Label( -text => 'Ville' , -font => 'Helvetica 11' , -height => '1' , -width => '10' , -padx => '15' , -pady => '5' ) -> pack( -side => 'left' ); # -- BEGIN ----------------------------------------------------------- +--------- MainLoop; sub show_client { my $add_client_win = $main_window -> DialogBox ( -title => "Title", -buttons => ["OK", "Cancel"] ); my $reponse = $add_client_win -> Show ( ) ; } sub show_object { } sub add_client { my $add_client_win = $main_window -> DialogBox ( -title => 'Ajouter un client' , -buttons => [ 'Valider' , 'Annuler' ] ); my $pers_data = $add_client_win -> add ( 'Label' , -height => '1' , -font => 'Helvetica 12 bold' , -text => 'Données personnelles' , -pady => '10' ) -> pack( -side => 'top' , -fill => 'x' ); # -- NOM -- my $name_line = $add_client_win -> add ( 'Label' , -height => '30' ) -> pack( -side => 'top' , -fill => 'x' ); my $label_name = $name_line -> Label ( -font => 'Helvetica 10 bold' , -text => 'Nom : ', -padx => '10' , -pady => '5' ) -> pack ( -side => 'left' ); my $entry_name = $name_line -> Entry ( -font => 'Helvetica 10 ' , -textvariable => "test" ) -> pack ( -side => 'right' ); # -- PRENOM -- my $firstname_line = $add_client_win -> add ( 'Label' , -height => '30' ) -> pack( -side => 'top' , -fill => 'x' ); my $label_firstname = $firstname_line -> Label ( -font => 'Helvetica 10 bold' , -text => 'Prénom :', -justify => 'left' , -padx => '10' , -pady => '5' ) -> pack ( -side => 'left' ); my $entry_firstname = $firstname_line -> Entry ( -font => 'Helvetica 10 ' , -textvariable => "test" ) -> pack ( -side => 'right' ); # -- ADRESSE -- my $address_line = $add_client_win -> add ( 'Label' , -height => '30' ) -> pack( -side => 'top' , -fill => 'x' ); my $label_address = $address_line -> Label ( -font => 'Helvetica 10 bold' , -text => 'Adresse :', -padx => '10' , -pady => '5' ) -> pack ( -side => 'left' ); my $entry_address = $address_line -> Entry ( -font => 'Helvetica 10 ' , -textvariable => "test" ) -> pack ( -side => 'right' ); # -- No POSTAL -- my $nopostal_line = $add_client_win -> add ( 'Label' , -height => '30' ) -> pack( -side => 'top' , -fill => 'x' ); my $label_nopostal = $nopostal_line -> Label ( -font => 'Helvetica 10 bold' , -text => 'No Postal :', -padx => '10' , -pady => '5' ) -> pack ( -side => 'left' ); my $entry_nopostal = $nopostal_line -> Entry ( -font => 'Helvetica 10 ' , -textvariable => "test" ) -> pack ( -side => 'right' ); # -- VILLE -- my $ville_line = $add_client_win -> add ( 'Label' , -height => '30' ) -> pack( -side => 'top' , -fill => 'x' ); my $label_ville = $ville_line -> Label ( -font => 'Helvetica 10 bold' , -text => 'Ville :', -padx => '10' , -pady => '5' ) -> pack ( -side => 'left' ); my $entry_ville = $ville_line -> Entry ( -font => 'Helvetica 10 ' , -textvariable => "test" ) -> pack ( -side => 'right' ); # -- TELEPHONE -- my $telephone_line = $add_client_win -> add ( 'Label' , -height => '30' ) -> pack( -side => 'top' , -fill => 'x' ); my $label_telephone = $telephone_line -> Label ( -font => 'Helvetica 10 bold' , -text => 'Téléphone :', -padx => '10' , -pady => '5' ) -> pack ( -side => 'left' ); my $entry_telephone = $telephone_line -> Entry ( -font => 'Helvetica 10 ' , -textvariable => "test" ) -> pack ( -side => 'right' ); # -- MOBILE -- my $mobile_line = $add_client_win -> add ( 'Label' , -height => '30' ) -> pack( -side => 'top' , -fill => 'x' ); my $label_mobile = $mobile_line -> Label ( -font => 'Helvetica 10 bold' , -text => 'Mobile :', -padx => '10' , -pady => '5' ) -> pack ( -side => 'left' ); my $entry_mobile = $mobile_line -> Entry ( -font => 'Helvetica 10 ' , -textvariable => "test" ) -> pack ( -side => 'right' ); # -- FAX -- my $fax_line = $add_client_win -> add ( 'Label' , -height => '30' ) -> pack( -side => 'top' , -fill => 'x' ); my $label_fax = $fax_line -> Label ( -font => 'Helvetica 10 bold' , -text => 'Fax :', -padx => '10' , -pady => '5' ) -> pack ( -side => 'left' ); my $entry_fax = $fax_line -> Entry ( -font => 'Helvetica 10 ' , -textvariable => "test" ) -> pack ( -side => 'right' ); # -- DATA -- my $search_data = $add_client_win -> add ( 'Label' , -height => '1' , -font => 'Helvetica 12 bold' , -text => 'Object recherché' , -pady => '10' ) -> pack( -side => 'top' , -fill => 'x' ); # -- CANTON -- my $canton_line = $add_client_win -> add ( 'Label' , -height => '30' ) -> pack( -side => 'top' , -fill => 'x' ); my $label_canton = $canton_line -> Label ( -font => 'Helvetica 10 bold' , -text => 'Localisation :', -padx => '10' , -pady => '5' ) -> pack ( -side => 'left' ); my ($localisation, $canton); my $canton_choice = $canton_line -> Optionmenu( -options => [ [ 'Genève' => '000' ] , [ 'Vaud' => '100' ] , [ ' - Chablais vaudois' => '110' ] , [ ' - Lausanne' => '120' ] , [ ' - Montreux-Vevey' => '130' ] , [ ' - Morges' => '140' ] , [ ' - Nyon' => '150' ] , [ ' - Yverdon' => '160' ] , [ ' - Arc lémanique' => '170' ] , [ 'Valais' => '200' ] , [ ' - Chablais valaisan' => '210' ] , [ ' - Bas Valais' => '220' ] , [ ' - Haut Valais' => '230' ] , [ 'Fribourg' => '400' ] , [ 'France voisine' => '500' ] , [ 'Paris' => '600' ] , [ 'Côte d\'Azur' => '700' ] , [ 'Italie' => '800' ] , ] , -command => sub { } , -variable => \$localisation, -textvariable => \$canton ) -> pack( -side => 'right' , ); # -- TYPE -- my $type_line = $add_client_win -> add ( 'Label' , -height => '30' ) -> pack( -side => 'top' , -fill => 'x' ); my $label_type = $type_line -> Label ( -font => 'Helvetica 10 bold' , -text => 'Type :', -padx => '10' , -pady => '5' ) -> pack ( -side => 'left' ); my ($type_data, $type_display); my $type_choice = $type_line -> Optionmenu( -options => [ [ 'Appartement' => '110' ] , [ 'Maison' => '120' ] , [ 'Propriété de maître' => '130' ] , [ 'Immeuble' => '140' ] , [ 'Chalet' => '150' ] , [ 'Ferme' => '160' ] , [ 'Local commercial' => '210' ] , [ 'Bureaux' => '220' ] , [ 'Dépôt' => '230' ] , [ 'Hôtel' => '240' ] , [ 'Parking' => '250' ] , [ 'Terrain' => '260' ] , ] , -command => sub { } , -variable => \$type_data, -textvariable => \$type_display ) -> pack( -side => 'right' , ); my $reponse = $add_client_win -> Show ( ) ; }
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2014-04-19 01:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (475 votes), past polls