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

Пребарај: #solenoye

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

@druschbaFm_en · Post #52752 · 01.04.2025 г., 07:57

⚡️ 🇷🇺 🇺🇦⚔️ Ukraine Fronts on the Morning of 1 April⚡️ 🔴 In #Chernigov Direction, the AFU has reportedly already crossed the Russian border of the #Bryansk region many times. Locals point to periodic incursions towards several villages. 🔴#Sumy Direction: 🔴In #Sudzha Sector, to the west on Ukrainian soil, the situation based on confirmed information and evidence is as follows: 🟡#Vladimirovka- AFU; {1st blue↗️}; 🟡#Vodolagi - AFU; 🟡#Uspenovka in Russia - contested {1st black↘️}; 🟡#Veselovka - contested {2nd black↖️}; 🟡#Belovody - AFU; 🟡 In #Zhuravka, fights in the central part; 🟡 In #Basovka, the RFAF assaults the eastern part. 🟡#Novenkoye - RFAF {1st red⬆️}. 🟡 In #Kursk region, reportedly, Russian troops have repelled an assault on the 'Border Checkpoint' {2nd red↙️}; the AFU have reinforced the battle area around #Oleshnya {4th blue⬅️}. 🟡 In #Guyevo, the RFAF have reportedly extended their control zone {5th black⬇️}. 🟡#Gornal remains AFU controlled. 🔴In #KrasnayaYaruga Sector, reportedly positional battles are taking place in #Popovka {6th black↙️}. 🟡 In #Demidovka, the AFU have advanced in the central part and in the area of ​​the farm in the village's eastern part. 🗺 Map 2 🟡 At #Grafovka and #Prilesye, lull. 🗺 All on Map 1 🔴#Kharkov Direction: 🔴In #Liptsy Section, positional battles. 🔴 In #Volchansk Section, as well in the city itself. 🔴#Svatovo Front: 🔴 In #Kupyansk and #Borovaya Sectors, reportedly slight tactical successes for the RFAF without major changes. 🔴In #Liman Sector, fighting south of #Katerinovka and east of #Novoye in the north. 🔴In #Seversk Sector, west of #Belogorovka, Russian troops reportedly approached #Grigorovka. 🔴#ChasovYar Direction: 🔴In #ChasovYar Sector, the battles continues. 🔴In #Toretsk Sector, fighting in the city and to the west for #Shcherbinovka and #Leonidovka continued. 🔴#Pokrovsk Direction: 🔴 On the right Flank, far to the east, fighting continues at #Valentinovka and in the area of #Panteleymonovka (towards #Toretsk northwards). To the west, urban battles in #Tarasovka. 🔴 South of the City, reportedly Russian advance in #Lysovka. Battles at #Shevchenko and #Peschanoye, and in #Kotlino fighting at the the far southeastern edge. 🔴 On the left Flank, the fighting for #Udachnoye's far southeastern reportedly continued. Otherwise, intense combat is taking place along the entire frontline from #Solenoye southwards. 🔴#Komar Direction: 🔴In #Bogatyr Sector, the battles near #Andreyevka and for #Konstantinopol continue. 🟡 In #Razliv, Russian troops extended the zone of control and raised the flag in the centre of the village. 📌Despite several Russian claims, there is no takeover yet! The village boundaries extend to the west, especially the large buildings with blue roofs are located within them. 🎬 Video 🗺 Map 3 🔴 In #Komar Sector, the RFAF are reportedly attacking towards #Otradnoye and #Komar. 🟡 In #Vesyoloye, the battle for the settlement is ongoing. 🔴#Zaporozhye Direction: 🔴In the #Orekhov Section, south of the city, the AFU positions are reportedly under permanent fire; Russian units are attacking towards #Novoandreyevka. To the west, the fighting especially in the 4 contested villages continues: 🟡#Shcherbaki; 🟡#MalyeShcherbakito the west; 🟡#Stepovoye, further west; 🟡#Lobkovoye; 🟡#Pyatikhatki remains RFAF controlled. 🟡 At #Kamenskoye, in the far west, the RFAF reportedly took one of the AFU's key strongholds. 🔴 In #Kherson Direction, Russian aviation struck Ukrainian positions on the opposite bank, while the AFU targeted villages. 💥 For #OldRussia and #RestUkraine, we have found no reports of new mutual strikes. ⚠️ The Term 'Reportedly' indicates that it is unconfirmed! 🎞 Video Source 🗺 Maps @olegtsarov; @petrenko_iHS@creamy_caprice 📋 Sources: CC; Tsarov; 🇺🇦Fiend;⚡️2M;🐈Cat😼VK 🕰As of 1 Apr 2025; 06:38 GMT+3;📃31 Mar 📱 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

DruschbaFM - English

