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

Резултати

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

Пребарај: #powr

当前筛选 #powr清除筛选
Pro Analysis

@proanalysistrader · Post #28382 · 11.01.2025 г., 13:30

#POWR/USDT analysis : #POWR has successfully broken above the trendline and is anticipated to continue its upward movement, with the potential to test previous highs. This breakout signals a bullish trend, suggesting further price appreciation in the near term. TF : 1D Entry : $0.3090 Target : $0.4500 SL : $0.2270

Hashtags

Pro Analysis

@proanalysistrader · Post #28307 · 04.12.2024 г., 08:45

#POWR/USDT analysis : #POWR is currently in an uptrend, trading above the 200 EMA. The price has bounced back from the support zone with strong volume. As a result, we can expect the price to maintain its bullish momentum and test higher levels. TF : 2H Entry : $0.3500 Target : $0.4200 SL : $0.3022

Hashtags

Pro Analysis

@proanalysistrader · Post #27824 · 09.08.2024 г., 17:35

#POWR/USDT analysis : #POWR is in a correction phase and has recently tested the resistance zone near the 200 EMA. The price is anticipated to be rejected from there and continue its downward direction. Wait for the break of the $0.1936 level for entry. TF : 4H Entry : $0.1936 Target : $0.1751 SL : $0.2058

Hashtags

Crypto Australia🇭🇲🇭🇲

@CryptoAustralia · Post #15811 · 13.02.2024 г., 14:43

⚡️⚡️#POWR/USDT ⚡️⚡️ Exchanges: Binance Futures Signal Type: Regular (Long) Leverage: Cross (50х) Entry Targets: 0.3596 Take-Profit Targets: 1)0.365 2)0.3686 3)0.3722 4)0.3776 5)0.3812 6)0.3866 7) 🚀🚀🚀 Stop Targets: 5-10% By Crypto Australia

Hashtags

Crypto Profit Coach™

@cryptoprofitcoach · Post #9037 · 28.07.2024 г., 07:15

#POWR👈 https://www.binance.com/en/trade/POWR_BTC Buy at current 320-335 Highly pumpable Coin on the brink of 🚀 Buy in parts 👈strictly follow for max profits as its pump coin Sell 🤑360-380 🤑380-410 🤑 410-440 🤑 440-470 🚀 470- 500 & above Bullish above -300

Hashtags

Crypto Profit Coach™

@cryptoprofitcoach · Post #9016 · 12.05.2024 г., 12:05

#POWR👈 https://www.binance.com/en/trade/POWR_BTC Buy at current 485-495 Highly pumpable Coin on the brink of 🚀 Buy in parts 👈strictly follow for max profits as its pump coin Sell 🤑520-550 🤑 550-600 🤑 600-650 🤑 650-700 🚀 700- 750 & above Bullish above -470

Hashtags

Crypto Profit Coach™

@cryptoprofitcoach · Post #8850 · 16.09.2023 г., 17:59

#POWR👈 https://www.binance.com/en/trade/POWR_BTC Buy at current 525-540 Highly pumpable Coin on the brink of 🚀 Buy in parts 👈strictly follow for max profits as its pump coin Sell 🤑 570-600 🤑 600-650 🤑 650-700 🚀 700- 750 & above Bullish above -510

Hashtags

Crypto Profit Coach™

@cryptoprofitcoach · Post #8797 · 19.05.2023 г., 16:40

#POWR👈 https://www.binance.com/en/trade/POWR_BTC Buy at current 605-610 Highly pumpable Coin on the brink of 🚀 Buy in parts 👈strictly follow for max profits as its pump coin Sell 🤑 640-670 🤑 670-730 🤑 730-790 🚀 790- 850 & above Stop Loss/Exit -590

Hashtags

12
ПретходнаСтраница 1 од 2Следна