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

Резултати

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

Пребарај: #uk

当前筛选 #uk清除筛选
Ultimora.net - POLITICS 24

@Ultimorapolitics24 · Post #52178 · 12.03.2026 г., 10:33

🇬🇧#UK - Il parlamento ha approvato in via definitiva una legge per eliminare i 92 “membri ereditari” della Camera dei Lord, la camera alta del parlamento. È una decisione storica che metterà fine a una consuetudine che durava da più di 700 anni. (ilPost) @UltimoraPolitics24

Hashtags

My Lifeguard

@lifegaurdhelp · Post #40010 · 30.04.2026 г., 06:55

🇬🇧#UK Trump has been at the center of discussion due to a breach of protocol. British social media is discussing an incident in which US President Donald Trump walked past Queen Camilla to shake hands with his acquaintances, which was considered a breach of protocol.

Hashtags

🇬🇧#UK. Armed police spotted outside a McDonald's in Kensington. Armed Police arresting a suspect outside McDonald's. Armed response was deployed due to intelligence suggesting high risk,possible weapon or violence, it's standard UK protocol for public safety. Police haven't released specifics on the exact reason or threat yet, as it's an active investigation. (By the looks of one of those green dots, someone has had far too much coffee.) Follow us -> LiveLeak

Hashtags

White House Watch

@WhiteHouseWatch · Post #17749 · 28.02.2026 г., 11:21

#UK: Il Regno Unito ha affermato che non parteciperà alle operazioni militari contro l'Iran, anche se il governo si è espresso in supporto agli obiettivi dichiarati dagli USA e Israele.

Hashtags

MessageInABottle

@mib_messageinabottle · Post #7070 · 08.08.2024 г., 22:02

🇬🇧The Psychological Attack on the UK, Part 2 | UKColumn - 2021 If Bezmenov had been correct in just one or two of his predictions, then we might assume that coincidence was at work. In reality, he was correct in all of his predictions. Common sense therefore tells us that the plan he describes must be both real and effective. And that plan ultimately leads from 'Demoralisation' to 'Destabilisation', to 'Crisis' (Chaos) and then 'Normalisation' — so-called 'peace' (actually pacification) under a socialist/communist dictatorship of global scale. In Part 2 as we tackle the key subversively targeted area of Security (covering the intelligence community, police and military), but first we address the demoralising and destructive plans detailed for Law and Order and Social Relations. To recap, the following descriptive paragraph sets out the key warning within Story's highly detailed and meticulously researched book: The European Union Collective Enemy of its members states @ukcolumn@EastApp #UK

Hashtags

MessageInABottle

@mib_messageinabottle · Post #7069 · 08.08.2024 г., 22:02

🇬🇧The Psychological Attack on the UK: Start of a Series | UKColumn – 2021 Alex Thomson and Brian Gerrish discuss the origins of the psychological attack on the UK in the first part of a series. Our starting documentation and analysis centres on the book by Christopher Story: The EU Collective - Enemy of its Members States. @ukcolumn@EastApp #UK

Hashtags

POPULAR FRONT

@popularxfront · Post #6272 · 16.05.2026 г., 15:20

🇬🇧#UK: Footage shows tens of thousands of protesters marching through London as two rival demonstrations, the “Unite the Kingdom” rally and a large pro-Palestine march, take place simultaneously across the capital. According to police, at least 11 people have been arrested since the demonstrations began.

Hashtags

POPULAR FRONT

@popularxfront · Post #6262 · 15.05.2026 г., 17:12

🇬🇧#UK: London is preparing for one of its largest public order operations in recent years as two major demonstrations, the pro-Palestine “Nakba Day” march and the “Unite the Kingdom” rally organised by Tommy Robinson, take place simultaneously this weekend in central London, alongside the FA Cup Final. For the first time in a protest policing operation in the UK, live AI facial recognition will be used alongside aerial surveillance employing helicopters and drones, as well as armoured vehicles and large-scale specialist policing units deployed across the capital. Around 4.000 officers will be involved in the operation, with reinforcements from forces across England and Wales, as authorities reportedly prepare for "significant public order risks" across multiple protest routes. (via Reuters & BBC)

Hashtags

123•••10•••2021
ПретходнаСтраница 1 од 21Следна