Когда разрабатываете свой 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
⚖️ Основатели проекта Dropil (DROP) Джереми Макалпин и Захари Матар согласились признать вину в мошенничестве с ICO на сумму почти $1,9 млн
Их обвинили в «серии ложных заявлений инвесторам» для «продвижения успеха криптовалюты». По данным Министерства юстиции США, основатели Dropil выплатили себе и партнерам как минимум $1,6 млн из привлеченных средств.
#ICO
Bought for $15.5k, sold for $122 million
#ETH holder purchased 50k$ETH at #ICO for $15.5k 9 years ago, and today he has 10 thousand coins ($24.37 million) on Kraken. In total, his coins are now valued at $122 million.
I waited for my chance🔥🔥🔥
💸Blockchain ICOs
This artist finally made me realize why all my money seem to vanish over time...
#Blockchain#ICO
🚀@PerspectiveIX via Reddit/u/nichlaes.
❓Have you invested in any ICOs?
An #Ethereum#ICO participant returned to sell 2,000 $ETH for 6M $USDC at $2,997 6 hours ago.
Notably, the whale received 33,213 $ETH at #Ethereum Genesis on Jul 30, 2015, at an ICO price of ~$0.31. So far, 5,110 $ETH has been deposited to #Kraken or sold via DEX at ~$2,545.
Currently, the whale still holds around 29.7K $ETH ($89.4M) across 3 wallets, mostly within staking platforms.
Follow @spotonchain and set alerts for the addresses of the ETH ICO participant via this entity now: https://platform.spotonchain.ai/en/entity/2098
An #Ethereum#ICO participant just woke up after 8.7 years of dormancy and transferred all 2,000 $ETH ($6.71M) to several new wallets!
The whale received 2,000 $ETH at #Ethereum Genesis on Jul 30, 2015, at the ETH ICO price of ~$0.31.
So far, 25 $ETH ($84.1K) has been deposited to #ChangeNOW at ~ $3,363.
Token flow: https://platform.spotonchain.com/en/visualizer?id=87887&thresholdOption=4
Follow @spotonchain and set alerts for the addresses of the $ETH ICO participant now!
An #Ethereum#ICO participant returned after 1.12 years to deposit 1,069 $ETH ($3.56M) to #Kraken at $3,329 3 hours ago.
The whale received 12,566 $ETH at #Ethereum Genesis in Jul 2015, at an ICO price of ~$0.31,
And then distributed the $ETH across 12 wallets in 2017, of which 4,847 $ETH have been deposited to #Kraken and #Gemini at ~$1,637.
Now still holds 7,719 $ETH ($25.7M) across 8 wallets.
Token flow: https://platform.spotonchain.ai/en/visualizer?id=99906
Follow @spotonchain and set alerts for the addresses of the $ETH ICO participant now!
🦄🦄Telegram is raising $1.7 billion in funding - and they're not even done!
#Telegram raised $850 million from 94 investors in March in addition to $850 million it gained in February. That's almost two whole unicorns in the largest #ICO (Initial Coin Offering) to date.
The company, founded by self-exiled Russian Pavel Durov, plans to use the ICO proceeds to develop the Telegram Open Network #blockchain, which includes the cryptocurrency #Gram.
Interest in the Telegram ICO has recently helped the company surpass the threshold of 200 million monthly active users, “with over 700,000 new users signing up each day.”
🚀@PerspectiveIX
🌀 http://prs.pctvix.co/TelegramIX
UK Regulator Takes Action Against Snap Over AI Chatbot
Hello, everyone! The UK Information Commissioner's Office (ICO) has issued a preliminary enforcement notice to Snap, the parent company of Snapchat. This notice could compel Snap to halt the processing of data associated with its AI chatbot, "My AI," for UK users unless an adequate risk assessment is carried out.
The ICO's provisional investigation revealed that the initial risk assessment conducted before the launch of My AI did not sufficiently evaluate its data protection risks, especially concerning children. As a result, Snap may be required to suspend its My AI product in the UK until these concerns are addressed.
#Snap#AI#DataProtection#ICO#UKRegulation