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

Резултати

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

Пребарај: #goodness

当前筛选 #goodness清除筛选
EKOLOG.UZ| ENG

@ekologuzenglish · Post #10069 · 24.10.2025 г., 12:02

🐾🔥 The Story of Scarlett — The Mother Cat Who Rushed Into Fire to Save Her Babies 💔🐱 Sometimes, true heroism doesn’t come from people, but from those who love unconditionally. 💖 This is how the world learned about Scarlett, a brave cat who, back in 1996, did something incredible — she ran five times into a burning garage to save her kittens. 🏚 It happened in one of the old garages in Brooklyn, New York, where Scarlett lived quietly with her kittens. But on the night of March 30, someone set the building on fire. Flames spread instantly, filling the place with smoke and unbearable heat. When the firefighters 🚒 arrived, they were stunned: they saw a cat running into the fire again and again, disappearing in the flames and coming out each time with a kitten in her mouth 🐈‍⬛🐈🐈‍⬛🐈🐈‍⬛ She carefully placed each baby in a safe spot, and despite the pain and fear, she rushed back into the fire to rescue the next one. 🔥 Each time she came out, she was weaker. Her fur was scorched, her ears and whiskers were burned, her paws were raw and blistered, and her eyes clouded from the heat… 😿 But she could only carry one kitten at a time, so she had no choice but to keep going. When the last, fifth kitten was finally safe, the now-blind Scarlett touched each baby with her nose, making sure all were alive ❤️ Only then did she collapse, unconscious… Deeply moved by her bravery, the firefighters rushed her and the kittens to a veterinary clinic 🏥 There, the vets treated and nursed them back to health. The story quickly made it into the New York Post 📰 — and it touched hearts all around the world. People sent letters, donations, and offers to adopt the little feline family. 😺 The kittens were soon adopted into loving homes. As for Scarlett, after recovering, she was adopted by a kind woman named Karen Wellen ❤️ In an interview, Karen said: “I will care for her as if she were my own child.” And she kept her promise 🙏 Scarlett lived 13 more happy years with Karen, never again knowing fear, pain, or hunger. Sometimes she would tremble in her sleep — as if remembering the fire — but she was always surrounded by love and safety. 🌷 🐾 Scarlett’s story became a symbol of motherly love, devotion, and courage. The media called her “Cat of the Century”, and millions of people around the world saw in her a reminder that even the smallest heart is capable of the greatest heroism 💫 💚 Let this story remind us all: Love is the power that can conquer even fire. 🔥 👇 ☘️ Read more inspiring stories and ecological news on @ekologuz 💌 Share your stories and suggestions through @eklguz_bot #ecology#animals#goodness#hero#ScarlettTheCat#ecologuz#animalheroes#love#motherhero🐾💚

Семеновский vs. Semenovskiy

@igor_semenovskiy · Post #3333 · 29.08.2025 г., 15:36

Вот и лето прошло, Словно и не бывало. На пригреве тепло. Только этого мало. . Всё, что сбыться могло, Мне, как лист пятипалый, Прямо в руки легло. Только этого мало. . Понапрасну ни зло, Ни добро не пропало, Всё горело светло. Только этого мало. . Жизнь брала под крыло, Берегла и спасала. Мне и вправду везло. Только этого мало. . Листьев не обожгло, Веток не обломало... День промыт, как стекло. Только этого мало. . Арсений Тарковский, 1967 г. . #лето#тепло#солнце#поэзия#стихи#творчество#искусство#добро#друзья#люьовь#прогулки#Москва#Зарядье#будущее#осень #summer#warm#sun#poetry#creativity#art#goodness#friends#love#walks#Moscow#Zaryadye#future#autumn