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

Резултати

Пронајдени 1,312 слични објави

Пребарај: #airdrop

当前筛选 #airdrop清除筛选
Legit Airdrop ❤️

@legit365airdropss · Post #36069 · 02.03.2026 г., 12:53

✉️Konnex Airdrop 🔸Reward: Confirmed ✅Register: https://hub.konnex.world/points?referral_code=AP40WF8P 🔸Connect Wallet 🔸Complete Tasks 🔸Done #Airdrop

Hashtags

Legit Airdrop ❤️

@legit365airdropss · Post #36046 · 27.02.2026 г., 06:28

✉️Konnex Airdrop 🔸Reward: Confirmed ✅Register: https://hub.konnex.world/points?referral_code=AP40WF8P 🔸Connect Wallet 🔸Complete Tasks 🔸Done #Airdrop

Hashtags

Airdrop Center

@centralchanel · Post #17289 · 17.05.2025 г., 19:24

📢 L1 project has $8,000,000 investment @pharos_network Let's be early for the approved #airdrop with the Testnet of the project! 💰 Cost: $0 ⌛️ Duration: 5 min. Take your place for this approved airdrop with our guide! 👇 📝 Airdrop transactions We will directly do the Testnet transactions of the project. 👇 🔗https://testnet.pharosnetwork.xyz/experience?inviteCode=0r2VJZpIPZ3Q84hh ➤ Connect your wallet with the Connect Wallet button and approve the addition of the testnet network. ➤ Scroll down on the homepage and complete the social tasks by connecting your social media accounts by pressing the follow button first. ➤ Then click on the Home button from the top left and scroll down to get test tokens from the faucet. ➤ Return to the Experience tab again and this time complete tasks such as Swap, adding liquidity (connect the wallet on the websites it directs and perform transactions from the relevant headings.) ➤ Leave the wallet you used for the testnet in the comments and let's send each other test tokens to complete the 3rd task. ➤ Finally, share your own invite links with friends.

Hashtags

Airdrop Center

@centralchanel · Post #16502 · 10.02.2025 г., 07:55

💵 Mevvynetwork Waiting List 💥A total of $2,800,000 investment was received. Join the project's waitlist and take your place for #airdrop now! 💥We will quickly join the project's waitlist and take our place as early birds. → Registration: https://mevvynetwork.com/waitlist?referralCode=dxan1dx&refSource=copy → Enter your e-mail address and confirm → Click the Join waitlist button and invite friends with your own invitation link

Hashtags

Airdrop Center

@centralchanel · Post #16016 · 13.01.2025 г., 10:18

🪂 High Potential Airdrop - Bubblemaps 🪂 Quickly take your place for #airdrop with the transactions of the @bubblemaps project that we use to follow smart money! 🚀 Cost: $0 💰 Duration: 5 Sec. ⌛️ 📝 Airdrop Transactions The project has started a waitlist, let's join quickly and take our place early. → First, go to bubblemaps.io/waitlist. → Then leave your email address. → Press the pink arrow button and send. ✔️ That's all the transactions. Don't forget to follow the official X account of the project! With our guide above, you have positioned yourself early for the approved airdrop!

Hashtags

🎁Airdrops Info🎁

@crypdrops · Post #9304 · 22.10.2024 г., 18:36

Probably making $0 Transaction narratives might get started fully on @ton_blockchain Soon! Get started with this #Airdrop before others jump to this narratives on $Ton! Introducing @keyytton#Airdrop! 📌Send 0 TON to the wallet address below 👇 UQB0ZszlqU7eabz_dyYfIAKsZ0F-U8b4iwJ1cTuePWIqipjA for the $KEY $Airdrop. 🔓 your reward in November. Season 1 ends on November 1st & TGE. Noted: Don't connect your wallet just send 0 Ton. Enjoy!

Hashtags

123•••100•••109110
ПретходнаСтраница 1 од 110Следна