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

Резултати

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

Пребарај: #blackwinter

当前筛选 #blackwinter清除筛选
Red Nile

@rednile12 · Post #10459 · 23.12.2025 г., 16:53

🔺Continuation from above @rednile12 🌍 Key Themes 1️⃣ Impending Crisis & Imperialism The “Black Winter” represents a deliberate destabilization of West Africa—akin to an “Arab Spring” engineered for the region. Traoré warns of wars, terrorism, and economic predation orchestrated by imperial powers: “My conviction, my analysis, is clear: something is happening in West Africa. I have called it the Black Winter. The Black Winter is coming. It will be a very cold winter. A bloody winter. A deadly winter. You will ask me why. Winter will come because war is spreading in West Africa. The imperialists are doing everything they can to plunge the region into fire and bloodshed. We risk killing each other in horrific ways while others stand ready to plunder our resources and impose their will. And those who survive this tragedy will have only two choices: unite definitively against imperialism or remain enslaved until they perish.” 2️⃣ Internal Sabotage & Division Traoré criticizes Africans who undermine collective defense: “By founding the AES Confederation, we anticipated this icy winter. Every day, we search for wood to light a fire—a fire that will warm the hearts, minds, and souls of Africans. We hunt wolves to use their pelts to make coats. We build mountains—solid and powerful mountains—to break the icy winds. But unfortunately, some of our own are determined to sabotage this effort. They are dousing the tree trunks with water to prevent the fire from burning. They transform into wolves so that hunters cannot catch them. They break rocks to prevent the building of mountains. We cannot accept that cowardly heads of state hide behind so-called 'free' media to discourage, insult, and incite hatred among the people. They are vile, spreading hatred daily on social media. Why do we Black people cultivate hatred among ourselves?” 3️⃣ Pan-Africanism & Unity The speech challenges the continent to reflect on its solidarity: “And when winter arrives, those who fought will come seeking refuge. They will want to wear the coats we have made, take shelter behind the mountains we have built, and warm themselves by our fire. So the real question is this: What will become of Pan-Africanism when winter arrives? Why are we unable to see the danger approaching? Why can't we unite to stop it? Let them be certain of one thing: we are united and we will remain so. No manipulation can divide us.” 4️⃣ Self-Reliance & Sovereignty Traoré frames AES institutions—like BCID-AES Bank and AES TV—as proactive defenses against the crisis: “Everything will not be perfect. Everything will not progress at the pace we would like. But we are moving forward—calmly, resolutely—and we will achieve our goal. We pray for protection if winter must come, because through it, we will achieve freedom and unity.” 🗣 Rhetorical Style ▪️Metaphor & Allegory: “Black Winter” for isolation, bloodshed, and death. ▪️Repetition & Urgency: “Winter is coming” evokes inevitability. ▪️Direct Address & Inclusion: “You will ask me why… we” fosters solidarity. ▪️Contrast of Alarm & Hope: Harsh words (“vile,” “miserable”) versus affirmations of unity. Traoré’s style mirrors Thomas Sankara, blending militaristic charisma with Pan-African inspiration. 📌 Context & Impact ▪️Delivered as AES evolved into a full confederation post-ECOWAS withdrawal, the speech reinforces sovereignty amid jihadist threats, sanctions, and Western influence. ▪️Signals defiance and appeals to non-Western partners, while naming internal “saboteurs” risks polarizing some factions. ▪️Positions Traoré as a visionary Pan-African leader, galvanizing anti-imperialist sentiment across the continent. 🔴 Follow @rednile12 for Geopolitical updates #BlackWinter#AESConfederation#PanAfricanUnity#WestAfrica#AntiImperialism#SelfReliance#RedNileMedia#Geopolitics#AfricaRising