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

  FORUM HardWare.fr
  Programmation
  Python

  debutant : pb d'héritage

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

debutant : pb d'héritage

n°1402722
lipaika
Posté le 07-07-2006 à 12:25:07  profilanswer
 


Bonjour, j'ai fait une classe qui me permet de faire une ListBox intégrée à 1 scrollbar verticale.
 
class maScrolllisteBox(Tk.Listbox):
    def __init__(self,master,h,w):
        yScroll = Tk.Scrollbar ( master, orient=Tk.VERTICAL )
        yScroll.grid ( row=0, column=1, sticky=Tk.N+Tk.S )
        self.liste=Tk.Listbox( master,yscrollcommand=yScroll.set )
        self.liste.grid( row=0, column=0, sticky=Tk.N+Tk.S )
        self.liste.configure(height=h,width=w)
        yScroll["command"] = self.liste.yview
 
    def insert(self,elem):
        self.liste.insert(Tk.END,elem)

 
j'aimerais pouvoir l'intégrer dans un canvas :  
 
def affiche_Champs(look,txt):
    look.listeChamps = maScrolllisteBox(look.can,20,35)
    load_listbox(look,txt,'champs')     #charge les valeurs dans la liste  
    look.can.create_window(380,230,window=look.listeChamps)
 
 
ERREUR :
    look.can.create_window(130,230,window=look.listeLiens)
  File "C:\Python24\lib\lib-tk\Tkinter.py", line 2104, in create_window
    return self._create('window', args, kw)
  File "C:\Python24\lib\lib-tk\Tkinter.py", line 2075, in _create
    return getint(self.tk.call(
  File "C:\Python24\lib\lib-tk\Tkinter.py", line 1153, in __str__
    return self._w
AttributeError: maScrolllisteBox instance has no attribute '_w'

 
j'ai rectifié en ajoutant :  
self._w=w
self._h=h
dans le __init__de maScrollListBox, et l'erreur ne s'affiche plus. Mais je ne suis pas sûre de la solution apportée.
De plus, une autre erreur s'affiche :  
 
ERREUR :
  File "C:\Documents and Settings\sgodon\Bureau\prog\appz.py", line 70, in affiche_Liens
    look.can.create_window(130,230,window=look.listeLiens)
  File "C:\Python24\lib\lib-tk\Tkinter.py", line 2104, in create_window
    return self._create('window', args, kw)
  File "C:\Python24\lib\lib-tk\Tkinter.py", line 2075, in _create
    return getint(self.tk.call(
TypeError: __str__ returned non-string (type int)

 
 
Ma question : quels paramètres dois-je définir dans mon constructeur pour que le canvas affiche mascrolllistBox?
Où puis-je le trouver dans la doc?
ou tout simplement : est-ce possible d'ajouter un element 'hybride' dans un canvas?

mood
Publicité
Posté le 07-07-2006 à 12:25:07  profilanswer
 


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Python

  debutant : pb d'héritage

 

Sujets relatifs
Grand débutant a besoin de petite aide mysql_resultsvp un peu d'aide pour un bougre debutant
Probleme sur petit programme de débutantDebutant: poster une variable
date et php : extraire le mois d'une date SQL (debutant)[shell] débutant : test sur la présence de fichiers
Petit programme de débutant[Debutant] Heritage et appel de fonction
[DEBUTANT] Problème héritage[C++][Débutant] Héritage et variables protected
Plus de sujets relatifs à : debutant : pb d'héritage


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