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 слични објави

Пребарај: #novosergeyevka

当前筛选 #novosergeyevka清除筛选
DruschbaFM - English

@druschbaFm_en · Post #52784 · 02.04.2025 г., 08:02

⚡️ 🇷🇺 🇺🇦⚔️ Ukraine Fronts on the Morning of 2 April⚡️ 🔴#Sumy Direction: 🔴In #Sudzha Sector, to the west on Ukrainian lands, there were no reports on major changes. Thus, the situation is likely as follows: 🟡#Vladimirovka- AFU; {1st blue↗️}; 🟡#Vodolagi - AFU; 🟡 Russian #Uspenovka - contested {1st black↘️}; 🟡#Veselovka - contested; 🟡#Belovody - AFU; 🟡#Zhuravka, contested; 🟡#Basovka, contested. 🟡#Novenkoye - RFAF {1st red⬆️}. 🟡 In #Kursk region, fighting continues north of the AFU controlled #Oleshnya, east of which Russian troops have (confirmed) advanced on the village. For #Guyevo the battle continues, the respective control zone of both parties is disputed. #Gornal is AFU controlled. 🔴In #KrasnayaYaruga Sector, fighting for #Popovka {6th black↙️} and #Demidovka is ongoing. 🗺 All on Map 1 🔴 In #Kharkov Direction, Russian aviation and artillery are reportedly striking the AFU's logistics routes. 🔴#Svatovo Front: 🔴 In #Kupyansk Sector, Russian units advanced west of the Oskol River towards #Kondrashovka, the battle for which has begun. Thus, the Russian claims regarding the village and #MalayaShapkovka to it's northwest, reported on 29 Mar have proven wrong. It has just been reported that Russian units have entered #Kondrashovka's north. 🗺 Map 2 🔴 In #Borovaya Sector, no major changes. 🔴In #Liman Sector, the battle at #Katerinovka and #Novoye continues. 🔴In #Seversk Sector, the most intense clashes are at #Belogorovka's chalk quarry. 🔴#ChasovYar Direction: 🔴In #ChasovYar Sector, positional battles without major changes. 🔴In #Toretsk Sector, fighting in the city for the 'Toretskaya Mine' in the north, in the western outskirts and in the southern 'Zabalka Microdistrict' continued, as well as to the west for the villages of #Shcherbinovka and #Leonidovka. 🔴#Pokrovsk Direction: 🔴 On the right Flank, far to the east, the RFAF are still assaulting the southern village edge of #Valentinovka. Fighting continues around the recently taken #Panteleymonovka and for #Tarasovka further west. 🔴 South of the City, ongoing fighting along the frontline, without changes. 🔴 On the left Flank, the situation is dynamic. Reportedly, fierce fighting continues for #Udachnoye and in the #Uspenovka - #Novoaleksandrovka area. The AFU are trying to take #Uspenovka to slow down the Russian advance in #Novoaleksandrovka, the capture of which would enable further advance to #Novosergeyevka. 🟡 South of #Kotlyarovka, there was reportedly a breakthrough, Russian units cut of #Preobrazhenka from #Troitskoye and blocked the approaches to it from #Kotlyarovka. Currently, #Preobrazhenka is being cleared. The battles for #Kotlyarovka and #Bogdanovka continue. 🗺 Map 3 🔴#Komar Direction: 🔴 In #Bogatyr Sector, fighting around #Andreyevka and for #Konstantinopol continues. 🟡 For #Razliv, the RF MoD also claimed the takeover, but failed to provide evidence. The published video did not include the large buildings with blue roofs we mentioned yesterday. 🎬 Video 🔴 In #Komar Sector, at #Vesyoloye, Russian stormtroopers reportedly penetrated the AFU defences. In #VolnoyePole, fierce fighting for control over the settlement continues. 🔴#Zaporozhye Direction: 🔴In the #Orekhov Section, the battles for the 4 contested villages continue. 💥 In the #DPR, an AFU UAV hit City Bus No. 2 in #Gorlovka yesterday morning, wounding 15 civilians. 💥 In #Kherson Direction, the RFAF aviation carried out a massive bombing of the right Dnieper bank. 💥#Russia: 🔵The AFU attacked with UAVs at night. In #Kursk, at least 15 explosions were reported. In #RostovRegion, two apartment buildings in #Taganrog were damaged. 💥#RestUkraine: 🔵 The RFAF struck #Kharkov, #Kramatorsk and #Odessa with UAVs. ⚠️ The Term 'Reportedly' indicates that it is unconfirmed! 🎞 Videos Source 🗺 Maps @olegtsarov; @petrenko_iHS 📋 Sources: CC; Tsarov; 🇺🇦Fiend;⚡️2M;🐈Cat😼VK 🕰As of 2 Apr 2025; 06:53 GMT+3;📃1 Apr 📱 Join GLOBAL DEPTH to boost your TG Feed 💬Join Military Chat for Comments & Discussions 🇺🇦On Ukraine Observer you will find your daily independent Ukraine War Battle Update