Contenu | Rechercher | Menus

Annonce

Si vous avez des soucis pour rester connecté, déconnectez-vous puis reconnectez-vous depuis ce lien en cochant la case
Me connecter automatiquement lors de mes prochaines visites.

À propos de l'équipe du forum.

#1 Le 30/08/2007, à 22:53

l e . n o x

pygtk - glade - debutant - recuperer texte dans textbox entryx -

bonsoir wink

Voici une question de débutant roll

je souhaiterais récupérer le texte d'une (textBox - GtkEntry*entry1) d'une interface Graphique crée avec glade et le stocker dans une variable, comme le montre cet exemple :

  /* Fetch the value of each widget */
  name    = gtk_entry_get_text(GTK_ENTRY(entryName));

mais le resultat est toujours le meme une belle erreur "NameErro":

Traceback (most recent call last):
  File "scpgui.py", line 32, in on_bp_ok_clicked
    str = gtk_entry_get_text(GtkEntry*entry1)
NameError: global name 'gtk_entry_get_text' is not defined

voici l'extrait du manuel GTK+

gtk_entry_get_text ()

const gchar*        gtk_entry_get_text                  (GtkEntry *entry);

Retrieves the contents of the entry widget. See also gtk_editable_get_chars().

entry :     a GtkEntry
Returns :     a pointer to the contents of the widget as a string. This string points to internally allocated storage in the widget and must not be freed, modified or stored.

voici le script de lancement Python scpgui.py que j'ai redigé grace a ce tuto: http://daniel.coquette.free.fr/dotclear/index.php/post/2006/12/11/Creer-des-interfaces-graphique-avec-PyGTK-et-Glade

#!/usr/bin/env python
import sys,os
try:
        import pygtk
        pygtk.require("2.0")
except:
        pass
try:
        import gtk
        import gtk.glade
except:
        sys.exit(1)
#========================= 
class GtkWindow:
        """This is an scpGui GTK application"""

        def __init__(self):
               
                #Set the Glade file
                self.gladefile = "scpgui.glade" 
                self.wTree = gtk.glade.XML(self.gladefile)

	#Create our dictionay and connect it
		dic = { 
		"on_bp_ok_clicked" : self.on_bp_ok_clicked,
        	"on_MainWindow_destroy" : gtk.main_quit,
		 }

		self.wTree.signal_autoconnect(dic)
	
	def on_bp_ok_clicked(self, widget):
		str = gtk_entry_get_text(GtkEntry*entry1)
 		print str 
#=================================
if __name__ == "__main__":
        hwg = GtkWindow()
        gtk.main()

voici le fichier cree par glade de l'interface graphique en question:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.2.0 on Thu Aug 30 22:53:39 2007 by user@noxdell-->
<glade-interface>
  <widget class="GtkWindow" id="MainWindow">
    <property name="visible">True</property>
    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
    <signal name="destroy" handler="on_MainWindow_destroy"/>
    <child>
      <widget class="GtkVBox" id="vbox1">
        <property name="visible">True</property>
        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
        <child>
          <widget class="GtkLabel" id="label1">
            <property name="visible">True</property>
            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
            <property name="label" translatable="yes">** SSH -scp- copy / coller ** </property>
          </widget>
        </child>
        <child>
          <widget class="GtkHBox" id="hbox1">
            <property name="visible">True</property>
            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
            <child>
              <widget class="GtkVBox" id="vbox3">
                <property name="visible">True</property>
                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                <child>
                  <widget class="GtkFileChooserButton" id="filechooserbutton1">
                    <property name="visible">True</property>
                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                  </widget>
                </child>
                <child>
                  <widget class="GtkFileChooserButton" id="filechooserbutton2">
                    <property name="visible">True</property>
                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                  </widget>
                  <packing>
                    <property name="position">1</property>
                  </packing>
                </child>
                <child>
                  <widget class="GtkFileChooserButton" id="filechooserbutton3">
                    <property name="visible">True</property>
                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                  </widget>
                  <packing>
                    <property name="position">2</property>
                  </packing>
                </child>
              </widget>
            </child>
            <child>
              <widget class="GtkVBox" id="vbox2">
                <property name="visible">True</property>
                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                <child>
                  <widget class="GtkEntry" id="entry1">
                    <property name="visible">True</property>
                    <property name="can_focus">True</property>
                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                  </widget>
                </child>
                <child>
                  <widget class="GtkEntry" id="entry2">
                    <property name="visible">True</property>
                    <property name="can_focus">True</property>
                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                  </widget>
                  <packing>
                    <property name="position">1</property>
                  </packing>
                </child>
                <child>
                  <widget class="GtkEntry" id="entry3">
                    <property name="visible">True</property>
                    <property name="can_focus">True</property>
                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                  </widget>
                  <packing>
                    <property name="position">2</property>
                  </packing>
                </child>
              </widget>
              <packing>
                <property name="position">1</property>
              </packing>
            </child>
          </widget>
          <packing>
            <property name="position">1</property>
          </packing>
        </child>
        <child>
          <widget class="GtkVBox" id="vbox4">
            <property name="visible">True</property>
            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
            <child>
              <placeholder/>
            </child>
            <child>
              <widget class="GtkProgressBar" id="progressbar1">
                <property name="visible">True</property>
                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                <property name="text" translatable="yes"></property>
              </widget>
              <packing>
                <property name="position">1</property>
              </packing>
            </child>
          </widget>
          <packing>
            <property name="position">2</property>
          </packing>
        </child>
        <child>
          <widget class="GtkButton" id="bp_ok">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">True</property>
            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
            <property name="label" translatable="yes">OK</property>
            <signal name="clicked" handler="on_bp_ok_clicked" object="bpok"/>
          </widget>
          <packing>
            <property name="position">3</property>
          </packing>
        </child>
      </widget>
    </child>
  </widget>
</glade-interface>

Merci pour votre aide.

Dernière modification par l e . n o x (Le 30/08/2007, à 22:59)


Zik Fan : " Vous seul savez mieux que quiconque comment organiser votre bibliothèque musicale ! "

Linux, y a moins bien.
Mais c'est plus cher. ;O)

Hors ligne

#2 Le 30/08/2007, à 23:07

trucutu

Re : pygtk - glade - debutant - recuperer texte dans textbox entryx -

Euh, gtk_entry_get_text, c'est du C sedmp.... Dans du code Python, ce n'est pas étonnant que ca ne marche pas.

Pour du Python, ca serait pas entry1.get_text() ?

[edit] Ah, autre chose : je ne sais pas trop comment ça marche (la création d'IHM avec Glade), mais ton entry1, pour être visible de la fonction où tu as mis le get_text, il faudra sûrement qu'il soit déclaré en tant qu'attribut de la classe GtkWindow (sûrement récupéré à partir du wTree...), donc self.entry1

Dernière modification par trucutu (Le 30/08/2007, à 23:19)


La chanson du dimanche - "La pêche !"
PC acheté chez Novatux : entièrement satisfait.
Faire des recherches solidaires !

Hors ligne

#3 Le 31/08/2007, à 00:52

l e . n o x

Re : pygtk - glade - debutant - recuperer texte dans textbox entryx -

Oupsss ! roll
pour un debutant quoi de plus ressemblent que du code, par rapport a du code ... big_smile

bon voila le pourquoi de mon erreur GTK != PyGTK (ben oui cela ne s'ecrit meme pas pareil lol  )

Je me suis basé sur des tutos et manuels en GTK vu que des tutos pour PyGtK ne courraient pas les NRA ...

Si cela peu aider quelqu'un : donc pour du PyGtk ne pas aller !
ici http://www.gtk.org/tutorial/x941.html ou encore ici http://www.gtk.org/tutorial1.2/gtk_tut-31.html#ss31.3

ben oui comme le dit  "trucutu" et a juste tire

Euh, gtk_entry_get_text, c'est du C sedmp....

Donc on bazard tous les marques pages et tuto recolté cet apres midi.
ceci a l'air plus correct : http://www.pygtk.org/pygtk2tutorial/sec-TextEntries.html
je retente l'aventure et je reviendrais poster le résultat...

Merci a toi trucutu" pour ces quelques remarques tongue

Heureusement que j'avais mis Debutant dans mon titre big_smile

Dernière modification par l e . n o x (Le 31/08/2007, à 00:57)


Zik Fan : " Vous seul savez mieux que quiconque comment organiser votre bibliothèque musicale ! "

Linux, y a moins bien.
Mais c'est plus cher. ;O)

Hors ligne

#4 Le 31/08/2007, à 07:55

trucutu

Re : pygtk - glade - debutant - recuperer texte dans textbox entryx -

En fait, tu verras que les deux tutos ont grosso modo, le même plan, les même exemples. Mais bien sûr, le contenu est différent... big_smile


La chanson du dimanche - "La pêche !"
PC acheté chez Novatux : entièrement satisfait.
Faire des recherches solidaires !

Hors ligne

#5 Le 31/08/2007, à 13:32

l e . n o x

Re : pygtk - glade - debutant - recuperer texte dans textbox entryx -

Salut wink

Bon voici les quelques pistes que j ai suivit:
Pyrhon ( "Apprendre à programmer avec Python"): http://www.cifen.ulg.ac.be/inforef/swi/python.htm

Tutorial Pygtk + glade :
http://daniel.coquette.free.fr/dotclear/index.php/post/2006/12/11/Creer-des-interfaces-graphique-avec-PyGTK-et-Glade

info sur PyGtk: http://www.pygtk.org/pygtk2tutorial/sec-TextEntries.html

voici les infos que j'ai essayé de dechiffrer, grace a trucutru wink :

[edit] ...mais ton entry1, pour être visible de la fonction où tu as mis le get_text, il faudra sûrement qu'il soit déclaré en tant qu'attribut de la classe GtkWindow (sûrement récupéré à partir du wTree...), donc self.entry1

En clair si j'ai bien compris je dois :
1) declarer comme attribu "get_text" dans la classe GtkWindow.
2)Recuperer "get_text" via  "self.wTree.signal_autoconnect(dic)"

Bon, alors premièrement merci a "trucutu" pour ces lumieres,donc voici se que j'ai fait :

#!/usr/bin/env python
import sys
try:
        import pygtk
        pygtk.require("2.0")
except:
        pass
try:
        import gtk
        import gtk.glade
except:
        sys.exit(1)
#========================= 
class GtkWindow:
        """This is an scpGui GTK application"""

        def __init__(self):
               
                #Set the Glade file
                self.gladefile = "scpgui.glade" 
                self.wTree = gtk.glade.XML(self.gladefile)


		
		#Create our dictionay and connect it

		dic = { 
		"on_bp_ok_clicked" : self.ok_clicked,
        	"on_MainWindow_destroy" : gtk.main_quit,
		"on_entry1_activate": self.entry1,
		
		 }

		self.wTree.signal_autoconnect(dic)

	def entry1(self, widget):		
		text = entry1.get_text()

	def ok_clicked(self, widget):
		text = entry1.get_text()
		print text
#=================================
if __name__ == "__main__":
        hwg = GtkWindow()
        gtk.main()

Mais le resultat est le suivant :

Traceback (most recent call last):
  File "scpgui.py", line 40, in ok_clicked
    text = entry1.get_text()
NameError: global name 'entry1' is not defined

Je serais preneur de quelques pistes et tuto (pygtk Glade) avec des exemples,si possible.
Si je peut abuser et si cela ne vous prend pas trop de temp pouriez vous corriger le script du dessu pour que je vois ou etait l'erreur.

Merci pour votre aide ;o)

Dernière modification par l e . n o x (Le 31/08/2007, à 14:50)


Zik Fan : " Vous seul savez mieux que quiconque comment organiser votre bibliothèque musicale ! "

Linux, y a moins bien.
Mais c'est plus cher. ;O)

Hors ligne

#6 Le 31/08/2007, à 13:56

trucutu

Re : pygtk - glade - debutant - recuperer texte dans textbox entryx -

A ce que j'en ai compris de ton tuto Glade, j'écrirais plutôt :

 
...        
        self.entry1 = self.wTree.get_widget("entry1")  # definition de entry1 comme attribut
        dic = { 
        "on_bp_ok_clicked" : self.ok_clicked,
        "on_MainWindow_destroy" : gtk.main_quit
         }
...

    def ok_clicked(self, widget):
        text = self.entry1.get_text() # Recupere le texte de l'attribut entry1
        print text

[edit] Au fait, tu n'est pas obligé de déclarer gladefile et wTree comme des attribut, si tu t'en sert seulement dans le constructeur (il ya une limitation sur le nombre de méthodes et d'attributs d'une classe, avec PyLint, mais bon...)

Dernière modification par trucutu (Le 31/08/2007, à 14:08)


La chanson du dimanche - "La pêche !"
PC acheté chez Novatux : entièrement satisfait.
Faire des recherches solidaires !

Hors ligne

#7 Le 31/08/2007, à 14:47

l e . n o x

Re : pygtk - glade - debutant - recuperer texte dans textbox entryx -

super,

tu es un chef tucutru big_smile
Maintenant je vais voir comment je n ai pas put trouver cela tout seul avec les tutos et exemples.

self.entry1 = self.wTree.get_widget("entry1")  # definition de entry1 comme attribut
.......
text = self.entry1.get_text() # Recupere le texte de l'attribut entry1

voici le script

#!/usr/bin/env python
import sys
try:
        import pygtk
        pygtk.require("2.0")
except:
        pass
try:
        import gtk
        import gtk.glade
except:
        sys.exit(1)
#========================= 
class GtkWindow:
        """This is an scpGui GTK application"""

        def __init__(self):
               
                #Set the Glade file
                self.gladefile = "scpgui.glade" 
                self.wTree = gtk.glade.XML(self.gladefile)
		self.entry1 = self.wTree.get_widget("entry1")  # definition de entry1 comme attribut
		
		#Create our dictionay and connect it

		dic = { 
		"on_bp_ok_clicked" : self.ok_clicked,
        	"on_MainWindow_destroy" : gtk.main_quit,
		 }

		self.wTree.signal_autoconnect(dic)

	def ok_clicked(self, widget):
		text = self.entry1.get_text() # Recupere le texte de l'attribut entry1
		print text
#=================================
if __name__ == "__main__":
        hwg = GtkWindow()
        gtk.main()

Zik Fan : " Vous seul savez mieux que quiconque comment organiser votre bibliothèque musicale ! "

Linux, y a moins bien.
Mais c'est plus cher. ;O)

Hors ligne

#8 Le 07/03/2008, à 00:21

l e . n o x

Re : pygtk - glade - debutant - recuperer texte dans textbox entryx -

Bon voici, mon Ptit Scripte avec beacoups de choses qui ne doivent pas servir a grand chose mais cela fonctionne roll

Suite aux différentes remarques sur la vitesse des serveurs SAMBA, je favorise dans mon réseau local la copie de fichier par "scp" donc : http://forum.ubuntu-fr.org/viewtopic.php?pid=1061438#p1061438

scpguizj8.th.jpg
Code Python : scpgui2.py

#!/usr/bin/env python

import sys,os,subprocess,commands
import gobject
try:
        import pygtk
        pygtk.require("2.0")
except:
        pass
try:
        import gtk
        import gtk.glade
except:
        sys.exit(1)


#===================================variables Global pour le projet 
os.system("clear")

user="login"
ip="192.168.1.2"
file_1="."
file_2="/home/login/"
file_3=" "
#cmdoutput = "wget -nv -E -H -k -nd -p -U 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT5.0; T312461; PC SRP 2.0; .NET CLR 1.1.4322)' "+url
#output = commands.getstatusoutput(cmdoutput)

#========================= je declare la class GtkWindow
class GtkWindow:



        """This is an scpGui GTK application"""

        def __init__(self):
               
                #Set the Glade file
                self.gladefile = "scpgui2.glade" 
                self.wTree = gtk.glade.XML(self.gladefile)

	#=================================Ici je declare les attributs recupere de l'interface Graphique 

		self.entry1 = self.wTree.get_widget("entry1")  # definition de entry1 comme attribut
		self.entry2 = self.wTree.get_widget("entry2")  # definition de entry2 comme attribut
		self.entry3 = self.wTree.get_widget("entry3")  # definition de entry3 comme attribut
		self.entry_ip = self.wTree.get_widget("entry4")  # definition de entry3 comme attribut
		self.entry_user = self.wTree.get_widget("entry5")  # definition de entry3 comme attribut

		self.cmd_txt = self.wTree.get_widget("textview1")  # definition de textview1 comme attribut

		self.file1 = self.wTree.get_widget("filechooserbutton1") # definition de file1 comme attribut
		self.file2 = self.wTree.get_widget("filechooserbutton2") # definition de file2 comme attribut
		self.file3 = self.wTree.get_widget("filechooserbutton3") # definition de file3 comme attribut
		self.fold1 = self.wTree.get_widget("filechooserbutton4") # definition de file1 comme attribut
		self.fold2 = self.wTree.get_widget("filechooserbutton5") # definition de file2 comme attribut
		self.fold3 = self.wTree.get_widget("filechooserbutton6") # definition de file3 comme attribut

		self.cbox_ip = self.wTree.get_widget("comboboxentry-entry1") # definition de cbox_ip comme attribut
		self.cbox_user = self.wTree.get_widget("comboboxentry-entry2") # definition de cbox_user comme attribut

	#=============Create our dictionay and connect it=================================
		dic = { 
		"on_bp_ok_clicked" : self.ok_clicked,
        	"on_MainWindow_destroy" : gtk.main_quit,
		"on_comboboxentry1_changed" : self.cbox_ip_clicked,
		"on_comboboxentry2_changed" : self.cbox_user_clicked,
		"on_filechooserbutton1_selection_changed" : self.explo1_clicked,
		"on_filechooserbutton2_selection_changed" : self.explo2_clicked,
		"on_filechooserbutton3_selection_changed" : self.explo3_clicked,
		"on_filechooserbutton4_selection_changed" : self.fold1_clicked,
		"on_filechooserbutton5_selection_changed" : self.fold2_clicked,
		"on_filechooserbutton6_selection_changed" : self.fold3_clicked,
		 }

		self.wTree.signal_autoconnect(dic)



	#================Ici les interactions sur l'interface ===========================

	def ok_clicked(self, widget):
		file_1 = self.entry1.get_text()
		file_2 = self.entry2.get_text()
		file_3 = self.entry3.get_text()
		csp_r = 'scp -r '
		arob='@'
		depoint=':'
		espace=''
		bash_csp=csp_r+file_1+" "+user+arob+ip+depoint+file_2+" "+file_3
		print bash_csp
		

#============= Cmd txt ==============
		#output = commands.getoutput(bash_csp)
		output = bash_csp		
		self.cmd_txt.get_buffer().set_text(output)
		os.system(bash_csp)

		print ".............."		
		print "..............(o; Transfert Termine ;o)..........."
		#self.cmd_txt(table=None)
		#self.cmd_txt.get_text(output)
		#self.entry2.set_text(output)
		#textbuffer.set_text(output)
#====================================

	def explo1_clicked(self, widget):
		global file_1	
		file_1 = self.file1.get_filename() # Recupere le texte de l'attribut filechooserbutton1
		if file_1==None:
			file_1= "/home/login/"
		self.entry1.set_text(file_1) # applique text dans entry1 de l'interface

	def explo2_clicked(self, widget):
		global file_2
		file_2 = self.file2.get_filename() # Recupere le texte de l'attribut filechooserbutton2
		if file_2==None:
			file_2= "/home/login/"
		self.entry2.set_text(file_2) # applique text dans entry2 de l'interface

	def explo3_clicked(self, widget):
		global file_3 
		file_3 = self.file3.get_filename() # Recupere le texte de l'attribut filechooserbutton3
		if file_3==None:
			file_3= "/home/login/"
		self.entry3.set_text(file_3) # applique text dans entry3 de l'interface


	def fold1_clicked(self, widget):
		global fold_1	
		fold_1 = self.fold1.get_filename() # Recupere le texte de l'attribut filechooserbutton1
		if fold_1==None:
			fold_1= "/home/login/"
		self.entry1.set_text(fold_1) # applique text dans entry1 de l'interface
		print fold_1

	def fold2_clicked(self, widget):
		global fold_2	
		fold_2 = self.fold2.get_filename() # Recupere le texte de l'attribut filechooserbutton1
		if fold_2==None:
			fold_2= "/home/login/"
		self.entry2.set_text(fold_2) # applique text dans entry1 de l'interface

	def fold3_clicked(self, widget):
		global fold_3	
		fold_3 = self.fold3.get_filename() # Recupere le texte de l'attribut filechooserbutton1
		if fold_3==None:
			fold_3= "/home/login/"
		self.entry3.set_text(fold_3) # applique text dans entry1 de l'interface

	def cbox_ip_clicked(self, widget):
		#ip==============
		global ip 
		ip = self.cbox_ip.get_text() # Recupere le texte de l'attribut comboboxEntry2	
		print "variable ip", ip
		#self.entry_ip.set_text(ip) # applique text dans entry_ip de l'interface

	def cbox_user_clicked(self, widget):
		#user=============
		global user 
		user = self.cbox_user.get_text() # Recupere le texte de l'attribut comboboxEntry1
		print "variable user",user
		#self.entry_user.set_text(user) # applique text dans entry_user de l'interface

	
#=================================
if __name__ == "__main__":
        hwg = GtkWindow()
        gtk.main()

Code Glade :
scpgui2.glade (garder le nom du fichier Glade pour que la GUI demarre)

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.4.0 on Sat Nov  3 20:31:48 2007 -->
<glade-interface>
  <widget class="GtkWindow" id="MainWindow">
    <property name="width_request">0</property>
    <property name="visible">True</property>
    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
    <property name="default_width">103</property>
    <signal name="destroy" handler="on_MainWindow_destroy"/>
    <child>
      <widget class="GtkVBox" id="vbox1">
        <property name="visible">True</property>
        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
        <child>
          <widget class="GtkLabel" id="label1">
            <property name="visible">True</property>
            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
            <property name="label" translatable="yes">************** SSH -scp- copy / coller ***************** </property>
          </widget>
        </child>
        <child>
          <widget class="GtkHBox" id="hbox1">
            <property name="visible">True</property>
            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
            <child>
              <widget class="GtkVBox" id="vbox3">
                <property name="width_request">1</property>
                <property name="visible">True</property>
                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                <child>
                  <widget class="GtkLabel" id="label2">
                    <property name="visible">True</property>
                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                    <property name="label" translatable="yes">[ Fichiers ]</property>
                  </widget>
                </child>
                <child>
                  <widget class="GtkFileChooserButton" id="filechooserbutton1">
                    <property name="visible">True</property>
                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                    <property name="do_overwrite_confirmation">True</property>
                    <signal name="selection_changed" handler="on_filechooserbutton1_selection_changed"/>
                  </widget>
                  <packing>
                    <property name="position">1</property>
                  </packing>
                </child>
                <child>
                  <placeholder/>
                </child>
                <child>
                  <widget class="GtkFileChooserButton" id="filechooserbutton2">
                    <property name="visible">True</property>
                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                    <signal name="selection_changed" handler="on_filechooserbutton2_selection_changed"/>
                  </widget>
                  <packing>
                    <property name="position">3</property>
                  </packing>
                </child>
                <child>
                  <placeholder/>
                </child>
                <child>
                  <widget class="GtkFileChooserButton" id="filechooserbutton3">
                    <property name="visible">True</property>
                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                    <signal name="selection_changed" handler="on_filechooserbutton3_selection_changed"/>
                  </widget>
                  <packing>
                    <property name="position">5</property>
                  </packing>
                </child>
              </widget>
            </child>
            <child>
              <widget class="GtkVBox" id="vbox5">
                <property name="width_request">1</property>
                <property name="visible">True</property>
                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                <child>
                  <widget class="GtkLabel" id="label4">
                    <property name="visible">True</property>
                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                    <property name="label" translatable="yes">[ Dossiers ]</property>
                  </widget>
                </child>
                <child>
                  <widget class="GtkFileChooserButton" id="filechooserbutton4">
                    <property name="visible">True</property>
                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                    <property name="action">GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER</property>
                    <signal name="selection_changed" handler="on_filechooserbutton4_selection_changed"/>
                  </widget>
                  <packing>
                    <property name="position">1</property>
                  </packing>
                </child>
                <child>
                  <placeholder/>
                </child>
                <child>
                  <widget class="GtkFileChooserButton" id="filechooserbutton5">
                    <property name="visible">True</property>
                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                    <property name="action">GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER</property>
                    <signal name="selection_changed" handler="on_filechooserbutton5_selection_changed"/>
                  </widget>
                  <packing>
                    <property name="position">3</property>
                  </packing>
                </child>
                <child>
                  <placeholder/>
                </child>
                <child>
                  <widget class="GtkFileChooserButton" id="filechooserbutton6">
                    <property name="visible">True</property>
                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                    <property name="action">GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER</property>
                    <signal name="selection_changed" handler="on_filechooserbutton6_selection_changed"/>
                  </widget>
                  <packing>
                    <property name="position">5</property>
                  </packing>
                </child>
              </widget>
              <packing>
                <property name="position">1</property>
              </packing>
            </child>
            <child>
              <widget class="GtkVBox" id="vbox2">
                <property name="visible">True</property>
                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                <child>
                  <widget class="GtkLabel" id="label5">
                    <property name="visible">True</property>
                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                    <property name="label" translatable="yes">Local :</property>
                  </widget>
                </child>
                <child>
                  <widget class="GtkEntry" id="entry1">
                    <property name="visible">True</property>
                    <property name="can_focus">True</property>
                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                  </widget>
                  <packing>
                    <property name="position">1</property>
                  </packing>
                </child>
                <child>
                  <widget class="GtkLabel" id="label6">
                    <property name="visible">True</property>
                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                    <property name="label" translatable="yes">Distant Cible :</property>
                  </widget>
                  <packing>
                    <property name="position">2</property>
                  </packing>
                </child>
                <child>
                  <widget class="GtkEntry" id="entry2">
                    <property name="visible">True</property>
                    <property name="can_focus">True</property>
                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                  </widget>
                  <packing>
                    <property name="position">3</property>
                  </packing>
                </child>
                <child>
                  <widget class="GtkLabel" id="label7">
                    <property name="visible">True</property>
                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                    <property name="label" translatable="yes">Local Cible : </property>
                  </widget>
                  <packing>
                    <property name="position">4</property>
                  </packing>
                </child>
                <child>
                  <widget class="GtkEntry" id="entry3">
                    <property name="visible">True</property>
                    <property name="can_focus">True</property>
                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                  </widget>
                  <packing>
                    <property name="position">5</property>
                  </packing>
                </child>
              </widget>
              <packing>
                <property name="position">2</property>
              </packing>
            </child>
          </widget>
          <packing>
            <property name="position">1</property>
          </packing>
        </child>
        <child>
          <widget class="GtkVBox" id="vbox4">
            <property name="visible">True</property>
            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
            <child>
              <widget class="GtkHBox" id="hbox3">
                <property name="visible">True</property>
                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                <child>
                  <widget class="GtkLabel" id="ip">
                    <property name="visible">True</property>
                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                    <property name="label" translatable="yes">[ IP ]</property>
                  </widget>
                </child>
                <child>
                  <widget class="GtkLabel" id="label3">
                    <property name="visible">True</property>
                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                    <property name="label" translatable="yes">[ Utilisateurs ]</property>
                  </widget>
                  <packing>
                    <property name="position">1</property>
                  </packing>
                </child>
              </widget>
            </child>
            <child>
              <widget class="GtkHBox" id="ip_utilistauer">
                <property name="visible">True</property>
                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                <child>
                  <widget class="GtkComboBoxEntry" id="comboboxentry1">
                    <property name="visible">True</property>
                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                    <property name="items" translatable="yes">192.168.1.1
192.168.1.2
192.168.1.3
192.168.1.20
192.168.1.30</property>
                    <signal name="changed" handler="on_comboboxentry1_changed"/>
                    <child internal-child="entry">
                      <widget class="GtkEntry" id="comboboxentry-entry1">
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                      </widget>
                    </child>
                  </widget>
                </child>
                <child>
                  <widget class="GtkComboBoxEntry" id="comboboxentry2">
                    <property name="visible">True</property>
                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                    <property name="items" translatable="yes">login
user
guest
</property>
                    <signal name="changed" handler="on_comboboxentry2_changed"/>
                    <child internal-child="entry">
                      <widget class="GtkEntry" id="comboboxentry-entry2">
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                      </widget>
                    </child>
                  </widget>
                  <packing>
                    <property name="position">1</property>
                  </packing>
                </child>
              </widget>
              <packing>
                <property name="position">1</property>
              </packing>
            </child>
            <child>
              <widget class="GtkProgressBar" id="progressbar1">
                <property name="visible">True</property>
                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                <property name="text" translatable="yes">----------------------------------------------------------------------------------------</property>
              </widget>
              <packing>
                <property name="position">2</property>
              </packing>
            </child>
          </widget>
          <packing>
            <property name="position">2</property>
          </packing>
        </child>
        <child>
          <widget class="GtkTextView" id="textview1">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
            <property name="resize_mode">GTK_RESIZE_IMMEDIATE</property>
          </widget>
          <packing>
            <property name="position">3</property>
          </packing>
        </child>
        <child>
          <widget class="GtkHBox" id="hbox4">
            <property name="visible">True</property>
            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
            <child>
              <widget class="GtkButton" id="button1">
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="receives_default">True</property>
                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                <property name="label" translatable="yes">Annuler</property>
                <property name="response_id">0</property>
                <signal name="destroy" handler="on_button1_destroy"/>
              </widget>
            </child>
            <child>
              <placeholder/>
            </child>
            <child>
              <placeholder/>
            </child>
            <child>
              <widget class="GtkButton" id="bp_ok">
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="receives_default">True</property>
                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                <property name="label" translatable="yes">OK</property>
                <property name="response_id">0</property>
                <signal name="clicked" handler="on_bp_ok_clicked" object="bpok"/>
              </widget>
              <packing>
                <property name="position">3</property>
              </packing>
            </child>
          </widget>
          <packing>
            <property name="position">4</property>
          </packing>
        </child>
      </widget>
    </child>
  </widget>
</glade-interface>

Dernière modification par l e . n o x (Le 07/03/2008, à 00:27)


Zik Fan : " Vous seul savez mieux que quiconque comment organiser votre bibliothèque musicale ! "

Linux, y a moins bien.
Mais c'est plus cher. ;O)

Hors ligne

#9 Le 02/07/2008, à 20:34

Defcom

Re : pygtk - glade - debutant - recuperer texte dans textbox entryx -

Bonsoir,


j'ai voulu tester le code ci dessus mais il me retourne une erreur qui est la suivante:


        self.entry1 = self.wTree.get_widget("entry1")  # definition de entry1 comme attribut
        NameError: name 'self' is not defined

quelque pourrait m'indiquer d'ou viens le probleme


merci

Hors ligne

#10 Le 03/07/2008, à 01:41

l e . n o x

Re : pygtk - glade - debutant - recuperer texte dans textbox entryx -

Bonsoir Defcom, smile

Comme tu as pu le voir dans les posts précédents ceci était mes premiers pas avec PyGTK, et mes tres tres limitées connaissances n'ont que légerement evoluées.

Je viens de retester sur ma machine le code ci-dessus et tout fonctionne.

1) Assures toi d'avoir les 2 fichiers (scpgui2.glade et scpgui2.py) dans le meme dossier.
Ouvre une console dans ce meme dossier, puis lance :

python scpgui2.py

2) Assure toi aussi de bien avoir tout copié du code "scpgui2.py"

Remarque : cette petite interface n'est pas réellement terminée.'excercice pour un debutant comme moi tongue .

Je ne suis pas arrivé a faire évoluer la barre de progression ainsi que de rapatrier les infos que l'on lit en mode texte dans la console.

Bon courrage pour la suite, et bon apprentissage @ toi. wink

Dernière modification par l e . n o x (Le 03/07/2008, à 01:43)


Zik Fan : " Vous seul savez mieux que quiconque comment organiser votre bibliothèque musicale ! "

Linux, y a moins bien.
Mais c'est plus cher. ;O)

Hors ligne

#11 Le 03/07/2008, à 18:07

Defcom

Re : pygtk - glade - debutant - recuperer texte dans textbox entryx -

bonjour,

j'ai suivi t'es recommandation mais j'ai toujours le même problème même avec ton premier programme.

Traceback (most recent call last):
  File "scpgui.py", line 14, in <module>
    class GtkWindow:
  File "scpgui.py", line 27, in GtkWindow
    "on_bp_ok_clicked" : self.ok_clicked,
NameError: name 'self' is not defined

Dernière modification par Defcom (Le 03/07/2008, à 18:09)

Hors ligne

#12 Le 04/07/2008, à 12:33

Defcom

Re : pygtk - glade - debutant - recuperer texte dans textbox entryx -

Bonjour

j'ai trouver pourquoi j'avais des erreurs
ces à cause de la mise en page.

maintenant cela fonctionne nikel.



merci

Hors ligne

#13 Le 04/07/2008, à 13:30

l e . n o x

Re : pygtk - glade - debutant - recuperer texte dans textbox entryx -

Bonjour Defcom,

C'est cool que cela fonctionne tongue

Dans quel but voulais tu faire fonctionner tout ceci ?
SI c'est dans le but d'apprendre, fait attention les commentaires dans le code n'est pas forcement cohérent (fainéantise de ma part roll ).

Si tu sais comment faire evoluer la barre de progression de l'interface je suis preneur wink

Bonne journée


Zik Fan : " Vous seul savez mieux que quiconque comment organiser votre bibliothèque musicale ! "

Linux, y a moins bien.
Mais c'est plus cher. ;O)

Hors ligne

#14 Le 04/07/2008, à 18:25

Defcom

Re : pygtk - glade - debutant - recuperer texte dans textbox entryx -

bonjour,


pour le moment j'apprends je début avec glade et python, et je trouve ton programme bien commenté ce qui être tres important pour comprendre.
Si je trouve quelque chose sur la barre de progression je te ferait signe.

Hors ligne

#15 Le 07/07/2008, à 17:56

Defcom

Re : pygtk - glade - debutant - recuperer texte dans textbox entryx -

bonjour,

comment fait on pour récupérer l'état d'une case à cocher et pour récupérer la valeur d'un bouton de sélection numérique.


merci

Hors ligne

#16 Le 08/07/2008, à 11:32

Defcom

Re : pygtk - glade - debutant - recuperer texte dans textbox entryx -

bonjour,


j'ai trouver en se qui concerne les bouton de sélection numérique.
il me reste à trouver pour les case à cocher.

Hors ligne