IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Interfaces Graphiques Perl Discussion :

Onglets et sous onglets Perl/Tk


Sujet :

Interfaces Graphiques Perl

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Septembre 2010
    Messages
    13
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Septembre 2010
    Messages : 13
    Par défaut Onglets et sous onglets Perl/Tk
    Salut à tous,
    je debute en Perl/Tk et j'en suis à ma 1ère interface graphique.
    Mon interface comporte 2 onglets qui ont 2 sous-onglets chacun...et pour éviter que je me retrouve sur un des sous-onglets sans qu'il ne soit actif je voudrais donner la priorité d'affichage au 1er sous-onglets de chaque onglets....comme ça dès que je clique sur un onglets Parents c'est le 1er sous-onglets qui apparait...
    Pas trop méchant à 1ère vue mais j'ai essayé raise,focus,focusforce et raised sans succès.

  2. #2
    Responsable Perl et Outils

    Avatar de djibril
    Homme Profil pro
    Inscrit en
    Avril 2004
    Messages
    19 822
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 19 822
    Par défaut
    Il faut utiliser la méthode raise en précisant en argument le nom de cet onglet.
    raise(pageName)

    Raise the page identified by pageName.

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Septembre 2010
    Messages
    13
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Septembre 2010
    Messages : 13
    Par défaut Onglets et sous onglets Perl/tk
    Merci djibril, pour la précision d'usage du raise...mais quand je place un raise(pagename) dans la section sub de l'onglet parent j'ai une erreur du genre:
    XS_Tk__Callback_Call error:bad window path name "pagename" ....

    Je revois mon code spaghetti pour voir exactement où placer cette solution miracle....:-)

  4. #4
    Responsable Perl et Outils

    Avatar de djibril
    Homme Profil pro
    Inscrit en
    Avril 2004
    Messages
    19 822
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 19 822
    Par défaut
    montre nous ton code.

  5. #5
    Membre averti
    Profil pro
    Inscrit en
    Septembre 2010
    Messages
    13
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Septembre 2010
    Messages : 13
    Par défaut
    Voici le code pas très lisible mais ...

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    use strict;
    #use warnings;
    use Tk; # Appel du module Tk
    use Tk::NoteBook;
     
     
     
    my $mw=MainWindow->new(-title=>"onglets",-background=>"white");
          $mw->geometry("900x700");
          $mw->minsize( 850, 685 );
          my $onglet_1_a;
          my $onglet_1_b;
          #création d'onglet
          my $blocnote = $mw->NoteBook(
    	-backpagecolor => 'white',
    	-bg=>'darkorange3',
    	-inactivebackground=>"white",
    	)->pack( qw/-fill both -expand 1/ );
     
          # onglets a et b
    	my $ongleta = $blocnote->add("ongleta", -label => "AMBA-a protocol",
    	                                                                    -raisecmd=>sub{
                                                                                           $onglet_1_a->raise;
    	                                                                    });
    	$ongleta->configure( -background => 'white');#donner le background white à l'onglet crée
    	my $ongletb = $blocnote->add("ongletb", -label => "AMBA-b protocol",
    	                                                                    -raisecmd=>sub{
                                                                                             $onglet_1_b->raise;
    											});
    	$ongletb->configure( -background => 'white');
     
     
          # onglets a1 et 2 pour a 
          my $blocnote_a = $ongleta->NoteBook(
    	-backpagecolor => 'white',
    	-bg=>'darkorange3',
    	-inactivebackground=>"white",
    	)->pack( qw/-fill both -expand 1/ );
          $onglet_1_a = $blocnote_a->add("onglet_1_a", -label => "a1",
                                                                                          -raisecmd=>sub{});
     
          $onglet_1_a->configure( -background => 'white',);
          my $onglet_2_a =$blocnote_a->add("onglet_2_a", -label => "2",
                                                                                          -raisecmd=>sub{});
          $onglet_2_a->configure( -background => 'white',);
     
          # onglets a1 et 2 pour b 
          my $blocnote_b = $ongletb->NoteBook(
    	-backpagecolor => 'white',
    	-bg=>'darkorange3',
    	-inactivebackground=>"white",
    	)->pack( qw/-fill both -expand 1/ );
          $onglet_1_b = $blocnote_b->add("onglet_1_b", -label => "a1",
                                                                                          -raisecmd=>sub{});
          $onglet_1_b->configure( -background => 'white',);
          my $onglet_2_b =$blocnote_b->add("onglet_2_b", -label => "2",
                                                                                       -raisecmd=>sub{});;
          $onglet_2_b->configure( -background => 'white',);
    MainLoop;

  6. #6
    Responsable Perl et Outils

    Avatar de djibril
    Homme Profil pro
    Inscrit en
    Avril 2004
    Messages
    19 822
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 19 822
    Par défaut
    Bien indenté son code est déjà une bonne façon de travailler.
    Voici un code fonctionnel.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    #!/usr/bin/perl
    use strict;
    use warnings;
    use Tk;
    use Tk::NoteBook;
     
    my $mw = MainWindow->new( -title => "onglets", -background => "white" );
    $mw->geometry("900x700");
    $mw->minsize( 850, 685 );
     
    #création d'onglet
    my $blocnote = $mw->NoteBook(
      -backpagecolor      => 'white',
      -bg                 => 'darkorange3',
      -inactivebackground => "white",
    )->pack(qw/-fill both -expand 1/);
     
    # onglets APB et AHB
    my $ongletapb = $blocnote->add( "ongletapb", -label => "AMBA-APB protocol", );
    my $ongletahb = $blocnote->add( "ongletahb", -label => "AMBA-AHB protocol", );
     
    # onglets Verilog et VHDL pour APB
    my $blocnote_apb = $ongletapb->NoteBook(
      -backpagecolor      => 'white',
      -bg                 => 'darkorange3',
      -inactivebackground => "white",
    )->pack(qw/-fill both -expand 1/);
     
    my $onglet_vlog_apb = $blocnote_apb->add( "onglet_vlog_apb", -label => "verilog", );
    my $onglet_vhdl_apb = $blocnote_apb->add( "onglet_vhdl_apb", -label => "vhdl", );
     
    # onglets Verilog et VHDL pour AHB
    my $blocnote_ahb = $ongletahb->NoteBook(
      -backpagecolor      => 'white',
      -bg                 => 'darkorange3',
      -inactivebackground => "white",
    )->pack(qw/-fill both -expand 1/);
     
    my $onglet_vlog_ahb = $blocnote_ahb->add( "onglet_vlog_ahb", -label => "verilog", );
    my $onglet_vhdl_ahb = $blocnote_ahb->add( "onglet_vhdl_ahb", -label => "vhdl", );
     
    $blocnote->pageconfigure(
      "ongletapb",
      -raisecmd => sub {
        $blocnote_apb->raise("onglet_vlog_apb");
      },
    );
     
    $blocnote->pageconfigure(
      "ongletahb",
      -raisecmd => sub {
        $blocnote_ahb->raise("onglet_vlog_ahb");
      },
    );
    $onglet_vlog_apb->configure( -background => 'blue' );
    $onglet_vhdl_apb->configure( -background => 'red' );
    $onglet_vlog_ahb->configure( -background => 'blue' );
    $onglet_vhdl_ahb->configure( -background => 'red' );
     
    MainLoop;
    Pour apprendre à bien coder en Perl commence par lire les cours et tutoriels : http://perl.developpez.com/cours/

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. onglets et sous onglets
    Par mathis86 dans le forum IHM
    Réponses: 2
    Dernier message: 13/09/2012, 10h21
  2. Onglet et sous onglets
    Par Marcel Chabot dans le forum Forms
    Réponses: 2
    Dernier message: 30/09/2010, 18h39
  3. chargement des formulaires sous onglets
    Par stagolee dans le forum IHM
    Réponses: 2
    Dernier message: 23/02/2007, 15h32
  4. Réponses: 2
    Dernier message: 05/01/2007, 11h38
  5. onglet DataAcess sous delphi 7 Architect Trial
    Par vbcasimir dans le forum Connexion aux bases de données
    Réponses: 3
    Dernier message: 07/01/2005, 10h19

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo