artiq/artiq/gui/tools.py

38 lines
895 B
Python
Raw Normal View History

import logging
2016-02-15 05:22:07 +08:00
from PyQt5 import QtCore, QtWidgets, QtGui
def log_level_to_name(level):
if level >= logging.CRITICAL:
return "CRITICAL"
if level >= logging.ERROR:
return "ERROR"
if level >= logging.WARNING:
return "WARNING"
if level >= logging.INFO:
return "INFO"
return "DEBUG"
class _WheelFilter(QtCore.QObject):
def eventFilter(self, obj, event):
if event.type() == QtCore.QEvent.Wheel:
event.ignore()
return True
else:
return False
def disable_scroll_wheel(widget):
widget.setFocusPolicy(QtCore.Qt.StrongFocus)
widget.installEventFilter(_WheelFilter(widget))
2016-02-15 05:22:07 +08:00
class QDockWidgetCloseDetect(QtWidgets.QDockWidget):
sigClosed = QtCore.pyqtSignal()
2016-02-15 05:42:25 +08:00
def closeEvent(self, event):
self.sigClosed.emit()
QtWidgets.QDockWidget.closeEvent(self, event)