Précédent   Forum du club des développeurs et IT Pro > Autres langages > Perl > Interfaces Graphiques
Interfaces Graphiques Forum d'entraide pour les interfaces graphiques en Perl (TK, GTK, Tk-Zinc, 2D et 3D avec OpenGPL, ....). Avant de poster, veuillez consulter la FAQ Perl/Tk , les cours Perl.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 05/12/2012, 11h33   #1
Isabella83
Nouveau Membre du Club
 
Inscription : janvier 2010
Messages : 200
Détails du profil
Informations forums :
Inscription : janvier 2010
Messages : 200
Points : 35
Points : 35
Par défaut Placement des elements

Bonjour à tous,

J'ai un petit soucis pour le placement de mes widget dans ma fenêtre.
J'ai fait ceci :
Code :
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
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
use Bio::SeqIO;
use List::MoreUtils qw/ uniq /; 
 
my $FBgn_entry;
 
my $fenetre_principale = MainWindow->new( -title => 'Visualisation' );
$fenetre_principale->Label( -text => 'Gene (FBgn) : ')->pack();
my $entry = $fenetre_principale->Entry( 
	-background => 'white',
	-textvariable => \$FBgn_entry,
); 
 
my $mycanvas = $fenetre_principale->Scrolled('Canvas',
	-scrollbars=>'oe',
	- background => 'white',
	-width => "1000" , 
	-height => "500",
);
 
my $widget_texte = $fenetre_principale->Scrolled('Text', 
	-scrollbars => 'oe',
	-setgrid=>'single',
);
 
my $clear_button = $fenetre_principale->Button(-text => "Clear",
                   -command => sub { $widget_texte->delete('0.0','end'), 
			$entry->delete(0,'end');}
);
# sequence du transcript
my $bouton = $fenetre_principale->Button( 
	-text => 'Sequence', 
);
 
$entry->pack();  
$bouton->pack(); 
$clear_button->pack(); 
$mycanvas->pack();  
$widget_texte->pack();  
 
MainLoop;
Mais j'aimerai que mon champs, entry et mes 2 boutons soient placé les un à coté des autres.
J'ai essayé avec pour chacun d'entre eux, mais cela me les place à gauche de mon widget text ...
Merci d'avance pour votre aide !
Isabella83 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/12/2012, 13h22   #2
djibril
Responsable Perl et Outils

 
Avatar de djibril
 
Homme
Inscription : avril 2004
Messages : 13 533
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 33
Localisation : France

Informations forums :
Inscription : avril 2004
Messages : 13 533
Points : 31 720
Points : 31 720
Avant de t'aider, je te recommande de lire la FAQ. C'est la base à maitriser en Tk. Il y a une longue explication sur le gestionnaire d'espace.
__________________
Pas de questions technique par messagerie privée (lisez les règles du forum Perl) et pour les nouveaux !
djibril est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/12/2012, 14h26   #3
Isabella83
Nouveau Membre du Club
 
Inscription : janvier 2010
Messages : 200
Détails du profil
Informations forums :
Inscription : janvier 2010
Messages : 200
Points : 35
Points : 35
Oui j'ai lu la FAQ perl, j'ai essayé avec "place", en faisant ceci :
Code :
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
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
use Bio::SeqIO;
use List::MoreUtils qw/ uniq /; 
 
my $FBgn_entry;
 
my $fenetre_principale = MainWindow->new( -title => 'Visualisation' );
$fenetre_principale->Label( -text => 'Entrez le FBgn : ')->place(-x => 100, -y => 5 );
my $entry = $fenetre_principale->Entry( 
	-background => 'white',
	-textvariable => \$FBgn_entry,
)->place(-x => 200, -y => 5 ); 
 
my $mycanvas = $fenetre_principale->Scrolled('Canvas',
	-scrollbars=>'oe',
	- background => 'white',
	-width => "1000" , 
	-height => "500",
);
 
my $widget_texte = $fenetre_principale->Scrolled('Text', 
	-scrollbars => 'oe',
	-setgrid=>'single',
);
 
# sequence du transcript
my $bouton = $fenetre_principale->Button( 
	-text => 'Sequence', 
)->place(-x => 300, -y => 5);
 
