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

Резултати

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

Пребарај: #one

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

@CoinSonar · Post #243768 · 17.04.2026 г., 16:12

#ONE | Volume spike (USDT PAIR) 101 times the average volume 108.21K USDT traded in 5 min └Buying vol: 77.02K USDT 🟢 Boost score: 6/10 24h Vol: 306.62K USDT (Binance) Price: 0.00251 (-2.7% in 24h)

Hashtags

Pro Analysis

@proanalysistrader · Post #28291 · 30.11.2024 г., 16:00

#ONE/USDT analysis : #ONE has broken out of the trendline following a bounce from the support zone, accompanied by a strong volume candle. The price is expected to continue its bullish momentum soon and test the previous highs. A potential gain of +1100% is anticipated from the current level. TF : 1M Entry : $0.03000 Target : $0.37897 SL : $0.02100

Hashtags

Pro Analysis

@proanalysistrader · Post #27862 · 21.08.2024 г., 14:22

#ONE/USDT analysis : #ONE is currently forming a structure of higher highs (HHs) and higher lows (HLs) above the 200 EMA. The price is anticipated to sustain its momentum and reach new highs. Wait for a pullback to enter long positions. TF : 1H Entry : $0.0113 Target : $0.0122 SL : $0.0108

Hashtags

Pro Analysis

@proanalysistrader · Post #27849 · 17.08.2024 г., 15:29

#ONE/USDT analysis : #ONE is currently consolidating sideways within the support and resistance zone. At the moment, the price is bouncing off the support zone and is expected to test the resistance zone. TF : 4H Entry : $0.0104 Target : $0.0110 SL : $0.0100

Hashtags

Pro Analysis

@proanalysistrader · Post #27708 · 26.06.2024 г., 06:31

#ONE/USDT analysis - #ONE is in a downtrend making lower lows (LLs) and lower highs (LHs). The price is currently facing resistance and is expected to be rejected from there, continuing its bearish momentum to test previous lows. TF : 4h Entry : $0.0150 Target : $0.0133 SL : $0.0162

Hashtags

American Crypto©

@americancryptotrading · Post #27441 · 17.11.2025 г., 09:10

🇺🇸#ONE/USDT is bouncing off the supportzone on the weekly timeframe🧐 Looks good for the midterm✈️ American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27337 · 09.08.2025 г., 09:08

🇺🇸#ONE/USDT is currently shaping the descendingtriangle pattern on the daily timeframe👀 Looking for a recovery🚀 American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27066 · 28.11.2024 г., 17:43

🇺🇸#ONE/USDT is testing the s/r zone on 3D timeframe👨‍💻 Full send if we manage to break upwards🐃 American Crypto©

Hashtags

123•••67
ПретходнаСтраница 1 од 7Следна