Когда разрабатываете свой GUI с помощью PyQt для какого-либо софта бывает необходимо позаимствовать цвета из текущего стиля интерфейса. Например, чтобы правильно раскрасить свои виджеты, подогнав их по цвету. Ведь бывает, что ваш GUI используется в разных софтах. Причём некоторые со светлой темой а другие с тёмной.
По умолчанию стили наследуются, но если вы задаёте какую-либо раскраску для части виджета через свой styleSheet, то требуется ссылаться на цвета текущего стиля.
Как это сделать? Как получить нужный цвет из палитры имеющегося стиля? Это достаточно просто, нужно использовать класс QPalette и его роли.
Например, мне нужно достать цвет текста из одного виджета и применить его в другом как цвет фона (не важно зачем именно так, просто захотелось😊).
Получаем палитру виджета и сразу достаём нужный цвет, указав его роль.
from PySide2.QtGui import QPalette
color = main_window.palette().color(QPalette.Text)
теперь можем использовать этот цвет в стилях
my_widget.setStyleSheet(f'background-color: {color.name()};')
Готово, мы динамически переопределили дефолтный стиль используя текущий стиль окна!
На самом деле есть запись покороче, в одну строку и без лишних переменных. Не очень-то по правилам CSS, но Qt это понимает.
my_widget.setStyleSheet('background-color: palette(Text);')
Этот способ не подходит если вам нужно как-то модифицировать цвет перед применением в своих стилях. В этом случае потребуется первый способ.
Зато он прекрасно сработает в файле .qss, то есть не придётся в коде прописывать раскраску отдельных элементов через ссылки на палитру, всё красиво сохранится в отдельном файле .qss!
QListView#my_widget::item:selected {
background: palette(Midlight);
}
Про имеющиеся роли можно почитать здесь🌍
#qt#tricks
#session
🟧“TechWomen” va “UEnter” sizni STEM sohasida ayollar uchun imkoniyatlar haqidagi bepul mashg‘ulotga taklif etadi!
🗓 2024-yil 1-dekabr, 13:00 – 15:00
📍 “UEnter”
🟧 Bunda siz “TechWomen 2024” bitiruvchilarining muvaffaqiyat hikoyalarini tinglaysiz hamda dastur, jumladan ariza topshirish jarayoni va talablar to‘g‘risida ma’lumot olasiz.
Sessiya Silikon vodiysida mentorlik, kasbiy rivojlanish va aloqalar o‘rnatishga bag‘ishlanadi.
⭐️Havola orqali ro‘yxatdan o‘ting.
🟧 O‘z mahoratingizni oshirish imkoniyatini qo‘ldan boy bermang!
______
TechWomen and UEnter cordially invite you to a complimentary session on opportunities for women in STEM!
🗓 December 1, 2024, 1:00 PM – 3:00 PM
📍 UEnter
🟧 Discover inspiring success stories from TechWomen 2024 alumnae and gain information about the program, including application procedures and eligibility requirements.
This session will highlight mentorship, professional development, and networking opportunities in Silicon Valley.
⭐️ Registrationlink
🟧 Do not miss this opportunity to expand your professional horizons!
Telegram | Instagram | Facebook | Youtube | LinkedIn
Instant messaging apps review
I tested a lot & mulled on this for a while.
Our goal was something less centralized, more private & harder to take down or block.
BRIAR is good & with p2p modes to be censorship resistant if internet is cut, but you have to invite each user separately to a group which is a pain
XMPP is archaic & behaves like a traditional one to one messenger. Yes, groups are there but are more like texting groups & you can't tag or reply to anyone directly.
MATRIX is better but ends up being 3rd party centralized because hosting yourself is a hog, which means you're bound by that hosted server & all those rules, giving up your email credentials, getting possibly kicked off, etc. Matrix.org server started requiring email verification for instance.
Matrix doesn't encrypt metadata, your IP is visible to others in chats.
The last 2 require a hosted server somewhere for large groups to function properly, and so does SESSION since it too has no servers of it's own. But its way lighter than Matrix & can be hosted on a mediocre VPS (which I've done, I can pay, its cheap its fine). The added benefit of Session is everything is onion routed automatically, and there's zero identifying factors when creating an ID. No phone numbers, no emails, nothing. Restore that ID on a new device using a cryptic passphrase, or start a new one if you want.
Check out @Nogoolag room with SESSION:
http://chat.nogoolag.com/nogoolag?public_key=53b45de08520eb3af97933e9a4991e74e26972ee91cc94e6a05da03d956d4313
#im#session
Session plénière du #Forum économique oriental : les détails avec Antoine Cléraux
Le Forum économique oriental se déroule actuellement à Vladivostok en Russie. Son but est de promouvoir les investissements étrangers dans l'Extrême-Orient russe. Le point d'orgue de ce forum est la #session plénière, à laquelle a participé Vladimir #Poutine. Retour sur ces trois heures de débat avec notre envoyé spécial Antoine Cléraux.
RT en français
The library allows us to store user-specific data into a #session object.
The session object has a dict-like interface (operations like session[key] = value, value = session[key] etc. are present).
Before processing the session in a web-handler, you have to register the session #middleware in #aiohttp.web.Application.
https://github.com/aio-libs/aiohttp-session
6 Best Secure Messaging Alternatives to WhatsApp | Avoid the Hack – https://avoidthehack.com/best-secure-messengers
The content of your messages and the metadata associated with them should be secure and private. Unfortunately many messengers out there fail to do this.
Telegram operates in the cloud, and while this does have good portability across multiple devices and device types, the service provider (or anyone with access to the cloud server) could theoretically read them at any time with relative ease; Telegram stores messages on the third-party cloud provider's server.
According to Telegram’s privacy policy, the service itself logs IP addresses and phone numbers.
#Infosec#Session#SimpleXchat#Briar#Threema
#Element#Telegram#privacy