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

Резултати

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

Пребарај: #communitydriven

当前筛选 #communitydriven清除筛选
UXLINK

@uxlink_community · Post #331 · 12.03.2025 г., 07:40

🚀 Big News! We’re joining forces with major DEXs to take our Web3 journey to the next level! 🌐But more importantly, YOUR voice matters. 🗳️ Cast your vote on our latest community proposal and shape the future of decentralized social platforms! Vote now 👉 [https://snapshot.box/#/s:uxlinkcommunity.eth/proposal/0xee641f312d19250357b0682604e167f4cfc259768c1c2d2aaa8e107a7feb8ffc] #UXLINK#DeFi#CommunityDriven

UXLINK

@uxlink_community · Post #543 · 11.07.2025 г., 01:30

Huge thanks to the #UXLINK global community for your support! 🎉 We’re thrilled to share that the proposal to cross-chain a portion of $UXLINK supply to @BNBCHAIN(for @PancakeSwap) passed with an 86.08% approval vote! Implementation will kick off soon, and plans for the UXLINK/USDT trading pair + official LP are already in the works. Stay tuned for updates💪 #BNBChain#PancakeSwap#CommunityDriven

ChatGPT AI Technology News

@chatgpt_officialnews · Post #20 · 28.01.2025 г., 17:01

🌟 Exciting News for Our Users! 🌟 We’ve upgraded our system with a token mechanism for seamless usage! 🎉 Here's how it works: 💡 Tokens are deducted based on the number of characters in your question and the bot’s response. 📥 Daily Bonus: Every day, you’ll receive a free token refill to keep chatting without interruptions! 💳 Recharge Options: You can now top up your balance using Telegram Stars and cryptocurrency payments (BTC, ETH, USDT, and more)! 🚀 Enjoy more flexibility and freedom with this new system. Thank you for being part of our community – stay tuned for more updates! 💬 ➖➖➖➖🔻 💎@Chatgpt_OfficialNews – Join Us! ⚡️ 🤖 BOT: @Chatgpt_OfficialBOT 📱#ChatGPT#AI#OpenAI#TokenSystem#CryptoPayments#BotSupport#CommunityDriven ➖➖➖➖🔺

UXLINK

@uxlink_community · Post #470 · 10.05.2025 г., 05:27

最近の日本Web3界隈で目立つのが、UXLINKの存在感。🇯🇵🔍 CNPとの提携を皮切りに、日本ローカルの強力なIPとの協業が加速⚡ オンチェーン/オフチェーン両方でのコミュニティ展開に加え、 Web2企業とのクロスパートナー戦略も水面下で進行中🤝 “ユーザー起点のWeb3ソーシャル”という文脈で、 UXLINKは今、日本で一番面白い動きをしているかもしれない。🚀 #UXLINK#Web3JP#CNP#ソーシャルレイヤー#CommunityDriven One of the most quietly significant players gaining traction in Japan’s Web3 scene 🇯🇵👀#UXLINK Following its recent collaboration with CNP—a top domestic IP—UXLINK is making inroads across both native Web3 communities and mainstream Web2 circles 🤝 IRL activations, on-chain social dynamics, and a clear long-term strategy signal a serious Japan play 🎯 If you're tracking the rise of social infrastructure in Asia’s Web3 movement, this is one to watch. 📡 #UXLINK#Web3Japan#CommunityLayer#CNP#Web3Social

EdgeMarket.AI 📣

@edgemarketai · Post #8086 · 31.03.2026 г., 11:54

The next layer of EdgeMarket is live. We’re introducing community validation for real world events feeding verified truth directly into AI systems. Every validation strengthens the network. Every correct signal earns rewards. ⚡ Validate events 🧠. Train AI with real data 💰 Earn $BET This is how decentralised intelligence is built. Signal Truth. Earn $BET Click Here ⬇️ To Start https://edgemarket.ai/bnb/validate-results #EdgeMarket#AI#Web3#Crypto#BET #Airdrop#EarnCrypto#SignalTruth#Validation #Decentralization#AITraining#Blockchain #CommunityDriven#OnChain#DePIN