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

Резултати

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

Пребарај: #uxuy

当前筛选 #uxuy清除筛选
Airdrop Center

@centralchanel · Post #16337 · 30.01.2025 г., 04:56

➡️ UXUY Wallet ✅ PLAY NOW: https://t.me/UXUYbot/app?startapp=A_452308012_inviteEarn Invested by BinanceLab 👈 Ends on January 10 ⛔️ $10.2M in funding successfully raised 🟢 1️⃣Securely store your private key 2️⃣Complete all tasks 3️⃣ Claim rewards every 3 hours 👍 UXUY: Don’t forget to back up your seed phrase! ❓ "Not your keys, not your crypto!" 👉 The Seed Phrase Backup Task is live! Complete the backup and claim your reward of 800 $UP! #UXUY

Hashtags

🪙UXUY Wallet: Mysterious Airdrop When? TOMORROW, March 11, the project on Binance Labs investments #UXUY Wallet launches distribution, but there is an important condition: ✅UXUY wallet in Telegram needs to be created today!🔥 What needs to be done? ✔️ Hurry up to create a wallet before March 11 00:00 UTC. ✔️ Tell your friends — let them get a drop too! ✔️Follow the news! ☝️Create UXUY wallet now!

Hashtags

UXLINK

@uxlink_community · Post #18 · 31.10.2024 г., 03:10

🥰Good morning fams! We are pleased to announce that UXLINK Mini App is live on LINE , now invite your friends on Line to join #UXLINK can get 10,000,000 #UXUY points reward! In UXLINK's "One Account, One Gas" roadmap, $UXLINK will be the universal gas token for users who interact with different blockchains, and LINE and Kakao Talk will be important pillars of social platforms, will keep build and keep our community updated.

Hashtags

Super Airdrop from UXUY Wallet #UXUY, incubated and supported by 🤑 Binance Labs, is launching the 2025 UXUY Points ($UP) #Airdrop! 🗓️ Dec 27, 2024 — Jan 10, 2025 How to join? Invite three or more friends using your unique referral link ✅Go to the UXUY Earn Center ✅ Click on Tasks ✅ Complete them to earn UXUY Points ($UP) 🎁Join the event now and earn 2,025 $UP per user!

🔠🔠2025 New Year Special Airdrop Event ends in just 2 days! 🔣 Users who successfully invite 3 friends during the event period (December 27, 2024 — January 10, 2025) will receive an exclusive bonus of 2,025 $UP! 🔠🔠 Don’t miss out — get in there and rack up more $UP before it’s over! #UXUY#wallet#airdrop

UXUY Wallet: Redefining Cross-Chain DeFi UXUY is a platform (wallet and DEX) that provides tools and solutions for DeFi, focusing on multi-chain transactions and interoperability. The main focus of the project is to facilitate the process of exchanging assets between different blockchains (cross-chain), with an emphasis on security, speed and convenience. The project raised $10.2M in a funding round from well-known funds such as Binance Lab, KuCoin Ventures, MEXC and others. Key features of UXUY: 1. Multi-chain compatibility: The platform supports interoperability between multiple blockchains, including Ethereum, BNB Chain, Polygon, Arbitrum, Avalanche and 🤑 TON. 2. Decentralization: Users retain full control over their assets as transactions are conducted directly through smart contracts, eliminating intermediaries. 3. Intuitive Interface: UXUY is focused on making DeFi easier for users, including a simplified asset exchange process. 4. Focus on Security: State-of-the-art security mechanisms, including multi-layered transaction verification architecture, are used to protect user funds. UXUY Wallet Token – $UP The $UP token is a key element of the UXUY ecosystem. It will be used to pay exchange fees, provide access to premium platform features, serve as collateral in staking programs, and will also become a tool for DAO governance. The reward program has allocated 100 million UP, which will be distributed among the most active UXUY Wallet users. 🎁Complete tasks in the mini-app #uxuy#dex#airdrop#binance

Airdrop Center

@centralchanel · Post #15668 · 27.12.2024 г., 17:27

#Reminder UXUY WALLET 💎A project followed and supported by #Binance laps. 👀It has received high investments and its infrastructure is solid. The listing will probably not be extended. It conflicts with the logic of Claim Every 3 Hours. Link:⤵️ JOIN NOW https://t.me/UXUYbot/app?startapp=A_452308012_inviteEarn ⛏#uxuy#wallet#binancelaps

Airdrop Center

@centralchanel · Post #15821 · 04.01.2025 г., 20:20

January Listing 🔥 ✅#Nodepay: 6 January ✅#MomoAi: 6 January ✅#Xterio: 8 January ✅#Sidekick : 8 January ✅ $Vertus :13 January ✅#Seed : 15 January ✅#Xcoin : 20 January ✅#Tapswap : 23 January ✅#Wcoin : 25 January ✅#CommunityGaming : 28 January Unofficial Listing ✅#PAWS ✅#UXUY ✅#Yuligo ✅#MemeWar ✅#DuckChain ✅#Celia Stay connected