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

Резултати

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

Пребарај: #pricedrop

当前筛选 #pricedrop清除筛选
Crypto M - Crypto News

@CryptoM · Post #65255 · 12.04.2026 г., 10:55

🚀 Ethereum(ETH) Drops Below 2,200 USDT with a 1.88% Decrease in 24 Hours On Apr 12, 2026, 10:55 AM(UTC). According to Binance Market Data, Ethereum has dropped below 2,200 USDT and is now trading at 2,198.01001 USDT, with a narrowed 1.88% decrease in 24 hours. #Ethereum#ETH#Crypto#USDT#Binance#CryptoNews#PriceDrop#Cryptocurrency

Crypto M - Crypto News

@CryptoM · Post #65204 · 12.04.2026 г., 01:34

🚀 Bitcoin(BTC) Drops Below 73,000 USDT with a 0.20% Decrease in 24 Hours On Apr 12, 2026, 01:34 AM(UTC). According to Binance Market Data, Bitcoin has dropped below 73,000 USDT and is now trading at 72,763.46875 USDT, with a narrowed 0.20% decrease in 24 hours. #Bitcoin#BTC#USDT#Crypto#Cryptocurrency#Binance#MarketUpdate#PriceDrop#CryptoNews

Crypto M - Crypto News

@CryptoM · Post #65307 · 12.04.2026 г., 19:51

🚀 Ethereum(ETH) Drops Below 2,200 USDT with a 5.06% Decrease in 24 Hours On Apr 12, 2026, 19:50 PM(UTC). According to Binance Market Data, Ethereum has dropped below 2,200 USDT and is now trading at 2,199.120117 USDT, with a narrowed 5.06% decrease in 24 hours. #Ethereum#ETH#USDT#Cryptocurrency#CryptoNews#Binance#PriceDrop#MarketUpdate#CryptoTrading#Blockchain

Crypto M - Crypto News

@CryptoM · Post #65286 · 12.04.2026 г., 14:44

🚀 BNB Drops Below 590 USDT with a 2.51% Decrease in 24 Hours On Apr 12, 2026, 14:43 PM(UTC). According to Binance Market Data, BNB has dropped below 590 USDT and is now trading at 589.280029 USDT, with a narrowed 2.51% decrease in 24 hours. #BNB#USDT#Binance#Crypto#Cryptocurrency#PriceDrop#MarketUpdate#Decreasing

Crypto M - Crypto News

@CryptoM · Post #65397 · 13.04.2026 г., 05:02

🚀 XRP's Social Fear Sentiment Reaches High Levels Amid Price Decline Social fear sentiment surrounding XRP has reached its third-highest level in the past two years, according to NS3.AI. The cryptocurrency has experienced a 63% decline over the past nine months. Historically, such high levels of pessimism have increased the likelihood of a rebound. #XRP#Cryptocurrency#CryptoSentiment#MarketDecline#InvestorFear#PriceDrop

Crypto M - Crypto News

@CryptoM · Post #65032 · 10.04.2026 г., 14:48

🚀 Significant NOM Transfer to Centralized Exchange Amid Price Drop On April 10, a substantial transfer of NOM tokens was observed. According to BlockBeats On-chain Detection, an address group holding at least 59% of NOM's circulating supply moved 23% of the tokens, totaling 674 million NOM, to a centralized exchange within the past hour. This transfer coincided with a 25% decline in NOM's price today. The address group is likely responsible for driving a sixfold increase in NOM's value over the past two weeks, from $0.0017 to $0.0126. On April 1, they withdrew 1.72 billion NOM from a centralized exchange using seven wallets, representing 59% of NOM's total circulating supply of 2.9 billion tokens. #NOM#centralizedexchange#tokentransfer#priceDrop#cryptocurrency#blockchain#onchain#crypto#cryptomarket#pricefluctuation#cryptotransfer

Crypto M - Crypto News

@CryptoM · Post #64789 · 10.04.2026 г., 00:04

🚀 OneFootball Club Token Faces Decline in Market Valuation The probability of OneFootball Club's fully diluted valuation (FDV) exceeding $50 million on Polymarket has dropped to 14%, marking a 51% decrease over 24 hours. According to Odaily, this decline follows the announcement made yesterday afternoon on the X platform that OneFootball Club's token, OFC, has officially launched with a current market valuation of $45 million. #OneFootball#Token#MarketValuation#FDV#Polymarket#Crypto#OFC#Web3#Blockchain#CryptoMarket#PriceDrop#ValuationDecline

Venture Village Wall 🦄

@venturevillagewall · Post #3668 · 21.12.2024 г., 13:28

Aptos Price Drop After CEO Exit Aptos' price has fallen over 25% in the last week following the departure of CEO Mo Sheikh. The project will now be led by co-founder and CTO Avery Ching, who Sheikh believes will drive the company's next growth phase. Learn more about Aptos in our educational material and read further insights in this article. #Aptos#Blockchain#Crypto#CEO#PriceDrop#MarketUpdate#Leadership#Growth#Web3#TechDirector#Investment#Decentralization#Fintech#Cryptocurrency#TechNews#Innovation#Finance#Resources#Education#Insights#News

Venture Village Wall 🦄

@venturevillagewall · Post #4328 · 07.03.2025 г., 07:00

Trump Establishes Strategic Bitcoin Reserve Former President Trump has signed an order to create a strategic Bitcoin reserve in the U.S., based on approximately 200,000 BTC confiscated by the government. This reserve will serve as a savings asset, not intended for sale, acting as a digital Fort Knox. Meanwhile, analysts indicate that governments may follow the U.S. lead, reducing the likelihood of Bitcoin bans from regulators. Post-announcement, Bitcoin saw a price drop from $91,000 to $85,000 but has since recovered to $88,000. No altcoins are currently included in the reserve plans. Full details here: Reuters #Bitcoin#crypto#Trumpr#US#Blockchain#Finance#Regulation#Assets#DigitalCurrency#Investments#Savings#Market#Trading#Reserves#Government#FTX#Securities#FortKnox#Economy#PriceDrop#StrategicReserve