@druschbaFm_en · Post #52724 · 31.03.2025 г., 08:55

⚡️ 🇷🇺 🇺🇦⚔️ Ukraine Fronts on the Morning of 31 March⚡️ 🔴#Sumy Direction: 🔴In #Sudzha Sector, to the west on Ukrainian lands, the AFU counterattacked. Furthermore, video evidence has 👉emerged. As a result, the corrected situation (our added large arrows on map have been always correct) based on confirmed information and evidence is as follows: 🟡#Vladimirovka- AFU; {1st blue⬆️}; 🟡#Vodolagi - AFU {2nd blue⬆️}; 🟡#Uspenovka in Russia - contested {1st black⬆️}; 🟡#Veselovka - contested {2nd black⬆️}; 🟡#Belovody - AFU; 🟡#Zhuravka - contested; 🟡#Basovka - contested. 🟡#Novenkoye, RFAF {1st red⬆️}. 🟡 In #Kursk region, #Gogolevka and the 'Border Checkpoint' are RFAF controlled, an entry in #Oleshnya {4th blue⬅️} remained unconfirmed, fighting towards the village. 🟡 For #Guyevo, the battle continues. 🟡#Gornal is AFU controlled. 🔴In #KrasnayaYaruga Sector, the AFU in #Popovka and surrounding are under constant fire {6th black↙️}. 🟡 In #Demidovka, the battle on the ground continues. 🟡 At #Grafovka and #Prilesye, lull. 🗺 All on Map 1 🔴#Kharkov Direction: 🔴In #Liptsy Section and in #Volchansk, positional battles. 🔴#Svatovo Front: 🔴 In #Kupyansk Sector, Russian troops are expanding the bridgehead north of the city. 🔴In #Liman Sector, the battle for #Katerinovka has begun. 🔴In #Seversk Sector, fighting at #Belogorovka and towards #Verkhnekamenskoye. An entry into the latter remained unconfirmed. 🔴#ChasovYar Direction: 🔴In #ChasovYar Sector, without major changes. 🔴In #Toretsk Sector, the battle for the city continues. To the west, the AFU have further advanced in #Shcherbinovka and entered #Leonidovka. 🗺 Map 2 🔴#Pokrovsk Direction: 🔴 On the right Flank, far to the east, fighting continues in the area of #Panteleymonovka and #Aleksandropol, the full control of which is disputed. Northwest of the former, the RFAF advanced to the southern edge of #Valentinovka. To the west, the battle for #Tarasovka is ongoing. 🔴 South of the City, fighting for #Lysovka. #Shevchenko and #Peschanoye are RFAF controlled for now. East of #Kotlino the AFU advanced; in the village itself the RFAF at best hold the far southeastern edge (see 28 Mar). 🗺 Map 3 🔴 On the left Flank, Russian troops have at best presence in #Udachnoye's far southeastern part. The AFU have breached into #Solenoye. In #Uspenovka the RFAF reentered (earlier reports on clearing have not been confirmed) and attack towards #Novoaleksandrovka (reports on fights inside have not been confirmed). 🗺 Map 3 🟡#Nadezhdinka (#Nadeyevka) has been reentered by Russian forces (in the meantime, they have somehow lost control of the village). 🟡 Towards#Kotlyarovka and #Preobrazhenka, Russian assaults continue. 🔴#Komar Direction: 🔴In #Bogatyr Sector, the battle for #Konstantinopol continues. This contrary to 'Two Majors,' who have emphasised 'liberated' more than once (they know about the real facts). In #Razliv, the RFAF have consolidated their positions in the eastern, central and western parts of the settlement. 🔴 In #Komar Sector, the battle for #Novosyolka has shifted to the village's centre. 🔴#Zaporozhye Direction: 🔴In #Orekhov Section, the fighting continues. 4 villages remain contested: 🟡#Shcherbaki; 🟡#MalyeShcherbakito the west; 🟡#Stepovoye, further west; 🟡#Lobkovoye; 🟡#Pyatikhatki is RFAF controlled. 🗺 Map 4 🔴 In #Kherson Direction, the AFU shell villages. 💥#OldRussia: 🔵 AFU UAVs attacked #Bryansk, #Belgorod and Kursk regions, as well as #Crimea. 💥#RestUkraine: 🔵 The RFAFstruck with Iskanders in the #Sumy region, and 'Geraniums' worked in #Kiev, they reported a massive strike by UAVs on targets in the Zhitomir region. ⚠️ The Term 'Reportedly' indicates that it is unconfirmed, today without! 🗺 Maps @olegtsarov; @z_arhiv 📋 Sources: CC; Tsarov; 🇺🇦Fiend;⚡️2M;🐈Cat😼VK 🕰As of 31 Mar 2025; 07:26 GMT+3;📃29 Mar 📱 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