В фреймворке PyQt (и PySide тоже) часто встречается настройка чего-либо с помощью так называемых флагов.
widget.setWindowFlags(Qt.Window)
Взаимодействие нескольких флагов делается с помощью бинарных (или побитовых) операторов.
Несколько флагов можно указать с помощью оператора "|"
list_item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
исключить флаг из уже имеющегося набора можно так
list_item.setFlags(list_item.flags() ^ Qt.ItemIsEnabled)
Добавить новый флаг к имеющимся можно так
list_item.setFlags(list_item.flags() | Qt.ItemIsEnabled)
А проверка наличия делается так
is_enabled = item.flags() & Qt.ItemIsEnabled > 0
Почему именно так? Всё дело в том как именно работают побитовые операторы. Но об этом в следующем посте.
#qt
📚Jim Is Tired of Jo’burg… but Yekaterinburg isn’t tired of Jim!
Discover the Russian-language edition of the book by South African writer and former Ambassador to Russia, Mzuvukile Maqetuka 🇿🇦, at the annual international literary festival Krasnaya Strоka (Red Line, or Linea Rubra).
🎤Speakers (pictured):
— Dmitry Pobedash (left), translator of Jim Is Tired of Jo’burg
— Mikhail Brodsky, editor of the literary translation
💡 New to the book? Curious about literary translation? This is for you!
🎁 The most active guests can win a free copy.
🗓 Date: Saturday, August 23
📍 Time & place — coming soon
#Books#Festival#Yekaterinburg#SouthAfrica#Translation#LiteraryTranslation#RedLine#LineaRubra#Literature
📚Jim Is Tired of Jo’burg… but Yekaterinburg isn’t tired of Jim!
Join us for the presentation of the Russian-language edition of the novel by South African writer and former Ambassador of South Africa to Russia 🇿🇦 Mzuvukile Maqetuka, at the annual international book festival “Red Line” (a.k.a. Linea Rubra).
🎤 Speakers (in the photo):
— Dmitry Pobedash (left), translator of Jim Is Tired of Jo’burg
— Mikhail Brodsky, editor of the literary translation
💡 Haven’t read the book yet? Curious about the art of literary translation? This event is for you!
🎁 The most active guests will have a chance to win a free copy.
🗓 Date: Saturday, August 23, 5:00–5:45 PM
📍Historic Riverside Park (a.k.a. Plotinka, The Dam, Roots (Korni) Lecture Hall
📖 The translation project was initiated by Sergey Mazurkevich, Honorary Consul of South Africa in Yekaterinburg.
#Books#Literature#Festival#Yekaterinburg#SouthAfrica#Mazurkevich#Translation#LiteraryTranslation#RedLine#LineaRubra