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 :

ajouter un lien html


Sujet :

Interfaces Graphiques Perl

  1. #1
    Membre émérite
    Avatar de Jasmine80
    Femme Profil pro
    Bioinformaticienne
    Inscrit en
    Octobre 2006
    Messages
    3 157
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 44
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Bioinformaticienne
    Secteur : Santé

    Informations forums :
    Inscription : Octobre 2006
    Messages : 3 157
    Points : 2 673
    Points
    2 673
    Par défaut ajouter un lien html
    Bonjour,


    J'aimerais ajouter un lien html dans une interface Tk, comment est-ce réalisable? Le module Tk-HTML sert-il à cela? Comment l'utiliser?


    Merci,
    -- Jasmine --

  2. #2
    Membre émérite
    Avatar de Jasmine80
    Femme Profil pro
    Bioinformaticienne
    Inscrit en
    Octobre 2006
    Messages
    3 157
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 44
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Bioinformaticienne
    Secteur : Santé

    Informations forums :
    Inscription : Octobre 2006
    Messages : 3 157
    Points : 2 673
    Points
    2 673
    Par défaut
    Voici le code, le lien apparait dans l'AIDE.

    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
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    #!/usr/bin/perl
     
    use warnings;
    use strict;
     
    use Tk;
     
     
     
    my $main = MainWindow->new(
        -background => 'blue',
        -title      => "Calcul de la température de fusion",
    );
    $main->minsize( 250, 150 );
     
     
    # lien : http://www.omrf.org/omrf/research/09/FrankLab/HYBNOTES.html
     
     
    my $RefLabel = $main->Label(
        -text       => "T° basée sur l'analyse des plus proches voisins (revu par Genosys) ",
        -background => 'blue',
        -foreground => 'white',
        -justify    => 'left',
    );
     
    my $SeqLabel = $main->Label(
        -text       => 'Séquence : ',
        -background => 'blue',
        -foreground => 'white',
        -justify    => 'left',
    );
    my $SeqEntry = $main->Entry(
        -background => 'white',
        -width      => 50,
    );
     
    my $NaLabel = $main->Label(
        -text       => 'Concentration en sel (M): ',
        -background => 'blue',
        -foreground => 'white',
    );
    my $NaEntry = $main->Entry(
        -background   => 'white',
        -textvariable => '5E-02',
        -width        => 15
    );
     
    my $CtLabel = $main->Label(
        -text       => 'Concentration en amorces (M): ',
        -background => 'blue',
        -foreground => 'white',
    );
    my $CtEntry = $main->Entry(
        -background   => 'white',
        -textvariable => '2E-07',
        -width        => 15
    );
     
    # bouton initialiser
    my $btn_initialiser = $main->Button(
        -text             => 'Initialiser',
        -activeforeground => 'red',
        -borderwidth      => 5,
        -command          => \&Initialiser,
    );
     
    # bouton aide
    my $btn_aide = $main->Button(
        -text             => 'Aide',
        -activeforeground => 'red',
        -borderwidth      => 5,
        -command          => [ \&Aide, $main, ],
    );
     
    # bouton calculer
    my $btn_tm = $main->Button(
        -text             => 'Tm',
        -activeforeground => 'red',
        -borderwidth      => 5,
        -command          => [ \&Result, $main, ],
    );
     
    # bouton quitter
    my $btn_quitter = $main->Button(
        -text             => 'Quitter',
        -activeforeground => 'red',
        -borderwidth      => 5,
        -command          => \&Quitter,
    );
     
    # Effet clavier, touche entrée
    $main->bind( 'Tk::Entry','<Return>', sub { $btn_tm->invoke(); } );
     
    # Placement de mes widgets
    $RefLabel->grid( -row => 0, -column => 0, -sticky => 'w', -pady => 20, -columnspan =>2);
     
    $SeqLabel->grid( -row => 1, -column => 0, -sticky => 'w' );
    $SeqEntry->grid( -row => 1, -column => 1, -sticky => 'w', -columnspan => 2);
     
    $NaLabel->grid( -row => 2, -column => 0, -sticky => 'w' );
    $NaEntry->grid( -row => 2, -column => 1, -sticky => 'w', -columnspan => 2);
     
    $CtLabel->grid( -row => 3, -column => 0, -sticky => 'w' );
    $CtEntry->grid( -row => 3, -column => 1, -sticky => 'w', -columnspan => 2);
     
    $btn_initialiser->grid( -row => 4, -column => 0, -pady => 20, );
    $btn_tm->grid( -row => 4, -column => 1, -pady => 20 );
    $btn_aide->grid( -row => 4, -column => 2, -pady => 20 );
    $btn_quitter->grid( -row => 4, -column => 3, -pady => 20 );
     
    MainLoop;
     
    # Fonctions utiliser par l'interface graphique
    sub Initialiser {
        $SeqEntry->delete(0, 'end');
     
        $NaEntry->delete(0, 'end');
        $NaEntry->insert('end', '5E-02');  
     
        $CtEntry->delete(0, 'end');
        $CtEntry->insert('end', '2E-07');
     
        return;
    }
     
    sub Quitter {
        exit(0);
    }
     
     
    # Aide
    sub Aide {
     
    	my ($fenetre_principale) = @_;
     
     
            my $help_frame = $fenetre_principale->Toplevel(
                -title      => 'AIDE',
                -background => 'blue',
            );
     
            $help_frame->minsize( 1200, 700 );
     
    	$help_frame->Label(
    		-text       => 'HYBRIDIZATION NOTES - Melting and Annealing Temperature',
    		-foreground => 'white',
    		-background => 'blue',
    	)->pack(qw/ -side top -fill x/);
     
     
     
    	$help_frame->Button(
    		-text    => 'Fermer',
    		-command => sub { $help_frame->destroy; },
    	)->pack(qw/ -side bottom /);	
     
    	my $help_text 
    	= $help_frame->Scrolled( 'Text', -scrollbars => 'osoe', )->pack(qw/ -fill both -expand 1 /);
     
     
            $help_text->insert(  'end',
     
    			q{  SITE DE REFERENCE : http://www.omrf.org/omrf/research/09/FrankLab/HYBNOTES.html
     
      AUTEUR : Frank, M. B. Hybridization Notes - Melting and Annealing Temperature. In: Frank, M. B. ed. Molecular Biology Protocols. 1997. Oklahoma City. Revision Date: October 2, 1997.			
     
     
     
      Other estimates of melting points have been determined for DNA3 or RNA4 based on nearest neighbor analysis (reviewed by Genosys5). Breslauer, et al3 showed that melting behavior of a DNA duplex is predictable from its primary sequence.
     
      Tm = 1000(DH)/[A+DS)+Rln(Ct/4)]-273.15+16.6log(Na+)].
      where
      DH = the sum of nearest neighbor enthalpy changes moving one base at a time through the sequence
      A = correction for initiation of pairing (= -10.8)
      DS = the sum of nearest neighbor entropy changes
      R = 1.987 cal deg-1 mol-1)
      Ct is the molar concentration of strands.
      For self-complementary strands, the term "Ct/4" is replaced by Ct.
      The values for DH and DS are shown in the table.
     
      Nearest Neighbor DH DNA (kcal/mol) DH RNA (kcal/mol) DS DNA (cal/mol); DNA DS RNA (cal/mol)
      AA or TT        - 9.1 - 6.6 -24.0 -18.4
      AT              - 8.6 - 5.7 -23.9 -15.5
      TA              - 6.0 - 8.1 -16.9 -22.6
      CA or TG        - 5.8 -10.5 -12.9 -27.8
      GT or AC        - 6.5 -10.2 -17.3 -26.2
      CT or AG        - 7.8 - 7.6 -20.8 -19.2
      GA or TC        - 5.6 -13.3 -13.5 -35.5
      CG              -11.9 - 8.0  -27.8 -19.4
      GC              -11.1 -14.2 -26.7 -34.9
      GG              -11.0 -12.2 -26.6 -29.7
     
      As an example, a 1 µM solution of the probe mentioned above (AGGTCATTG) in a 150 mM solution has a predicted Tm of:
       Tm = 1000(-7.8-11.0-6.5-5.6-5.8-8.6-9.1-5.8) / [-10.8+(-20.8-26.6-17.3—13.5-12.9-23.9-24.0-12.9) + 1.987ln[(1E-06)/4]] - 273.15 + 16.6log(0.15)
    	      = [-60900 / (-10.8-151.9-30.2)] - 273.15 - 13.7
    	      = (-60900/-192.9) - 286.9
    	      = 29°C
     
       Calcul de la temperature optimale de fusion du duplex amorce-ADN
       en utilisant des criteres energetiques
       dH,dS de la formation de l'helice
       R cste gaz parfait= 1.987 cal*k-1.mol-1
       C concentration de l'oligo en Molaire
       Na+ concentration en sels en Molaire
     
     
    	       dH
      Tmam = _________________   -273.15 + 16.6 log[Na+]      (1),(2),(3)
    	 dS + R*ln(C/4)
     
        Parametres thermodynamiques des
        plus proches voisins pour l ADN (1):
     
      ______________________________________
      
      Interaction       dH       dS      dG
      ______________________________________
      AA/TT            9.1      24.0     1.9
      AT               8.6      23.9     1.5
      TA               6.0      16.9     0.9
      CA/TG            5.8      12.9     1.9
      GT/AC            6.5      17.3     1.3
      CT/AG            7.8      20.8     1.6
      GA/TC            5.6      13.5     1.6
      CG              11.9      27.8     3.6
      GC              11.1      26.7     3.1
      GG/CC           11.0      26.6     3.1
      initiation                10.8
      ______________________________________
      dG, dH Kcal/mol
      dS  cal/mol (1 cal = 4.184 J)
      ______________________________________
    },
    	);
     
    	return;
    }
     
    # calcul du Tm
    sub Result {
     
        my ($fenetre_principale) = @_;
        # récupération des données
        #----------------------------
        my $seq = $SeqEntry->get();
        my $Na  = $NaEntry->get();
        my $Ct  = $CtEntry->get();
     
        # suppression des espaces éventuels
        #------------------------------------
        $seq =~ s/\s//g;
        $seq = uc($seq);
     
     
        # Vérification
        #---------------
        if ( $seq !~ m/^[ATCGRKSWMYDVBHN]+$/ ) {
     
            # fenêtre d'erreur
            #--------------------
            my $error_frame = $fenetre_principale->Toplevel(
                -title      => 'MESSAGE D\'ERREUR',
                -background => 'red',
            );
            $error_frame->minsize( 250, 50 );
     
            $error_frame->Label(
                -text =>
                    "La séquence ne peut contenir\nque des lettres du code IUPAC",
                -background => 'red',
    	    -font => "courrier 10 bold",
                -foreground => 'black',
            )->pack;
     
        }
        else {
     
            #-------------------------
            # fenêtre de résultat
            #-------------------------
     
    	my $amorce_l = length($seq);
     
    	my %correspondances =
    	    (
    		    'R' => ['A', 'G'],
    		    'K' => ['G', 'T'],
    		    'S' => ['C', 'G'],
    		    'W' => ['A', 'T'],
    		    'M' => ['A', 'C'],
    		    'Y' => ['C', 'T'],
    		    'D' => ['A', 'G', 'T'],
    		    'V' => ['A', 'C', 'G'],
    		    'B' => ['C', 'G', 'T'],
    		    'H' => ['A', 'C', 'T'],
    		    'N' => ['A', 'C', 'G', 'T']
    	    );
     
     
    	my @liste_amorces;
    	core( sub { push (@liste_amorces, $_);}, $seq) ;
     
    	my @a_tm;
    	my %h_tm;
     
    	foreach my $seq (@liste_amorces){
    	    my $tm = Tm($seq,$Ct,$Na);
    	    $h_tm{$seq}= $tm;
    	    push (@a_tm, $tm);
    	}
     
    	my $moyenne_tm;
    	map{$moyenne_tm += $_} @a_tm;
    	$moyenne_tm /= int(@a_tm);
    	$moyenne_tm = sprintf("%.3f", $moyenne_tm);
     
     
    	my $fenetre_resultat = $fenetre_principale->Toplevel(
    		-title      => "Tm de $seq (Na : $Na  Ct : $Ct)",
    		-background => 'blue',
    	);
    	$fenetre_resultat->minsize( 500, 600 );
     
    	$fenetre_resultat->Label(
    		-text       => 'Résultat',
    		-foreground => 'white',
    		-background => 'blue',
    	)->pack(qw/ -side top -fill x/);
     
    	$fenetre_resultat->Button(
    		-text    => 'Fermer',
    		-command => sub { $fenetre_resultat->destroy; },
    	)->pack(qw/ -side bottom /);
     
    	my $text_resultat
    	= $fenetre_resultat->Scrolled( 'Text', -scrollbars => 'osoe', )->pack(qw/ -fill both -expand 1 /);
     
     
    	# Tag GRAS
    	$text_resultat->tagConfigure('GRAS',
    		-font => '{Times New Roman} 8 {bold}',
    	);
    	# Tag Rouge
    	$text_resultat->tagConfigure('ROUGE',
    		-foreground => 'red',
    	);
     
     
    	# lignes d'affichage
    	while ( my ( $s, $t ) = each %h_tm ) {
    		$text_resultat->insert( 'end', "$s : $t °C\n" );
    	}
    	if ( int(@a_tm) > 1 ) {
    		$text_resultat->insert( 'end', "$seq : $moyenne_tm °C\n", ['GRAS','ROUGE'] );
    	}
     
     
        }
        return;
    }
     
     
     
    sub core
    {
      my ($code, $amorce) = @_ ; 
     
      my %correspondances = (
        'R' => ['A', 'G'],
        'K' => ['G', 'T'],
        'S' => ['C', 'G'],
        'W' => ['A', 'T'],
        'M' => ['A', 'C'],
        'Y' => ['C', 'T'],
        'D' => ['A', 'G', 'T'],
        'V' => ['A', 'C', 'G'],
        'B' => ['C', 'G', 'T'],
        'H' => ['A', 'C', 'T'],
        'N' => ['A', 'C', 'G', 'T']
      );
     
      if ( my ($start, $middle, $end) = ($amorce =~ /^([ACGT]*)([RKSWMYDVBHN])(\w*)$/i) )  {
        foreach my $alt (@{$correspondances{$middle}}) {
          core( $code, "$start$alt$end" );
        }
      }
      else {
        local $_ = $amorce ;                                                                          # Le mot clé "local" "localise" une variable globale de sorte que à la sortie du bloc celle-ci reprenne la valeur qu'elle avait juste avant d'être localisée
        $code->();                                                                                    # $code->() est simplement une manière d'appeler la fonction référencée par $code
      }
    }
     
     
     
    sub Tm{
     
            my $Amorce = $_[0];
            my $Ct = $_[1];
            my $Na = $_[2];
     
            my %dH =
            (
                    AA => -9.1,
                    TT => -9.1,
                    AT => -8.6,
                    TA => -6.0,
                    CA => -5.8,
                    TG => -5.8,
                    GT => -6.5,
                    AC => -6.5,
                    CT => -7.8,
                    AG => -7.8,
                    GA => -5.6,
                    TC => -5.6,
                    CG => -11.9,
                    GC => -11.1,
                    GG => -11.0,
                    CC => -11.0,
            );
     
            my %dS =
            (
                    AA => -24.0,
                    TT => -24.0,
                    AT => -23.9,
                    TA => -16.9,
                    CA => -12.9,
                    TG => -12.9,
                    GT => -17.3,
                    AC => -17.3,
                    CT => -20.8,
                    AG => -20.8,
                    GA => -13.5,
                    TC => -13.5,
                    CG => -27.8,
                    GC => -26.7,
                    GG => -26.6,
                    CC => -26.6,
            );
     
            my $H = 0;
            my $S = 0;
     
            my $NbScan = length($Amorce)-2+1;
            for(my$i=0; $i<$NbScan; $i++)
            {
     
                    my $N2 = substr($Amorce, $i, 2);
                    if((!exists $dH{$N2}) | (!exists $dS{$N2})){print "ERREUR N2 ($N2) $Amorce, $i\n";};
                    unless($N2=~/N/i)
                    {
                            $H += $dH{$N2};
                            $S += $dS{$N2};
                    }
            }
     
     
     
            my $Tm = 1000 * $H / ((-10.8 + $S)+1.987*log($Ct/4)) - 273.15 + 16.6*(log($Na)/log(10));
            $Tm = sprintf("%.3f", $Tm);
            return $Tm;
    }
    Merci pour votre aide.
    -- Jasmine --

  3. #3
    Responsable Perl et Outils

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

    Informations forums :
    Inscription : Avril 2004
    Messages : 19 820
    Points : 498 771
    Points
    498 771
    Par défaut
    Absolument non. Le widget text affichera ce que tu lui demandes d'afficher. Donc il t'affichera les balises.

    Pour créer des liens hypertextes dans un widget Text, il y a plusieurs façon (faudrait que je trouve le temps d'en parler dans la FAQ ) :
    - Soit vous utilisez le module Tk::HyperText qui est pas mal. Il permet de créer un widget ROText et son contenu au format html sera convertit comme il faut. Il permet de gérer la plupart des balises html. Pour un lien il suffira de mettre du texte de la sorte
    Code html : Sélectionner tout - Visualiser dans une fenêtre à part
    <a href='http://www.developpez.ne'>dvp.com</a>
    Et le module se charge de convertir comme il se doit.
    - Soit il vous faudra créer des marqueurs de texte. et sur ces marqueurs, jouer avec bind afin d'appliquer des événements lors d'un clic sur le texte, etc.

    voilà l'idée général.

  4. #4
    Membre émérite
    Avatar de Jasmine80
    Femme Profil pro
    Bioinformaticienne
    Inscrit en
    Octobre 2006
    Messages
    3 157
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 44
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Bioinformaticienne
    Secteur : Santé

    Informations forums :
    Inscription : Octobre 2006
    Messages : 3 157
    Points : 2 673
    Points
    2 673
    Par défaut
    Il est indiqué que le widget crée est un 'simple HTML-rendering widget' et n'est pas un 'full-fledged web browser widget' qu'est-ce que cela signifie?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    	my $html = $help_frame->Scrolled ('HyperText',
    		-scrollbars => 'ose',
    		-wrap       => 'word',
    	)->pack (-fill => 'both', -expand => 1);
     
    	$html->setHandler (Title    => \&onNewTitle);
    	$html->setHandler (Resource => \&onResource);
    	$html->setHandler (Submit   => \&onFormSubmit);
     
    	$html->loadString (qq~<a href='http://www.developpez.ne'>dvp.com</a>~);
    Que dois-je mettre dans Titre, Ressource et Soumission? Merci.
    -- Jasmine --

Discussions similaires

  1. Ajouter un lien HTML
    Par karnivor dans le forum Débuter
    Réponses: 4
    Dernier message: 22/02/2013, 00h10
  2. Réponses: 0
    Dernier message: 23/12/2012, 22h22
  3. REGEX : ajout de liens dans un texte HTML
    Par Tororo73 dans le forum Langage
    Réponses: 2
    Dernier message: 24/06/2011, 12h46
  4. Liens html pour un éditeur (ajouter une action javascript à un lien html)
    Par psychoBob dans le forum Général JavaScript
    Réponses: 17
    Dernier message: 25/05/2006, 18h41
  5. équivalent lien HTML
    Par Dra_Gun dans le forum Flash
    Réponses: 3
    Dernier message: 15/12/2003, 16h25

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