I want to pass 2 ComboBox instances to a a method and use them there (e.g., print their active selection). I have something similar to the following:
class GUI():
...
def gui(self):
...
combobox1 = gtk.combo_box_new_text()
# code for inserting some values into the combobox
combobox2 = gtk.combo_box_new_text()
# code for inserting some values into the combobox
btn_new = gtk.Button("new")
btn_new.connect("clicked", self.comboprint)
def comboprint(self):
# do something with the comboboxes - print what is selected, etc.
How can I pass combobox1 and combobox2 to the method “comboprint”, so that I can use them there? Is making them class fields (self.combobox1, self.combobox2) the only way to do this?
do something like this:
and in your callback
comboprintit should be something like this: