TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #381 · 23 окт.

Установить свойства виджета в PySide можно не только через соответствующие методы и конструктор класса. Можно их изменять с помощью метода setProperty по имени. btn = QPushButton("Click Me") btn.setProperty("flat", True) Это аналогично вызову btn.setFlat(True) Если указать несуществующее свойство, то оно просто создается btn.setProperty("btnType", "super") Получить его значение можно методом .property(name) btn_type = btn.property("btnType") Когда это может быть полезно? ▫️Можно просто хранить какие то данные в виджете и потом их доставать обратно widget = QWidget() widget.setProperty('my_data', 123) print(widget.property('my_data')) ▫️ Назначая эти свойства разным виджетам можно потом отличить виджеты во время итераци по ним. Например, найти все кнопки со свойством my_data="superbtn". Но ведь вместо кастомного свойства можно использовать objectName, будет тот же результат. Да, но y ObjectName есть ограничение - только строки. ▫️ Если нам потребуется не просто поиск а, например, сортировка по числу, то свойства позволяют нам это сделать. Поддерживается любой тип данных widget.setProperty('my_data', {'Key': 'value'}) widget.setProperty('order', 1) all_widgets.sort(key=w: w.property('order')) Но ведь Python позволяет всё вышеперечисленное сделать простым созданием атрибута у объекта widget.order = 1 widget.my_data = 123 Да, но я думаю что не надо объяснять почему не стоит так делать. К тому же, если у виджета нет свойства то метод .property(name) вернет None, а отсутствующий атрибут выбросит исключение. ▫️ Действительно полезное применение кастомным свойствам - контроль стилей. Здесь атрибутами не обойтись, нужны именно свойства. Дело в том, что в селекторах стилей можно указывать конкретные свойства виджетов на которые следует назначать стиль. Просто запустите этот код from PySide2.QtWidgets import * if __name__ == "__main__": app = QApplication([]) widget = QWidget(minimumWidth=300) layout = QVBoxLayout(widget) btn1 = QPushButton("Action 1") btn2 = QPushButton("Action 2") btn3 = QPushButton("Action 3", flat=True) layout.addWidget(btn1) layout.addWidget(btn2) layout.addWidget(btn3) # добавим кастомное свойство одной кнопке btn1.setProperty("btnType", "super") # добавляем стили widget.setStyleSheet( """ QPushButton[btnType="super"] { background-color: yellow; color: red; } QPushButton[flat="true"] { color: yellow; } """ ) widget.show() app.exec_() С помощью селектора мы избирательно назначили стили на конкретные кнопки. Как получить список всех кастомный свойств? Функция получения списка кастомных свойств отличается от получения дефолтных. def print_widget_dyn_properties(widget): for prop_name in widget.dynamicPropertyNames(): property_name = prop_name.data().decode() property_value = widget.property(property_name) print(f"{property_name}: {property_value}") #tricks#qt

Hashtags

Резултати

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

Пребарај: #proton

当前筛选 #proton清除筛选
Linuxgram 🐧

@linuxgram · Post #18608 · 28.04.2026 г., 22:27

📰 Proton Experimental and Proton 11 Beta updated to fix issues with the EA App Valve released a small tweak update to both Proton Experimental and the Proton 11 Beta, bringing in an update to help with the EA App.Read the full article on GamingOnLinux. 🔗 Source: https://www.gamingonlinux.com/2026/04/proton-experimental-and-proton-11-beta-updated-to-fix-issues-with-the-ea-app/ #proton

Hashtags

sudo recast

@sudo_recast · Post #341 · 11.07.2022 г., 17:47

#Proton Down - https://twitter.com/search?q=protonmail%20down&src=typed_query&f=live - https://twitter.com/ProtonSupport/status/1546545761512464385 - https://protonstatus.com/incidents/195

Hashtags

sudo recast

@sudo_recast · Post #337 · 09.07.2022 г., 12:41

> If you have been inactive on #Proton Mail for one year (12 months) or more, access to your account and all data associated with it may be removed. https://proton.me/support/inactive-accounts

Hashtags

Linuxgram 🐧

@linuxgram · Post #18715 · 08.05.2026 г., 21:21

📰 Proton Experimental gets fixes for Rocket League, Crimson Desert, Helldivers 2 and more Valve just launched the latest exciting upgrade for Proton Experimental, to ensure as many Windows games as possible run well on Linux / SteamOS machines.Read the full article on GamingOnLinux. 🔗 Source: https://www.gamingonlinux.com/2026/05/proton-experimental-gets-fixes-for-rocket-league-crimson-desert-helldivers-2-and-more/ #linux#proton

Linuxgram 🐧

@linuxgram · Post #18688 · 06.05.2026 г., 13:24

📰 VKD3D-Proton 3.0.1 Brings More Improvements For Direct3D 12 On Vulkan Hans-Kristian Arntzen of Valve's Linux graphics driver team announced the release today of VKD3D-Proton 3.0.1 for Direct3D 12 over the Vulkan API... 🔗 Source: https://www.phoronix.com/news/VKD3D-Proton-3.0.1 #linux#proton

Linuxgram 🐧

@linuxgram · Post #18623 · 30.04.2026 г., 08:40

📰Proton Experimental updated to get Crimson Desert working again on Linux / SteamOS A recent update to Crimson Desert has been causing problems on Linux / SteamOS with it not launching, so Valve patched Proton Experimental to fix it.Read the full article on GamingOnLinux. 🔗 Source: https://www.gamingonlinux.com/2026/04/proton-experimental-updated-to-get-crimson-desert-working-again-on-linux-steamos/ #linux#proton

Linuxgram 🐧

@linuxgram · Post #18518 · 21.04.2026 г., 21:04

📰 Proton Experimental upgraded to Proton 11 for better Linux gaming compatibility After releasing the big Proton 11 Beta to run more Windows games on Linux / SteamOS, Valve just upgraded Proton Experimental some more too.Read the full article on GamingOnLinux. 🔗 Source: https://www.gamingonlinux.com/2026/04/proton-experimental-upgraded-to-proton-11-for-better-linux-gaming-compatibility/ #linux#proton

Linuxgram 🐧

@linuxgram · Post #18580 · 27.04.2026 г., 08:04

📰D7VK v1.8 Continues Improving Legacy Direct3D Atop The Vulkan API D7VK as what began as an implementation of the Direct3D 7 API on top of the Vulkan API, based off DXVK as part of Steam Play (Proton) for D3D8 through D3D11 support, continues enhancing its legacy D3D API support that over time has stretched now from D3D7 to D3D3... 🔗 Source: https://www.phoronix.com/news/D7VK-1.8-Released #proton#steam

Linuxgram 🐧

@linuxgram · Post #18654 · 02.05.2026 г., 16:30

📰 Steam On Linux In April Pulled Back From Its Record High Marketshare Steam on Linux use in March had skyrocketed to 5.33%, a 3.1% boost month-over-month and easily the highest level we've seen Steam on Linux at since its inception more than a decade ago. This record growth came amid the ongoing success of the Steam Deck handheld and Steam Play (Proton) for enabling more Windows games to run well on Linux. The April numbers are in and the Linux gaming marketshare pulled back somewhat but still remaining healthy... 🔗 Source: https://www.phoronix.com/news/Steam-April-2026-Survey #linux#proton#steam

sudo recast

@sudo_recast · Post #260 · 05.06.2022 г., 19:59

#ProtonMail 啓用新的品牌名 #Proton 統一多項服務,意在構建隱私生態 https://www.wired.com/story/proton-mail-calendar-drive-vpn/ https://proton.me/news/updated-proton 新的設計風格相當輕浮。 #design

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