|
@@ -1,4 +1,3 @@
|
|
-# flake8: noqa
|
|
|
|
#
|
|
#
|
|
# Copyright (C) 2011 Michael Pitidis, Hussein Abdulwahid.
|
|
# Copyright (C) 2011 Michael Pitidis, Hussein Abdulwahid.
|
|
#
|
|
#
|
|
@@ -21,29 +20,32 @@
|
|
from math import sqrt
|
|
from math import sqrt
|
|
|
|
|
|
try:
|
|
try:
|
|
- from PyQt5.QtGui import *
|
|
|
|
- from PyQt5.QtCore import *
|
|
|
|
- from PyQt5.QtWidgets import *
|
|
|
|
|
|
+ from PyQt5 import QtCore
|
|
|
|
+ from PyQt5 import QtGui
|
|
|
|
+ from PyQt5 import QtWidgets
|
|
except ImportError:
|
|
except ImportError:
|
|
- from PyQt4.QtGui import *
|
|
|
|
- from PyQt4.QtCore import *
|
|
|
|
|
|
+ from PyQt4 import QtCore
|
|
|
|
+ from PyQt4 import QtGui
|
|
|
|
+ from PyQt4 import QtGui as QtWidgets
|
|
|
|
|
|
|
|
|
|
def newIcon(icon):
|
|
def newIcon(icon):
|
|
- return QIcon(':/' + icon)
|
|
|
|
|
|
+ return QtGui.QIcon(':/' + icon)
|
|
|
|
+
|
|
|
|
|
|
def newButton(text, icon=None, slot=None):
|
|
def newButton(text, icon=None, slot=None):
|
|
- b = QPushButton(text)
|
|
|
|
|
|
+ b = QtWidgets.QPushButton(text)
|
|
if icon is not None:
|
|
if icon is not None:
|
|
b.setIcon(newIcon(icon))
|
|
b.setIcon(newIcon(icon))
|
|
if slot is not None:
|
|
if slot is not None:
|
|
b.clicked.connect(slot)
|
|
b.clicked.connect(slot)
|
|
return b
|
|
return b
|
|
|
|
|
|
|
|
+
|
|
def newAction(parent, text, slot=None, shortcut=None, icon=None,
|
|
def newAction(parent, text, slot=None, shortcut=None, icon=None,
|
|
- tip=None, checkable=False, enabled=True):
|
|
|
|
|
|
+ tip=None, checkable=False, enabled=True):
|
|
"""Create a new action and assign callbacks, shortcuts, etc."""
|
|
"""Create a new action and assign callbacks, shortcuts, etc."""
|
|
- a = QAction(text, parent)
|
|
|
|
|
|
+ a = QtGui.QAction(text, parent)
|
|
if icon is not None:
|
|
if icon is not None:
|
|
a.setIcon(newIcon(icon))
|
|
a.setIcon(newIcon(icon))
|
|
if shortcut is not None:
|
|
if shortcut is not None:
|
|
@@ -66,23 +68,25 @@ def addActions(widget, actions):
|
|
for action in actions:
|
|
for action in actions:
|
|
if action is None:
|
|
if action is None:
|
|
widget.addSeparator()
|
|
widget.addSeparator()
|
|
- elif isinstance(action, QMenu):
|
|
|
|
|
|
+ elif isinstance(action, QtGui.QMenu):
|
|
widget.addMenu(action)
|
|
widget.addMenu(action)
|
|
else:
|
|
else:
|
|
widget.addAction(action)
|
|
widget.addAction(action)
|
|
|
|
|
|
|
|
+
|
|
def labelValidator():
|
|
def labelValidator():
|
|
- return QRegExpValidator(QRegExp(r'^[^ \t].+'), None)
|
|
|
|
|
|
+ return QtGui.QRegExpValidator(QtCore.QRegExp(r'^[^ \t].+'), None)
|
|
|
|
|
|
|
|
|
|
class struct(object):
|
|
class struct(object):
|
|
def __init__(self, **kwargs):
|
|
def __init__(self, **kwargs):
|
|
self.__dict__.update(kwargs)
|
|
self.__dict__.update(kwargs)
|
|
|
|
|
|
|
|
+
|
|
def distance(p):
|
|
def distance(p):
|
|
return sqrt(p.x() * p.x() + p.y() * p.y())
|
|
return sqrt(p.x() * p.x() + p.y() * p.y())
|
|
|
|
|
|
|
|
+
|
|
def fmtShortcut(text):
|
|
def fmtShortcut(text):
|
|
mod, key = text.split('+', 1)
|
|
mod, key = text.split('+', 1)
|
|
return '<b>%s</b>+<b>%s</b>' % (mod, key)
|
|
return '<b>%s</b>+<b>%s</b>' % (mod, key)
|
|
-
|
|
|