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

Резултати

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

Пребарај: #maldives

当前筛选 #maldives清除筛选
Voyage.Travel.Tourism

@VOYAGE · Post #1700 · 26.03.2026 г., 13:14

🌴 Maldives Atolls — a natural wonder created from coral reefs and the crystal-clear waters of the Indian Ocean 🌊🐠 ✨ The Maldives Atolls are the lowest-lying country in the world. They consist of hundreds of coral islands scattered over an area of more than 90,000 km² 🏝. This archipelago is a diver's dream 🤿 and a paradise for snorkeling enthusiasts #Maldives | @voyage

Hashtags

Voyage.Travel.Tourism

@VOYAGE · Post #1692 · 18.03.2026 г., 13:14

🌴 Vaavu Atoll – a Maldivian paradise! 🐠 Seclusion in nature, comfort, and a stunning underwater world make this the perfect spot for both relaxation and adventure! ✨ #Maldives | @voyage

Hashtags

Voyage.Travel.Tourism

@VOYAGE · Post #1528 · 12.08.2025 г., 12:14

🌴 Vaavu Atoll – a Maldivian paradise! 🐠 Seclusion in nature, comfort, and a stunning underwater world make this the perfect spot for both relaxation and adventure! ✨🌊 📏 📏 📏 📏 📏 📏 📏 📏 #Maldives | @voyage

Hashtags

Voyage.Travel.Tourism

@VOYAGE · Post #1507 · 23.07.2025 г., 12:14

🌴 Maldives Atolls — a natural wonder created from coral reefs and the crystal-clear waters of the Indian Ocean 🌊🐠 ✨ The Maldives Atolls are the lowest-lying country in the world. They consist of hundreds of coral islands scattered over an area of more than 90,000 km² 🏝. This archipelago is a diver's dream 🤿 and a paradise for snorkeling enthusiasts 🐬 📏 📏 📏 📏 📏 📏 📏 📏 #Maldives | @voyage

Hashtags

Voyage.Travel.Tourism

@VOYAGE · Post #1437 · 31.05.2025 г., 12:14

🌴 Vaavu Atoll – a Maldivian paradise! 🐠 📏 📏 📏 📏 📏 📏 📏 📏 Seclusion in nature, comfort, and a stunning underwater world make this the perfect spot for both relaxation and adventure! ✨🌊 📏 📏 📏 📏 📏 📏 📏 📏 #Maldives🇲🇻@voyage

Hashtags

Voyage.Travel.Tourism

@VOYAGE · Post #1327 · 24.02.2025 г., 13:14

🌴 Vaavu Atoll – a Maldivian paradise! 🐠 📏 📏 📏 📏 📏 📏 📏 📏 Seclusion in nature, comfort, and a stunning underwater world make this the perfect spot for both relaxation and adventure! ✨🌊 📏 📏 📏 📏 📏 📏 📏 📏 #Maldives🇲🇻@voyage

Hashtags

Voyage.Travel.Tourism

@VOYAGE · Post #1304 · 13.02.2025 г., 13:14

🌊 Shipwreck in Keyodhoo – the pearl of Vaavu Atoll! 🟠This sunken treasure lures divers from all over the world. Explore the deep and witness the magic of the underwater realm! 🐠🤿 📏 📏 📏 📏 📏 📏 📏 📏 #Maldives🇲🇻@voyage

Hashtags

Voyage.Travel.Tourism

@VOYAGE · Post #1196 · 15.12.2024 г., 13:14

Oh, these unique Maldives! 🌴🌞 📏 📏 📏 📏 📏 📏 📏 📏 A paradise of turquoise waters, white sandy beaches, and endless sunshine. The Maldives offer a dreamlike escape to anyone seeking tranquility and natural beauty. 📏 📏 📏 📏 📏 📏 📏 📏 #Maldives🇲🇻 @voyage

Hashtags

123•••56
ПретходнаСтраница 1 од 6Следна