Re: [COOT] toolbox and color of symmetry related chains not working

2026-05-24 Thread Paul Emsley

On 24/05/2026 02:17, Georg Mlynek wrote:


Dear Paul, many thanks. It works now. However in my case the 
difference between the  reference and symmetry related chain is not 
strong.



You mean the colour thereof?


Changes in bot these lines have no effect

        coot.set_symmetry_colour(0.4, 0.4, 0.4)


Oh, yes - haha, not updated since olden graphics.

Noted.


        coot.set_default_bond_thickness(2)

This sets the bond width (thickness) for the next time you generate 
bonds - e.g. reading a pdb file.


The documentation could do with an overhaul.

coot.set_bond_thickness(imol, w)

is the one that you want.


Paul.









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/


Re: [COOT] toolbox and color of symmetry related chains not working

2026-05-23 Thread Georg Mlynek
Dear Paul, many thanks. It works now. However in my case the difference 
between the  reference and symmetry related chain is not strong.


Changes in bot these lines have no effect

        coot.set_symmetry_colour(0.4, 0.4, 0.4)
        coot.set_default_bond_thickness(2)

What can I do?

Many thanks for all your efforts, br Georg.



import gi
gi.require_version("Gtk", "4.0")
from gi.repository import Gtk
import coot
import coot_utils
import coot_gui_api

def toggle_quicksymm(button):
    """
    Toggle Quick Symmetry based on the button's active state for ALL 
open molecules.

    Displays ALL ATOMS instead of just C-alphas.
    """
    if button.get_active():
        # Global settings
        coot.set_show_symmetry_master(1)
        coot.set_show_unit_cells_all(0)
        coot.set_symmetry_colour(0.4, 0.4, 0.4)
        coot.set_symmetry_size(15)
        coot.set_default_bond_thickness(2)

        # Apply to all open molecules
        for imol in coot_utils.model_molecule_number_list():
            coot.set_symmetry_colour_by_symop(imol, 0)
            coot.set_symmetry_molecule_rotate_colour_map(imol, 0)
            coot.set_symmetry_whole_chain(imol, 0)
            # 0 = False (Show all atoms instead of just C-alphas)
            coot.symmetry_as_calphas(imol, 0)

        coot.add_status_bar_text("Quick Symmetry: ON (All Atoms)")
    else:
        coot.set_show_symmetry_master(0)
        coot.set_show_unit_cells_all(0)

        coot.add_status_bar_text("Quick Symmetry: OFF")

# Create a GTK4 ToggleButton natively
quicksymm_button = Gtk.ToggleButton(label="QuickSymm")
quicksymm_button.connect("toggled", toggle_quicksymm)
coot_gui_api.main_toolbar().append(quicksymm_button)

Am 24.05.2026 um 02:24 schrieb Paul Emsley:



On 23/05/2026 21:42, Georg Mlynek wrote:

I then asked Gemini 3.1 Pro (which has access to the Wincoot folder):

Can you figure out in the code which problem there is in the 
coot_gui.coot_toolbar_button function?
9:29 PM


Yes, I can! I looked into the source code for coot_gui.py and found exactly why 
it is failing.

The coot_gui.coot_toolbar_button function in your version of Coot 1 is 
unfortunately completely broken due to several severe coding errors left by the 
Coot developers during their transition to the new GTK4 interface.


Well, yes... I suppose so. We don't use coot_gui (much?) now. It's 
basically abandoned since Gtk3+.


I wrote a blog post

https://pemsley.github.io/coot/blog/2026/04/11/adding-toolbar-buttons.html

That should get you going.

Paul.






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/

Re: [COOT] toolbox and color of symmetry related chains not working

2026-05-23 Thread Paul Emsley


On 23/05/2026 21:42, Georg Mlynek wrote:

I then asked Gemini 3.1 Pro (which has access to the Wincoot folder):

Can you figure out in the code which problem there is in the 
coot_gui.coot_toolbar_button function?
9:29 PM


Yes, I can! I looked into the source code for coot_gui.py and found exactly why 
it is failing.

The coot_gui.coot_toolbar_button function in your version of Coot 1 is 
unfortunately completely broken due to several severe coding errors left by the 
Coot developers during their transition to the new GTK4 interface.


Well, yes... I suppose so. We don't use coot_gui (much?) now. It's 
basically abandoned since Gtk3+.


I wrote a blog post

https://pemsley.github.io/coot/blog/2026/04/11/adding-toolbar-buttons.html

That should get you going.

Paul.




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/


[COOT] toolbox and color of symmetry related chains not working

2026-05-23 Thread Georg Mlynek
Dear Bernhard and Paul,

I am running Coot 1.2 on windows.
I tried to implement a toolbox button for showing symmtry, but the toolbox is 
not created.
Writing a script for switching on symmtery via keybinding works.

import coot
# Track whether the symmetry is currently on or off
quicksymm_is_on = False
def toggle_quicksymm():
global quicksymm_is_on
if quicksymm_is_on:
coot.set_show_symmetry_master(0)
coot.set_show_unit_cells_all(0)
coot.add_status_bar_text("Quick Symmetry: OFF")
quicksymm_is_on = False
else:
coot.set_show_symmetry_master(1)
coot.set_show_unit_cells_all(1)
coot.set_symmetry_colour_by_symop(0, 0)
coot.set_symmetry_molecule_rotate_colour_map(0, 0)
coot.set_symmetry_colour(0.4, 0.4, 0.4)
coot.set_symmetry_size(10)
coot.set_symmetry_whole_chain(0, 0)
coot.set_default_bond_thickness(2)
coot.symmetry_as_calphas(0, 1)
coot.add_status_bar_text("Quick Symmetry: ON")
quicksymm_is_on = True
# 115 is the ASCII code for lowercase 's'
# 0 means no modifiers (like Ctrl or Shift) are required
coot.add_key_binding_gtk4_py(115, 0, toggle_quicksymm, "Toggle Quick Symmetry")

Additionally, swtching the colors using  coot.set_symmetry_colour(0.4, 0.4, 
0.4) or the gui is not working.

Is there a command to change the thickness of the symmetry related chains?



For testing if the toolbox works at all I used that script which does not work:

import coot
import coot_gui

def toggle_quicksymm(button):
if button.get_active():
coot.set_show_symmetry_master(1)
coot.set_show_unit_cells_all(1)
coot.add_status_bar_text("Symmetry: ON")
else:
coot.set_show_symmetry_master(0)
coot.set_show_unit_cells_all(0)
coot.add_status_bar_text("Symmetry: OFF")

coot_gui.coot_toolbar_button("QuickSymm", toggle_quicksymm,
 icon_name="gtk-yes",
 tooltip="Toggle Quick Symmetry on/off",
 toggle_button_flag=True,
 use_button_flag=True)

I then asked Gemini 3.1 Pro (which has access to the Wincoot folder):

Can you figure out in the code which problem there is in the 
coot_gui.coot_toolbar_button function?
9:29 PM


Yes, I can! I looked into the source code for coot_gui.py and found exactly why 
it is failing.

The coot_gui.coot_toolbar_button function in your version of Coot 1 is 
unfortunately completely broken due to several severe coding errors left by the 
Coot developers during their transition to the new GTK4 interface.

Here are the three major bugs present in the coot_gui.py code that cause it to 
fail:

1. The "get_label" Crash
At the very beginning of the function, it calls toolbar_label_list() to loop 
through every existing item on the toolbar. To get their names, it runs 
.get_label() on every single child widget. However, toolbars contain items like 
spacer lines (Separators) and raw images, which don't have text labels. When it 
hits one of these, Python throws an AttributeError and the script silently 
crashes before it even attempts to draw your button!

2. The "String Indexing" Bug
Even if the above crash didn't happen, the new version of toolbar_label_list() 
accidentally returns a list of text strings (like ["Update Maps", "Shiftfield 
B"]). However, the coot_toolbar_button function was written expecting a list of 
pairs [[label, widget_object], ...].

It checks if button_label in f:, and if it matches, it does found_button = 
f[1]. Because f is just a text string, f[1] grabs the second letter of the 
word. It literally tries to assign a single letter of the alphabet as a GTK 
Toolbar Button widget, which is totally invalid.

3. Deprecated GTK4 Icon Methods
At the very end of the function, it tries to assign your icon using 
toolbutton.set_stock_id() and toolbutton.set_icon_widget(). Both of these 
methods were completely removed by the creators of GTK when they upgraded from 
GTK3 to GTK4. Coot will throw a hidden error here because those commands 
literally don't exist in GTK4 anymore.

Conclusion: It's structurally impossible for coot_toolbar_button to work in 
this build of Coot 1 because it's full of half-finished GTK4 transition code!

The Keyboard Shortcut and Extensions Menu methods I provided earlier are the 
official, working replacements that the developers actually finished testing. I 
highly recommend using the "s" keyboard shortcut we set up!

Would be curious how good the answer is.

Many thanks to both of you in advance. It is not a urgent issue.

Br, Georg.



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