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

Резултати

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

Пребарај: #ama

当前筛选 #ama清除筛选
SIDUS HEROES Channel

@sidus_heroes_channel · Post #873 · 20.12.2022 г., 18:10

🗣 Attention all #AMA fans! Because of the Christmas Holiday, we will be rescheduling our session with Roman Povolotski from Dec 24 to Dec XXX.📅 🙏 We hope you'll join us for an extra special AMA session with awesome rewards! Merry Christmas! Drop your preferable date and questions in the comments - will pick new one!

Hashtags

TokenPocket

@tokenpocket_channel · Post #809 · 25.09.2023 г., 09:44

#AMA TokenPocket_TP x Owlto_Finance ⏰Sept 27th, 12:00 PM UTC 🪑 Venue: https://t.me/tokenPocket_en ✅Comment your Qs about Owlto_Finance on Twitter before the AMA ✅Join Telegram and enjoy the live AMA 🎁10 Arbitrum-Owlto NFTs to 5 best Twitter Qs & 5 best Live Qs 【Details】https://twitter.com/TokenPocket_TP/status/1706242563206742067 【Powered By】Crypto Box

Hashtags

TokenPocket

@tokenpocket_channel · Post #795 · 18.09.2023 г., 10:10

【TokenPocket Retweeted】 Retweeted TronDao_RUS : #AMA TRON DAO Россия × TokenPocket 💰Погрузитесь в призовой фонд 100USDT! ⏰20 сентября в 13:00(Московское время) 🪑Место проведения: https://t.me/tronnetworkRU ✅Следите за TronDao_RUS TokenPocket_TP 【Details】https://twitter.com/TronDao_RUS/status/1703711833079861717 【Powered By】Crypto Box

Hashtags

TokenPocket

@tokenpocket_channel · Post #648 · 20.06.2023 г., 11:51

#AMA TokenPocket x Bitstar War ⏰Jun 20th, 12:00 PM UTC 🪑 Venue: https://t.me/tokenPocket_en ✅Comment your Qs about BitstarWar on Twitter before AMA ✅Join Telegram and enjoy the live AMA 🎁$450 NFT Mystery Boxes to 5 best Twitter Qs & 5 best Live Qs https://twitter.com/TokenPocket_TP/status/1670732579077779456

Hashtags

TokenPocket

@tokenpocket_channel · Post #645 · 19.06.2023 г., 10:01

#AMA TokenPocket x Bitstar War ⏰Jun 20th, 12:00 PM UTC 🪑 Venue: https://t.me/tokenPocket_en ✅Comment your Qs about BitstarWar on Twitter before AMA ✅Join Telegram and enjoy the live AMA 🎁$450 NFT Mystery Boxes to 5 best Twitter Qs & 5 best Live Qs https://twitter.com/TokenPocket_TP/status/1670732579077779456

Hashtags

RCNN Ticker

@RCNNticker · Post #443 · 30.04.2018 г., 15:24

#AMA 5月的社群經理你問我答 (AMA) 取消,有疑問要提問的探員請將問題留待六月初的 AMA 提出 https://plus.google.com/+AndrewKrug/posts/7vF7kvzmC9a

Hashtags

Block Daily Dance & Podcast/Space List

@blockdancenews · Post #366 · 28.07.2022 г., 13:52

🎙️Block Dance 7月29日AMA/播客/线上讲座 list🎙️ ⛳️【Twitter Space】⛳️ 「SynFutures Protocol AMA with PARSIQ」 ⏰ 7:30 AM 🔗https://twitter.com/SynFuturesDefi/status/1552008014324006912 👤Hoster:SynFutures Protocol 💫Type: Web3 「History DAO AMA with Jungo」 ⏰ 8:00 PM 🔗https://twitter.com/History_DAO/status/1552571939658809344 👤Hoster:History DAO 💫Type: GameFi/Metaverse 「2000年后出生的数字世界原住民正加速涌入Web3,且看年轻人们如何搅动加密市场?」 ⏰ 8:00 PM 🔗https://twitter.com/FTX_Chinese/status/1552583784389754880 👤Hoster:FTX 中文 💫Type: 综合 「Web2.0到Web3.0的迁徙之路」 ⏰ 8:00 PM 🔗https://twitter.com/Web3Go_/status/1552489313862295552 👤Hoster:Web3GO 💫Type: Web3 「LiveArtX AMA with Avarik Saga」 ⏰ 11:00 PM 🔗https://twitter.com/avariksaga/status/1552297005309128704 👤Hoster:LiveArtX 💫Type: NFT 「Orca AMA with Star Atlas」 ⏰ 11:00 PM 🔗https://twitter.com/orca_so/status/1552018522494193666 👤Hoster:Orca 💫Type: GameFi/Metaverse ————————————- ⛳️【Telegram】⛳️ 「BOOM #AMA with @voicestreetnft」 ⏰ 6:00 PM 🔗https://twitter.com/boomapporg/status/1552218421647278081 👤Hoster:NFT 💫Type: BOOM 「LOKR AMA with its CTO」 ⏰ 10:00 PM 🔗https://twitter.com/Lokr_io/status/1551900171482664961 👤Hoster:LOKR 💫Type: Web3 ————————————- ⛳️【Discord】⛳️ 「Web3Games Community AMA: Guardians of Arcanum」 ⏰ 12:00 AM 🔗https://blog.web3games.com/ama-guardians-of-arcanum-981eca515983 👤Hoster:Web3Games 💫Type: GameFi/Metaverse 「ATTA Movie Party」 ⏰ 10:00 PM 🔗https://twitter.com/ATTA_Protocol/status/1552519827184824320 👤Hoster:ATTA 💫Type: Web3 ————————————- ⛳️【Webniar】⛳️ 「关于币安ETH2.0的一切」 ⏰ 8:00 PM 🔗https://twitter.com/binancezh/status/1552504086217383936 👤Hoster:币安 💫Type: L1/L2/crosschain 「GMA AMA with Monsterra」 ⏰ 8:00 PM 🔗https://twitter.com/G_M_Alliance/status/1552203147732750336 👤Hoster:Game Mine Alliance 💫Type: GameFi/Metaverse ————————————- 👉点击订阅谷歌日历,可及时收到AMA提示; https://calendar.google.com/calendar/u/1/r?cid=YmxvY2tkYW5jZTAxQGdtYWlsLmNvbQ 👉关注我们的Twitter:https://twitter.com/BlockDanceCN

Hashtags

Go! Announcements

@gorwachain_announcements · Post #347 · 19.02.2024 г., 21:42

#AMA Alert! 🚨 Join us on an amazing AMA, in which we'll discuss the role of real world assets tokenization and how The Go! Project is leading the next generation of RWA L1s. When? Thursday, February 22 @ 11am PST Where? https://twitter.com/i/spaces/1mrxmybeWPnxy Don't miss out!

Hashtags

UXLINK

@uxlink_community · Post #343 · 19.03.2025 г., 02:21

Fams, please join our #AMA with @RollandSaf, hosted by @bitfinex and @BitFreedomGus on March 21st 2PM UTC. Submit your question here: https://docs.google.com/forms/d/e/1FAIpQLSdxEXPefE4kApt_WAovyJQ8Jf6G8ENnlLas-9VneQ8tKhQaJA/viewform

Hashtags

Nicegram

@nicegramapp · Post #243 · 23.01.2023 г., 13:06

✅Text AMA with Nicegram CPO is starting right now! ✅ Sergey S. will provide his answers in the comments under the AMA announcement post. Drop your questions with the #AMAhashtag in the comments section below and get your answers in real time! The authors of the three most evocative questions will take home a neat reward of 20 USDT! 💰 If you don't have time to visit the AMA, don't worry! We will make a publication with all the questions and answers. You will have the opportunity to get acquainted with all the information at any time. 📝

Hashtags

Nicegram

@nicegramapp · Post #242 · 23.01.2023 г., 12:10

Hey Nicegrammers! 👌 💰 Today at 4 P.M. GMT+3 we will hold a textAMA session with Sergey S., the Nicegram CPO.The authors of the three most evocative questions will take home a neat reward of 20 USDT! ✅ Sergey S. will provide his answers in the comments under the AMA announcement post. Drop your questions with the #AMAhashtag in the comments section below and get your answers in real time! Thank you so much for being a part of our close-knit Nicegram community! 👌

Hashtags

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