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

Резултати

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

Пребарај: #nfts

当前筛选 #nfts清除筛选

Aqua Army is launching its first NFT project🌊 Mint 31/05/22 🚀 Release/reveal 06/06/22🧨 Aqua Army is an exclusive collection of 4,444 unique #NFTs that submerge you into a world of deep-sea adventure, purpose and collectibles living on the Ethereum network🐟 Every NFT is hand drawn with over 500+ traits over 8 sea characters living in different waters. 1 mint of 0.09ETH will clean up 300 plastic bottles from our oceans. A great portion of the proceeds will be donated to 5 non-profit based charities, who they've officially partnered with💰 Any Whitelist member will automatically be enrolled into a prize draw to WIN one of five AA NFTs 💵💵 Twitter 👇 https://twitter.com/AquaArmyNFT Join Minting👇 https://bit.ly/3NLQmgF Website & WL👇 https://aquaarmynft.com/?whitelist=true

Hashtags

​​🎙Aqua Army is launching its first NFT project🌊 Mint = 17th of May 🔥 Reveal/release = 23rd May🔥 Aqua Army is an exclusive collection of 4,444 unique #NFTs that submerge you into a world of deep-sea adventure, purpose and collectibles living on the Ethereum network🐟 Every NFT is hand drawn with over 500+ traits over 8 sea characters living in different waters. 1 mint of 0.09ETH will clean up 300 plastic bottles from our oceans. A great portion of the proceeds will be donated to 5 non-profit based charities, who they've officially partnered with💰 Any Whitelist member will automatically be enrolled into a prize draw to WIN one of five AA NFTs 💵💵 Twitter👇 https://twitter.com/AquaArmyNFT Discord👇 https://discord.com/invite/2ZnscjzSJZ Website & WL👇 https://aquaarmynft.com/?whitelist=true

Hashtags

🚀🚀The intelligent investors💯💯

@the_intelligent_investors · Post #42 · 15.12.2021 г., 15:18

Rad rabbits intensified! Sold over 1000 Rad rabbit #NFTs in less than 24 hours Last chance to get your rad rabbits with $AAA : http://radrabbbits.org 5600 #NFTs already sold Funds and projects are considering these #NFTs as bluechips Don’t miss out on these #NFTs

Hashtags

News and Tips

@NewsAndTipsNT · Post #3166 · 02.03.2025 г., 17:35

#Telegram now displays #NFTs in the profile background. You can click on them individually to view their details. Only pinned NFTs appear in the background, they appear exactly like your pinned order.

TONlines – News

@tonlines · Post #6920 · 23.04.2025 г., 17:20

TON Community: Guide to the Revival of NFTs #NFTs#Telegram The TON Community discusses the resurgence of NFTs in 2025, highlighting their integration into Telegram for easy use without wallets or gas fees. Animated stickers, digital gifts, and collectible items are now easily accessible. For more details, check their latest blog on TON NFTs. Source: link @tonlines

🏆 Premium, NFT, Tokens

@giiveaways · Post #3315 · 29.11.2024 г., 08:53

Boost Your Wins! 🏹 Complete tasks, grow your streak, and earn rewards like NFTs and TON tokens. 🎉Grand Lottery with 2,000 TON ends December 26th! 👉 Start now: https://t.me/tapps/app ➖➖➖➖➖➖➖➖➖➖➖ #NFTs#TON

Hashtags

Walken.io - Announcement

@walken_channel · Post #52 · 11.03.2022 г., 09:19

Next Monday we are releasing the beta version for the first 2000 testers on iOS. Are you excited? We definitely are! 🎉🎉🎉 P.s. you still can sign up for the whitelist on the website. $WLKN #gamefi#nfts

Hashtags

Walken.io - Announcement

@walken_channel · Post #39 · 21.02.2022 г., 14:29

Get ready for sprint🦶 A road race with a distance of 60 to 400 meters where most speed is the key. 3..2..1 - and the competition is kicked off. Just challenge a randomly selected rival and win the race😉 $WLKN #gamefi#nfts

Hashtags

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