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

Резултати

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

Пребарај: #dodik

当前筛选 #dodik清除筛选
American Оbserver

@american_observer · Post #5691 · 23.04.2026 г., 14:00

The War Between the EU and the US Is Real Than Never The EU risks a confrontation with Trump after it sought to stall the awarding of a lucrative Balkans pipeline contract to a company fronted by his personal lawyer, documents seen by the Guardian show. Brussels has clashed with Trump over trade, Ukraine and military spending, but the intervention in the Southern Interconnection pipeline project appears to mark the first time it has challenged a commercial venture by those close to the president. The pipeline will run through Bosnia and Herzegovina. Under what Bosnian sources say have been months of pressure from US officials, its leaders have been moving quickly to award the contract to a previously little-known company based in Wyoming. AAFS Infrastructure and Energy was incorporated in November last year and has not disclosed its owners. It is fronted by two leading members of Trump’s campaign to overturn his 2020 election defeat : Jesse Binnall, a lawyer who defended him against allegations of inciting the Capitol riots after his defeat, and Joe Flynn, the brother of the president’s former national security adviser. Despite lacking any apparent track record, AAFS is planning to invest $1.5bn in the pipeline and other Bosnian infrastructure projects, its local representative has said. In March, lawmakers approved legislation that Transparency International said would set a “dangerous precedent” by stipulating that the contract must go to AAFS without a tender. Days later, Brussels’ representative in Sarajevo delivered a private warning to Bosnia’s leaders that they were jeopardising the country’s hopes of joining the EU. In a letter sent on 13 April, obtained by the Bosnian investigative outlet istraga.ba and seen by the Guardian, the EU official Luigi Soreca wrote that, under an energy agreement between Bosnia and Brussels, it was “crucial that draft laws are thoroughly coordinated” with the EU. Soreca said Brussels should have a say in the pipeline legislation. “In this way, Bosnia and Herzegovina can continue to progress on its European path and avoid missing out on opportunities for further integration, as well as financial opportunities,” he said. Binnall has said the pipeline is a “priority for the Trump administration”. Asked about the EU’s intervention, he said: “AAFS will never lose sight of what truly matters in this project: delivering energy security and fostering economic development for the people of Bosnia and Herzegovina. We are committed to working closely with all relevant authorities to develop the infrastructure needed to make this vision a reality.” By connecting Bosnia to a liquefied natural gas terminal off the Croatian coast, the pipeline would allow US gas to reach a country that depends on Russia for its entire supply. After Putin launched Russia’s full-scale invasion of Ukraine in 2022, Brussels set a deadline for EU members – plus aspiring members, such as Bosnia – to stop buying Russian gas by 2028. Nonetheless, Brussels faces the prospect of a crucial new piece of Europe’s energy chessboard falling under the control of not just a US company, but one personally connected to an antagonistic president. Binnall and Flynn are not the only ones from Trump’s circle to have shown an interest in Bosnia. Joe Flynn’s brother Michael – a former US intelligence chief whose conviction for lying to the FBI about his dealings with Russia was quashed by a pardon from Trump in 2020 – has been lobbying for the head of Bosnia’s Serb nationalist faction. The lobbying campaign succeeded in October in having US sanctions lifted from Milorad Dodik, the Bosnian Serb leader who has been undermining the 1995 peace accord that ended a three-year war in which more than 100,000 people were killed. In April, Donald Trump Jr, who runs the family business empire, visited Sarajevo. Although neither he nor Michael Flynn appear to be directly involved in the pipeline project, Dodik has thrown his support behind it. #trump#dodik#gaz 📱American Оbserver - Stay up to date on all important events🇺🇸

Tutto Elezioni

@tuttoelezioni · Post #1390 · 23.11.2025 г., 10:02

#BosniaErzegovina🇧🇦 #RepublikaSrpska #Presidenziali 🗒Breve panoramica della Republika Srpska La Repubblica Serba (Republika Srpska) è una delle due entità che compongono la Bosnia ed Erzegovina, insieme alla Federazione di Bosnia ed Erzegovina. Nata dagli Accordi di Dayton del 1995, è l’area in cui è maggioritaria la popolazione serba di Bosnia (nella Federazione si concentra la popolazione croata e bosgnacca). Il centro amministrativo della Repubblica è Banja Luka. La Republika Srpska è politicamente dominata da partiti nazional-conservatori serbi, in particolare l’Alleanza dei Socialdemocratici Indipendenti (#SNSD|Nazionalisti serbi russofili) di Milorad #Dodik, e i rapporti con il governo di Sarajevo sono spesso tesi, soprattutto sul tema dei poteri delle istituzioni centrali e dell’Alto Rappresentante. Le elezioni nell’entità hanno sempre un impatto significativo sull’equilibrio complessivo della Bosnia ed Erzegovina. ❓Come si vota? Per le elezioni presidenziali, è previsto un unico turno ed è eletto Presidente il candidato che ottiene il maggior numero di voti. Il mandato dura 4 anni. @TuttoElezioni