本文整理汇总了Python中PyQt4.QtGui.QGraphicsOpacityEffect类的典型用法代码示例。如果您正苦于以下问题:Python QGraphicsOpacityEffect类的具体用法?Python QGraphicsOpacityEffect怎么用?Python QGraphicsOpacityEffect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QGraphicsOpacityEffect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Minimap
class Minimap(QsciScintilla):
def __init__(self, weditor):
QsciScintilla.__init__(self, weditor)
self._weditor = weditor
self._indentation = self._weditor._indentation
self.setLexer(self._weditor.lexer())
# Configuración Scintilla
self.setMouseTracking(True)
self.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, False)
self.SendScintilla(QsciScintilla.SCI_HIDESELECTION, True)
self.setFolding(QsciScintilla.NoFoldStyle, 1)
self.setReadOnly(True)
self.setCaretWidth(0)
self.setStyleSheet("background: transparent; border: 0px;")
# Opacity
self.effect = QGraphicsOpacityEffect()
self.setGraphicsEffect(self.effect)
self.effect.setOpacity(0.5)
# Deslizador
self.slider = Slider(self)
self.slider.hide()
def resizeEvent(self, event):
super(Minimap, self).resizeEvent(event)
self.slider.setFixedWidth(self.width())
lines_on_screen = self._weditor.SendScintilla(
QsciScintilla.SCI_LINESONSCREEN)
self.slider.setFixedHeight(lines_on_screen * 4)
def update_geometry(self):
self.setFixedHeight(self._weditor.height())
self.setFixedWidth(self._weditor.width() * 0.13)
x = self._weditor.width() - self.width()
self.move(x, 0)
self.zoomIn(-3)
def update_code(self):
text = self._weditor.text().replace('\t', ' ' * self._indentation)
self.setText(text)
def leaveEvent(self, event):
super(Minimap, self).leaveEvent(event)
self.slider.animation.setStartValue(0.2)
self.slider.animation.setEndValue(0)
self.slider.animation.start()
def enterEvent(self, event):
super(Minimap, self).enterEvent(event)
if not self.slider.isVisible():
self.slider.show()
else:
self.slider.animation.setStartValue(0)
self.slider.animation.setEndValue(0.2)
self.slider.animation.start()
示例2: SliderArea
class SliderArea(QFrame):
def __init__(self, minimap):
super(SliderArea, self).__init__(minimap)
self._minimap = minimap
self.pressed = False
self.setMouseTracking(True)
self.setCursor(Qt.OpenHandCursor)
color = resources.CUSTOM_SCHEME.get(
'MinimapVisibleArea', resources.COLOR_SCHEME['MinimapVisibleArea'])
if ACTIVATE_OPACITY:
self.setStyleSheet("background: %s;" % color)
self.goe = QGraphicsOpacityEffect()
self.setGraphicsEffect(self.goe)
self.goe.setOpacity(settings.MINIMAP_MAX_OPACITY / 2)
else:
self.setStyleSheet("background: transparent;")
def mousePressEvent(self, event):
super(SliderArea, self).mousePressEvent(event)
self.pressed = True
self.setCursor(Qt.ClosedHandCursor)
def mouseReleaseEvent(self, event):
super(SliderArea, self).mouseReleaseEvent(event)
self.pressed = False
self.setCursor(Qt.OpenHandCursor)
def update_position(self):
font_size = round(self._minimap.font().pointSize() / 2.5)
lines_count = self._minimap._editor.SendScintilla(
QsciScintilla.SCI_LINESONSCREEN)
height = lines_count * font_size
self.setFixedHeight(height)
self.setFixedWidth(self._minimap.width())
def paintEvent(self, event):
"""Paint over the widget to overlay its content."""
if not ACTIVATE_OPACITY:
painter = QPainter()
painter.begin(self)
painter.setRenderHint(QPainter.TextAntialiasing, True)
painter.setRenderHint(QPainter.Antialiasing, True)
painter.fillRect(event.rect(), QBrush(
QColor(226, 0, 0, 80)))
painter.setPen(QPen(Qt.NoPen))
painter.end()
super(SliderArea, self).paintEvent(event)
def mouseMoveEvent(self, event):
super(SliderArea, self).mouseMoveEvent(event)
if self.pressed:
pos = self.mapToParent(event.pos())
self._minimap.scroll_area(pos)
示例3: SliderArea
class SliderArea(QFrame):
def __init__(self, parent):
super(SliderArea, self).__init__(parent)
self._parent = parent
self.setMouseTracking(True)
self.setCursor(Qt.OpenHandCursor)
color = "#858585"
self.setStyleSheet("background: %s;" % color)
self.goe = QGraphicsOpacityEffect()
self.setGraphicsEffect(self.goe)
self.goe.setOpacity(MINIMAP_MAX_OPACITY / 2)
self.pressed = False
self.__scroll_margins = None
def paintEvent(self, event):
"""Paint over the widget to overlay its content."""
super(SliderArea, self).paintEvent(event)
def update_position(self):
font_size = QFontMetrics(self._parent.font()).height()
height = self._parent.lines_count * font_size
self.setFixedHeight(height)
self.setFixedWidth(self._parent.width())
self.__scroll_margins = (height, self._parent.height() - height)
def move_slider(self, y):
self.move(0, y)
def mousePressEvent(self, event):
super(SliderArea, self).mousePressEvent(event)
self.pressed = True
self.setCursor(Qt.ClosedHandCursor)
def mouseReleaseEvent(self, event):
super(SliderArea, self).mouseReleaseEvent(event)
self.pressed = False
self.setCursor(Qt.OpenHandCursor)
def mouseMoveEvent(self, event):
super(SliderArea, self).mouseMoveEvent(event)
if self.pressed:
pos = self.mapToParent(event.pos())
y = pos.y() - (self.height() / 2)
if y < 0:
y = 0
if y < self.__scroll_margins[0]:
self._parent.verticalScrollBar().setSliderPosition(
self._parent.verticalScrollBar().sliderPosition() - 2)
elif y > self.__scroll_margins[1]:
self._parent.verticalScrollBar().setSliderPosition(
self._parent.verticalScrollBar().sliderPosition() + 2)
self.move(0, y)
self._parent.scroll_area(pos, event.pos())
示例4: __init__
def __init__(self, parent=None, caption=None):
QLabel.__init__(self, parent)
self.setText(self.accessibleName())
self.setFont(QtGui.QFont("Arial", 12))
self.__separator = chr(004) #Used as separator while scrolling text
#BLINK
self.__blink_timer = QTimer(parent)
self.__blink_timer.timeout.connect(self.__on_blink_timer)
self.__blink_timer_interval = 1000
#FADING
self.__opacity_effect = QGraphicsOpacityEffect()
self.__fading_timer = QTimer(parent)
self.__fading_timer.timeout.connect(self.__on_fading_timer)
self.__FADE_TYPE = Enum("IN", "OUT")
self.__fade_time = 20
self.__opacity = 1.0
self.__opacity_fading_coefficient = 0.02
self.__selected_fade_type = self.__FADE_TYPE.IN
#SCROLLING
self.__scrolling_timer = QTimer(parent)
self.__scrolling_timer.timeout.connect(self.__on_scrolling_timer)
self.__scroll_time = 1000
self.__original_text = ""
#MOVE
self.__move_animation_type = QEasingCurve.Linear
self.__move_time = 350
示例5: __init__
def __init__(self, parent):
super(MiniMap, self).__init__(parent)
# self.setWordWrapMode(QTextOption.NoWrap)
# self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
# self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.setReadOnly(True)
self.SendScintilla(QsciScintilla.SCI_SETBUFFEREDDRAW, 0)
self.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 0)
self.SendScintilla(QsciScintilla.SCI_SETVSCROLLBAR, 0)
self.setMarginWidth(1, 0)
self.setFolding(self.NoFoldStyle, 2)
# self.setCenterOnScroll(True)
self.setMouseTracking(True)
# self.viewport().setCursor(Qt.PointingHandCursor)
# self.setTextInteractionFlags(Qt.NoTextInteraction)
self._parent = parent
# self.highlighter = None
# self.lines_count = 0
self.connect(self._parent, SIGNAL("updateRequest(const QRect&, int)"), self.update_visible_area)
if ACTIVATE_OPACITY:
self.goe = QGraphicsOpacityEffect()
self.setGraphicsEffect(self.goe)
self.goe.setOpacity(settings.MINIMAP_MIN_OPACITY)
self.animation = QPropertyAnimation(self.goe, "opacity")
示例6: __init__
def __init__(self, parent):
super(MiniMap, self).__init__(parent)
self.setWordWrapMode(QTextOption.NoWrap)
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.setReadOnly(True)
self.setCenterOnScroll(True)
self.setMouseTracking(True)
self.viewport().setCursor(Qt.PointingHandCursor)
self.setTextInteractionFlags(Qt.NoTextInteraction)
self._parent = parent
self.highlighter = None
self.lines_count = 0
self.connect(self._parent, SIGNAL("updateRequest(const QRect&, int)"), self.update_visible_area)
if ACTIVATE_OPACITY:
self.goe = QGraphicsOpacityEffect()
self.setGraphicsEffect(self.goe)
self.goe.setOpacity(settings.MINIMAP_MIN_OPACITY)
self.animation = QPropertyAnimation(self.goe, "opacity")
self.slider = SliderArea(self)
self.slider.show()
示例7: __init__
def __init__(self, editor):
super(MiniMap, self).__init__(editor)
self._editor = editor
self.SendScintilla(QsciScintilla.SCI_SETCARETSTYLE, 0)
self.SendScintilla(QsciScintilla.SCI_SETBUFFEREDDRAW, 0)
self.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 0)
self.SendScintilla(QsciScintilla.SCI_SETVSCROLLBAR, 0)
self.SendScintilla(QsciScintilla.SCI_SETZOOM, -10)
self.SendScintilla(QsciScintilla.SCI_SETREADONLY, 1)
self.SendScintilla(QsciScintilla.SCI_HIDESELECTION, 1)
self.SendScintilla(QsciScintilla.SCI_SETCURSOR, 8)
# Hide markers
for i in range(1, 5):
self.SendScintilla(
QsciScintilla.SCI_MARKERDEFINE, i, QsciScintilla.SC_MARK_EMPTY)
self.SendScintilla(QsciScintilla.SCI_SETMARGINWIDTHN, 1, 0)
self.setMouseTracking(True)
if ACTIVATE_OPACITY:
self.goe = QGraphicsOpacityEffect()
self.setGraphicsEffect(self.goe)
self.goe.setOpacity(settings.MINIMAP_MIN_OPACITY)
self.animation = QPropertyAnimation(self.goe, "opacity")
self.animation.setDuration(300)
self.slider = SliderArea(self)
self.slider.show()
示例8: __init__
def __init__(self, parent):
super(SliderArea, self).__init__(parent)
self._parent = parent
self.setMouseTracking(True)
self.setCursor(Qt.OpenHandCursor)
color = "#858585"
self.setStyleSheet("background: %s;" % color)
self.goe = QGraphicsOpacityEffect()
self.setGraphicsEffect(self.goe)
self.goe.setOpacity(MINIMAP_MAX_OPACITY / 2)
self.pressed = False
self.__scroll_margins = None
示例9: __init__
def __init__(self, minimap):
QFrame.__init__(self, minimap)
self._minimap = minimap
self.setStyleSheet("background: gray; border-radius: 3px;")
# Opacity
self.effect = QGraphicsOpacityEffect()
self.setGraphicsEffect(self.effect)
self.effect.setOpacity(0.2)
# Animación
self.animation = QPropertyAnimation(self.effect, "opacity")
self.animation.setDuration(150)
# Cursor
self.setCursor(Qt.OpenHandCursor)
示例10: __init__
def __init__(self, parent):
super(SliderArea, self).__init__(parent)
self._parent = parent
self.setMouseTracking(True)
self.setCursor(Qt.OpenHandCursor)
color = resources.CUSTOM_SCHEME.get('current-line',
resources.COLOR_SCHEME['current-line'])
self.setStyleSheet("background: %s;" % color)
self.goe = QGraphicsOpacityEffect()
self.setGraphicsEffect(self.goe)
self.goe.setOpacity(settings.MINIMAP_MAX_OPACITY / 2)
self.pressed = False
self.__scroll_margins = None
示例11: Slider
class Slider(QFrame):
def __init__(self, minimap):
QFrame.__init__(self, minimap)
self._minimap = minimap
self.setStyleSheet("background: gray; border-radius: 3px;")
# Opacity
self.effect = QGraphicsOpacityEffect()
self.setGraphicsEffect(self.effect)
self.effect.setOpacity(0.2)
# Animación
self.animation = QPropertyAnimation(self.effect, "opacity")
self.animation.setDuration(150)
# Cursor
self.setCursor(Qt.OpenHandCursor)
def mouseMoveEvent(self, event):
super(Slider, self).mouseMoveEvent(event)
#FIXME: funciona algo loco
pos = self.mapToParent(event.pos())
dy = pos.y() - (self.height() / 2)
if dy < 0:
dy = 0
self.move(0, dy)
pos.setY(pos.y() - event.pos().y())
self._minimap._weditor.verticalScrollBar().setValue(pos.y())
self._minimap.verticalScrollBar().setSliderPosition(
self._minimap.verticalScrollBar().sliderPosition() + 2)
self._minimap.verticalScrollBar().setValue(pos.y() - event.pos().y())
def mousePressEvent(self, event):
super(Slider, self).mousePressEvent(event)
self.setCursor(Qt.ClosedHandCursor)
def mouseReleaseEvent(self, event):
super(Slider, self).mouseReleaseEvent(event)
self.setCursor(Qt.OpenHandCursor)
示例12: __init__
def __init__(self, logger):
self.logger = logger
self.good = False
self.fadingEnabled = False
self.minOpacity = 0.
self.maxOpacity = 1.
self.incr = (self.maxOpacity - self.minOpacity) / self.NUM_STEPS
self.fadeIn = False
try:
from PyQt4.QtGui import QGraphicsOpacityEffect
self.effect = QGraphicsOpacityEffect(self)
self.setGraphicsEffect(self.effect)
self.timer = QTimer(self)
self.timer.timeout.connect(self._fade)
self.good = True
except:
self.logger.debug(u"Could not enable opacity effects. %s: %s", sys.exc_info()[0].__name__, unicode(sys.exc_info()[1]))
示例13: __init__
def __init__(self, parent):
super(MiniMap, self).__init__(parent)
self.setWordWrapMode(QTextOption.NoWrap)
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.setReadOnly(True)
self.setCenterOnScroll(True)
self.setMouseTracking(True)
self.setTextInteractionFlags(Qt.NoTextInteraction)
self._parent = parent
self.highlighter = None
styles.set_style(self, 'minimap')
self.max_line = 0
self.goe = QGraphicsOpacityEffect()
self.setGraphicsEffect(self.goe)
self.goe.setOpacity(settings.MINIMAP_MIN_OPACITY)
self.animation = QPropertyAnimation(self.goe, "opacity")
示例14: __init__
def __init__(self, parent=None):
QFrame.__init__(self, parent)
#FADING
self.__opacity_effect = QGraphicsOpacityEffect()
self.__fading_timer = QTimer(parent)
self.__fading_timer.timeout.connect(self.__on_fading_timer)
self.__FADE_TYPE = Enum("IN", "OUT")
self.__fade_time = 20
self.__opacity = 1.0
self.__opacity_fading_coefficient = 0.02
self.__selected_fade_type = self.__FADE_TYPE.IN
self.resizeEvent = self.__onResize
#MOVE
self.__move_animation_type = QEasingCurve.Linear
self.__move_time = 350
self.__is_moving = False
#RESIZE
self.__resize_animation_type = QEasingCurve.Linear
self.__resize_time = 700
self.__is_resizing = False
#PIXMAP & MASCHERA
self.__pmap = QPixmap(self.size())
self.__pmap_fname = ""
self.__show_mask_preview = False
#SHADOW
self.__shadow_Xoffset = 3.0 #default value
self.__shadow_Yoffset = 3.0 #default value
self.__shadow_blur_radius = 8.0 #default value
self.__shadow_color = QColor(38,38,38,150) #default value
self.__shadow_effect = QGraphicsDropShadowEffect()
self.__shadow_effect.setXOffset(self.__shadow_Xoffset)
self.__shadow_effect.setYOffset(self.__shadow_Yoffset)
self.__shadow_effect.setBlurRadius(self.__shadow_blur_radius)
self.__shadow_effect.setColor(self.__shadow_color)
self._shadow_visible = False
示例15: HiddenWidgetBase
class HiddenWidgetBase(object):
INITIAL_TIMEOUT = 2000
NUM_STEPS = 15
INTERVAL = 20
def __init__(self, logger):
self.logger = logger
self.good = False
self.fadingEnabled = False
self.minOpacity = 0.
self.maxOpacity = 1.
self.incr = (self.maxOpacity - self.minOpacity) / self.NUM_STEPS
self.fadeIn = False
try:
from PyQt4.QtGui import QGraphicsOpacityEffect
self.effect = QGraphicsOpacityEffect(self)
self.setGraphicsEffect(self.effect)
self.timer = QTimer(self)
self.timer.timeout.connect(self._fade)
self.good = True
except:
self.logger.debug(u"Could not enable opacity effects. %s: %s", sys.exc_info()[0].__name__, unicode(sys.exc_info()[1]))
# cannot use loggingSlot here because this is no QObject
@loggingFunc
def setMinOpacity(self, newVal):
self.minOpacity = newVal
self.incr = (self.maxOpacity - self.minOpacity) / self.NUM_STEPS
if self.fadingEnabled and not self.timer.isActive():
self.timer.start(self.INTERVAL)
# cannot use loggingSlot here because this is no QObject
@loggingFunc
def setMaxOpacity(self, newVal):
self.maxOpacity = newVal
self.incr = (self.maxOpacity - self.minOpacity) / self.NUM_STEPS
if self.fadingEnabled and not self.timer.isActive():
self.timer.start(self.INTERVAL)
# cannot use loggingSlot here because this is no QObject
@loggingFunc
def showTemporarily(self):
if self.good:
self.fadingEnabled = False
self.fadeIn = False
self.timer.stop()
self.effect.setOpacity(self.maxOpacity)
QTimer.singleShot(self.INITIAL_TIMEOUT, self._fadeOut)
def _fadeOut(self):
self.fadingEnabled = True
self.timer.start(self.INTERVAL * 1.5)
# cannot use loggingSlot here because this is no QObject
@loggingFunc
def _fade(self):
if self.fadeIn:
desOp = self.maxOpacity
else:
desOp = self.minOpacity
opacity = self.effect.opacity()
if abs(opacity - desOp) < self.incr:
# prevent flickering if timer does not stop immediately
return
if opacity < desOp:
opacity += self.incr
self.effect.setOpacity(opacity)
else:
opacity -= self.incr
self.effect.setOpacity(opacity)
#finish animation if desired opacity is reached
if abs(opacity - desOp) < self.incr:
self.timer.stop()
def _mouseEntered(self):
if self.good and self.fadingEnabled:
self.fadeIn = True
self.timer.start(self.INTERVAL)
def _mouseLeft(self):
if self.good and self.fadingEnabled:
self.fadeIn = False
self.timer.start(self.INTERVAL)