TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #380 · 21 окт.

Регулярно приходится писать и ревьюить код, где используется PySide2-6. Заметил, что в подавляющем большинстве случаев настройка создаваемых базовых виджетов происходит через методы. Думаю, всем знаком такой способ. Простой пример с кнопкой: button = QPushButton("Click Me") button.setMinimumWidth(300) button.setFlat(True) button.setStyleSheet("font-size: 20pt") button.setToolTip("Super Button") button.clicked.connect(lambda: print("Button clicked")) Но есть и альтернативный способ - настройка через свойства. Это просто ключевые аргументы конструктора класса. Хоть они и не указаны в документации как аргументы, но они есть) Этот код делает тоже самое но с помощью Property button = QPushButton( "Click Me", minimumWidth=300, flat=True, styleSheet="font-size: 20pt", toolTip="Super Button", clicked=lambda: print("Button clicked"), ) Где это может быть полезно ▫️ Это выглядит более аккуратно и коротко, уже повод использовать ▫️ Может использоваться в заполнении лейаута, когда нам не нужно никакое другое взаимодействие с виджетом и поэтому сохранять его в переменную не требуется. Например, лейбл или кнопка. widget = QWidget(minimumWidth=400) layout = QHBoxLayout(widget) layout.addWidget(QLabel("Button >", alignment=Qt.AlignRight)) layout.addWidget(QPushButton("Click Me", clicked=lambda: print("Button clicked"))) widget.show() Либо так widget = QWidget(minimumWidth=400) layout = QHBoxLayout(widget) for wd in ( QLabel("Button >", alignment=Qt.AlignRight), QPushButton("Click Me", clicked=lambda: ...) ): layout.addWidget(wd) widget.show() ▫️ Можно хранить настройки в каком-то конфиге или генерировать на лету, после чего передавать как kwargs. kwargs = {"text": "Hello " * 30, "wordWrap": True} my_label = QLabel(**kwargs) Как получить полный список доступных свойств? Эта функция распечатает в терминал все свойства виджета и их текущие значения def print_widget_properties(widget): meta_object = widget.metaObject() for i in range(meta_object.propertyCount()): property_ = meta_object.property(i) property_name = property_.name() property_value = property_.read(widget) print(f"{property_name}: {property_value}") #tricks#qt

Hashtags

Резултати

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

Пребарај: #trailer

当前筛选 #trailer清除筛选
Journey to Fluency

@fluencyinenglish · Post #6861 · 14.02.2019 г., 05:57

‍#trailer ❇️Days Gone 🔹 Plot A global pandemic occurred which decimated the globe, turning millions of humans into feral cannibalistic creatures, called Freakers. The remnants of humanity have abandoned towns to seek refuge in the wilderness creating safe zones. ❇️Aftermath Deacon St. John, a member of the Mongrels MC, is among the survivors of the epidemic. Deacon drifts through the wasteland of the Pacific Northwest, never staying in one place for too long. Deacon often takes work as a Bounty Hunter/Mercenary, offering his services in exchange for supplies. However, Deacon learns that there is a price on his head adding to his list of enemies. @fluencyinenglish @ieltsstrategies

Hashtags

Journey to Fluency

@fluencyinenglish · Post #6282 · 26.07.2018 г., 19:31

‍#trailer ❇️GLASS Trailer (2019) @fluencyinenglish Security guard David Dunn uses his supernatural abilities to track Kevin Wendell Crumb, a disturbed man who has 23 personalities. @fluencyinenglish In the trailer (via THR), Sarah Paulson (American Horror Story series) appears as a psychiatrist who describes herself as someone that specializes in “individuals who believe they are superheroes.” Present among her patients at a Philadelphia asylum are Bruce Willis’ David Dunn, Samuel L. Jackson’s Elijah Price, aka Mr. Glass, and James McAvoy’s Kevin Wendell Crumb, aka The Horde. @fluencyinenglish

Hashtags

Journey to Fluency

@fluencyinenglish · Post #6278 · 25.07.2018 г., 10:08

‍#trailer ❇️The passage @fluencyinenglish The plot: 🔹When a botched U.S. government experiment turns a group of death row inmates into highly infectious vampires, an orphan girl might be the only person able to stop the ensuing crisis. @fluencyinenglish

Hashtags

Journey to Fluency

@fluencyinenglish · Post #6251 · 14.07.2018 г., 13:41

‍#trailer ❇️How It Ends [HD] | Netflix The plot: In the midst of an apocalypse, a man struggles to reach his pregnant wife, who is thousands of miles away. @fluencyinenglish @ieltsstrategies

Hashtags

Viral Today

@viral_today · Post #3229 · 21.11.2024 г., 11:31

The live-action adaptation of the beloved How to Train Your Dragon franchise is set to hit theaters on June 13, 2025 @Viral_Today / #trailer

Hashtags

Viral Today

@viral_today · Post #3032 · 19.09.2024 г., 16:38

Black Mirror Season 7 teaser just dropped This globally popular Netflix series has drawn millions of viewers with its chilling, dystopian stories about the dark side of technology. Past episodes like ‘Bandersnatch’ became worldwide hits, and this new season promises more twists and turns. @Viral_Today / #trailer

Hashtags

Viral Today

@viral_today · Post #2975 · 04.09.2024 г., 14:30

🌐 Warner Bros. has released the first trailer for A Minecraft Movie, which hits theaters in April 2025 and stars Jack Black and Jason Momoa. @Viral_Today / #trailer

Hashtags

123•••1011
ПретходнаСтраница 1 од 11Следна