Когда разрабатываете свой 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
#FARM/USDT analysis :
#FARM is currently in an uptrend, exhibiting a series of higher highs (HHs) and higher lows (HLs). The price is presently consolidating above the 200-period exponential moving average (EMA), and a bounce is anticipated, which would support the continuation of its bullish momentum. For a long entry, it is advisable to wait for a breakout above the $53 level to confirm the upward movement.
TF : 1H
Entry : $53.00
Target : $66.00
SL : $47.50
⚠️ Осторожно: после этого AMA может внезапно потянуть в #stake, #lend и #farm.
@bemofinance + @evaaprotocol + @bidask = 🔥
Увидимся завтра в 08:00 UTC! 👀
⚡️Electra meets you
The first DEX to trade perp assets directly from your wallet with high leverage, deep liquidity and the lowest fees.
Warm up with Bulls'n'Bears Game — pump $BTC to 1 billion, rack up points, and bring in more frens-electrons.
⭐️ More points mean bigger rewards!
⚡️Join Electra now!⏺
#TON#DEX#trade#farm#BTC
🤑Blum has released update — now we have the opportunity to create a tribe!
⚫️Go to tribe
⚫️ Every 8 hours we press “Claim”
⚫️ If possible, we spend tickets, because there was information that after a while they will expire
Also recently added the function of connecting a wallet and unlimited invites
♾
🛖Join our tribe and farm points for
💵 10% faster, as usual, let's try to reach the top together!
#blum#tribe#ton#farm
😸Farm $CATI on🎰🎰🎰
Today, 2 new farming pools with impressive prize pools appeared on the STON.fi exchange:
💎CATI/TON: 10,000 STON ($43,000)
🪙CATI/USDT: 10,000 STON ($43,000)
🗓 Farming will last until October 4. There is no blocking of LP tokens.
How to get rewards?
1. Top up the liquidity pool and receive your LP tokens
2. Click Farm on your liquidity pool
You can find detailed instructions here or watch our video guide📹
Farming is the process of earning rewards for providing your cryptocurrency as liquidity to decentralized finance platforms #DeFi.
#catizen#farm#stonfi#DEX#CATI
Raffle-airdrop $THNG from Drop Hunter and a mini-review of the token
😀 Things Token plans to launch an RWA platform for buying and selling real assets. It is hosted on our 🪙#TON blockchain and is already available on DEX platforms. You can learn more about the project.
The conditions for the #Airdrop are below:
🟡Launch the bot.
🟡Subscribe to the channel.
🟡Invite 5 friends (old referrals count).
🟡Buy 1 ticket and wait for the results to be announced.
Two-tier token system:
➖$THNGP: A token with voting rights in the DAO, mined through mining and participation in the presale. Can be exchanged for 👁#THNG at a ratio of 1:10. The transfer of this token is limited to a single transaction (for example, if you need to change your wallet). It can only be freely sent and received through mining, voting, and exchange (conversion) smart contracts. Do not attempt to sell these tokens or transfer them to exchanges.
😀$THNG: A freely tradable token for trading, transferring and other purposes.
🟡Drop type - Raffle.
🟡Total volume - 28 million $THNG coins
🟡Total winners - 400 people.
🟡For each user – $65,000 THNG for 1 ticket (50,000 points = 1 ticket)
😀 At the moment, THNG 2.0 staking is available with an APR of ~ 160% from August 23 to September 24.
🔥Keep farming and participate in all activities of DropHunters
#farm#drop#TON#web3