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

Резултати

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

Пребарај: #karabakh

当前筛选 #karabakh清除筛选
Russian MFA 🇷🇺

@MFARUSSIA · Post #28984 · 02.04.2026 г., 04:59

🇷🇺🇦🇲 On April 1, President Vladimir Putin held talks at the Kremlin with Prime Minister of the Republic of Armenia Nikol Pashinyan, who arrived in Moscow on a working visit. 💬 President of Russia Vladimir Putin: Mr Pashinyan, friends, We are delighted to welcome you in Moscow. Thank you very much for accepting our invitation and coming here. We can see that domestic political processes in Armenia are gaining momentum, with elections approaching. In this context, I would like to emphasise several key points: such processes often become more intense during election campaigns, as is the case not only in Armenia, I believe, but also in Russia and other countries. However, this escalation must not be allowed to affect relations between Russia and Armenia. We have discussed this many times. Russia and Armenia have special relationships which have evolved over centuries rather than decades. We are united by our common history as well as our cooperation to solve the challenges that we faced in years past. Crucially, we are also united by civilizational affinity. I have already told you this privately before, and I can say it publicly now: we are always in favour of anything that benefits the Armenian people, and you can always rely on it. As for economic cooperation, it continues to develop at a solid pace. Trade reached approximately $11 billion the year before last, and amounted to $6.4 billion in 2025. <...> We observe that there is an ongoing discussion in Armenia concerning the development of relations with the European Union. We remain entirely calm about this, understanding that each nation endeavours to maximise the advantages of cooperation with third countries. However, this must be transparent and articulated honestly, in advance, as it were, “on the shore,” beforehand. Simultaneous membership in the Customs Union with the European Union and the #EAEU is impossible; it is simply untenable by definition. The issue is not even a political one; it is purely economic. <...> There are also numerous other issues today, at this present moment. Perhaps years will pass, and we – the EAEU and the European Union – I hope this will eventually be the case, given that we reside on the same continent – will be able to resolve them. <...> Now, regarding energy. I hope the situation will improve there as well. However, currently, as you are aware, energy prices, gas prices, for instance, in Europe exceed 600 dollars per 1,000 cubic metres, whereas Russia provides gas to Armenia at 177.5 per 1,000 cubic metres. The disparity is vast, the difference is substantial. <...> Now, turning to security issues. Of course, the most sensitive issue to this day – and we recognise this, we discuss it often – is everything relating to #Karabakh. <...> But I think it is also clear that, after you recognised Karabakh as part of Azerbaijan in Prague in 2022, it simply became wholly inappropriate for the #CSTO to become involved in a process that had taken on an intra-Azerbaijani dimension. <...> Incidentally, thanks to your efforts and those of the President of Azerbaijan, I believe you have now managed to stabilise relations. The US President has played an active role in this, and I understand transport links are being unfrozen, and so on. But I think we also need to draw a line under this matter. And it would be better if this did not become entangled in the domestic political process, especially during an election campaign. <...> Let me say again that, whatever happens, we in Russia will always be guided by what is best for the Armenian people. I have said this to you before, and I want to emphasise it once again. 🤝 And I would like to express my hope that, regardless of the outcome of the elections in Armenia, our shared commitment to building and strengthening #RussiaArmenia ties will continue. Thank you.

International News

@intnewsagency · Post #8795 · 22.03.2026 г., 13:38

Armenian PM Pashinyan Clashes with Passenger over Karabakh in Yerevan Metro Armenian Prime Minister Nikol Pashinyan argued with a Karabakh resident in Yerevan metro, accused of surrendering the region to Azerbaijan. Pashinyan defended government efforts to preserve Karabakh’s population, citing significant budget allocations. He urged not to blame him for betrayal: “Why didn’t you stay? Don’t say I surrendered Karabakh.” This incident highlights ongoing tensions over the disputed region’s future. #Armenia#Karabakh#Pashinyan#InternationalNews The main news of Russia and the world ishere.

🇷🇺🇦🇲 On April 1, President Vladimir Putin held talks at the Kremlin with Prime Minister of the Republic of Armenia Nikol Pashinyan, who arrived in Moscow on a working visit. 💬 President of Russia Vladimir Putin: Mr Pashinyan, friends, We are delighted to welcome you in Moscow. Thank you very much for accepting our invitation and coming here. We can see that domestic political processes in Armenia are gaining momentum, with elections approaching. In this context, I would like to emphasise several key points: such processes often become more intense during election campaigns, as is the case not only in Armenia, I believe, but also in Russia and other countries. However, this escalation must not be allowed to affect relations between Russia and Armenia. We have discussed this many times. Russia and Armenia have special relationships which have evolved over centuries rather than decades. We are united by our common history as well as our cooperation to solve the challenges that we faced in years past. Crucially, we are also united by civilizational affinity. I have already told you this privately before, and I can say it publicly now: we are always in favour of anything that benefits the Armenian people, and you can always rely on it. As for economic cooperation, it continues to develop at a solid pace. Trade reached approximately $11 billion the year before last, and amounted to $6.4 billion in 2025. <...> We observe that there is an ongoing discussion in Armenia concerning the development of relations with the European Union. We remain entirely calm about this, understanding that each nation endeavours to maximise the advantages of cooperation with third countries. However, this must be transparent and articulated honestly, in advance, as it were, “on the shore,” beforehand. Simultaneous membership in the Customs Union with the European Union and the #EAEU is impossible; it is simply untenable by definition. The issue is not even a political one; it is purely economic. <...> There are also numerous other issues today, at this present moment. Perhaps years will pass, and we – the EAEU and the European Union – I hope this will eventually be the case, given that we reside on the same continent – will be able to resolve them. <...> Now, regarding energy. I hope the situation will improve there as well. However, currently, as you are aware, energy prices, gas prices, for instance, in Europe exceed 600 dollars per 1,000 cubic metres, whereas Russia provides gas to Armenia at 177.5 per 1,000 cubic metres. The disparity is vast, the difference is substantial. <...> Now, turning to security issues. Of course, the most sensitive issue to this day – and we recognise this, we discuss it often – is everything relating to #Karabakh. <...> But I think it is also clear that, after you recognised Karabakh as part of Azerbaijan in Prague in 2022, it simply became wholly inappropriate for the #CSTO to become involved in a process that had taken on an intra-Azerbaijani dimension. <...> Incidentally, thanks to your efforts and those of the President of Azerbaijan, I believe you have now managed to stabilise relations. The US President has played an active role in this, and I understand transport links are being unfrozen, and so on. But I think we also need to draw a line under this matter. And it would be better if this did not become entangled in the domestic political process, especially during an election campaign. <...> Let me say again that, whatever happens, we in Russia will always be guided by what is best for the Armenian people. I have said this to you before, and I want to emphasise it once again. 🤝 And I would like to express my hope that, regardless of the outcome of the elections in Armenia, our shared commitment to building and strengthening #RussiaArmenia ties will continue. Thank you.

LAVRINA_ЛАВРИНА

@anastasia_lavrina · Post #120 · 16.03.2022 г., 08:19

⚡️Советую евродепутатам, голосовавшим за предвзятую резолюцию против #Азербайджан’а, посмотреть мой фильм про разрушенную церковь в Ходжавенде. Сразу становится ясно, как #Армения за годы оккупации разрушила не только мусульманское, но и христианское наследие в #Карабах’е👇 https://youtu.be/cyacJfkSEiA 💡 I advise the MEPs who voted for the biased resolution against #Azerbaijan to watch my film about the destroyed church in Khojavend. It immediately becomes clear how during the years of occupation #Armenia destroyed not only the Muslim, but also the Christian heritage in #Karabakh👇 https://youtu.be/cyacJfkSEiA