@vpstuijianaaa · Post #23 · 01.11.2021 г., 14:39
#VPN#speed 【已亲测可用,下载速度5M左右,有二十多个国家线路】
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
Пребарај: #speed
@vpstuijianaaa · Post #23 · 01.11.2021 г., 14:39
#VPN#speed 【已亲测可用,下载速度5M左右,有二十多个国家线路】
@TFGames · Post #1825 · 04.01.2024 г., 18:14
#NRO#SPEED#GAMES https://testflight.apple.com/join/Yw3RBuRK
@interesting_planet_facts · Post #1189 · 03.01.2026 г., 22:11
🌎 The peregrine falcon holds the speed record for any animal on Earth. During hunting dives called “stoops,” it can reach over 320 kilometers per hour. This speed helps it catch birds in midair. ✨ #animals⚡#records⚡#speed 👉subscribe Interesting Planet 👉more Channels
@interesting_planet_facts · Post #695 · 05.09.2025 г., 20:22
🌎 The cheetah is the fastest land animal, capable of sprinting up to 112 kilometers per hour for short distances. Its slender body and long tail provide balance while chasing prey across African plains. ✨ #animals⚡#speed⚡#records 👉subscribe Interesting Planet
@wildthemestelegram · Post #1014 · 24.01.2024 г., 12:00
White Car #black #gray #white #car #speed #light ᅠ𝐖𝐢𝐥𝐝 𝐓𝐞𝐥𝐞𝐠𝐫𝐚𝐦 𝐓𝐡𝐞𝐦𝐞𝐬 ᅠ═──═⌘═──═ᅠ
@wildthemestelegram · Post #1026 · 26.01.2024 г., 10:00
Orange Car #black #gray #orange #car #dark #night #speed #art ᅠ𝐖𝐢𝐥𝐝 𝐓𝐞𝐥𝐞𝐠𝐫𝐚𝐦 𝐓𝐡𝐞𝐦𝐞𝐬 ᅠ═──═⌘═──═ᅠ
@interesting_planet_facts · Post #589 · 19.08.2025 г., 16:22
🌎 Some bamboo species can grow up to 91 centimeters in a single day, making bamboo one of the fastest-growing plants on Earth. This rapid growth helps bamboo quickly regenerate after being harvested and provides vital habitats for many animals. ✨ #botany⚡#speed⚡#ecosystems 👉subscribe Interesting Planet
Hashtags
@wildthemestelegram · Post #969 · 18.01.2024 г., 10:00
Sport Car #black #gray #biege #yellow #road #speed #car ᅠ𝐖𝐢𝐥𝐝 𝐓𝐞𝐥𝐞𝐠𝐫𝐚𝐦 𝐓𝐡𝐞𝐦𝐞𝐬 ᅠ═──═⌘═──═ᅠ
@cosmomyst · Post #222 · 04.09.2025 г., 20:11
🪐 The pulsar PSR J1748−2446ad in the globular cluster Terzan 5 holds the record as the fastest-spinning known pulsar, rotating an astonishing 716 times per second. Pulsars are ultra-dense neutron stars that emit narrow beams of radiation, and this particular cosmic beacon spins so rapidly that its surface moves at about a quarter of the speed of light. ✨ #pulsars⚡#neutronstars⚡#speed⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries
@interesting_planet_facts · Post #524 · 08.08.2025 г., 20:22
🌎 Lightning-fast, the peregrine falcon dives at up to 320 km/h, making it the fastest animal on Earth. Specialized nostrils and strong muscles let it hunt mid-air with pinpoint accuracy. ✨ #falcon⚡#speed⚡#wildlife 👉subscribe Interesting Planet
@Wallpaper_INT · Post #47346 · 20.12.2025 г., 15:35
#Set#Car#Tunnel#Speed#Red#8K @Wallpaper_INT
@Wallpaper_INT · Post #46480 · 28.05.2025 г., 16:30
#Cars#Road#Race#Speed#8K @Wallpaper_INT