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

Пребарај: #hassan

当前筛选 #hassan清除筛选
Addis Standard

@addisstandardeng · Post #21313 · 05.02.2026 г., 05:34

#Somali president orders urgent drought response as famine fears grow Somali President #Hassan Sheikh Mohamud on Wednesday ordered all government institutions to prioritise emergency drought response after visiting the National Disaster Management Agency’s emergency operations centre. The president received a detailed briefing from agency officials on the worsening drought, including the hardest-hit areas, displacement, environmental degradation and reported loss of life. Officials warned the crisis had reached a critical stage and risked tipping into famine if urgent action is not taken. Mohamud called on government officials, Somali business leaders, humanitarian organisations and international partners to unite in responding to the growing humanitarian emergency and to prevent further human suffering. He also instructed the country’s financial authorities to exempt from taxes all aid, donations and.... https://shabellemedia.com/somali-president-orders-urgent-drought-response-as-famine-fears-grow/

Addis Standard

@addisstandardeng · Post #21378 · 12.02.2026 г., 08:30

News: #Somali president witnesses #Egyptian troop deployment to AU mission in Somalia Somali President #Hassan Sheikh Mohamud has witnessed the formation of Egyptian forces assigned to the #African_Union Support and Stabilization Mission in Somalia (#AUSSOM), according to a report by Egypt Today, citing a statement from Egypt’s military spokesman. The formation ceremony was attended by Egypt’s Minister of Defense and Military Production Gen. Abdel Mageed Saqr, Chief of Staff Lt. Gen. Ahmed Khalifa, and senior Egyptian military commanders. The military spokesman said the visit included briefings on the preparation, equipping, and operational readiness of Egyptian troops designated for the mission. The program also featured training exercises and a display of vehicles intended for deployment, with officials stating the forces had completed intensive professional training to ensure.... https://web.facebook.com/AddisstandardEng/posts/pfbid02D7ibS3RJJRGZzoYDziFEYk4VKn5vmQXDQVkAtLaU2C4EuxFtVrj8HUbHXYrD4eFSl