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

Резултати

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

Пребарај: #tokenlaunch

当前筛选 #tokenlaunch清除筛选

🚀 Top news! 🚀 We are launching the OCRO token with guaranteed growth - the price will rise from $0.02 to $0.10 in just 90 days from June 6th! 💥 And the best part: register with our exclusive link NOW and get a $50 gift as a thank you! 🎁 🔗 *https://octario.exchange/login/register?InvitationCode=833700* Join the future of crypto with guaranteed growth and cool bonuses! Don't miss your chance - join today! 🚀✨ #Crypto#TokenLaunch#OCRO#GuaranteedGrowth#Investments#CryptoCommunity#IEO

Venture Village Wall 🦄

@venturevillagewall · Post #4168 · 16.02.2025 г., 19:00

Argentina's Opposition Eyes Impeachment Over LIBRA Argentina's opposition is considering impeachment for President Milei after conflicting support for the LIBRA token. This follows a controversial launch that saw rapid investment and then a significant drop in value, leading to accusations of mismanagement and deception. The situation raises questions about political influence in cryptocurrency projects. Read more: Reuters #Argentina#LIBRA#Crypto#Impeachment#Milei#Investment#MarketManipulation#EconomicCrisis#Blockchain#DeFi#RugPull#Politics#Cryptocurrency#TokenLaunch#InsiderTrading#Securities#AI#VC

Venture Village Wall 🦄

@venturevillagewall · Post #4003 · 27.01.2025 г., 22:00

SEC Reviews Bitcoin and Ethereum ETFs Cboe BZX proposed rule changes to SEC for ARK 21Shares Bitcoin ETF and 21Shares Core Ethereum ETF, allowing in-kind creations and redemptions. Additionally, Venice, founded by Erik Voorhees, opened its API for AI development and launched the Venice token (VVV) with airdrop to over 250k users. DARPA initiated a pre-crime AML program to combat digital asset money laundering, raising concerns over discrimination. Kucoin pled guilty to unlicensed money transmitter charges, resulting in deferred prosecution agreements. Bitcoin prices fluctuating, with recent transactions indicating notable movements. More developments in the crypto market with potential implications on broader economic issues. 📈 Current Bitcoin price: $102,000. For more: Nate Geraci, Leviathan News, Leviathan News, Leviathan News #SEC#Bitcoin#Ethereum#ETF#Crypto#AI#VC#Venice#Kucoin#AML#DARPA#DigitalAssets#CryptoMarket#Investing#MoneyLaundering#FinancialRegulation#Cryptocurrency#TokenLaunch#TechInnovation#FutureFinance#MarketTrends

Venture Village Wall 🦄

@venturevillagewall · Post #4061 · 03.02.2025 г., 22:00

Major Bitcoin Moves & New Token Launch 🔹 Bitcoin reaches $101,898. 🔹 Leviathan’s Legal-Squid-in-Residence launches new token on flaunch.gg. 5% of the supply locked with GAIB BORG. 🔹 150,000,000 #USDT transferred to unknown wallet (worth $150,040,874). 🔹 59,000,000 #USDC minted at USDC Treasury. 🔹 Senator Lummis calls President Trump’s sovereign wealth fund order a '*₿ig deal*'. 🔹 Trump reportedly purchases 86,000 ETH for $220 million amidst market fears. Stay updated for more! #Bitcoin#USDT#USDC#Crypto#Finance#WealthFund#Lummis#Trump#ETH#TokenLaunch#GAIBBORG#Investment#WhaleAlert#MarketNews#SovereignWealth#Ethereum#Flaunch#Leviathan#TraderAlert#CryptoMarket

Venture Village Wall 🦄

@venturevillagewall · Post #4104 · 09.02.2025 г., 07:00

Pumpfun Launching Token via Dutch Auction Pumpfun, a Solana-based token launch platform, plans to conduct public offerings using the Dutch auction model. The initiative has garnered interest from CEXs for system development. Reports indicate Pumpfun has earned $572M in fees and transferred $386.8M to Kraken. However, ongoing lawsuits in the U.S. may affect its token issuance plans. Details were confirmed by the WuBlockchain team and insiders. #Pumpfun#Solana#TokenLaunch#DutchAuction#CEX#Binance#HeYi#Lawsuit#CryptoNews#Finance#Blockchain#Investing#ICO#IEO#MarketTrends#Fees#Kraken#Innovation#PublicOfferings#VC#AI

Venture Village Wall 🦄

@venturevillagewall · Post #3507 · 19.12.2024 г., 15:57

Monad Ecosystem's Rising Interest The Monad blockchain ecosystem is gaining attention ahead of its launch, focusing on community engagement and innovative projects. Key highlights include: - Event: Demo day showcased 20 projects, co-hosted by Paradigm with a $750k prize pool. - Projects: Noteworthy initiatives included: - Kizzy: A mobile betting platform based on Twitter events. - Sparkball: A team strategy game soon on Steam. - LootGO: A Walk2Earn project, previously overlooked. - Pulse: A health-monitoring bracelet securing $1.8M funding. - Community and Hype: Founders cite strong community support as a major attractor to Monad. - Future Vision: Excitement surrounds Monad’s upcoming testnet and potential partnerships with platforms like TON. #Blockchain#Monad#Crypto#Web3#Gaming#Social#Fundraising#EVMcompatible#Paradigm#DemoDay#Kizzy#Sparkball#LootGO#Pulse#NEOWIZ#Ethereum#Funding#TokenLaunch#Community#Hype