Chinese (People's Republic of China)  English  Français


Supinfo-Projects.com
Tous les projets des élèves ingénieurs de Supinfo



Projets
  Dernier Projet
  Les plus populaires
  Tous les Projets

342 Visiteurs
3168 Projets


My Supinfo-Projects

   Connectez-vous
   Créez un Compte


Synopsis

   174 Visites
   Note INTERNET : 13.3
    (3 Votants)
   236 Commentaires

   Lire l'article

Evaluez cet article

20
18
16
14
12
10
8
6
4
2
0


Commentez cet article

Auteur :

Email :

Votre commentaire :



 
2005 - Note de Synthèse Stage
Introduction to Gtk2-Perl
[30 mn de lecture - paru le 10/7/2004 3:02:44 PM - Public : Confirmé]

Auteur

artistPrzemyslaw BRODACKI
Elève-Ingénieur Supinfo Paris
Promotion SUPINFO 2004

   Lui écrire
   Tous les projets de cet auteur
   Le mini-CV de cet auteur

2. Standard elements

There are more complex elements.

    2.1. Adjustements

The adjustment elements may be compared to buttons but they are more complex because their operation is not boolean and allows a choice of several values.

In fact GTK allows here to create several types of adjustments. The problem might be related to the signals. If each adjustment passes a different signal, it will be a nightmare for thr programmer. There is thus an adjustement object which makes it possible to store signals from adjustments and to use them to make the use of the adjustments flexible:

$ajust = Gtk2::Adjustment->new($value,$lower,$upper,$step_increment,$page_increment,$page_size);

Here is a beautiful adjustment object, invisible because it does nothing but manage the data resulting from the other (visible) objects.

Parameters are :

- $value actual value
- $lower is the lower limit
- $upper is the upper showed limit (it's not the highest value of $value)
- $step_increment is the incrementation step
- $page_size is the visible zone of the widget

To get these information that you want to use differently, with your own manager:

get_adjustment->nom ;

where 'nom' is one of the following:
value  
lower  
upper  
step_increment  
page_increment  
page_size

To use the signals resulting from the adjustments:

$ajust->signal_connect("value_changed",\&function);

Here, it is enough to connect a visible object to the desired adjustment:

$echelle = Gtk2::HScale->new( $ajust ) ;

Some adjustement widgets: HScale, VScale, HScrollBar, VScrollBar...

The update of the value changed by the user using the adjustments can be made in three ways:

$echelle->set_update_policy($update) ;

where $update is one of the following:

- continuous thus real time(default)
- discontinuous thus once the mouse button has been released
- delayed thus after a certain time.

    2.2. Menus

Menus are essential elements in any application. They are cut out in 3 distinct elements:

- the menubar which comprises menu elements
- the menu which appears while clicking on an element of the menu
- the element of the menu or of the menubar.

The order of creation of a menu is thus made in this way:

- 1. We create the menubar
- 2. We create elements in the menubar
- 3. For each element in the menubar we create a menu
- 4. In each menu we create elements
- For each element in aech menu we create actions or other menus
- etc....

Lets see the it step by step:

1. $menubarre = Gtk2::MenuBar->new ();

2. $element01 = Gtk2::MenuItem->new($label);
   $menubarre->append($element01);   #To add element at the begining
or
   $menubarre->prepend($element01);  #To addelement at the end

3. $menu1 = Gtk2::Menu->new ();

4. $element11 = Gtk2::MenuItem->new($label);
   $menu1->append($element11);
ou
   $menu1->prepend($element11);

etc...

Very simple :)

    2.3. Status Bar

The status bars post text, in general current usefull information for users.

$statusbar = Gtk::Statusbar->new();

The creation of a status bar implies the generation af an unique identificator used to identify the user. To get this id:

$statusbar->get_context_id( $description );

With the id we can modify the posting of the status bar which functions like a stack. The events are stacked before being posted. Here possible operations on the stack:

$statusbar->push( $context_id, $text );  
$statusbar->pop( $context_id );  
$statusbar->remove( $context_id, $message_id );

    2.4. Barre d'outils

A basic tool bar is quite as easy to create:

$toolbar = Gtk2::Toolbar->new();

And we add the tool bar button as follows:

$toolbar->append_item ($text, $tooltip_text, $tooltip_private_text,  
           $icon, $fonction, $user_data);  
$toolbar->prepend_item ($text, $tooltip_text, $tooltip_private_text,  
           $icon, $fonction, $user_data);  
$toolbar->insert_item ($text,$tooltip_text,$tooltip_private_text,  
           $icon, $fonction, $user_data, $position);

Parameters are easy to understand but tooltip_private_text which must stay undefined because it's obsolete. user_data is a complementary parameter to pass to the called function.

We can add other elements than standard buttons:

$toolbar->append_element ( $type, $widget, $text,  
           $tooltip_text, $tooltip_private_text, $icon, $fonction, $user_data);  
$toolbar->prepend_element ( $type, $widget, $text,  
           $tooltip_text, $tooltip_private_text, $icon, $fonction, $user_data);  
$toolbar->insert_element ( $type, $widget, $text,  
           $tooltip_text, $tooltip_private_text, $icon, $fonction, $user_data,$position);

where type is one of the following:

- 'space' to add a space
- 'button' to add a button
- 'togglebutton' to add a toggle button
- 'radiobutton' to add a radio button
- 'widget' to add any other widget

We just can add any other object (widget) to the tool bar:

$toolbar->append_widget ($objet, $tooltip_text, $tooltip_private_text);

Parameters and methods allow various spacings between the objects, but also the insertion of icones starting from an ASCII ART. The bar can be vertical or horizontal...

    2.5. Baloon tips

The baloon tips are small helpful popup messages which show up when one leaves the mouse one moment on an object:

$bulle = Gtk2::Tooltips->new();
$bulle->set_tip ( $element01 , "our first element in the menu " , "" ) ;

We can enable or disable them or set up the delay:

$bulle->enable();
$bulle->disable();
$bulle->set_delay ( $delay );



Articles de la même catégorie

 Pages : Top


449 Visites
1 Commentaires
Réalisation d'un questionnaire médical sur PocketPC
[15 mn de lecture - paru le 10/7/2004 2:48:25 PM - Public : Débutant]

En savoir plus


429 Visites
0 Commentaires
Socle Technique EAI
[20 mn de lecture - paru le 10/7/2004 1:55:40 PM - Public : Confirmé]

En savoir plus


136 Visites
0 Commentaires
Framework EAI
[20 mn de lecture - paru le 10/7/2004 1:54:26 PM - Public : Confirmé]

En savoir plus

   Tous les Articles


SUPINFO Training Center peut vous proposer une formation ...

   Devenez Ingénieur Système Microsoft en 35 jours avec SUPINFO Training Center
   Devenez Certifiés Cisco en 13 jours avec SUPINFO Training Center
   Devenez Administrateur Système Microsoft avec SUPINFO Training Center
   Devenez Développeur Microsoft .NET en 13 jours avec SUPINFO Training Center



Powered by Campus-Booster Technology
Conditions d'utilisation & Copyright | Respect de la vie privée
© Copyright 1965-2006 Supinfo Paris, Paris Academy of Computer Science
Supinfo, Ecole Supérieure d'Informatique et Paris Academy Of Computer Science are trade marks.
23, rue de Château LANDON - 75010 PARIS - Phone : +33 (0) 153359 700 Fax : +33 (0) 153359 701

Web site autided by :