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

Резултати

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

Пребарај: #frogs

当前筛选 #frogs清除筛选
Tesla Calls Official

@teslacallsofficial · Post #10006 · 14.03.2026 г., 22:17

🔥$FROGS Rolled the dice on this BSC play dip hunters know the drill: time it right, and always DYOR. X: https://x.com/christanxsx/status/2019762141427900628?s=46 🔗 Contract: https://solscan.io/token/0xC3B1A6229D9017376cF9a5Ba7a60782BD8dB4444 https://dexscreener.com/bsc/0x3357047F963d6459FB8C4e43c78392e09734e53C #FROGS#BSC#TESLACALLS

Interesting Planet 🌍

@interesting_planet_facts · Post #459 · 29.07.2025 г., 17:22

🌎 The mimic poison frog of Central America’s rainforests sports dazzling colors that copy other toxic frogs, deterring predators through clever visual deception rather than its own strong toxins. ✨ #rainforest⚡#mimicry⚡#frogs 👉subscribe Interesting Planet

Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40855 · 24.03.2026 г., 23:01

Boreal chorus frogs can make their loud, high-pitched “reeeek” calls underwater, which is rare among frogs. They are small frogs found in Canada and the northern United States, usually growing to about 3 centimeters long. Their bodies are brown, tan, or green, and they often have three dark stripes running down the back and a dark line through each eye. They live near ponds, marshes, and wetlands. Males call in groups to attract mates and warn other males. Calls are most common during the spring breeding season. 🐸🌿🌊 [Read more 1] [Read more 2] @googlefactss #Animals#Nature#Frogs#Wildlife#DidYouKnow#Communication#wednesdayfrog

Your Own Ads

@yourownads · Post #41 · 03.09.2024 г., 03:19

The Next #DOGS?! 🐸 FROGS 🐱 CATS 🐷 PIGS 🤑 BLUM 🐐 GOATS 🦆 DUCK ⭐️MAJOR 🌈These apps are similar to $DOGS. Some from them might be the next Airdrops, but nothing official announcement yet.! 🐦 Twitter 𝕏 ✔️ Follow us 💬Join Community ✔️ #aridrops#dogs#cats#frogs#pigs#blum#goats#duck#hamsterkombat

Venture Village Wall 🦄

@venturevillagewall · Post #3770 · 01.01.2025 г., 22:00

Telegram Unveils Major NFT Update 🎉 Telegram introduces a big update allowing gifts and stickers to be converted into NFTs. Gifts gain unique traits like emotions, backgrounds, and colors, enhancing their individuality and value. Rare traits will be limited to 10% of users, creating opportunities for resale at higher prices. Gifts can be converted for 25 Stars, while minting NFTs incurs network fees. Future integration with platforms like Fragment or GG is expected for seamless NFT creation. 🐸 The latest highlight is a unique frog gift gaining traction! For more details, visit: Full Update #Telegram#NFT#Gifts#Crypto#Updates#Blockchain#Stars#Minting#Fragment#GG#Frogs#RareItems#DigitalAssets#Community#Market#Trading#Tech#Innovation#SocialMedia#Engagement#CryptoTrends