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

Резултати

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

Пребарај: #ogn

当前筛选 #ogn清除筛选
Coin Sonar

@CoinSonar · Post #243848 · 17.04.2026 г., 21:36

#OGN | Volume spike (USDT PAIR) 119 times the average volume 109.63K USDT traded in 5 min └Buying vol: 74.11K USDT 🟢 Boost score: 7/10 24h Vol: 263.92K USDT (Binance) Price: 0.0243 (-1.7% in 24h)

Hashtags

Coin Sonar

@CoinSonar · Post #243729 · 17.04.2026 г., 15:04

#OGN | Volume spike (USDT PAIR) 523 times the average volume 95.96K USDT traded in 1 min └Buying vol: 65.78K USDT 🟢 Boost score: 8/10 24h Vol: 263.92K USDT (Binance) Price: 0.0246 (-1.7% in 24h)

Hashtags

Coin Sonar

@CoinSonar · Post #243481 · 17.04.2026 г., 06:30

#OGN | Volume spike (USDT PAIR) 117 times the average volume 107.72K USDT traded in 5 min └Buying vol: 66.46K USDT 🟢 Boost score: 5/10 24h Vol: 263.92K USDT (Binance) Price: 0.0236 (-1.7% in 24h)

Hashtags

Pro Analysis

@proanalysistrader · Post #28527 · 08.03.2025 г., 16:29

#OGN/USDT analysis : #OGN is currently in a downtrend, trading below the 200 EMA. The price has broken and retested the support zone, suggesting a continuation of the bearish momentum and a potential drop to lower levels. For short entry, look for a pullback. TF : 2H Entry : $0.0653 Target : $0.0600 SL : $0.0690

Hashtags

Pro Analysis

@proanalysistrader · Post #28345 · 17.12.2024 г., 13:33

#OGN/USDT analysis : #OGN is in an uptrend, making higher highs (HHs) and higher lows (HLs) above the 200 EMA. Currently, it’s consolidating over the 200 EMA, which suggests a potential bounce back and continuation of the bullish momentum. Watch for a breakout above the $0.1460 level to enter a long position, as this will lead to testing previous highs. TF : 4H Entry : $0.1460 Target : $0.1700 SL : $0.1300

Hashtags

Pro Analysis

@proanalysistrader · Post #28281 · 28.11.2024 г., 15:03

#OGN/USDT analysis : #OGN is currently in a downward slope, consistently forming lower lows (LLs) and lower highs (LHs). The price is anticipated to continue its bearish momentum and may test the previous swing low. TF : 15min Entry : $0.1242 Target : $0.1201 SL : $0.1270

Hashtags

Pro Analysis

@proanalysistrader · Post #27933 · 14.09.2024 г., 15:14

#OGN/USDT analysis : #OGN has broken out above previous highs and the 200 EMA, currently finding support above these levels. The price is expected to bounce off from this support and continue its bullish momentum to test previous highs. TF : 1H Entry : $0.0854 Target : $0.0937 SL : $0.0800

Hashtags

American Crypto©

@americancryptotrading · Post #27300 · 03.07.2025 г., 08:44

🇺🇸#OGN/USDT is printing the descendingresistance line on the daily timeframe👨‍💻 A breakout is coming✈️ American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27118 · 12.01.2025 г., 17:04

🇺🇸#OGN/USDT is consolidating within the descendingtriangle on the weekly chart🧐 Looking for a leg upwards✈️ American Crypto©

Hashtags

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