Для тех кто пишет расширения на 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
🌎 The African buffalo, also known as Cape buffalo, is responsible for more deaths in Africa than most other large animals. Adult males can weigh up to 900 kilograms and have powerful horns, making them extremely dangerous when threatened. Herds can number in the hundreds and will defend injured members against predators, including humans. ✨
#wildlife⚡#mammals⚡#danger
👉subscribe Interesting Planet
👉more Channels
🌎 Mosquitoes are responsible for more human deaths than any other animal on Earth. They transmit diseases like malaria, dengue, Zika, and yellow fever, causing over 700,000 deaths each year worldwide. Some mosquito species can breed in just a bottle cap of water. ✨
#animals⚡#danger⚡#mosquitoes
👉subscribe Interesting Planet
👉more Channels
🌎 The assassin bug, found in tropical and subtropical regions, can inject a powerful enzyme that liquefies the insides of prey. Some species can also deliver painful bites to humans that may trigger allergic reactions. Assassin bugs are responsible for transmitting Chagas disease, which affects millions in Central and South America each year. ✨
#animals⚡#danger⚡#bites
👉subscribe Interesting Planet
👉more Channels
🌎 The mosquito is considered the deadliest animal on Earth, causing over 700,000 human deaths each year. Mosquitoes spread malaria, dengue, Zika, yellow fever, and other life-threatening diseases across tropical and subtropical regions, making them a major global health threat. ✨
#animals⚡#danger⚡#diseases
👉subscribe Interesting Planet
🪐 The asteroid (137108) 1999 AN10 is an Apollo-type near-Earth object roughly 800 meters wide, and its orbit brings it close enough to Earth every few decades that scientists label it as potentially hazardous. Current calculations predict an especially close approach in 2027, when it will pass within about 390,000 kilometers—almost the same distance as the Moon—making it one of the larger asteroids to come so near our planet in the 21st century. ✨
#asteroids⚡#danger⚡#nearEarth⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🌎 Saltwater crocodiles are among the most dangerous animals on Earth. These massive reptiles can exceed 6 meters in length and have the strongest recorded bite force of any living animal—over 16,000 newtons. Saltwater crocodiles are responsible for hundreds of attacks on humans annually throughout Southeast Asia and northern Australia. ✨
#crocodile⚡#danger⚡#reptiles
👉subscribe Interesting Planet
👉more Channels
🌎 Hippos are among the most dangerous large animals in Africa, causing more human deaths annually than lions. Territorial males can attack boats and move surprisingly fast on land, reaching speeds of up to 30 kilometers per hour. ✨
#hippo⚡#wildlife⚡#danger
👉subscribe Interesting Planet
🪐 The asteroid (7335) 1989 JA is classified as a "potentially hazardous asteroid" because it's over 1.8 kilometers wide and its orbit brings it close enough to Earth to be watched carefully by astronomers. In 2022, it made a safe pass at about 4 million kilometers from our planet, but its great size means that any future close approach will always be closely monitored for any change in its path. ✨
#asteroids⚡#danger⚡#nearearthobjects⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🌎 The freshwater African Nile crocodile holds a notorious reputation as one of Earth's most dangerous animals, responsible for hundreds of human fatalities yearly. Adult males can reach up to 5 meters in length and exert a bite force exceeding 16,000 newtons—one of the strongest in the animal kingdom. ✨
#crocodile⚡#danger⚡#predators
👉subscribe Interesting Planet
👉more Channels
🌎 Saltwater crocodiles are Earth's largest living reptiles and among the most dangerous animals, capable of ambushing and killing prey as large as water buffalo. Adult males can grow over 6 meters long and weigh up to 1,000 kilograms. ✨
#crocodile⚡#predators⚡#danger
👉subscribe Interesting Planet
🪐 On June 30, 1908, a small asteroid or comet exploded over Tunguska, Siberia, flattening 2,000 square kilometers of forest in an instant. Known as the Tunguska event, this airburst was caused by an object about 50–60 meters wide—large enough to release energy more powerful than the largest nuclear bomb ever detonated, yet leaving no impact crater. ✨
#asteroids⚡#danger⚡#Tunguska⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
Why did yhe 2026 SuperbOwl logo colors match the Emergency Broadcast System colors??? What do they have planned or already know is coming??? #migrateEast#Danger#EmergencyBroadcastSystem#SuperBowl