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

Резултати

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

Пребарај: #cycles

当前筛选 #cycles清除筛选
Amazing Geography 🌍

@amazingeo · Post #459 · 17.11.2025 г., 12:31

🌍 Each year, vast dust storms from the Sahara cross the Atlantic, carrying nutrients that fertilize the Amazon rainforest. This airborne soil links continents in a natural, global recycling process. ✨ #cycles⚡#atmosphere⚡#continents⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #70 · 18.08.2025 г., 09:12

🌍 The global carbon cycle constantly moves carbon between the air, land, water, and living things. This cycle helps regulate Earth’s climate by storing and releasing carbon dioxide. ✨ #carbon⚡#climate⚡#cycles⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography🌍

Amazing Geography 🌍

@amazingeo · Post #548 · 31.12.2025 г., 20:31

🌍 Some lake water can take hundreds of years to fully circulate from the surface to the deepest layers and back again, creating slow, hidden water cycles that influence local climates and ecosystems. ✨ #hydrology⚡#lakes⚡#cycles⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #265 · 19.09.2025 г., 13:12

🌍 Earth’s tides are driven mostly by the Moon’s gravity, causing oceans to rise and fall all over the globe. These constant movements help mix ocean waters and shape coastal ecosystems. ✨ #tides⚡#ocean⚡#cycles⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography🌍 ​

Amazing Geography 🌍

@amazingeo · Post #384 · 17.10.2025 г., 18:31

🌍 Earth’s magnetic field flips direction every few hundred thousand years, a process called geomagnetic reversal. These flips are recorded in volcanic rocks and help scientists trace ancient geologic changes. ✨ #geomagnetism⚡#volcanism⚡#cycles⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

PRICE ACTION EXPERT

@priceactionexpert · Post #7663 · 03.08.2024 г., 16:38

https://x.com/priceactiongann/status/1819774789399224477 #nifty#nifty50#stocks Price and Time Relation: strong connection and cycle of 144 and 108 or 1440 and 1080 Nifty low of march 24 , 2020 = 7511 price Nifty all time high august 1 2024=25078 price price moved from low to high or total range from low to high is 17567 #trading Price 17567/144= 122 #priceaction 122x144=17658 Time taken to reach is 1081 bars and 1591 days 1080 trading days or bars to reach from low to high 1080/144=7.5 1080/1440=.75 17657 is price moved and 1081 is time taken 2.177860006167129 17657/1081 =16.33395004625347(163) 16.33395004625347/7.5 =2.177860006167129(216 or 217) 2.177860006167129x5 =10.88930003083565(108 or 1080) 1080 or 1081 days to reach from low to high! #Stocks 90 years cycle the great cycle is 90x12 =1080 months 18x60(great cycle) = 1080 circle 360 =3 (holytrinity)x360 =1080 3x3x3= 27 27x4 =108 108/3=36 666=6x6x6 also 108 is 18 degree cancer 108 is half of 216 (144 + 72) and its 1/4 of 432 #numerology#financialastrology#astrology 1080/666=1.62 If this post gets 108 likes and 108 comments i will post more calculations 1080/666=1.62 #time#price one important cycle about above number and how it connects to nifty high it will deal with other number like 555,666,777 etc. more u will get in that too once reaches 108 likes and 108 comments here. #stockmarket#stockmarketcrash#economy#timecycle#pricecycle#gann#cycles https://x.com/priceactiongann/status/1819774789399224477