[Tutor] (no subject)
Alan Gauld
alan.gauld at btinternet.com
Wed Apr 28 09:09:42 CEST 2010
"Marco Rompré" <marcodrompre at gmail.com> wrote
> Oups my posting was too big!!!
In general it is better to popst long listings (over 100 lines say)
to a web site such as pastebin. That will ensure they are readable
and will not fill up peoples mailboxes unnecessarily.
However, even better is to reproduce your error in a small sample
program so we do not have to read all of your code!
> Why is none of my items button works???? In this, I have two files and in
> my second file I imported all the function of the first one
I can't speak for all of them but the first one I looked at had an error,
very similar to that suggested by your error message.
> self.afficher_item_bouton = Button(
> self, text = "Modifier", fg = "blue", command =
> self.modifier_item
> )
> self.afficher_item_bouton.pack(side = LEFT)
> def afficher_item(self):
> items = self.liste.curselection()
> items = [self.app.modele.items[int(item)] for item in items]
> if (items != []):
> items = items[0]
> itemsFrame = ItemsFrame(self, item)
>
In this code the method assigns a value to items, then reassigns items to a
modified list.
If the list is not empty it reassigns items to the first element. It then
creates a new variable.
passing a variable item which does bot exist in the method so shouldbe defined
globally.
But your error message suggests it is not. I suspect the items[0] assignment
should be
to item? Or maybe to self.item?
> Here is my codes and my error code for the two files please help me:
> Traceback (most recent call last):
>
>
> File "F:\School\University\Session 4\Programmation
> SIO\magasingolfvues.py", line 426, in <module>
> app = App(racine, "magasinmodele.txt")
> File "F:\School\University\Session 4\Programmation
> SIO\magasingolfvues.py", line 23, in __init__
> ItemsFrame(contexte, item)
> NameError: global name 'item' is not defined
> >>>
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list