Skip to content

Commit

Permalink
qtvcp -work around Q_ENUM/Q_ENUMS errors in older pyqt libraries
Browse files Browse the repository at this point in the history
HalBar and JoyPad use Q_ENUM, older systems Q_ENUMS
Now we can switch between them
  • Loading branch information
c-morley committed Jul 17, 2023
1 parent 3992793 commit 8350826
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
10 changes: 3 additions & 7 deletions lib/python/qtvcp/plugins/qtvcp_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,16 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

# helps confirm designer is set up with right paths
print('Qtvcp python plugin found:',__file__)

# HAL only widgets
from qtvcp.plugins.simplewidgets_plugin import *
from qtvcp.plugins.led_plugin import LEDPlugin
from qtvcp.plugins.hal_label_plugin import HALLabelPlugin
from qtvcp.plugins.detach_tabs_plugin import DetachTabWidgetPlugin
from qtvcp.plugins.round_progress_bar_plugin import RoundProgressBarPlugin
from PyQt5.QtCore import PYQT_VERSION_STR
try:
v = PYQT_VERSION_STR.split('.')
if int(v[1]) > 10:
from qtvcp.plugins.joypad_plugin import *
except:
print('PyQt version {} to old for JoyPad widget'.format(PYQT_VERSION_STR))
from qtvcp.plugins.joypad_plugin import *

# plain widgets
from qtvcp.plugins.nurbs_editor_plugin import NurbsEditorPlugin
Expand Down
8 changes: 7 additions & 1 deletion lib/python/qtvcp/widgets/bar.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
from PyQt5 import QtWidgets
from PyQt5.QtGui import QColor, QBrush, QPainter
from PyQt5.QtCore import (Qt, pyqtSlot, pyqtProperty, QVariant, QRectF,
QSize, Q_ENUM)
QSize)

try:
from PyQt5.QtCore import Q_ENUM
except:
# before Qt 5.10
from PyQt5.QtCore import Q_ENUMS as Q_ENUM

from qtvcp.widgets.widget_baseclass import _HalWidgetBase
import hal
Expand Down
8 changes: 7 additions & 1 deletion lib/python/qtvcp/widgets/joypad.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@
###############################################################################
import sys
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import Qt, QPoint, QPointF, QRect, QRectF, QSize, QSizeF, QEvent, Q_ENUM
from PyQt5.QtCore import Qt, QPoint, QPointF, QRect, QRectF, QSize, QSizeF, QEvent
from PyQt5.QtGui import QPainter, QPainterPath, QPen, QBrush, QColor, QFont, QPixmap, QRadialGradient

try:
from PyQt5.QtCore import Q_ENUM
except:
# before qt5.10
from PyQt5.QtCore import Q_ENUMS as Q_ENUM

import hal
from qtvcp.widgets.widget_baseclass import _HalWidgetBase

Expand Down

0 comments on commit 8350826

Please sign in to comment.