Для тех кто пишет расширения на PyQt/PySide для CG-софтов.
Когда я только начинал писать тулзы под Maya (тогда еще версия 2010-2011) мне приходилось ручками ставить PyQt4 под Maya. Даже написал мануалы по установке на своём сайте. Но потом стал доступен из коробки PySide и позже он обновится до PySide2. Для некоторых систем была поддержка PyQt5.
И как простому разработчику поддерживать этот зоопарк? Ведь хочется чтобы тул работал на любой версии (вы тоже делали модуль что-то типа import_qt.py?😁)
На помощь приходит проект Qt.py который поставил себе цель унифицировать использование Qt-биндингов вне зависимости от среды где запускается код. Те, кто давно пишут на Qt, скорее всего знают этот проект.
Он стал стандартом для CG-индустрии и используется в топовых студиях и проектах.
Qt․py помогает запускать один и тот же код на разных платформах с разными вариантами Qt-библиотек. Это может быть как интеграция в CG-софт, так и переносимость стендалонов между разными платформами с разными версиями Python.
Я решил рассказать о некоторых особенностях работы с этой библиотекой.
Сегодня о том, как установить и использовать Qt․py и что это вам даёт.
Установка
pip install Qt.py
Чтобы начать использовать Qt․py в коде достаточно заменить импорт вашего варианта Qt-биндинга на Qt․py
from [PySide|PyQt4|PySide2|PyQt5] import QtWidgets
=>
from Qt import QtWidgets
Теперь ваш код будет поддерживать любой вариант биндинга Qt в Python.
При этом не потребуется использовать if-else конструкции под разные версии. Все вызовы теперь одинаковы.
Всё что нужно сделать, это написать его по правилам PySide2. Именно эта версия была взята за основу.
Приоритет импорта такой:
1. PySide2
2. PyQt5
3. PySide
4. PyQt4
Что именно загрузилось можно посмотреть в переменной __binding__
>>> import Qt
>>> Qt.__binding__
'PySide2'
Приоритет имопрта можно изменить через переменные QT_PREFERRED_BINDING и QT_PREFERRED_BINDING_JSON. Причем под каждый проект оверрайды можно настраивать индивидеально.
#qt#libs
Amazing close finish in the Paralympic 100m swim! Athletes are classified by functionality, so even with different impairments, like no hands or paralyzed legs, they compete on an even playing field.
@Viral_Today / #Olympics
The first-ever Olympic breakdancing tournament is underway in Paris, and it’s already giving us some unforgettable moments.
Australian dancer Rachael “Raygun” Gunn went viral for all the wrong reasons—her bizarre moves and headstands left everyone cringing.
Gunn lost all three of her matches without scoring a single point. Safe to say, people are now questioning the decision to make breaking an Olympic sport.
@Viral_Today / #Olympics
Speed in 1924 vs. 2024: How much faster is today's Olympic gold medalist compared to 100 years ago? The progress might surprise you.
Only 0.81 seconds!
@Viral_Today / #Olympics
Italian Olympic gold medalist Thomas Ceccon was spotted sleeping in a park after complaining about the poor conditions at the Olympic Village in Paris.
Despite the lack of air conditioning and noisy environment, Ceccon didn’t let it stop him from winning gold in the 100m backstroke.
@Viral_Today / #Olympics
Another video from Olympics going viral. The cameraman closely following the athletes jumping on the trampoline throughout the entire event.
@Viral_Today / #Olympics
The Egyptian fencer Nada Hafez revealed that she competed in the Olympics' women’s sabre competition — advancing to the round of 16 — while seven months pregnant.
@Viral_Today / #Olympics
Bob the Cap Catcher: The First Viral Hero of the Paris Olympics
'Bob the Cap Catcher' became the first viral hero of the Paris Olympics when he jumped into the pool to save a swimmer's lost cap, earning loud cheers from the audience.
@Viral_Today / #Olympics
جمهوری اسلامی قهرمانان ورزش ایران را وادار میکند تا وطنشان را ترک و بر خلاف میلشان زیر پرچم کشورهای دیگر در رقابتهای بینالمللی و المپیک شرکت کنند. این رژیم، حتی از رقابت دو ورزشکار ایرانی، دو دوست، که مثل هر رقابت ورزشی دیگری با برد و باخت همراه است، سوءاستفاده سیاسی میکند و تلاش میکند ایرانی را در مقابل ایرانی قرار دهد.
من هم برای ناهید کیانی در رقابت فینال آرزوی پیروزی و کسب مدال طلا را دارم، و هم امیدوارم کیمیا علیزاده در ادامه بتواند مدال باارزش برنزش در المپیک ریو را تکرار کند. اما فارغ از هر نتیجهای، ناهید و کیمیا هر دو برنده این صحنه هستند؛ و بازنده، رژیم پلید و اهریمنی جمهوری اسلامی است.
باور دارم روزی دوباره، ورزشکاران ایرانی با افتخار و آزادانه زیر پرچم ملی ایران در مسابقات المپیک شرکت خواهند کرد، و با پشتیبانی یک ملت، برای ایران، افتخار به ارمغان خواهند آورد.
The Islamic Republic forces Iran's champions to leave their homeland against their will and compete under the flags of other nations in international competitions like the #Olympics. This regime even attempts political exploitation of the competition between two Iranian athletes, two friends, where, like any other sporting contest, there are winners and losers. Yet the regime nonetheless tries to pit Iranian against Iranian.
I wish Nahid Kiyani victory and a gold medal in the final and I also hope Kimiya Alizadeh can replicate her valuable bronze medal from the Rio Olympics. But regardless of the outcome, both Nahid and Kimiya are winners. The loser is the vile and evil Islamic Republic.
I know that one day, Iranian athletes will again proudly and freely compete under the national flag of Iran in the Olympics and, with the support of a nation, bring Iran honor.
@OfficialRezaPahlavi
FC Bayern (TikTok)
❄️ 𝟮𝟬𝟮𝟲 𝗪𝗶𝗻𝘁𝗲𝗿 𝗢𝗹𝘆𝗺𝗽𝗶𝗰𝘀 🥇🥈🥉 The Allianz Arena shines in the colors of the German and Italian flags at the start of the Olympic Games in Milano Cortina. 🇩🇪🏟️🇮🇹 This is a symbol of solidarity and stands for the unique power of sport to bring people from all nations together. We keep our fingers crossed for all athletes and wish them a peaceful and successful Olympic and Paralympic Games.#Olympics#MilanoCortina2026
FC Bayern (TikTok)
The Olympic Winter Games in Milano Cortina are about to start today! ❄️🎿 Our players about the winter sport they most enjoy watching. 🏒⛷️⛸️#Olympics#MilanoCortina2026