TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #62 · 4 апр.

Когда разрабатываете свой 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

Hashtags

Резултати

Пронајдени 2 слични објави

Пребарај: #season4

当前筛选 #season4清除筛选
MoonPlay

@moonplay_official · Post #104 · 02.09.2024 г., 05:47

Welcome to Season 4 🚀 Hey, Space Explorers! 3️⃣ is in the books, and wow, what a ride it has been! We’ve captured all your achievements as of 12 AM UTC — from those hard-earned Space Bucks to your referrals, levels, and missions completed. Your Season 3 Badge3️⃣ is waiting for you in your Profile, so go ahead and bask in that glory! Quick heads up: with the new season comes a fresh start. The progress of your space missions (levels and balances) has been reset. But don’t sweat it — each season is a new shot at reaching for the stars. 💫 New challenges, new strategies, and more flights to the moon. But don’t pack up your spacesuits just yet! Season 4 is already here!⭐️ It’s going to be an epic journey, and we couldn’t be more excited to see where this season takes us, especially with such an amazing community by our side. Ready for liftoff? Let’s make Season 4 one to remember! 🚀 👉TO THE MOON APP👈 Website | Telegram Chat | X | Discord | Medium #ToTheMoon#MoonPlay#ecosystem#blockchain#gamefi#web3#wenlisting#communityfirst#season4#taptap#clicker#game

MoonPlay

@moonplay_official · Post #120 · 24.09.2024 г., 09:49

Season 4 Badge Contest: Share & Win Big! 💰 Hey Space Cadets! 4️⃣ wrapped up yesterday, and it’s time to celebrate all your epic achievements! We’re excited to kick off our popular contest where you can show off your Season 4 Badge4️⃣ and have a chance to win big! Here’s how to join the fun: 1️⃣Follow the @moonplay_official group. 2️⃣Join our lively chat at @moonplay_chat. 3️⃣Share a screenshotof your Season 4 Badge and use the hashtag #Season4in the comments. ⭐️ To find your Season 4 Badge, just tap your profile in the top right and check under Loot Capsules. We’ll be picking 20 lucky winners in 24 hours, so keep an eye out! Good luck, and may your Badge shine the brightest! ✨ 👉TO THE MOON APP👈 Website | Telegram Chat | X | Discord | Medium #ToTheMoon#MoonPlay#ecosystem#blockchain#gamefi#web3#wenlisting#communityevent#communitymilestone#communityfirst#taptap#clicker#game