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

Резултати

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

Пребарај: #govsgexplains

当前筛选 #govsgexplains清除筛选
gov.sg

@Govsg · Post #3330 · 17.03.2026 г., 06:38

Tensions in the Middle East are driving global fuel prices up. #govsgexplains how this could affect you and what measures are available to help Singapore and Singaporeans navigate this period.

gov.sg

@Govsg · Post #3283 · 06.02.2026 г., 07:19

🚦Parliament passed the new Land Transport and Related Matters Bill on 4 Feb 2026. #govsgExplains four key changes in this Act that facilitate the ERP 2 transition and strengthen deterrence for active mobility and vehicular offences. More info: go.gov.sg/govsgexplains-ltrma

gov.sg

@Govsg · Post #3227 · 07.11.2025 г., 11:35

📢The Weekly Wrap – 7 November 2025 1) Wondering how Singapore is tackling online harms? The new Online Safety (Relief and Accountability) Bill (OSRA) is a comprehensive legal framework that offers better protection to victims of online harms. Here’s how OSRA will strengthen online safety👇 1) Set up the Online Safety Commission to help victims seek timely redress 2) Introduce Statutory Torts to enhance perpetrators’ accountability 3) Support victims in identifying wrongdoers 🔗 Learn more: go.gov.sg/parl-roundup-osra 2) Site of 38 Oxley Road intended to be gazetted as a National Monument The National Heritage Board’s Preservation of Sites and Monuments Advisory Board has assessed the Site of 38 Oxley Road to be of historic significance and national importance. If preserved and acquired, all private living spaces will be removed to respect Mr Lee Kuan Yew’s wishes for privacy. #govsgexplains: go.gov.sg/explains-38oxleyroad-1 ➡️ You can also read more about Mr Lee’s views on the Site: go.gov.sg/explains-38oxleyroad-2 3) Visit “We Can ACT Against Scams” Roadshow Learn ways to protect yourself and your loved ones from scams. Don’t miss the interactive activities this weekend! 🗓️ 8 & 9 Nov 2025 (Sat & Sun) 🕙 10am – 8pm 📍Toa Payoh HDB Hub Atrium 🔗 Plan your visit: go.gov.sg/antiscamroadshow

gov.sg

@Govsg · Post #3201 · 03.11.2025 г., 08:01

In its 2018 Report, the Ministerial Committee on the Site of 38 Oxley Road concluded that while Mr Lee Kuan Yew preferred the building to be demolished, he was prepared to accept other options. #govsgexplains more about the background of Mr Lee’s views on the Site of 38 Oxley Road. ⬆️

gov.sg

@Govsg · Post #3191 · 03.11.2025 г., 07:37

The National Heritage Board’s (NHB) Preservation of Sites and Monuments (PSM) Advisory Board has assessed the Site of 38 Oxley Road to be of historic significance and national importance. No other site or monument represents this foundational part of Singapore’s independence history. The Government intends to gazette the Site of 38 Oxley Road to safeguard and preserve it as a National Monument for possible use as a heritage park. If preserved and acquired, all private living spaces will be removed to respect Mr Lee Kuan Yew’s wishes for privacy. #govsgexplains more ⬆️

gov.sg

@Govsg · Post #2596 · 20.12.2024 г., 13:00

#govsgexplains: Incorrect use of NRICs has made us more vulnerable over time. However, the shift from using masked NRIC numbers does not mean automatically unmasking and using the full NRIC number in all circumstances. How can we better protect our personal data? Find out more ⬆️

gov.sg

@Govsg · Post #2563 · 15.11.2024 г., 10:25

📢The Weekly Wrap – 15 November 2024 1. Supporting our Hawkers 🍽 Hawker centres are an integral part of our daily lives. How can we support hawkers better while keeping food prices affordable? 👉#govsgexplains more: • Balancing fair incomes for hawkers while keeping food options affordable: go.gov.sg/hawkers-wrap • Decisive actions taken to support Singaporeans with their cost of living: go.gov.sg/col-support-wrap 2. Live longer, Learn for Life 📈 Are you considering a career switch but afraid to take the first step? PM Lawrence Wong shares more on how the Government can support and journey with you through SkillsFuture 💪 🔗 Find out more at: go.gov.sg/learnforlife2024 3. Managing community disputes more effectively Want to resolve disputes with neighbours faster? There are now better mediation efforts and a dedicated team to facilitate this. Say yes to good neighbourliness! 🔗 Find out more at: go.gov.sg/community-disputes-wrap

gov.sg

@Govsg · Post #2552 · 15.11.2024 г., 01:31

🔼 Find out more about the decisive actions taken to support Singaporeans with their cost of living. We stand ready to do more to address these concerns. #govsgexplains

gov.sg

@Govsg · Post #2542 · 14.11.2024 г., 12:07

How can we ensure fair incomes for our hawkers while keeping food prices affordable for everyone? #govsgexplains more ⬆️

gov.sg

@Govsg · Post #2460 · 13.09.2024 г., 08:15

Curious about why public transport fares are being adjusted? Read on ⬆️ to find out the reasons for the review and the measures in place to support you. #govsgexplains

gov.sg

@Govsg · Post #2213 · 24.05.2024 г., 10:32

In view of the heightened threat situation, Ministry of Home Affairs and Home Team Departments have stepped up patrols and security measures. 📢 With the June school holidays round the corner, please continue to stay safe and vigilant! #govsgexplains

gov.sg

@Govsg · Post #2194 · 17.05.2024 г., 04:32

Singapore has voted in favour of a resolution at the United Nations General Assembly that expresses support for the admission of Palestine as a UN member. Find out why ⬆️#GovsgExplains

12
ПретходнаСтраница 1 од 2Следна