my $clear_button = $fenetre_principale->Button(-text => "Clear",
                   -command => sub { $widget_texte->delete('0.0','end'), 
			$entry->delete(0,'end');}
)->place(-x => 400, -y => 5);
 
 
 
#$entry->pack();  
#$bouton->pack(); 
#$clear_button->pack(); 
$mycanvas->pack();  
$widget_texte->pack();  
 
MainLoop;
Cela fonctionne bien quand j'affiche le Label et le Entry, mais quand je veux ajouter les deux bouttons, il n'y a plus que ces deux derniers qui sont affichés ... Je dois louper quelque chose !
Isabella83 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/12/2012, 15h59   #4
Isabella83
Nouveau Membre du Club
 
Inscription : janvier 2010
Messages : 200
Détails du profil
Informations forums :
Inscription : janvier 2010
Messages : 200
Points : 35
Points : 35
En fait, j'ai un problème dans l'affichage dès que je mets place pour le clear_button, comment ça se fait que je ne puisse pas le placer ?
Faut t'il que je reserve une place spéciale pour Entry, Label et Button, et que je les place ensuite à cet endroit là ?
Isabella83 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/12/2012, 17h01   #5
djibril
Responsable Perl et Outils

 
Avatar de djibril
 
Homme
Inscription : avril 2004
Messages : 13 533
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 33
Localisation : France

Informations forums :
Inscription : avril 2004
Messages : 13 533
Points : 31 720
Points : 31 720
Je recommande l'usage de grid.
__________________
Pas de questions technique par messagerie privée (lisez les règles du forum Perl) et pour les nouveaux !
djibril est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/12/2012, 17h02   #6
Isabella83
Nouveau Membre du Club
 
Inscription : janvier 2010
Messages : 200
Détails du profil
Informations forums :
Inscription : janvier 2010
Messages : 200
Points : 35
Points : 35
D'accord je vais essayer, merci !
Isabella83 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/12/2012, 10h08   #7
Isabella83
Nouveau Membre du Club
 
Inscription : janvier 2010
Messages : 200
Détails du profil
Informations forums :
Inscription : janvier 2010
Messages : 200
Points : 35
Points : 35
Bonjour,
J'ai fais comme vous me l'avez conseillé avec "grid" , et cela fonctionne très bien :
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
use Bio::SeqIO;
use List::MoreUtils qw/ uniq /; 
 
my $FBgn_entry;
 
my $mw = new MainWindow;
$mw -> title("Visualisation");
my $frame = $mw ->Frame(-bg=>'grey')->grid( -row => 2, -column => 15 
);
$frame ->Label( -text => 'Entrez votre FBgn: ')->grid( -row => 0, -column => 1, -columnspan => 2,-rowspan => 2
);
$frame->Entry( 
	-background => 'white',
	-textvariable => \$FBgn_entry)->grid( -row => 0, -column => 4, -columnspan => 2,-rowspan => 2
); 
$frame->Button( -text => "Sequence")->grid( -row => 0, -column => 6 , -columnspan => 2,-rowspan => 2
);
$frame->Button(-text => "Clear")->grid( -row => 0, -column => 8 , -columnspan => 2,-rowspan => 2
);
MainLoop;
En revanche, lorsque j'essaie d'ajouter mon canvas comme ceci :
Code :
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
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
use Bio::SeqIO;
use List::MoreUtils qw/ uniq /; 
 
my $FBgn_entry;
 
my $mw = new MainWindow;
$mw -> title("Visualisation");
my $frame = $mw ->Frame(-bg=>'grey')->grid( -row => 2, -column => 15 
);
$frame ->Label( -text => 'Entrez votre FBgn: ')->grid( -row => 0, -column => 1, -columnspan => 2,-rowspan => 2
);
$frame->Entry( 
	-background => 'white',
	-textvariable => \$FBgn_entry)->grid( -row => 0, -column => 4, -columnspan => 2,-rowspan => 2
); 
$frame->Button( -text => "Sequence")->grid( -row => 0, -column => 6 , -columnspan => 2,-rowspan => 2
);
$frame->Button(-text => "Clear")->grid( -row => 0, -column => 8 , -columnspan => 2,-rowspan => 2
);
 
my $mycanvas = $mw->Scrolled('Canvas',
	-scrollbars=>'oe',
	- background => 'white',
	-width => "1000" , 
	-height => "500",
);
$mycanvas->pack();  
#$widget_texte->pack();  
 
