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

Резултати

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

Пребарај: #olf

当前筛选 #olf清除筛选
Addis Standard

@addisstandardeng · Post #21815 · 24.03.2026 г., 09:43

News: OLF-OLA joins #Fano in criticizing #Ethiopia’s upcoming election, calls it a ‘hollow ritual’ A week after the #Amhara Fano National Movement issued warnings over participation, the Oromo Liberation Front–Oromo Liberation Army (#OLF-#OLA) has also dismissed Ethiopia’s upcoming national election as lacking credibility, claiming that much of the country remains beyond the reach of a meaningful electoral process. In a press release issued on March 23, the group said the election has been reduced to “a performance staged for foreign consumption,” with over seventy percent of the country inaccessible for credible voting. According to the statement, major opposition parties have either withdrawn or are participating solely to avoid deregistration or to expose what it described as flaws in the process. “All remaining parties in the process are either created by or colluding with the regime,” the group added. Last week, Addis Standard reported, citing the….. Read more: https://addisstandard.com/?p=56026

Addis Standard

@addisstandardeng · Post #21037 · 10.01.2026 г., 11:26

News: #PM_Abiy lays foundation for #Africa’s largest Airport; #OLF describes project as extension of 2014 “Master Plan,” demands equity Prime Minister Abiy Ahmed on Saturday laid the foundation stone for the #Bishoftu International Airport, poised to become Africa’s largest aviation hub, while the Oromo Liberation Front (OLF) condemned the project as involving “forced displacement,” alleging that thousands of residents are being uprooted and demanding ownership stakes for affected farmers. The ceremony in Abbuu Seeraa, Bishoftu, was attended by Deputy Prime Minister Temesgen Tiruneh, #Oromia Regional President Shimelis Abdisa, & Ethiopian Airlines Group CEO Mesfin Tasew. Speaking at the event, Prime Minister Abiy described the airport as a “mega station” central to Ethiopia’s long-term aviation and industrial strategy, with the capacity to handle up to 110 million passengers. The OLF described the project as a humanitarian crisis, alleging that it extends Read more: https://addisstandard.com/?p=54477

Borkena

@borkena · Post #5937 · 06.03.2026 г., 06:56

የኦነግ ሸኔ አባላት ሴቶች ላይ የአስገድዶ መድፈር ወንጀል መፈፀማቸውን አምነስቲ አረጋገጠ። ዓለም አቀፉ የሰብአዊ መብቶች ተቋም አምነስቲ ኢንተርናሽናል፤ የኦሮሞ ነጻነት ሠራዊት አባላት በሴቶች እና ሴት ልጆች ላይ ለወሲብ ባርነት እና በቡድን መድፈርን ጨምሮ የተለያዩ ወሲባዊ ጥቃቶችን ፈጽመዋል ሲል አዲስ ባወጣው ሪፖርት ወንጅሏል። አምነስቲ ኢንተርናሽናል ዛሬ አርብ የካቲት27/2018 ዓ.ም. ይፋ ያደረገው የምርመራ ሪፖርት፤ በኦሮሚያ ክልል የሚንቀሳቀሱት የታጣቂ ቡድኑ አባላት ከአውሮፓውያኑ 2020 እስከ 2024 ባሉት ዓመታት የፈጸሟቸውን ድርጊቶች በመዳሰስ ያካተተ ነው። የታጣቂ ቡድኑ አባላት በሴቶች ላይ የፈጸሟቸው ፆታዊ ጥቃቶች፣ ከፍርድ ውጪ የሆነ ግድያ እና የንጹኃንን ንብረት የማውደም ድርጊቶች "በጦር ወንጀልነት ሊፈረጁ የሚችሉ" እንደሆነ አስታውቋል። ምርመራው የተደረገው በኦሮሚያ ክልል ቄለም ወለጋ ዞን ውስጥ በሚገኙት ሳዮ እና አንፊሎ ወረዳዎች ውስጥ እንደሆነ ገልጿል። የሰብአዊ መብቶች ተቋሙ ምርመራውን ሲያከናውን በቡድኑ አባላት ወሲባዊ ጥቃት ለተፈጸመባቸው 10 ሴቶች ቃለ መጠይቅ ማድረጉን እንዲሁም የጤና ባለሙያዎችን ማነጋገሩን እና የሕክምና መዝገቦችን መመርመሩን አስረድቷል። አምነስቲ ቃለ መጠይቅ ከተደረገላቸው 10 ሴቶች መካከል አምስቱ ለወሲብ ባርነት ተዳርገው ነበር ሲል በሪፖርቱ አመላክቷል። የድርጅቱ የምሥራቅ እና ደቡብ አፍሪካ ሪጅናል ዳይሬክተር ቲጌሬ ቻጉታህ፤ "ለሰባት ዓመታት ያህል ኦሮሚያ ክልል ውስጥ ያሉ ታጣቂዎች በኮሚዩኒኬሽን እና በመገናኛ ብዙኃን መገደብ ምክንያት በተፈጠረው የጨለማ ሽፋን ስር ሆነው ንጹኃንን ለከፍተኛ ስቃይ ዳርገዋል" ብለዋል። #Ethiopia#Oromia#AmnestyInternational#OLF#news#ዜና#ኦነግሸኔ#አምነስቲ

Addis Standard

@addisstandardeng · Post #22050 · 17.04.2026 г., 16:32

#Premiering_now: Two Years Without Justice: Remembering the BrutalAssassination of Bate Urgessa April 9, 2024, a night that ended in a brutal execution a husband, a father of five, an intellectual and a peaceful politician. Two years later, the questions remain. Click here to watch: https://youtu.be/gAXvr9JN3Y8?si=q7C8otTOvcTw_fZ5 In this commemorative episode of The Standard Signal, host Tsedale Lemma discusses with Prof. Ezekiel Gebissa to revisit the life, final hours, and aftermath of Bate Urgessa’s brutal assassination by government forces, and examine what has (and hasn’t) changed since. #BateUrgessa#Ethiopia#JusticeDelayed#HumanRights#Oromo#OLF#PoliticalViolence#Accountability#AfricaNews#HornOfAfrica#TheStandardSignal#NeverForget

Addis Standard

@addisstandardeng · Post #22049 · 17.04.2026 г., 14:53

The Standard Signal Ep 16| Two Years Without Justice: Remembering the Brutal Assassination of Bate Urgessa On April 9, 2024, Bate Urgessa was brutally assassinated by government forces. This special episode revisits the timeline, and what it reveals about justice and political space in Ethiopia today. #TsedaleLemma in conversation with #EzekielGebissa Premiers tonight at 7:30 PM EAT Subscribe to watch: https://youtube.com/@addisstandard #BateUrgessa#Ethiopia#Anniversary#JusticeDelayed#HumanRights#PoliticalViolence#Oromo#OLF#Accountability#HornOfAfrica#TheStandardSignal