В фреймворке 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
🤖 Aqlni shubha ostiga qo‘yadigan kapcha!
Bir dasturchi “I’m Not a Robot” nomli sayt ishga tushirdi. Bu yerda odatdagi kapcha emas, balki inson ekanligingizni isbotlash uchun 48 ta sinovdan o‘tishingiz kerak bo‘ladi.
🔹 Boshlanishida oddiy — yo‘l belgilarini topish kabi topshiriqlar.
🔹 Keyin esa mantiqiy boshqotirmalar, hatto “X va O” o‘yinigacha boradi.
🔹 Har bir keyingi kapcha avvalgisidan qiyinroq.
Jarayon ancha vaqt oladi, diqqat va topqirlikni talab qiladi. Oddiy botlar bunga dosh berolmaydi. Lekin odam ham oxiriga yetgach, o‘zidan so‘raydi: “Buni men qildimmi?” 😄
👉Bizning barcha loyihalar | #captcha
https://altcha.org/
Free, open-source #Captcha alternative
ALTCHA uses a proof-of-work mechanism to protect your website, APIs, and online services from spam and unwanted content.
Unlike other solutions, ALTCHA is free, open-source and self-hosted, does not use cookies nor fingerprinting, does not track users, and is compliant with data-privacy regulations and accessible.