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

Резултати

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

Пребарај: #gattoverse

当前筛选 #gattoverse清除筛选
TONlines – News

@tonlines · Post #7240 · 16.05.2025 г., 13:37

Gatto Official Channel: Weekend Tournament Begins #GattoVerse#TON The GattoVerse Weekend Tournament kicks off, offering players the chance to win extraordinary prizes, including TON and various resources. The tournament starts on May 16 and ends on May 19. Participants are encouraged to join PvP battles and climb the leaderboard to secure top spots. Source: link @tonlines

TONlines – News

@tonlines · Post #6757 · 14.04.2025 г., 14:29

⚡️Gatto Official Channel: Dive into the GattoVerse NFT Adventure! #GattoVerse#TON GattoVerse welcomes the legendary NFT collection The Doge Pound with a trading volume of over $50,000,000. Join the event "Who let the dogs out?" and obtain new pets by purchasing Diamond Paws, which will transform into unique collectibles in two weeks. Source: link @tonlines

TONlines – News

@tonlines · Post #7186 · 13.05.2025 г., 09:04

⚡️Gatto Channel: Exciting Rewards with Lord Diamondog #GTON#GattoVerse Lord Diamondog has brought silver coins for $GTON, allowing players to purchase them and receive special rewards from the Hat Mouse Shop. Key prizes include treasury gold, spells, and resources for the future Lords of the GattoVerse, with bonus advantages for premium ticket holders. Source: link @tonlines

TONlines – News

@tonlines · Post #7025 · 02.05.2025 г., 13:32

Gatto | Official Channel: Battle in the GattoVerse #GattoVerse#GTON Gatto | Official Channel announces an exciting Weekend Tournament in the GattoVerse. Participants can win marvelous gifts, including various eggs, gold coins, and exclusive Gattoboxes. The tournament starts today and ends on May 5, with a special raffle using Crocottery Tickets. Source: link @tonlines

TONlines – News

@tonlines · Post #7138 · 09.05.2025 г., 12:38

Gatto | Official Channel (18+): Weekend Tournament Details #GattoVerse#Tournament GattoVerse is hosting a high-stakes Weekend Tournament starting today and ending on May 12. Participants in the PvP battles for $GTON can win prizes, including gold coins and exclusive Gattoboxes. Source: link @tonlines

TONlines – News

@tonlines · Post #6875 · 21.04.2025 г., 11:30

Gatto | Official Channel: A New Chapter with Nessie #Nessie#GattoVerse The GattoVerse was once again visited by Nessie, revealed not to be a monster but a protective mother of her species. After hatching her offspring, Nessie passed the responsibility of their care to the event participants who achieved 1000 damage points, rewarding them through the league. Source: link @tonlines

TONlines – News

@tonlines · Post #6766 · 14.04.2025 г., 18:36

Gatto: Upcoming Mine Rescheduling Announcement #Aetherian#GattoVerse Gatto | Official Channel announces a rescheduling of the mine due to a portal opening in the Aetherian world. The next mine event, offering two opportunities with rewards, is scheduled for April 24th. Source: link @tonlines

TONlines – News

@tonlines · Post #6743 · 13.04.2025 г., 18:08

⚡️GattoVerse: A Star Marks a New Beginning #GattoVerse#Aetherian The GattoVerse is on the brink of transformation as a new star promises to illuminate the skies, potentially creating a portal to the ancient Aetherian world. This event could turn legendary tales into reality, and merchant Hat Mouse is poised to seize the moment. Source: link @tonlines