def go_function(*args): save_toolbuttons_qm = save_button.get_active() #print "do something, maybe, save state", save_toolbuttons_qm # iterate thru the widgets and get the state of check button and icon combobox frames = frame_vbox.get_children() for frame in frames: inner_vbox = frame.get_children()[0] hboxes = inner_vbox.get_children() for hbox in hboxes: left_hbox, right_hbox = hbox.get_children() check_button, description = left_hbox.get_children() label, combobox = right_hbox.get_children() model = combobox.get_model() button_label = check_button.get_label() if (check_button.get_active()): # make new button iter = combobox.get_active_iter() icon = None if (iter): icon, icon_stock, icon_filename = model.get( iter, 0, 1, 2) #print "icon", icon, icon_stock, icon_filename if (icon_stock): icon = icon_stock toolbar_ls = list_of_toolbar_functions() for group in toolbar_ls: group_name = group[0] group_items = group[1:len(group)] for item in group_items: if (len(item) > 0): check_button_label = item[0] callback_function = item[1] description = item[2] if (check_button_label == button_label ): new_toolbutton = coot_toolbar_button( button_label, callback_function, icon) # save save_toolbar_to_init_file( button_label, callback_function, icon) break else: # remove an existing button? # check if the button is in the existing button list for toolbar in toolbar_label_list(): if (button_label == toolbar[0]): coot_python.main_toolbar().remove( toolbar[1]) # remove from save remove_toolbar_from_init_file(button_label) window.destroy() return False
def go_function(*args): save_toolbuttons_qm = save_button.get_active() # print "do something, maybe, save state", save_toolbuttons_qm # iterate thru the widgets and get the state of check button and icon combobox frames = frame_vbox.get_children() for frame in frames: inner_vbox = frame.get_children()[0] hboxes = inner_vbox.get_children() for hbox in hboxes: left_hbox, right_hbox = hbox.get_children() check_button, description = left_hbox.get_children() label, combobox = right_hbox.get_children() model = combobox.get_model() button_label = check_button.get_label() if check_button.get_active(): # make new button iter = combobox.get_active_iter() icon = None if iter: icon, icon_stock, icon_filename = model.get(iter, 0, 1, 2) # print "icon", icon, icon_stock, icon_filename if icon_stock: icon = icon_stock toolbar_ls = list_of_toolbar_functions() for group in toolbar_ls: group_name = group[0] group_items = group[1 : len(group)] for item in group_items: if len(item) > 0: check_button_label = item[0] callback_function = item[1] description = item[2] if check_button_label == button_label: new_toolbutton = coot_toolbar_button(button_label, callback_function, icon) # save save_toolbar_to_init_file(button_label, callback_function, icon) break else: # remove an existing button? # check if the button is in the existing button list for toolbar in toolbar_label_list(): if button_label == toolbar[0]: coot_python.main_toolbar().remove(toolbar[1]) # remove from save remove_toolbar_from_init_file(button_label) window.destroy() return False
def __init__(self, pdb_file, map_file, needs_rebuild=False): self.file_name = pdb_file self.needs_rebuild = needs_rebuild import gtk import coot import coot_python toolbar = coot_python.main_toolbar() assert (toolbar is not None) return_button = gtk.ToolButton() return_button.set_label("Return to PHENIX") return_button.set_is_important(True) toolbar.insert(return_button, -1) return_button.connect("clicked", self.OnReturn) return_button.show() maps_button = gtk.ToolButton() maps_button.set_label("Fetch new maps") maps_button.set_is_important(True) toolbar.insert(maps_button, -1) maps_button.connect("clicked", self.OnNewMaps) maps_button.show() self._imol = read_pdb(to_str(pdb_file)) set_molecule_bonds_colour_map_rotation(self._imol, 30) self._map_mols = [] self.load_maps(map_file) dialog = gtk.MessageDialog( None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, "You may now edit your model to prepare for further " + "building and refinement. When you are finished, " + "click the \"Save model and return\" button on the toolbar, then close " + "Coot. If you want to recalculate the map coefficients, click \"Fetch " + "new maps\".") dialog.run() dialog.destroy()
def __init__ (self, pdb_file, map_file, needs_rebuild=False) : self.file_name = pdb_file self.needs_rebuild = needs_rebuild import gtk import coot import coot_python toolbar = coot_python.main_toolbar() assert (toolbar is not None) return_button = gtk.ToolButton() return_button.set_label("Return to PHENIX") return_button.set_is_important(True) toolbar.insert(return_button, -1) return_button.connect("clicked", self.OnReturn) return_button.show() maps_button = gtk.ToolButton() maps_button.set_label("Fetch new maps") maps_button.set_is_important(True) toolbar.insert(maps_button, -1) maps_button.connect("clicked", self.OnNewMaps) maps_button.show() self._imol = read_pdb(pdb_file) set_molecule_bonds_colour_map_rotation(self._imol, 30) self._map_mols = [] self.load_maps(map_file) dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, "You may now edit your model to prepare for further "+ "building and refinement. When you are finished, "+ "click the \"Save model and return\" button on the toolbar, then close "+ "Coot. If you want to recalculate the map coefficients, click \"Fetch "+ "new maps\".") dialog.run() dialog.destroy()
def __init__(self): self.flag_enable_xmlrpc = True self.xmlrpc_server = None self._server_toggle_btn = None self._current_model = None toolbar = coot_python.main_toolbar() port = 40000 if ("COOT_XMLRPC_PORT" in os.environ): port = string.atoi(os.environ["COOT_XMLRPC_PORT"]) try: self.xmlrpc_server = coot_xmlrpc_server(interface=self, addr=("127.0.0.1", port)) self.xmlrpc_server.socket.settimeout(0.01) except Exception as e: print("Error starting XML-RPC server:") print(str(e)) else: import gobject import gtk print("xml-rpc server running on port %d" % port) # timeout used to be set to whatever the Phenix preferences have it as, # but 250ms seems to be a universally good choice, and much shorter # intervals screw up the Coot GUI (at least on Windows) gobject.timeout_add(250, self.timeout_func) if (toolbar is not None): self._server_toggle_btn = gtk.ToggleToolButton() self._server_toggle_btn.set_label("Connected to PHENIX") self._server_toggle_btn.set_is_important(True) toolbar.insert(self._server_toggle_btn, -1) self._server_toggle_btn.connect("clicked", self.toggle_update) self._server_toggle_btn.set_active(True) self._server_toggle_btn.show()
def __init__(self, separator=False): import coot # import dependency import coot_python import gtk toolbar = coot_python.main_toolbar() assert (toolbar is not None) if (separator): toolbar.insert(gtk.SeparatorToolItem(), -1) self.h_button = gtk.ToggleToolButton() self.h_button.set_label("Hydrogens off") self.h_button.set_is_important(True) toolbar.insert(self.h_button, -1) self.h_button.connect("clicked", self.OnToggleHydrogens) self.h_button.set_active(True) self.h_button.show()
def __init__ (self, separator=False) : import coot # import dependency import coot_python import gtk toolbar = coot_python.main_toolbar() assert (toolbar is not None) if (separator) : toolbar.insert(gtk.SeparatorToolItem(), -1) self.h_button = gtk.ToggleToolButton() self.h_button.set_label("Hydrogens off") self.h_button.set_is_important(True) toolbar.insert(self.h_button, -1) self.h_button.connect("clicked", self.OnToggleHydrogens) self.h_button.set_active(True) self.h_button.show()
def __init__(self): self.flag_enable_xmlrpc = True self.xmlrpc_server = None self._server_toggle_btn = None self._current_model = None toolbar = coot_python.main_toolbar() port = 40000 if ("COOT_XMLRPC_PORT" in os.environ): port = string.atoi(os.environ["COOT_XMLRPC_PORT"]) try: self.xmlrpc_server = coot_xmlrpc_server(interface=self, addr=("127.0.0.1", port)) self.xmlrpc_server.socket.settimeout(0.01) except Exception, e: print "Error starting XML-RPC server:" print str(e)
def __init__ (self) : self.flag_enable_xmlrpc = True self.xmlrpc_server = None self._server_toggle_btn = None self._current_model = None toolbar = coot_python.main_toolbar() port = 40000 if ("COOT_XMLRPC_PORT" in os.environ) : port = string.atoi(os.environ["COOT_XMLRPC_PORT"]) try : self.xmlrpc_server = coot_xmlrpc_server( interface=self, addr=("127.0.0.1", port)) self.xmlrpc_server.socket.settimeout(0.01) except Exception, e : print "Error starting XML-RPC server:" print str(e)
iconset = gtk.IconSet(pixbuf) iconfactory.add(stock_id, iconset) iconfactory.add_default() if have_coot_python: # an example function for the toolbutton (not sure if it should be here!) def stereo_mono_toggle(): display_state = stereo_mode_state() if display_state == 0: hardware_stereo_mode() else: mono_mode() if coot_python.main_toolbar(): register_coot_icons() def activate_menuitem(widget, item): try: apply(item[1]) except: print "BL INFO:: unable to execute function", item[1] # takes list with [["item_name", func],...] def create_show_pop_menu(item_n_funcn_list, event): menu = gtk.Menu() for item in item_n_funcn_list: item_name = item[0] # item_func = item[1]
iconset = gtk.IconSet(pixbuf) iconfactory.add(stock_id, iconset) iconfactory.add_default() if (have_coot_python): # an example function for the toolbutton (not sure if it should be here!) def stereo_mono_toggle(): display_state = stereo_mode_state() if (display_state == 0): hardware_stereo_mode() else: mono_mode() if coot_python.main_toolbar(): register_coot_icons() def activate_menuitem(widget, item): try: apply(item[1]) except: print "BL INFO:: unable to execute function", item[1] # takes list with [["item_name", func],...] def create_show_pop_menu(item_n_funcn_list, event): menu = gtk.Menu() for item in item_n_funcn_list: item_name = item[0] #item_func = item[1]