Mic wrote:

class SeatButton(tk.Button):
     def __init__(self, master, index):
         text = str(index+1)
         super(SeatButton, self).__init__(master,
                                          text=text, bg=FREE,
                                          command=self.clicked)
         self.filename = "Germany_France{}.txt".format(index+1)
         self.occupied = False
         if os.path.exists(self.filename):
              self["bg"]=OCCUPIED

In the above snippet button color and the occupied-flag can get out of sync.
If a seat is occupied the color is correcly updated to red bot the
self.occupied remains False.
A simple fix:

self.occupied = os.path.exists(self.filename)
if self.occupied:
   >self["bg"] = OCCUPIED


Thanks!

Say that I want to try and open 10 files. If none of these exists, I want an error
message to appear. But only if NONE of these files exists.

I know how to handle this with one file. But I don't know how to do that with more than one. So the program should try and open all 10 files and if, and only if, none of the files exists I want en error message to appear.


Thanks for your help guys!




_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to