带GTK盒的"For"循环
嗨,
我有不同数量的复选按钮和组合框想要添加到窗口中;然而,当我试图水平放置复选按钮和组合框,然后垂直地对它们逐个进行装箱时,我总是遇到内存故障。如有任何帮助,我们将不胜感激:
选择 | 换行 | 行号
- window = gtk.Window(gtk.WINDOW_TOPLEVEL)
- combobox = gtk.combo_box_new_text()
- box1_vbox = gtk.VBox(False, 2)
- list_vbox = gtk.VBox(True, 6)
- check_hbox = gtk.HBox(True, 6)
- buttons_hbox = gtk.HBox(True, 6)
- title = gtk.Label("Superimpose models")
- for imol in molecule_number_list():
- combobox_name = molecule_name(imol)
- combobox.append_text(combobox_name)
- combobox.connect('changed', sel_ref_mol)
- box1_vbox.pack_start(title, False, False)
- box1_vbox.pack_start(combobox, False, False)
- box1_vbox.pack_start(check_hbox, False, False)
- for imol in molecule_number_list():
- button_name = molecule_name(imol)
- button_imol = gtk.CheckButton(button_name)
- combobox_imol = gtk.combo_box_new_text()
- button_imol.connect("toggled", moving_mol, imol)
- combobox_imol.append_text(combobox_name)
- check_hbox_imol = gtk.HBox(True, 6)
- check_hbox_imol.pack_start(button_imol, False, False)
- check_hbox_imol.pack_start(combobox_imol, False, False)
- #for imol in molecule_number_list():
- box1_vbox.pack_start(check_hbox_imol, False, False)
- ok_button = gtk.Button(" Go! ")
- cancel_button = gtk.Button(" Cancel ")
- cancel_button.connect("clicked", delete_event)
- buttons_hbox.pack_start(ok_button, False, False)
- buttons_hbox.pack_start(cancel_button, False, False)
- box1_vbox.pack_start(buttons_hbox, False, False)
- window.add(box1_vbox)
- window.show_all()
谢谢!