Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1556 connectés 

  FORUM HardWare.fr
  Linux et OS Alternatifs
  Codes et scripts

  Programmation HMI (python + glade-gtk2)

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Programmation HMI (python + glade-gtk2)

n°1346813
sined40
Posté le 22-10-2013 à 22:21:10  profilanswer
 

Bonjour,
 
Je viens d'utiliser Glade pour faire une HMI en C.  
Ne trouvant pas d'exemple de code C permettant de vérifier le rendu de mon IHM, j'ai trouvé un exemple en python.
 
En faisant un tour sur Google, j'ai trouvé un exemple en python et du coup, je l'ai essayé mais malheureusement mon HMI ne s'affiche pas.
 
Apparement mon code Python est correcte car je l'ai utilisé avec un programme type "Hello World" et là mon HMI (Hello World) s'affiche bien.
Donc j'en ai déduit que c'est le fichier HMI_01.glade qui n'est pas correctement formatté.
 
Pouvez-vous me dire comment on peut débugger un programme Glade en Python ou bien corriger les warnings de Glade ?
 
Pour info, ma config est:
 

  • Ubuntu 12.04.3 LTS

  • glade-gtk2  


Quand je lance glade, j'ai les warnings suivants qui s'affiche:
GladeUI-Message: No displayable values for property GtkToolPalette::icon-size
GladeUI-Message: No displayable values for property GtkToolItemGroup::ellipsize
GladeUI-Message: No displayable values for property GtkToolItemGroup::header-relief
GladeUI-Message: The DevHelp installed on your system is too old, devhelp feature will be disabled.
 
Voici mon code Glade (HMI_01.glade):

Code :
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <glade-interface>
  3.   <!-- interface-requires gtk+ 2.24 -->
  4.   <!-- interface-naming-policy project-wide -->
  5.   <widget class="GtkWindow" id="window1">
  6.     <property name="can_focus">False</property>
  7.     <property name="resizable">False</property>
  8.     <property name="modal">True</property>
  9.     <signal name="delete_event" handler="delete"/>
  10.     <child>
  11.       <widget class="GtkTable" id="table1">
  12.         <property name="visible">True</property>
  13.         <property name="can_focus">False</property>
  14.         <property name="n_rows">5</property>
  15.         <property name="n_columns">5</property>
  16.         <child>
  17.           <widget class="GtkFrame" id="frame1">
  18.             <property name="visible">True</property>
  19.             <property name="can_focus">False</property>
  20.             <property name="label_xalign">0</property>
  21.             <property name="shadow_type">none</property>
  22.             <child>
  23.               <widget class="GtkAlignment" id="alignment1">
  24.                 <property name="visible">True</property>
  25.                 <property name="can_focus">False</property>
  26.                 <property name="left_padding">12</property>
  27.                 <child>
  28.                   <widget class="GtkLabel" id="label5">
  29.                     <property name="visible">True</property>
  30.                     <property name="can_focus">False</property>
  31.                     <property name="label" translatable="yes">Cadre-01</property>
  32.                   </widget>
  33.                 </child>
  34.               </widget>
  35.             </child>
  36.             <child>
  37.               <widget class="GtkLabel" id="label1">
  38.                 <property name="visible">True</property>
  39.                 <property name="can_focus">False</property>
  40.                 <property name="label" translatable="yes">Cadre_01</property>
  41.                 <property name="use_markup">True</property>
  42.               </widget>
  43.               <packing>
  44.                 <property name="type">label_item</property>
  45.               </packing>
  46.             </child>
  47.           </widget>
  48.           <packing>
  49.             <property name="right_attach">3</property>
  50.             <property name="bottom_attach">3</property>
  51.           </packing>
  52.         </child>
  53.         <child>
  54.           <widget class="GtkFrame" id="frame2">
  55.             <property name="visible">True</property>
  56.             <property name="can_focus">False</property>
  57.             <property name="label_xalign">0.5</property>
  58.             <property name="shadow_type">none</property>
  59.             <child>
  60.               <widget class="GtkAlignment" id="alignment2">
  61.                 <property name="visible">True</property>
  62.                 <property name="can_focus">False</property>
  63.                 <property name="left_padding">12</property>
  64.                 <child>
  65.                   <widget class="GtkLabel" id="label8">
  66.                     <property name="visible">True</property>
  67.                     <property name="can_focus">False</property>
  68.                     <property name="label" translatable="yes">Cadre-04</property>
  69.                   </widget>
  70.                 </child>
  71.               </widget>
  72.             </child>
  73.             <child>
  74.               <widget class="GtkLabel" id="label2">
  75.                 <property name="visible">True</property>
  76.                 <property name="can_focus">False</property>
  77.                 <property name="label" translatable="yes">Cadre_04</property>
  78.                 <property name="use_markup">True</property>
  79.               </widget>
  80.               <packing>
  81.                 <property name="type">label_item</property>
  82.               </packing>
  83.             </child>
  84.           </widget>
  85.           <packing>
  86.             <property name="right_attach">5</property>
  87.             <property name="top_attach">3</property>
  88.             <property name="bottom_attach">5</property>
  89.           </packing>
  90.         </child>
  91.         <child>
  92.           <widget class="GtkFrame" id="frame3">
  93.             <property name="visible">True</property>
  94.             <property name="can_focus">False</property>
  95.             <property name="label_xalign">0</property>
  96.             <property name="shadow_type">none</property>
  97.             <child>
  98.               <widget class="GtkAlignment" id="alignment3">
  99.                 <property name="visible">True</property>
  100.                 <property name="can_focus">False</property>
  101.                 <property name="left_padding">12</property>
  102.                 <child>
  103.                   <widget class="GtkLabel" id="label6">
  104.                     <property name="visible">True</property>
  105.                     <property name="can_focus">False</property>
  106.                     <property name="label" translatable="yes">Cadre-02</property>
  107.                   </widget>
  108.                 </child>
  109.               </widget>
  110.             </child>
  111.             <child>
  112.               <widget class="GtkLabel" id="label3">
  113.                 <property name="visible">True</property>
  114.                 <property name="can_focus">False</property>
  115.                 <property name="label" translatable="yes">Cadre_02</property>
  116.                 <property name="use_markup">True</property>
  117.               </widget>
  118.               <packing>
  119.                 <property name="type">label_item</property>
  120.               </packing>
  121.             </child>
  122.           </widget>
  123.           <packing>
  124.             <property name="left_attach">3</property>
  125.             <property name="right_attach">5</property>
  126.           </packing>
  127.         </child>
  128.         <child>
  129.           <widget class="GtkFrame" id="frame4">
  130.             <property name="visible">True</property>
  131.             <property name="can_focus">False</property>
  132.             <property name="label_xalign">0</property>
  133.             <property name="shadow_type">none</property>
  134.             <child>
  135.               <widget class="GtkAlignment" id="alignment4">
  136.                 <property name="visible">True</property>
  137.                 <property name="can_focus">False</property>
  138.                 <property name="left_padding">12</property>
  139.                 <child>
  140.                   <widget class="GtkLabel" id="label7">
  141.                     <property name="visible">True</property>
  142.                     <property name="can_focus">False</property>
  143.                     <property name="label" translatable="yes">Cadre-03</property>
  144.                   </widget>
  145.                 </child>
  146.               </widget>
  147.             </child>
  148.             <child>
  149.               <widget class="GtkLabel" id="label4">
  150.                 <property name="visible">True</property>
  151.                 <property name="can_focus">False</property>
  152.                 <property name="label" translatable="yes">Cadre_03</property>
  153.                 <property name="use_markup">True</property>
  154.               </widget>
  155.               <packing>
  156.                 <property name="type">label_item</property>
  157.               </packing>
  158.             </child>
  159.           </widget>
  160.           <packing>
  161.             <property name="left_attach">3</property>
  162.             <property name="right_attach">5</property>
  163.             <property name="top_attach">1</property>
  164.             <property name="bottom_attach">3</property>
  165.           </packing>
  166.         </child>
  167.       </widget>
  168.     </child>
  169.   </widget>
  170. </glade-interface>


 
Voici mon code Python (HMI_01.py):

Code :
  1. #!/usr/bin/python
  2. # -*- coding: iso-8859-1 -*-
  3. import pygtk
  4. pygtk.require("2.0" )
  5. import gtk
  6. import gtk.glade
  7. class monprogramme:
  8.     def __init__(self):
  9.         self.widgets = gtk.glade.XML('HMI_01.glade',"window1" )
  10.         events = { 'delete': self.delete               }
  11.         self.widgets.signal_autoconnect(events)
  12.     def delete(self, source=None, event=None):
  13. print "Fin du programme";
  14. gtk.main_quit()
  15. if __name__ == '__main__':
  16.     print "Debut du programme";
  17.     app = monprogramme()
  18.     gtk.main()

mood
Publicité
Posté le 22-10-2013 à 22:21:10  profilanswer
 

n°1346814
sined40
Posté le 22-10-2013 à 22:28:55  profilanswer
 

Désolé, j'ai résolu mon probleme, il s'agit du parametre Visible qui était à FALSE au lieu de TRUE.

n°1346815
sined40
Posté le 22-10-2013 à 22:29:43  profilanswer
 

Mais si vous avez des infos sur les warnings et la façon de debugger du python & Glade, je suis toujours preneur.


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Linux et OS Alternatifs
  Codes et scripts

  Programmation HMI (python + glade-gtk2)

 

Sujets relatifs
Python 3.3 et QTPython: supprimen N niveau à une string qui est un chemin
CentOS 5, suppession et reinstall pythonProblème de python ?? [Gentoo]
Script en Perl vers script Python, interêt?Impossible d'installer obexftp sous Gentoo, a cause de Python ?
installation de Python 2.6 sur xandrosoutils de génération de diagramme code python
Débuter programmation shell 
Plus de sujets relatifs à : Programmation HMI (python + glade-gtk2)


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR