В фреймворке 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
The euro banknotes feature the name of the currency in how many different scripts?
(hidden behind the cat in the image)
Options:
A) 1
B) 2
C) 3
D) 4
@languagetrivia#script
#Python#script
🤖
PlotAI
PlotAI es una herramienta para generar gráficos en Matplotlib.
— el usuario envía un marco de datos como entrada;
— PlotAI crea un mensaje para LLM, que contiene los primeros cinco registros y genera código Python;
- Se ejecuta el código Python devuelto y se muestra el gráfico.
pip install plotai
🔗Github
-----
Main channel: @repo_science
Coupons: @freecoupons_reposcience
-----
🌍 Which African country uses Amharic as an official language?
A) 🇪🇹 Ethiopia
B) 🇪🇷 Eritrea
C) 🇸🇴 Somalia
D) 🇸🇩 Sudan
@languagetrivia#guess_the_country#script
Which language is written in a script called ‘Devanagari’, a script characterized by a horizontal line running along the top of the letters, connecting them?
Follow @languagetrivia🌏 for more!
#script#image#guess_the_language