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

Резултати

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

Пребарај: #berbera

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

@addisstandardeng · Post #21943 · 04.04.2026 г., 12:45

#Saudi_Arabia expands shipping routes linking #Berbera Port, 16 global hubs Addis Abeba — Saudi Ports Authority has launched new maritime shipping services connecting its ports to 17 regional and international destinations, including #Somaliland’s Berbera Port in a move aimed at strengthening trade routes across Asia, the Middle East, and Africa. The initiative links Saudi ports with major global hubs as part of the Kingdom’s broader push to position itself as a global logistics centre under its Vision 2030 program. According to Horn Diplomat, the new services connect Saudi ports to 17 destinations, including key ports in China such as Qingdao, Shanghai, Ningbo, Nansha and Shekou; Singapore; Sokhna in Egypt; Aqaba in Jordan; Nhava Sheva and Mundra in India; as well as Djibouti, Berbera, Hamad Port, Umm Qasr Port, Khalifa Port in Bahrain, Shuwaikh Port and Shuaiba Port. via HornDiplomat https://www.horndiplomat.com/saudi-port-expansion-shines-global-spotlight-on-berbera/

Addis Standard

@addisstandardeng · Post #21201 · 27.01.2026 г., 06:32

#Op_ed: Diversification Over Dependency: Why #Ethiopia should fast-track #Berbera amid #Djibouti’s ban on multimodal operators In this op-ed, Adam Daud Ahmed argues that Ethiopia faces a logistics “moment of truth” as Djibouti’s ban on newly licensed Ethiopian Multimodal Transport Operators exposes “a dangerous structural weakness” in the country’s trade system. “What began as a technical dispute over regulatory classifications has rapidly evolved into a strategic economic challenge,” he notes, highlighting the risks of relying on a single maritime gateway. Ahmed calls the situation a “diplomatic impasse,” leaving reforms subject to foreign discretion. Ahmed presents the Port of Berbera—modernized under DP World—as a “credible alternative” and emphasizes that diversification is not abandonment but a way to “reclaim negotiating leverage through structural pragmatism.” https://addisstandard.com/?p=54765

Addis Standard

@addisstandardeng · Post #22078 · 21.04.2026 г., 13:25

News: Container shipping giant #Maersk suspends #Berbera port bookings, affecting cargo bookings including #Ethiopia-bound routes Global container shipping giant Maersk has announced a temporary suspension of new cargo bookings to and from #Somaliland's Berbera Port, a key logistics gateway used for cargo destined for neighboring countries including Ethiopia. https://addisstandard.com/?p=56572

Addis Standard

@addisstandardeng · Post #21405 · 14.02.2026 г., 10:44

#Op_ed: Crumbling of Rentier Fortress: #Ethiopia’s maritime pivot, decline of #Djibouti’s monopoly In this op-ed, Adam Daud Ahmed argues that for three decades, the Horn of Africa rested on a fragile arrangement: Ethiopia relied almost entirely on Djibouti for maritime access, while Djibouti turned geography into political and economic leverage. He notes, “That arrangement is now in terminal decline.” Ahmed points to the January 2024 MoU between Ethiopia and #Somaliland on #Berbera port as the turning point, aimed at “diversifying its access to seaports.” For Djibouti—once handling over 95% of Ethiopia’s trade—the move threatens “a rent-based model” already strained by debt. He emphasizes, “The Horn of #Africa is no longer organized around a single gatekeeper,” contending, “Rentier systems seldom survive erosion of monopoly; they either reform or they fracture.” https://addisstandard.com/?p=55189

Addis Standard

@addisstandardeng · Post #21060 · 13.01.2026 г., 14:50

#Dubai's #DP World says operations at #Somaliland's #Berbera port unaffected by #UAE-#Somalia dispute Dubai-owned ports and logistics company DP World said on Tuesday its operations at Berbera port in Somalia’s breakaway region of Somaliland were continuing under existing agreements, amid regional tensions following an escalation in nearby Yemen. Somalia's government said on Monday it was annulling all agreements with the UAE, including port deals and defense and security cooperation, accusing the Gulf country of undermining its national sovereignty. The move followed an investigation that Mogadishu launched last week after a Saudi-led coalition in Yemen, where tensions between global oil heavyweights Saudi Arabia & the UAE have been running high, said the UAE had spirited a separatist leader out of Yemen via Somalia. A crisis erupted last month in Yemen when the separatists swept... https://web.facebook.com/AddisstandardEng/posts/pfbid02kYCWGkrFMJ2gaGsCuZgsKWBDeZzkjceLpFSTT4iPEPHq5SosuUeuRqiHhSCKmA5ql

Addis Standard

@addisstandardeng · Post #21234 · 29.01.2026 г., 10:47

#Opinion: From Horn of #Africa to Middle East: #Somaliland as strategic connector in Red Sea corridor In this opinion piece, Abdifataah Hussien Osman argues that the Horn of Africa and the #Middle_East have merged into a single strategic theater, with the #Red_Sea acting as a “connective corridor” for trade and security. Strategically located along the Gulf of Aden, Somaliland has turned geography into “strategic reliability through effective territorial control,” while the Port of #Berbera has grown into a key regional hub. For the #United_States and Middle Eastern states, Somaliland offers a pragmatic, low-risk partner, as “Somaliland’s consistency becomes a strategic resource in itself.” Recognition, the author concludes, is not symbolism but “strategic alignment,” because “stability is not declared by recognition; it is proven by practice.” https://addisstandard.com/?p=54829

