Когда разрабатываете свой 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
📢 Tycoon Airdrop Reminder!
🚨 Snapshot: Nov 17 (at a random time during the day)
📌 Airdrop Eligibility:
- Complete all Mandatory Criteria ✅
- Have 100+ Tycoon Points (Details: https://t.me/singsingchannel/965)
💱 Conversion Rate: 10 Tycoon Points = 1 $SING
🔥 Note: Top Daily Chat event will also end on this date!
Don’t miss out—secure your Tycoon Points now! 🚀
#Airdrop#SingSing
⁉️⁉️ What's coming up ⁉️⁉️
🎉Good News: TON is officially listed on Binance! 🚀
🚨Even Better News: SingSing is now supporting $TON! 🎉
You now can participate in SingSing events using both RUBY, ETH and TON, and of course, there are exciting TON rewards up for grabs too! 💎
#SingSing#TON#Binance#Crypto
🚀 We’re officially 100% READY for the highly anticipated $SING Listing! 🎉
The team has worked tirelessly, and here’s the checklist to prove it:
✅ Investors - locked in
✅ Market Maker - confirmed and ready to go
✅ CEX - fully secured
✅ Key Partners - all on board
✅ Launchpad - set and ready
✅ KOLs - confirmed 🔥
This is just the beginning! Get ready for the $SING launch—big things are coming! ⏳
#SingSing#Crypto#Blockchain#Web3
🎤Announcement | Chat | X (Twitter) | Website | Game
🚨SingSing Airdrop Criteria Explained🚨
1. Mandatory Criteria 📌
To qualify, you must:
✅Connect Wallet (EVM&TON)
✅Own a KTV NFT or a Karaoke Box NFT (Rare or higher)
✅Upgrade Building Level to 6 or above
2. Scoring System 🔢
✅1 Day Wallet Check-in: +20 points (Counting from Sep 27)
✅Invite a Friend: +50 points per invite (Counting from Sep 22)
✅1 Supreme Spin: +50 points per spin (Counting from Oct 22)
✅Have NFT Point: +10 points per NFT Point
✅Chat in SingSing Group: +1 point per 100 messages (capped at 500 points/day per user)
✅Reach a Successful Business Rank or higher: +100 points
To receive the airdrop, you'll need to meet all mandatory criteria and achieve a high enough score—minimum score requirement will be announced soon! 🏆
Note: This is our first major airdrop ahead of SingSing's token listing. Even after the listing, our game will continue to offer play-to-earn features and more airdrop events! 🌟
#SingSing#Airdrop#PlayToEarn
🎤Announcement | Chat | X (Twitter) | Website | Game
🌟 A huge shoutout to our incredible partners for their invaluable support in making SingSing what it is today! 🎉
@koi_protocol, @BuildOnHybrid, @dechat_io, @ARCreactorAI, @realDogX, @SocialGrowAIand all the amazing teams who’ve been with us on this journey – we couldn’t have done it without you. 💪 Your dedication fuels our growth and vision to redefine social gaming! 🚀
Here’s to more milestones and breaking new ground together! 🥂 Thank you for being a part of the SingSing family! 💎
#SingSing#Partnership#Web3
🎤Announcement | Chat | X (Twitter) | Website | Game
🔥 Top Blacksmiths #4 is NOW LIVE! 🔥
🏆 Rewards: Top 50 Blacksmiths will share 150,000 AURA
🎖 Reward Breakdown:
🥇 Top 1: 25K AURA
🥈 Top 2: 15K AURA
🥉 Top 3: 10K AURA
🏅 Top 4-10: 5K AURA
🏅 Top 11-20: 3K AURA
🏅 Top 21-30: 2K AURA
🏅 Top 31-40: 1K AURA
🏅 Top 41-50: 500 AURA
⏰ Duration: Mar 15, 14:00 UTC - Mar 29, 14:00 UTC
📌 Note: Leaderboard rank is based on Points. If Points are tied, higher pot tier ranks higher.
🔨 Prove you're the ultimate Blacksmith! 🏅
#SingSing#TopBlacksmiths
🎤Announcement| Mystic Garden Game |Chat| Spotlight Channel
🔥 Top Blacksmiths #3 is NOW LIVE! 🔥
🏆 Rewards: Top 50 Blacksmiths will share 150,000 AURA
🎖 Reward Breakdown:
🥇 Top 1: 25K AURA
🥈 Top 2: 15K AURA
🥉 Top 3: 10K AURA
🏅 Top 4-10: 5K AURA
🏅 Top 11-20: 3K AURA
🏅 Top 21-30: 2K AURA
🏅 Top 31-40: 1K AURA
🏅 Top 41-50: 500 AURA
⏰ Duration: Feb 15, 14:00 UTC - Mar 1, 14:00 UTC
📌 Note: Leaderboard rank is based on Points. If Points are tied, higher pot tier ranks higher.
🔨 Prove you're the ultimate Blacksmith! 🏅
#SingSing#TopBlacksmiths
🎤Announcement| Mystic Garden Game |Chat| Spotlight Channel
🔥 Top Blacksmiths #2 is NOW LIVE! 🔥
🏆 Rewards: Top 50 Blacksmiths will share 150,000 AURA + $100 $SING!
🎖 Reward Breakdown:
🥇 Top 1: 25K AURA + $20 $SING
🥈 Top 2: 15K AURA + $15 $SING
🥉 Top 3: 10K AURA + $10 $SING
🏅 Top 4-10: 5K AURA + $5 $SING each
🏅 Top 11-20: 3K AURA + $2 $SING each
🏅 Top 21-30: 2K AURA
🏅 Top 31-40: 1K AURA
🏅 Top 41-50: 500 AURA
⏰ Duration: Jan 15, 14:00 UTC - Feb 5, 14:00 UTC
📌 Note: Leaderboard rank is based on Points. If Points are tied, higher pot tier ranks higher.
🔨 Prove you're the ultimate Blacksmith! 🏅
#SingSing#TopBlacksmiths
🎤Announcement| Mystic Garden Game |Chat| Spotlight Channel
🌟 MYSTIC GARDEN: WHERE MAGIC MEETS GAMING 🌟
SingSing proudly presents an upcoming game - Mystic Garden, a GameFi adventure! 🌱 Grow elemental plants, craft NFTs, harvest BNB rewards, and battle for leaderboard supremacy. 💎
🚀Launchpool Alert!
We’ll snapshot launchpool participants to grant early access to Mystic Garden and offer exclusive rewards!
Join Launchpool now - https://t.me/SingSing_TG_bot/app?startapp=_launchpool
📌 Launch Date: Coming Soon.
Follow us for whitelist spots and updates!
#GameFi#NFTGaming#SingSing
🎉 Sing and Earn is LIVE! 💸✨
Earn Singing Tickets by completing actions and unlock rewards in the Vault! Here's how:
1️⃣ Perform at least one action:
✅Buy $KARA
✅Lucky Spin
✅Supreme Spin
✅Wallet Check-in
2️⃣ Go to Vault ➡️ Items ➡️ Open your Singing Ticket 🎟
Start earning CASH today! 🚀
#SingAndEarn#SingSing
🎤Announcement | Chat | X (Twitter) | Website | Game
🎤 Sing and Earn Cash WILL GO LIVE today! 💸✨
Every action earns you a singing ticket, bringing you closer to CASH rewards! 🎶🔥
📜 Details:
🪙 KARA purchase in the shop = 1 Singing Ticket
💳1 Wallet Check-in = 1 Singing Ticket
💫1 Lucky Spin = 1 Singing Ticket
🎟 Collect tickets and claim CASH effortlessly. Ready to sing and win? 🚀
#SingAndEarn#SingSing
🎤Announcement | Chat | X (Twitter) | Website | Game
🚀 Withdrawals Are Back Online! 🚀
Good news, fam! 🥳 The maintenance is complete, and withdrawals are officially open again! 💸✨
We appreciate your patience, and now everything’s running smoother than ever. Get back to those moves, and as always, thanks for being legends! 💪🔥
#SingSing#Withdrawal
🎤Announcement | Chat | X (Twitter) | Website | Game