@wal_pep · Post #307 · 05.03.2025 г., 21:42
#Clouds #4K
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
Пребарај: #clouds
@wal_pep · Post #307 · 05.03.2025 г., 21:42
#Clouds #4K
@NatureTravelVacationPictures · Post #1201 · 13.05.2019 г., 06:30
🌿❤️✨🍃 Perfect Timing📸 #Scenery#Nature#Clouds 💁Join Us ✅🔜@Discover_Nature 🍃🍃🍃🍃🍃🍃🍃🍃🍃🍃🍃🍃🍃
@NatureTravelVacationPictures · Post #1346 · 23.05.2019 г., 00:30
🌿🍁🍃 #Clouds#Mountains#Nature 💁Join Us ✅🔜@BillionaireHomes 🍃🍃🍃🍃🍃🍃🍃🍃🍃🍃🍃🍃🍃
Hashtags
@depthwallpaper · Post #167 · 24.12.2022 г., 07:47
Hi-Res. Source: iSpazio #hres#mountain#clouds
@depthwallpaper · Post #811 · 11.07.2025 г., 20:51
Hi-Res ☁️ #hres#clouds#art
@amazingeo · Post #587 · 22.01.2026 г., 20:31
🌍 Polar stratospheric clouds, also known as nacreous clouds, shimmer with pastel colors and only form in extremely cold conditions. They set the stage for both rare atmospheric optics and ozone loss. ✨ #aurora⚡#clouds⚡#atmosphere⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels
@amazingeo · Post #511 · 13.12.2025 г., 12:31
🌍 The highest clouds on Earth are called noctilucent clouds. They glow at twilight and form up to 85 kilometers above ground, in the edge of space—far higher than any weather clouds. ✨ #meteorology⚡#clouds⚡#atmosphere⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels
@interesting_planet_facts · Post #519 · 08.08.2025 г., 00:22
🌎 The horseshoe vortex, or “smoke ring” in the sky, is a rare weather phenomenon where winds sculpt swirling, donut-shaped clouds. These dramatic rings form after volcanic eruptions, industrial blasts, or even lightning, showcasing nature’s surprising ability to twist air into geometric shapes. ✨ #atmosphere⚡#clouds⚡#weather 👉subscribe Interesting Planet
Hashtags
@IOSTelegramThemes · Post #706 · 07.11.2025 г., 14:48
#Wallpaper #background #Nature #clouds ☆𝗝𝗼𝗶𝗻 𝗶𝗣𝗵𝗼𝗻𝗲𝘀
@Wallpaper_INT · Post #46787 · 08.07.2025 г., 17:30
#Astronaut#Clouds#Aesthetic#4K @Wallpaper_INT
Hashtags
@IOSTelegramThemes · Post #674 · 20.10.2025 г., 14:48
#Wallpaper #background #AIphoto #clouds ☆𝗝𝗼𝗶𝗻 𝗶𝗣𝗵𝗼𝗻𝗲𝘀
@cosmomyst · Post #84 · 05.08.2025 г., 13:11
🪐 In the atmosphere of the giant planet Neptune, astronomers have discovered clouds of methane ice drifting in bands, creating ghostly streaks against the blue background. These shimmering clouds form when sunlight breaks apart methane gas and turns it into icy crystals high above the planet’s swirling, windy storms. ✨ #Neptune⚡#planets⚡#clouds⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries