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

Резултати

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

Пребарај: #ginettaakula

当前筛选 #ginettaakula清除筛选
Car News

@car_news · Post #509 · 10.09.2024 г., 12:43

📸 Meet the Ginetta Akula, a bespoke limited-edition supercar derived from a racing machine 💸 The British have started production of the Ginetta Akula supercar. The prototype of the sports car was shown back in 2019, but production has only started now. Only 20 of these cars will be assembled at a price from 275 thousand pounds. 🏎 This is a classic supercar with an atmospheric 6.4-liter V8 with 600 horsepower, “mechanics” and rear-wheel drive. Despite the large motor, the coupe weighs only 1.2 tons and can accelerate to 100 km/h in 2.9 seconds at a top speed of 290 km/h. @CarsNews #GinettaAkula#supercar

Автоновости

@avtonovosti · Post #488 · 10.09.2024 г., 12:44

📸Встречайте Ginetta Akula, лимитированный суперкар, созданный на основе гоночной машины 💸 Британцы начали производство суперкара Ginetta Akula. Прототип спорткара показали ещё в 2019 году, про этом производство началось только сейчас. Всего соберут только 20 таких автомобилей по цене от 275 тысяч фунтов. 🏎 Это классический суперкар с атмосферным 6,4-литровым V8 на 600 сил, «механикой» и задним приводом. Несмотря на крупный мотор, весит купе всего 1,2 тонны и может разогнаться до 100 км/ч за 2,9 секунды при максимальной скорости 290 км/ч. @avtoNovosti #GinettaAkula#суперкар

Auto Life

@revheadcrypto · Post #464 · 08.09.2024 г., 16:39

🌟 Exciting News for Supercar Enthusiasts! 🚗💨 The British have officially kicked off production of the stunning Ginetta Akula! 🦈✨ First unveiled in 2019, this masterpiece is limited to just 20 units, starting at £275,000. 💰 Featuring a classic design, the Akula boasts a powerful 6.4L V8 engine with 600 hp, paired with a manual transmission and rear-wheel drive. 🔥 Despite its robust engine, it weighs only 1.2 tons, accelerating from 0 to 100 km/h in just 2.9 seconds! ⚡️🏁 With a top speed of 290 km/h, this beauty is ready to roar! Are you ready to experience the thrill? 😍 #GinettaAkula#Supercar#LimitedEdition#V8Power#CarEnthusiast#LuxuryCars#SpeedDemon#Auto