I’m connecting to the ‘state-flags-changed’ signal of an entry ( in a ColumnView ), and I get a lot of events with variable flags of type Gtk.StateFlags. What is the proper way to match a particular state flag that I’m trying to react to?
Gtk.StateFlags are bitfields. This means that the bits in
GtkStateFlags indicate if a flag is present/active. Take for example the dummy bitfield of:
0000001001 here the 1st and the 4th bit are set.
We can test if individual bit (flag) is set with a logical
& operation between the bitfield and the flag we want to test . As one property of the flag is that only one bit can be set to a
1. If the result is non-zero then the flag must be present.
for example here we test if the widget is
widget.get_state_flags() print('active:', bool(Gtk.StateFlags.ACTIVE & flags))
Note that the cast to a boolean is not strictly necessary.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.