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 слични објави

Пребарај: #mndtalkofthetown

当前筛选 #mndtalkofthetown清除筛选
MND Singapore

@mndsingapore · Post #649 · 06.08.2024 г., 04:02

#MNDTalkOfTheTown: Let’s plan the future of Singapore together with the Draft Master Plan 2025 (DMP 2025) 🗺️ All Singaporeans are welcomed to share their thoughts and ideas for the DMP 2025, co-creating Singapore’s land use plans for the next 10-15 years based on 4 key themes: ⭐️ Shaping a Happy Healthy City ⭐️ Enabling Sustainable Growth ⭐️ Strengthening Urban Resilience ⭐️ Stewarding Our Nature and Heritage More exciting updates will be coming your way. Stay tuned to #TalkofTheTown for updates!

MND Singapore

@mndsingapore · Post #644 · 26.07.2024 г., 10:03

#MNDTalkOfTheTown: HDB has adopted precast technology for improved productivity and quality 🏗️ With precast technology, building components can be manufactured off-site before being delivered and assembled on-site. The precast components include: - Household Shelters - Staircases - Walls - Refuse Chute - Air-Con Ledge Stay tuned for the next part of our series where we introduce Singapore’s land-use plans for the future. #TalkOfTheTown

MND Singapore

@mndsingapore · Post #639 · 03.07.2024 г., 09:04

#MNDTalkOfTheTown: Introducing the BudgetMealGoWhere platform, where you can find cheap and good meals in Singapore 😋 Here’s how you can find your favourite meals on a budget: - Enter a postal code on https://gowhere.gov.sg/budgetmeal/ to find your nearest coffeeshop - Look out for stalls with the Budget Meal sticker Keep a lookout for the next part of our series to find out how we’re improving productivity at construction sites. #TalkOfTheTown

MND Singapore

@mndsingapore · Post #565 · 20.02.2024 г., 09:31

#MNDTalkOfTheTown: Playgrounds have come a long way since the 1960s. Here are some fun facts about these fun spaces: 💪 Playgrounds today are designed to help develop children’s motor skills, like climbing and balancing. 🌈 They are also themed to encourage children to stretch their imaginations and play pretend. 👨‍👩‍👧‍👦 Many are intentionally placed near fitness corners to allow families to come together and bond. 📖 Some of the thematic playgrounds even reflect the history and heritage of the towns. Even more exciting developments are unfolding in your neighbourhoods. Stay tuned to #TalkofTheTown for updates!

MND Singapore

@mndsingapore · Post #560 · 13.02.2024 г., 09:30

#MNDTalkOfTheTown: In the second part of our series, we learn more about the developing🏗️ Jurong Lake District (JLD). JLD’s infrastructure is designed with sustainability in mind. Some of the green initiatives are: ☀️Solar panels on all suitable surfaces. 💨District Cooling System to cool down buildings and the streets more effectively. 🚘EV charging points placed throughout the district. Keep a lookout for the next part of the series as we talk about the evolution of our playgrounds. #TalkOfTheTown

MND Singapore

@mndsingapore · Post #555 · 06.02.2024 г., 09:31

#MNDTalkOfTheTown: Let’s explore how technology has transformed the management of our trees! 🌳 With the help of Light Detection and Ranging (LiDAR) technology and advanced modelling tools like the Tree Structural Model (TSM), we can now accurately assess which trees need our attention – keeping our parks and neighbourhoods a safer place for all. Stay tuned to this series for more about how tech and innovation has transformed the way we work, play and live! #TalkOfTheTown

MND Singapore

@mndsingapore · Post #682 · 26.08.2024 г., 04:02

#MNDTalkOfTheTown: Let’s find out how Project ADORE has helped more dogs to find their forever homes ❤️ Under Project ADORE, led by NParks, HDB flat owners can adopt local mixed-breed dogs of up to 55 cm in height, with proper safeguards in place. The project has even been expanded to allow for the rehoming of retired sniffer dogs too! 🐶 #TalkOfTheTown#projectADORE