Addis Standard

@addisstandardeng · Post #21580 · 02.03.2026 г., 11:06

News: #Somaliland's #Israel deal could put #Berbera port at risk #Somaliland says its recognition by Israel could be a boon for its Berbera port. But with missiles flying across the region, it could also be a target. Berbera port on the Gulf of Aden has been transformed by the #UAE firm #DP_World over the past decade into a state-of-the-art facility on one of the world's busiest trade routes. Berbera still handles far fewer containers than nearby #Djibouti or #Mombasa, but port traffic was up 30 percent from 2023 to 2025, and recent diplomatic moves could lead to much more. A deal under negotiation with #Ethiopia, a landlocked neighbour with more than 130 million inhabitants, could see traffic rise by another 80 percent, said port authority director Ali Diriye Ahmed. Ethiopia did not respond to queries on the subject. But an alliance with Israel also brings risks, particularly as the US-Israeli attacks on Iran this weekend increase the threat of ........ Read more: https://addisstandard.com/?p=55487

Addis Standard

@addisstandardeng · Post #21699 · 13.03.2026 г., 06:55

#Somalia warns against any #Israeli base plans on #Somaliland Somalia has warned that its territory cannot be used as a launching pad for military operations, after two media reports that said Israel is planning to establish a military base in the breakaway region of Somaliland, directly across the Gulf of #Aden from #Yemen. “Somalia does not want to see its territory pulled into external confrontations or used in ways that could further destabilise an already sensitive region,” Ali Omar, Somalia’s state minister for foreign affairs, told Al Jazeera on Thursday. The warning from #Mogadishu comes after #US outlet Bloomberg and Sweden’s public radio Ekot reported this week about Israeli plans for a military installation near the strategic port city of #Berbera on the Gulf of Aden. The reports come as the US Israeli war on Iran edges towards its second week, with the Strait of Hormuz effectively closed...... https://www.aljazeera.com/news/2026/3/12/somalia-warns-against-any-israeli-base-plans-on-somaliland

Addis Standard

@addisstandardeng · Post #21562 · 28.02.2026 г., 10:58

#Djibouti leader wary of #Israel’s presence in #Somaliland Djibouti President Ismail Omar #Guelleh on Friday warned that the establishment of an Israeli military base in the strategic port city of #Berbera in Somaliland will pose a direct threat to regional stability. Speaking to a local media, Guelleh accused Israel of exploiting Somaliland’s decades-long quest for statehood to secure a foothold in the Horn of Africa. He expressed deep concern that the authorities in #Hargeisa might agree to any geopolitical concession in exchange for formal recognition. The veteran leader also leveled uncharacteristically blunt criticism at the United Arab Emirates, describing the Gulf nation as Israel’s primary “gateway” into the region. Guelleh pointed out that the #UAE is driving strategic shifts in the Horn of Africa and the #Red_Sea that exacerbate existing conflicts. He further alleged.... https://web.facebook.com/AddisstandardEng/posts/pfbid02eCjUg8BmbcGMNdTaybhh1dcaRUKUG8Gt8batRZvmsGemat4LxFLfoWLCD8eVbcdUl

Addis Standard

@addisstandardeng · Post #21305 · 04.02.2026 г., 11:08

#Opinion: Encircled and Exposed: #Berbera as #Ethiopia’s last strategic exit Ethiopia’s status as the Horn’s stabilizer has eroded, leaving the nation “constrained, exposed, and increasingly boxed in” by unfriendly neighbors, writes Mohamed Guleid. He cautions that #Djibouti, Ethiopia’s maritime lifeline, has compromised its neutrality by agreeing to host an #Egyptian military presence, while #Eritrea and #Somalia align with #Cairo over the #Nile dispute. Allowing adversaries to shadow its main supply route crosses a “strategic red line.” For a nation of 120 million, “diversification is no longer a luxury.” Guleid argues the solution lies in Somaliland, highlighting that the Berbera Port and its corridor are operational but underused. He notes, “Recognition of Somaliland would change Ethiopia’s position overnight,” expanding sea access, easing pressure, and restoring strategic leverage. https://addisstandard.com/?p=54982

Addis Standard

@addisstandardeng · Post #21990 · 09.04.2026 г., 06:30

#Opinion: From #Tokyo to Addis: Trilateral alliance redefining #Red_Sea security On 25 December 2025, #Israel became the first #UN member to formally recognize #Somaliland, ending a 34-year diplomatic deadlock and demonstrating “principled realism" in the Red Sea and Indo-Pacific, writes Hiroko Kasai. For #Ethiopia, this recognition establishes a “Trilateral Stability Axis” with Israel and Somaliland, transforming the 2024 bilateral MoU into a multilateral security framework. Kasai highlights practical benefits: the #Berbera Corridor offers Ethiopia a secure route for trade and industrial growth, while #Japanese engagement via the Ethiopian Investment Commission strengthens B2B cooperation. She notes, “By leveraging the Berbera Corridor—now bolstered by Israeli technological cooperation—Japanese firms can view Ethiopia as a primary industrial hub for the 1.4 billion people of the #AfCFTA.” https://addisstandard.com/?p=56442