MCPcopy Create free account
hub / github.com/PyQt5/PyQt / __init__

Method __init__

QGraphicsDropShadowEffect/ShadowEffect.py:27–61  ·  view source on GitHub ↗
(self, *args, **kwargs)

Source from the content-addressed store, hash-verified

25class Window(QWidget):
26
27 def __init__(self, *args, **kwargs):
28 super(Window, self).__init__(*args, **kwargs)
29 layout = QHBoxLayout(self)
30
31 # 绿色边框
32 labelGreen = QLabel(self, pixmap=QPixmap('Data/1.jpg').scaled(100, 100))
33 layout.addWidget(labelGreen)
34 aniGreen = AnimationShadowEffect(Qt.darkGreen, labelGreen)
35 labelGreen.setGraphicsEffect(aniGreen)
36 aniGreen.start()
37
38 # 红色边框,圆形图片
39 labelRed = QLabel(self)
40 labelRed.setMinimumSize(100, 100)
41 labelRed.setMaximumSize(100, 100)
42 labelRed.setStyleSheet('border-image: url(Data/1.jpg);border-radius: 50px;')
43 layout.addWidget(labelRed)
44 aniRed = AnimationShadowEffect(Qt.red, labelGreen)
45 labelRed.setGraphicsEffect(aniRed)
46 aniRed.start()
47
48 # 蓝色边框按钮
49 button = QPushButton('按钮', self)
50 aniButton = AnimationShadowEffect(Qt.blue, button)
51 layout.addWidget(button)
52 button.setGraphicsEffect(aniButton)
53 button.clicked.connect(aniButton.stop) # 按下按钮停止动画
54 aniButton.start()
55
56 # 青色边框输入框
57 lineedit = QLineEdit(self)
58 aniEdit = AnimationShadowEffect(Qt.cyan, lineedit)
59 layout.addWidget(lineedit)
60 lineedit.setGraphicsEffect(aniEdit)
61 aniEdit.start()
62
63
64if __name__ == '__main__':

Callers

nothing calls this directly

Calls 3

startMethod · 0.95
addWidgetMethod · 0.80

Tested by

no test coverage detected