Когда разрабатываете свой 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
⚡️Tether kompaniyasi Neuralink chiplariga o‘xshash texnologiya ustida ishlamoqda
⚡️ Tether kompaniyasi BrainOS deb nomlangan tizimni ishlab chiqayotganini e’lon qildi. Bu tizim inson aqlini sun’iy intellektning hisoblash imkoniyatlari bilan birlashtirishi mumkin.
⚡️ Kompaniyaning bashoratiga ko‘ra, yaqin 5–10 yil ichida sun’iy intellekt ko‘plab kasblarning ajralmas qismiga aylanadi va odamlar bunga moslashishga majbur bo‘ladi.
⚡️BrainOS bu muammoni hal qilish uchun taklif etilgan — texnologiyalarni to‘g‘ridan-to‘g‘ri inson miyasi bilan integratsiya qilish. Bu orqali fikrlash jarayoni tezlashadi va insoniyat sun’iy intellekt davrida yetakchilikni saqlab qolishi mumkin.
👉Bizning barcha loyihalar | #tether
CEO of #Tether warns about the possibility of mass mailing of phishing emails with the distribution of crypts
Hackers have hacked a "well-known" service provider for email newsletters (the name is not disclosed)
New investments by #Tether💵
Tether has invested $200 million in the biotech company Blackrock Neurotech, with a Brain-Computer-Interface (chipping, etc.. it looks like a Neuralink Mask)
Against the background of such investments by Blackrock Neurotech, Tether introduced its new division Tether Evo. The division will be engaged in investing in "human-oriented" technologies.
Earlier, Tether announced a new concept for the company, and also stated that they would invest in various areas of the global economy.
It is worth noting that Blackrock Neurotech has nothing to do with the Blackrock we know.
In general, biotechnology is an interesting investment direction, and Tether only confirms this + such movements pull the company beyond the framework of stablecoins.
Euro #Tether (EUR₮) and #Tether Gold (XAU₮) To Launch on BitMart Exchange
https://tether.to/en/euro-tether-eurt-and-tether-gold-xaut-to-launch-on-bitmart-exchange/
Euro #Tether (EURT) and #Tether Gold (XAUT) To Launch on SimpleSwap
https://tether.to/en/euro-tether-eurt-and-tether-gold-xaut-to-launch-on-simpleswap/