Great Lucrezia,
Thanks a lot, I will have a look at your script in the two coming weeks
and come back to you.
All the best,
Pascal
> Le 8 sept. 2025 à 16:29, Lucrezia Catapano <[email protected]> a
> écrit :
>
> Dear Pascal,
>
> I had a look at your script. I already have created a plugin for coot 1.1
> that changes representations, using the python GTK.
> You can use it as a reference to change the part of your code that uses menus.
> Attached the script.
>
> Let me know if you have any questions.
>
########################################################################
To unsubscribe from the COOT list, click the following link:
https://www.jiscmail.ac.uk/cgi-bin/WA-JISC.exe?SUBED1=COOT&A=1
This message was issued to members of www.jiscmail.ac.uk/COOT, a mailing list
hosted by www.jiscmail.ac.uk, terms & conditions are available at
https://www.jiscmail.ac.uk/policyandsecurity/
import coot
import gi
gi.require_version('Gtk', '4.0')
from gi.repository import Gtk
from gi.repository import Gio
from gi.repository import GLib
import coot_gui_api
from typing import Callable, Any
def attach_module_menu_button(module_name: str) -> Gio.Menu:
menu = Gio.Menu.new()
popover = Gtk.PopoverMenu()
popover.set_menu_model(menu)
module_menu_button = Gtk.MenuButton(label=module_name)
module_menu_button.set_popover(popover)
coot_gui_api.main_toolbar().append(module_menu_button)
return menu
def add_simple_action_to_menu(menu: Gio.Menu, displayed_name: str, action_name: str, on_activate_callback: Callable[[Gio.SimpleAction,Any],Any]):
"""Creates and adds a stateless Gio.SimpleAction globally to the app and appends a corresponding menu item to the menu"""
app = coot_gui_api.application()
action = Gio.SimpleAction.new(action_name, None)
action.connect("activate", on_activate_callback)
app.add_action(action)
menu.append(displayed_name,f"app.{action_name}")
menu = attach_module_menu_button('Model repr')
main_menumodel = coot_gui_api.main_menumodel()
menu_label = "Model Representation"
menu.append("Do Something", "app.something")
def add_action(displayed_name,action_name,on_activate_callback):
add_simple_action_to_menu(menu, displayed_name, action_name, on_activate_callback)
# Or you would do app.something if you had attached the
def model_representation(mode: str):
active_atom = coot.active_residue_py()
imol = active_atom[0]
if mode == 'line':
coot.graphics_to_bonds_representation(imol)
coot.set_model_molecule_representation_style(imol, 0)
coot.set_bond_thickness(imol,1)
coot.close_all_generic_objects()
if mode == 'stick':
coot.graphics_to_bonds_representation(imol)
coot.set_model_molecule_representation_style(imol, 0)
coot.set_atom_radius_scale_factor(imol, 1)
coot.set_bond_thickness(imol,5)
coot.close_all_generic_objects()
if mode == 'ball and stick':
coot.graphics_to_bonds_representation(imol)
coot.set_model_molecule_representation_style(imol, 0)
coot.set_atom_radius_scale_factor(imol, 2.0)
coot.set_bond_smoothness_factor(3)
coot.set_bond_thickness(imol,4)
coot.close_all_generic_objects()
if mode == 'sphere':
coot.set_model_molecule_representation_style(imol, 1)
coot.set_bond_smoothness_factor(3)
coot.close_all_generic_objects()
if mode == 'ribbon':
coot.add_molecular_representation_py(imol,"//*", "RampChainsScheme", "Ribbon")
coot.graphics_to_ca_representation(imol)
coot.set_bond_thickness(imol,0)
coot.close_all_generic_objects()
if mode == 'ribbon by sec. struct.':
coot.add_molecular_representation_py(imol,"//*", "colorBySecondaryScheme", "Ribbon")
coot.graphics_to_ca_representation(imol)
coot.set_bond_thickness(imol,0)
coot.close_all_generic_objects()
if mode == 'gaussian surface':
coot.gaussian_surface(imol)
def model_representation_lines(mode: str, arg2):
model_representation('lines')
def model_representation_ball_and_stick(mode: str, arg2):
model_representation('ball and stick')
def model_representation_sphere(mode: str, arg2):
model_representation('sphere')
def model_representation_ribbon(mode: str, arg2):
model_representation('ribbon')
def model_representation_ribbon_sec(mode: str, arg2):
model_representation('ribbon by sec. struct.')
def model_representation_gaussian(mode: str, arg2):
model_representation('gaussian surface')
add_action('lines', 'lines_mode', model_representation_lines)
add_action('ball and stick', 'ball_and_stick_mode', model_representation_ball_and_stick)
add_action('sphere', 'sphere_mode', model_representation_sphere)
add_action('ribbon', 'ribbon_mode', model_representation_ribbon)
add_action('ribbon by sec. struct.', 'ribbon_by_sec_mode', model_representation_ribbon_sec)
add_action('gaussian surface', 'gaussian_surface_mode', model_representation_gaussian)>
>
> Lucrezia
> Lucrezia Catapano, PhD (she/her)
> Postdoctoral Scientist
> Murshudov Group
> MRC Laboratory of Molecular Biology
> Francis Crick Avenue, Biomedical Campus, Cambridge CB2 0QH, UK.
>
>
>
>> On 3 Sep 2025, at 18:10, Auffinger Pascal
>> <[email protected]> wrote:
>>
>> CAUTION: This email originated from outside of the LMB:
>> [email protected].
>> Do not click links or open attachments unless you recognize the sender and
>> know the content is safe.
>> If you think this is a phishing email, please forward it to
>> [email protected]
>> --
>>
>> Dear All,
>>
>> We wrote a very lengthy script for Coot 0.9.8.96 that opens GTK windows.
>>
>> We would like to translate them so that they will work with 1.0
>> versions (Linux, Mac, Wincoot, ...).
>>
>> Where can I get help ?
>> Are there any translation tools/pages ?
>> Help pages for 1.0 ?
>>
>> Thanks,
>>
>> Pascal
>>
>> ########################################################################
>>
>> To unsubscribe from the COOT list, click the following link:
>> https://www.jiscmail.ac.uk/cgi-bin/WA-JISC.exe?SUBED1=COOT&A=1
>>
>> This message was issued to members of www.jiscmail.ac.uk/COOT, a mailing
>> list hosted by www.jiscmail.ac.uk, terms & conditions are available at
>> https://www.jiscmail.ac.uk/policyandsecurity/
>>
>>
>
########################################################################
To unsubscribe from the COOT list, click the following link:
https://www.jiscmail.ac.uk/cgi-bin/WA-JISC.exe?SUBED1=COOT&A=1
This message was issued to members of www.jiscmail.ac.uk/COOT, a mailing list
hosted by www.jiscmail.ac.uk, terms & conditions are available at
https://www.jiscmail.ac.uk/policyandsecurity/