In the following code :

#!/usr/bin/python
# -*- coding: iso-8859-1 -*-

import Tkinter
import os
import threading


class Fil (threading.Thread):
   def __init__ (self):
      threading.Thread.__init__ (self)
      print "Init Fil"

   def f1 (self):
      print 'f1'
      #app().ecrit(1)

class App(Tkinter.Tk):
    def __init__(self,parent):
        Tkinter.Tk.__init__(self,parent)
	print "Init App"
	self.initialize()
	ping()

    def initialize(self):
	self.grid()
        self.bouton1L = Tkinter.Label(text="-", bg = "#00ffc0")
	self.bouton1L.grid(column=0, row=1)
        self.bouton2L = Tkinter.Label(text="-", bg = "#00ffc0")
	self.bouton2L.grid(column=1, row=1)
	self.x = Tkinter.Label(width=32)
	self.x.grid(column=0, row=2)

    def ecrit(self, num):
	if num == 1:
	   self.bouton1L.configure(text="0")
	elif num == 2:
	   self.bouton2L.configure(text="1")

def ping():
	for x in xrange ( 2 ):
   	   Fil().f1()
	   app.bouton1L.reconfigure(text="A") # app not recognized
                                              # ------------------

if __name__ == "__main__":
    app = App(None)
    app.ecrit(2)
    app.mainloop()

"app" is not recognized, for example in function "ping" in the above example. I am trying to write a program with several threads and a single window where results of threads are displayed.
Thanks for your help.

Please use code tags not color tags. I do not know what the program is supposed to do (for example you are calling class method at line 41 in ping, there is not reconfigure method) you must pass the object to function (it could event be method in App, I think):

# -*- coding: iso-8859-1 -*-

import Tkinter
import os
import threading


class Fil (threading.Thread):
   def __init__ (self):
      threading.Thread.__init__ (self)
      print "Init Fil"

   def f1 (self):
      print 'f1'
      #app().ecrit(1)

class App(Tkinter.Tk):
    def __init__(self,parent):
        Tkinter.Tk.__init__(self,parent)
        print "Init App"
        self.initialize()
        ping(self)

    def initialize(self):
        self.grid()
        self.bouton1L = Tkinter.Label(text="-", bg = "#00ffc0")
        self.bouton1L.grid(column=0, row=1)
        self.bouton2L = Tkinter.Label(text="-", bg = "#00ffc0")
        self.bouton2L.grid(column=1, row=1)
        self.x = Tkinter.Label(width=32)
        self.x.grid(column=0, row=2)

    def ecrit(self, num):
        if num == 1:
           self.bouton1L.configure(text="0")
        elif num == 2:
           self.bouton2L.configure(text="1")

def ping(app):
    for x in xrange(2):
       Fil().f1()
       app.bouton1L.configure(text="A")

if __name__ == "__main__":
    app = App(None)
    app.ecrit(2)
    app.mainloop()

Thanks a lot for your fast answer, and sorry for the misuse of colours. I am new on daniweb and do not master the tool...
This program does nothing interesting, it is just a more or less minimal expression of the problem I met.
Initially ping (line 39) was within a method when I got the problem.
Your solution does not work either : i get the following error message :

Init App
Init Fil
f1
Traceback (most recent call last):
File "testthr1.py", line 47, in <module>
app = App(None)
File "testthr1.py", line 23, in __init__
ping(self)
File "testthr1.py", line 43, in ping
app.bouton1L.reconfigure(text="A") # app not recognized
AttributeError: Label instance has no attribute 'reconfigure'

The "real" program I want to do is a multiping with results within the same window "app" : this is represented by line 15 that does not work for the same problem of "app" being not recognized. When I got this problem, I tried another way with the "ping" of line 39.
When coming back to the initial program, my real problem is the one of line 15 where I try to display something in the "app" window via the "ecrit" method.
Thanks a lot for your help and sorry for the complexity of my answer that refers to an "initial" problem and to the one I submitted. But in both cases, for me, there is a problem of having "app" being global.
Best regards

command is configure, not reconfigure. App is self inside it's definition.

Grate !
I am confused, such a beginner's error !
My only "proof" of some intelligence (with the french meaning of this word) is that the error message is more or less misleading.
Have a good night (if you are in Europe of course).
Best regards.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.