MainLoop;
Cela ne fonctionne plus ... Faut il que je crée un autre Frame, pour y inserer mon canvas ? Je ne peux pas utiliser pack et grid c'est bien ca ?
Isabella83 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/12/2012, 10h11   #8
djibril
Responsable Perl et Outils

 
Avatar de djibril
 
Homme
Inscription : avril 2004
Messages : 13 533
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 33
Localisation : France

Informations forums :
Inscription : avril 2004
Messages : 13 533
Points : 31 720
Points : 31 720
Deux gestionnaires différents ne peuvent pas être utilisés dans le même cadre.
__________________
Pas de questions technique par messagerie privée (lisez les règles du forum Perl) et pour les nouveaux !
djibril est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/12/2012, 10h12   #9
Isabella83
Nouveau Membre du Club
 
Inscription : janvier 2010
Messages : 200
Détails du profil
Informations forums :
Inscription : janvier 2010
Messages : 200
Points : 35
Points : 35
Cadre = MainWindow ?
Isabella83 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/12/2012, 10h14   #10
djibril
Responsable Perl et Outils

 
Avatar de djibril
 
Homme
Inscription : avril 2004
Messages : 13 533
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 33
Localisation : France

Informations forums :
Inscription : avril 2004
Messages : 13 533
Points : 31 720
Points : 31 720
Un Frame est un cadre. MainWindows est également une fenêtre, un cadre spécial pouvant contenir des cadres.
__________________
Pas de questions technique par messagerie privée (lisez les règles du forum Perl) et pour les nouveaux !
djibril est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/12/2012, 10h30   #11
Isabella83
Nouveau Membre du Club
 
Inscription : janvier 2010
Messages : 200
Détails du profil
Informations forums :
Inscription : janvier 2010
Messages : 200
Points : 35
Points : 35
D'accord,
donc en fait, j'ai voulu créer un autre Frame, de façon à pouvoir y placer mon canvas de cette façon :
Code :
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
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
use Bio::SeqIO;
use List::MoreUtils qw/ uniq /; 
 
my $FBgn_entry;
 
my $mw = new MainWindow;
$mw -> title("Visualisation");
my $frame = $mw ->Frame(-bg=>'grey')->grid( -row => 2, -column => 9 
);
$frame ->Label( -text => 'Entrez votre FBgn: ')->grid( -row => 0, -column => 1, -columnspan => 1,-rowspan => 2
);
$frame->Entry( 
	-background => 'white',
	-textvariable => \$FBgn_entry)->grid( -row => 0, -column => 4, -columnspan => 1,-rowspan => 2
); 
$frame->Button( -text => "Sequence")->grid( -row => 0, -column => 6 , -columnspan => 1,-rowspan => 2
);
$frame->Button(-text => "Clear")->grid( -row => 0, -column => 8 , -columnspan => 1,-rowspan => 2
);
my $other = $frame->Frame(-bg=>'red'
)->pack(); 
my $mycanvas = $other->Scrolled('Canvas',
	-scrollbars=>'oe',
	- background => 'white',
	-width => "1000" , 
	-height => "500",
);
$mycanvas->pack();  
#$widget_texte->pack();  
 
MainLoop;
Mais ça ne fonctionne pas .... où est ce que je fais mal ?
Car quand je fais comme ceci, le rendu ne me plais pas ... Je trouve les Entry, et Button trop espacés ...
Code :
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
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
use Bio::SeqIO;
use List::MoreUtils qw/ uniq /; 
 
my $FBgn_entry;
 
my $mw = new MainWindow;
$mw -> title("Visualisation");
my $frame = $mw ->Frame(-bg=>'grey')->grid( -row => 2, -column => 9 
);
$frame ->Label( -text => 'Entrez votre FBgn: ')->grid( -row => 0, -column => 1, -columnspan => 1,-rowspan => 2
);
$frame->Entry( 
	-background => 'white',
	-textvariable => \$FBgn_entry)->grid( -row => 0, -column => 4, -columnspan => 1,-rowspan => 2
); 
$frame->Button( -text => "Sequence")->grid( -row => 0, -column => 6 , -columnspan => 1,-rowspan => 2
);
$frame->Button(-text => "Clear")->grid( -row => 0, -column => 8 , -columnspan => 2,-rowspan => 2
);
my $other = $frame->Frame(-bg=>'red')->grid( -row => 2, -column => 1, -columnspan => 9
); 
my $mycanvas = $other->Scrolled('Canvas',
	-scrollbars=>'oe',
	- background => 'white',
	-width => "1000" , 
	-height => "500",
);
$mycanvas->grid();  
#$widget_texte->pack();  
 
