Для тех кто пишет расширения на 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 galaxy IC 1101 is one of the largest known galaxies in the universe, stretching about 6 million light-years across—nearly 60 times the diameter of the Milky Way. If you tried to cross IC 1101 at the speed of light, it would still take 6 million years, highlighting just how colossal the distances between and within galaxies can be in the cosmos. ✨
#spacedistances⚡#galaxies⚡#universe⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 The Sombrero Galaxy (Messier 104), located about 31 million light-years away in the constellation Virgo, stretches 50,000 light-years across—nearly half the diameter of our Milky Way. Even the fastest spacecraft ever built would need millions of years to traverse a single galaxy like Sombrero, showing how cosmic distances turn entire galaxies into vast, seemingly unreachable islands amid the universe’s dark ocean. ✨
#spacedistances⚡#galaxies⚡#universe⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 The James Webb Space Telescope has identified a galaxy named JADES-GS-z13-0, whose light began its journey over 13.4 billion years ago—only about 320 million years after the Big Bang. Observing JADES-GS-z13-0 helps astronomers peer back to the universe’s infancy, revealing what the very first galaxies were like just after cosmic dawn. ✨
#spacedistances⚡#galaxies⚡#universe⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 The radial size of our Milky Way Galaxy is about 52,850 light-years from its center to edge, but the spiral arms themselves can be thousands of light-years wide—wider than the distance between our Sun and the Andromeda Galaxy. To cross this enormous span at the speed of the fastest human-made object, Voyager 1, would take over a billion years, demonstrating just how mind-bogglingly vast even our own galaxy truly is. ✨
#spacedistances⚡#milkyway⚡#galaxy⚡#nasa⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 The Milky Way galaxy itself is so vast that it spans about 100,000 light-years from edge to edge—a light-year is the distance light travels in a year, roughly 9.46 trillion kilometers. If you could shrink our solar system down to the size of a coin, the Milky Way would be as wide as North America, revealing just how immense the distances are even within a single galaxy. ✨
#spacedistances⚡#milkyway⚡#astronomy⚡#nasa⚡#galaxy⚡#stars⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🪐 The distance from Earth to Proxima Centauri, the closest known star beyond our Sun, is about 4.24 light-years—a distance so vast that if you traveled as fast as New Horizons (the fastest spacecraft launched from Earth), it would take over 78,000 years to get there. Even within our own solar system, Neptune is so far from the Sun—about 4.5 billion kilometers—that sunlight takes over four hours to reach it, showing how truly immense the spaces between cosmic objects really are. ✨
#spacedistances⚡#stars⚡#solarystem⚡#nasa⚡#galaxy⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🪐 The distance from Earth to the Sun, known as an astronomical unit (AU), is about 149.6 million kilometers—and it serves as a standard ruler for measuring space distances within our solar system. For example, Jupiter is about 5.2 AU from the Sun, which means it orbits nearly 780 million kilometers away, showing how even our neighboring planets are separated by unimaginable expanses. ✨
#spacedistances⚡#solarorbit⚡#astronomy⚡#nasa⚡#galaxy⚡#stars⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 The nearest bright star in our night sky, Sirius, is about 8.6 light-years from Earth—meaning the light you see from it tonight actually left the star nearly a decade ago. Even within our own galaxy, these incredible distances show that starlight is a message from the past, traveling billions of kilometers before reaching our eyes. ✨
#spacedistances⚡#sirius⚡#astronomy⚡#nasa⚡#galaxy⚡#stars⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 Light from the galaxy NGC 4992, located nearly 150 million light-years away in Leo, takes so long to reach us that we observe it as it was when dinosaurs still roamed Earth. Even within our own Milky Way, stars like V404 Cygni are thousands of light-years away, meaning every twinkle in the night sky is a peek deep into the past—a testament to the truly immense distances that fill the universe. ✨
#spacedistances⚡#lightyears⚡#galaxies⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 The distance from Earth to the Virgo Cluster, a giant grouping of galaxies, is about 55 million light-years—meaning the light we see from its member galaxies, like Messier 87, began its journey long before the first dinosaurs appeared on our planet. Even within the Virgo Cluster, galaxies can be separated by hundreds of thousands of light-years, showing that cosmic neighborhoods are staggeringly vast compared to our entire solar system. ✨
#spacedistances⚡#galaxies⚡#virgo⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 The nearest galaxy to our Milky Way, the Large Magellanic Cloud, is about 163,000 light-years away—which means its light takes 163,000 years to reach us. Even though this galaxy sits relatively close on a cosmic scale, traveling that distance with today’s fastest spacecraft would still take millions of years, revealing just how vast even our local corner of the universe truly is. ✨
#spacedistances⚡#galaxies⚡#lightyears⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🪐 The distance between Earth and the edge of the observable universe is about 46.5 billion light-years—meaning the furthest galaxies seen by the Hubble Space Telescope, like GN-z11, are so distant that their light has taken over 13 billion years to reach us, yet the universe has expanded even farther in that time. This immense scale exists because space itself stretches as light travels, making cosmic distances far greater than the simple time since the Big Bang would suggest. ✨
#spacedistances⚡#cosmology⚡#hubble⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels