Re: [Csnd] Python help please
Date | 2011-08-26 17:43 |
From | "Art Hunkins" |
Subject | Re: [Csnd] Python help please |
Thanks both to Andres and Olivier.
Using both of your suggestions, I modified my
Python script segments to the following. However I'm missing something related
to "index" (do I need to declare it?), and get various error messages related to
the choose function. Can you see what I'm doing wrong?
self.paths = ["0"]*26
self.jobjects = [None]*26 def choose(self, index,
widget):
chooser = ObjectChooser(parent=self, what_filter=mime.GENERIC_TYPE_AUDIO) result = chooser.run() if result == gtk.RESPONSE_ACCEPT: self.jobject[index] = chooser.get_selected_object() self.paths[index] = str(self.jobjects[index].get_file_path()) else: self.jobject[index] = None self.path[index] = "0" def send_data(self):
for i in range(26): self.w.set_filechannel("file%d" % i, self.paths[i]) Choose is being called by one of 26 cbbuttons (from
csndsugui, which is what win. refers to), as in:
but6 =
win.cbbutton(self.b3box, self.choose(self, 1), " 1")
This may well be the source of my problem. Am I perhaps passing the index value 1 to the
choose function incorrectly? (I tried: self.choose(self, index=1),
"1"
which made no difference.
Thanks again for your help.
Art Hunkins
|
Date | 2011-08-26 20:46 |
From | Olivier Bélanger |
Subject | Re: [Csnd] Python help please |
I have not used gtk for a while but I'm sure this line doesn't work: but6 = win.cbbutton(self.b3box, self.choose(self, 1), " 1") You execute self.choose inside the definition of the widget, but what you want to do is to pass a callback reference to the widget, something like: but6 = win.cbbutton(self.b3box, self.choose, " 1") The signature of the callback function is defined inside win.cbutton, I don't think it's a good idea to try to modify it. Every buttons will call the same function with the widget in argument, so you have to grab the index from the widget... maybe the index inside the box self.b3box: def choose(self, widget): index = self.b3box.get_position(widget) # this is only the idea, I don't know if get_position is implemented in the class used to create self.b3box... Olivier 2011/8/26 Art Hunkins <abhunkin@uncg.edu>
|