MainLoop;
Isabella83 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/12/2012, 10h33   #12
djibril
Responsable Perl et Outils

 
Avatar de djibril
 
Homme
Inscription : avril 2004
Messages : 13 533
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 33
Localisation : France

Informations forums :
Inscription : avril 2004
Messages : 13 533
Points : 31 720
Points : 31 720
Pourquoi tu n'utilises pas grid pour ton canvas ?
__________________
Pas de questions technique par messagerie privée (lisez les règles du forum Perl) et pour les nouveaux !
djibril est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/12/2012, 10h34   #13
Isabella83
Nouveau Membre du Club
 
Inscription : janvier 2010
Messages : 200
Détails du profil
Informations forums :
Inscription : janvier 2010
Messages : 200
Points : 35
Points : 35
Je viens d'editer mon message, en fait en utilisant grid, le rendu ne me plait pas !
Isabella83 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/12/2012, 11h06   #14
Isabella83
Nouveau Membre du Club
 
Inscription : janvier 2010
Messages : 200
Détails du profil
Informations forums :
Inscription : janvier 2010
Messages : 200
Points : 35
Points : 35
En fait j'ai simplifié : et j'ai vu à quoi servait l'option -sticky !!
Code :
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
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
use Bio::SeqIO;
use List::MoreUtils qw/ uniq /; 
 
my $FBgn_entry;
 
my $mw = new MainWindow;
$mw -> title("Visualisation");
#my $frame = $mw ->Frame(-bg=>'grey')->grid( -row => 2, -column => 9 
#);
my $label = $mw ->Label( -text => 'Entrez votre FBgn: '
);
my $entry = $mw->Entry( 
	-background => 'white',
	-textvariable => \$FBgn_entry
); 
my $button_sequence = $mw->Button( -text => "Sequence"
);
my $button_clear = $mw->Button(-text => "Clear"
);
 
my $mycanvas = $mw->Scrolled('Canvas',
	-scrollbars=>'oe',
	- background => 'white',
	-width => "1000" , 
	-height => "500"
);
 
$label->grid($entry,$button_sequence,$button_clear,-sticky => 'nsew');
$mycanvas ->grid(-columnspan=>'4');  
#$widget_texte->pack();  
 
MainLoop;
Isabella83 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/12/2012, 11h48   #15
djibril
Responsable Perl et Outils

 
Avatar de djibril
 
Homme
Inscription : avril 2004
Messages : 13 533
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 33
Localisation : France

Informations forums :
Inscription : avril 2004
Messages : 13 533
Points : 31 720
Points : 31 720
Autre exemple :
Code :
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
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
use Bio::SeqIO;
use List::MoreUtils qw/ uniq /; 
 
my $FBgn_entry;
 
my $mw = new MainWindow;
$mw -> title("Visualisation");
my $label = $mw ->Label( -text => 'Entrez votre FBgn: '
);
my $entry = $mw->Entry( 
	-background => 'white',
	-textvariable => \$FBgn_entry
); 
my $button_sequence = $mw->Button( -text => "Sequence"
);
my $button_clear = $mw->Button(-text => "Clear"
);
 
my $mycanvas = $mw->Scrolled('Canvas',
	-scrollbars=>'oe',
	- background => 'white',
	-width => "1000" , 
	-height => "500"
);
 
$label->grid($entry,$button_sequence,$button_clear,-sticky => 'new');
$mycanvas->grid(-columnspan=>'4', ,-sticky => 'nsew');  
 
$mw->gridColumnconfigure(2, -weight => 1);
$mw->gridRowconfigure(1, -weight => 1);
 
 
MainLoop;
__________________
Pas de questions technique par messagerie privée (lisez les règles du forum Perl) et pour les nouveaux !
djibril est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 13h50.


 
 
 
 
Partenaires

Hébergement Web