本文整理汇总了Python中PyQt4.QtGui.QGraphicsDropShadowEffect.setColor方法的典型用法代码示例。如果您正苦于以下问题:Python QGraphicsDropShadowEffect.setColor方法的具体用法?Python QGraphicsDropShadowEffect.setColor怎么用?Python QGraphicsDropShadowEffect.setColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QGraphicsDropShadowEffect
的用法示例。
在下文中一共展示了QGraphicsDropShadowEffect.setColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: must_glow
# 需要导入模块: from PyQt4.QtGui import QGraphicsDropShadowEffect [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsDropShadowEffect import setColor [as 别名]
def must_glow(widget_list):
" apply an glow effect to the widget "
for glow, each_widget in enumerate(widget_list):
try:
if each_widget.graphicsEffect() is None:
glow = QGraphicsDropShadowEffect(self)
glow.setOffset(0)
glow.setBlurRadius(99)
glow.setColor(QColor(99, 255, 255))
each_widget.setGraphicsEffect(glow)
# glow.setEnabled(False)
try:
each_widget.clicked.connect(
lambda: each_widget.graphicsEffect().setEnabled(True)
if each_widget.graphicsEffect().isEnabled() is False
else each_widget.graphicsEffect().setEnabled(False)
)
except:
each_widget.sliderPressed.connect(
lambda: each_widget.graphicsEffect().setEnabled(True)
if each_widget.graphicsEffect().isEnabled() is False
else each_widget.graphicsEffect().setEnabled(False)
)
except:
pass
示例2: enableHoverEffect
# 需要导入模块: from PyQt4.QtGui import QGraphicsDropShadowEffect [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsDropShadowEffect import setColor [as 别名]
def enableHoverEffect(self):
e = QGraphicsDropShadowEffect()
e.setEnabled(False)
e.setBlurRadius(2 * _trackWidth)
e.setColor(_hoverColor)
e.setOffset(0, 0)
self.setGraphicsEffect(e)
self.setAcceptHoverEvents(True)
示例3: Meterbar
# 需要导入模块: from PyQt4.QtGui import QGraphicsDropShadowEffect [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsDropShadowEffect import setColor [as 别名]
class Meterbar(Button):
def __init__(self, max=255, filename=None, width=None, height=None, x=0, y=0, pixmap=None, group=None, pos=None, size=None, padding=None):
Button.__init__(self, filename, width, height, x, y, pixmap, group, pos, size, padding)
self.max = max
self.outer = QGraphicsRectItem(x,y,width,max + 2)
self.outer.setPen(QPen(QColor(Qt.black), 1, Qt.SolidLine))
self.outer.setBrush(Qt.green)
# self.outer.hide()
self.inner = QGraphicsRectItem(x + 1,y + 1,width - 2,max)
self.inner.setPen(QPen(QColor(Qt.green), 1, Qt.SolidLine))
self.inner.setBrush(Qt.blue)
self.items = [self.outer, self.inner]
self.current = 255
self.effect = QGraphicsDropShadowEffect()
self.effect.setOffset(0, 0)
self.effect.setBlurRadius(0)
self.effect.setColor(Qt.green)
self.item = self.outer
self.addEffect('shadow', self.effect, True)
self.addAnimation('glow', Glow(15, 300, self, maxRadius=80, minRadius=5))
# self.test(10)
def test(self, x):
self.tl = QTimeLine(10000)
self.tl.setFrameRange(0, 10000)
self.a = QGraphicsItemAnimation()
self.a.setItem(self.inner)
self.a.setTimeLine(self.tl)
# self.a.setPosAt(0, QPointF(self.getX(), self.current))
# self.a.setTranslationAt(1, self.getX(), self.getY() + self.max - x + 1)
self.a.setScaleAt(0, 1, 1)
self.a.setScaleAt(1, 1, 0.1)
self.current = x
self.tl.start()
def update(self, x):
x2 = 1 - (float(x) * 1.0 / float(self.max))
# print x
# return
self.tl = QTimeLine(10)
self.tl.setFrameRange(0, 10)
self.a = QGraphicsItemAnimation()
self.a.setItem(self.inner)
self.a.setTimeLine(self.tl)
# self.a.setPosAt(0, QPointF(self.getX(), self.current))
# self.a.setTranslationAt(1, self.getX(), self.getY() + self.max - x + 1)
self.a.setScaleAt(0, 1, self.current)
self.a.setScaleAt(1, 1, x2)
self.current = x
self.tl.start()
if x > 3 :
self.play('glow')
def setScene(self, scene):
self.scene = scene
for item in self.items :
self.scene.addItem(item)
示例4: FaceButtonsView
# 需要导入模块: from PyQt4.QtGui import QGraphicsDropShadowEffect [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsDropShadowEffect import setColor [as 别名]
class FaceButtonsView(QGraphicsView):
def __init__(self, *args):
QGraphicsView.__init__(self, *args)
self.move(170, 90)
self.btnSize = 40
self.padding = 5
self.setMaximumHeight(self.btnSize * 4)
self.setMaximumWidth(self.btnSize * 4)
self.setMinimumHeight(self.btnSize * 4)
self.setMinimumWidth(self.btnSize * 4)
self.adjustSize()
self.setStyleSheet('background-color:transparent; border-width: 0px; border: 0px;')
self.scene = QGraphicsScene(self)
self.psButtons = QPixmap(os.getcwd() + '/../icons/PS3_Buttons.png')
self.triangle = self.psButtons.copy(0, 0, 220, 225)
self.triangle = self.triangle.scaled(self.btnSize, self.btnSize, Qt.KeepAspectRatio)
self.square = self.psButtons.copy(220, 0, 220, 225)
self.square = self.square.scaled(self.btnSize, self.btnSize, Qt.KeepAspectRatio)
self.circle = self.psButtons.copy(440, 0, 220, 225)
self.circle = self.circle.scaled(self.btnSize, self.btnSize, Qt.KeepAspectRatio)
self.cross = self.psButtons.copy(660, 0, 220, 225)
self.cross = self.cross.scaled(self.btnSize, self.btnSize, Qt.KeepAspectRatio)
self.triangleItem = QGraphicsPixmapItem(self.triangle)
self.triangleItem.setOffset(QPointF(self.btnSize + self.padding, 0))
self.scene.addItem(self.triangleItem)
self.squareItem = QGraphicsPixmapItem(self.square)
self.squareItem.setOffset(QPointF(0, self.btnSize + self.padding))
self.scene.addItem(self.squareItem)
self.circleItem = QGraphicsPixmapItem(self.circle)
self.circleItem.setOffset(QPointF(self.btnSize * 2 + self.padding * 2, self.btnSize + self.padding))
self.scene.addItem(self.circleItem)
self.crossItem = QGraphicsPixmapItem(self.cross)
self.crossItem.setOffset(QPointF(self.btnSize + self.padding, self.btnSize * 2 + self.padding * 2))
self.scene.addItem(self.crossItem)
self.effect = QGraphicsDropShadowEffect()
self.effect.setOffset(0, 0)
self.effect.setBlurRadius(20)
self.effect.setColor(Qt.green)
self.triangleItem.setGraphicsEffect(self.effect)
self.setScene(self.scene)
self.tl2 = QTimeLine(10000)
self.tl2.setFrameRange(0, 10000)
self.t = QGraphicsItemAnimation()
self.t.setItem(self.triangleItem)
self.t.setTimeLine(self.tl2)
self.tl2.connect(self.tl2, SIGNAL('frameChanged(int)'), self.updateEffect)
self.effectd = 3
self.tl2.start()
def updateEffect(self):
if self.effect.blurRadius() > 50:
self.effectd = -3
elif self.effect.blurRadius() < 5:
self.effectd = 3
self.effect.setBlurRadius(self.effect.blurRadius() + self.effectd)
示例5: select
# 需要导入模块: from PyQt4.QtGui import QGraphicsDropShadowEffect [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsDropShadowEffect import setColor [as 别名]
def select(self):
if not self.__selected:
self.set_selected(True)
effect = QGraphicsDropShadowEffect()
effect.setBlurRadius(20)
effect.setXOffset(0)
effect.setYOffset(0)
effect.setColor(QColor(0, 0, 0, 180))
self.setGraphicsEffect(effect)
self.raise_()
示例6: DpadView
# 需要导入模块: from PyQt4.QtGui import QGraphicsDropShadowEffect [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsDropShadowEffect import setColor [as 别名]
class DpadView(QGraphicsView):
def __init__(self, *args):
QGraphicsView.__init__(self, *args)
self.move(2, 90)
self.btnSize = 75
self.padding = -35
self.setMaximumHeight(self.btnSize * 2 + 20)
self.setMaximumWidth(self.btnSize * 2 + 20)
self.setMinimumHeight(self.btnSize * 2 + 20)
self.setMinimumWidth(self.btnSize * 2 + 20)
self.adjustSize()
self.setStyleSheet('background-color:transparent; border-width: 0px; border: 0px;')
self.scene = QGraphicsScene(self)
self.left = QPixmap(os.getcwd() + '/../icons/left.png')
self.left = self.left.scaled(self.btnSize, self.btnSize, Qt.KeepAspectRatio)
self.right = QPixmap(os.getcwd() + '/../icons/right.png')
self.right = self.right.scaled(self.btnSize, self.btnSize, Qt.KeepAspectRatio)
self.up = QPixmap(os.getcwd() + '/../icons/up.png')
self.up = self.up.scaled(self.btnSize, self.btnSize, Qt.KeepAspectRatio)
self.down = QPixmap(os.getcwd() + '/../icons/down.png')
self.down = self.down.scaled(self.btnSize, self.btnSize, Qt.KeepAspectRatio)
self.leftItem = QGraphicsPixmapItem(self.left)
self.leftItem.setOffset(QPointF(0, self.btnSize + self.padding))
self.scene.addItem(self.leftItem)
self.rightItem = QGraphicsPixmapItem(self.right)
self.rightItem.setOffset(QPointF(self.btnSize * 2 + self.padding * 2, self.btnSize + self.padding))
self.scene.addItem(self.rightItem)
self.upItem = QGraphicsPixmapItem(self.up)
self.upItem.setOffset(QPointF(self.btnSize + self.padding, 0))
self.scene.addItem(self.upItem)
self.downItem = QGraphicsPixmapItem(self.down)
self.downItem.setOffset(QPointF(self.btnSize + self.padding, self.btnSize * 2 + self.padding * 2))
self.scene.addItem(self.downItem)
self.effect = QGraphicsDropShadowEffect()
self.effect.setOffset(0, 0)
self.effect.setBlurRadius(20)
self.effect.setColor(Qt.green)
self.downItem.setGraphicsEffect(self.effect)
self.setScene(self.scene)
self.tl2 = QTimeLine(10000)
self.tl2.setFrameRange(0, 10000)
self.t = QGraphicsItemAnimation()
self.t.setItem(self.downItem)
self.t.setTimeLine(self.tl2)
self.tl2.connect(self.tl2, SIGNAL('frameChanged(int)'), self.updateEffect)
self.effectd = 3
self.tl2.start()
def updateEffect(self):
if self.effect.blurRadius() > 50:
self.effectd = -3
elif self.effect.blurRadius() < 5:
self.effectd = 3
self.effect.setBlurRadius(self.effect.blurRadius() + self.effectd)
示例7: must_glow
# 需要导入模块: from PyQt4.QtGui import QGraphicsDropShadowEffect [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsDropShadowEffect import setColor [as 别名]
def must_glow(widget_list):
' apply an glow effect to the widget '
for glow, each_widget in enumerate(widget_list):
try:
if each_widget.graphicsEffect() is None:
glow = QGraphicsDropShadowEffect(self)
glow.setOffset(0)
glow.setBlurRadius(99)
glow.setColor(QColor(99, 255, 255))
each_widget.setGraphicsEffect(glow)
glow.setEnabled(True)
except:
pass
示例8: select
# 需要导入模块: from PyQt4.QtGui import QGraphicsDropShadowEffect [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsDropShadowEffect import setColor [as 别名]
def select(self, val: bool):
if val:
effect = QGraphicsDropShadowEffect()
effect.setBlurRadius(20)
effect.setXOffset(0)
effect.setYOffset(0)
effect.setColor(QColor(0, 0, 0, 180))
self.setGraphicsEffect(effect)
self.raise_()
else:
eff = self.graphicsEffect()
del eff
self.setGraphicsEffect(None)
示例9: HighlightEdit
# 需要导入模块: from PyQt4.QtGui import QGraphicsDropShadowEffect [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsDropShadowEffect import setColor [as 别名]
class HighlightEdit(QLineEdit):
clicked = pyqtSignal(name="clicked")
def __init__(self, parent):
QLineEdit.__init__(self, parent)
self._highlight_effect = QGraphicsDropShadowEffect(self)
self._highlight_effect.setOffset(0.0)
self._highlight_effect.setBlurRadius(5.0)
self._highlight_effect.setColor(QColor(50, 50, 200))
self.setGraphicsEffect(self._highlight_effect)
self._highlight_effect.setEnabled(False)
self.clear_button = QToolButton(self)
self.clear_button.setIcon(QIcon.fromTheme("edit-clear", QIcon("icons/delete_icon.png")))
self.clear_button.setCursor(Qt.ArrowCursor)
self.clear_button.setStyleSheet("QToolButton { border: none; padding: 1.5px; }")
icon_size = int(self.sizeHint().height() * 0.65)
self.clear_button.setIconSize(QSize(icon_size, icon_size))
self.clear_button.clicked.connect(self.clear)
# self.clear_button.hide()
# some padding stuff
frameWidth = self.style().pixelMetric(QStyle.PM_DefaultFrameWidth)
self.setStyleSheet(
"QLineEdit {{ padding-right: {}px; }} ".format(self.clear_button.sizeHint().width() + frameWidth)
)
# create a signal on doubleclick events
def mouseDoubleClickEvent(self, ev):
ev.accept()
self.clicked.emit()
# fix up the clear button positioning
def resizeEvent(self, ev):
sz = self.clear_button.sizeHint()
frameWidth = self.style().pixelMetric(QStyle.PM_DefaultFrameWidth)
self.clear_button.move(
self.rect().right() - frameWidth - sz.width(), (self.rect().bottom() + 1 - sz.height()) / 2
)
# a slot for turning the graphics effect on and off
@pyqtSlot(bool)
def highlight(self, val):
self._highlight_effect.setEnabled(val)
示例10: __init__
# 需要导入模块: from PyQt4.QtGui import QGraphicsDropShadowEffect [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsDropShadowEffect import setColor [as 别名]
def __init__(self, parent=None, workdir=None, fontsize=42):
super(BillboardDisplay, self).__init__(parent)
self.workdir = workdir
self.logger = logging.getLogger('display')
self.logger.info('Working directory: {}'.format(self.workdir))
self.current_display = os.path.join(self.workdir, 'current.jpg')
desktop = QDesktopWidget()
self.display = QWidget(self)
size = desktop.availableGeometry(desktop.primaryScreen());
self.display.resize(size.width(), size.height())
self.display.setWindowTitle("Billboard")
self.image_label = QLabel(self.display)
self.image_label.resize(size.width(), size.height())
self.text_label = QLabel(self.display)
self.text_label.resize(size.width(), size.height())
self.text_label.setMargin(100)
self.text_label.setStyleSheet('''
QLabel {{
font-size: {}pt;
font-weight: bold;
color: #eeeeee;
text-align: center;
}}
'''.format(fontsize))
self.text_label.setWordWrap(True)
self.text_label.setAlignment(Qt.AlignCenter)
dse = QGraphicsDropShadowEffect()
dse.setBlurRadius(0)
dse.setXOffset(5)
dse.setYOffset(5)
dse.setColor(QColor(0, 0, 0, 255))
self.text_label.setGraphicsEffect(dse)
QObject.connect(self, SIGNAL("updateimage"),
self.display_image)
QObject.connect(self, SIGNAL("updatecurrent"),
self.take_screenshot)
示例11: initialize
# 需要导入模块: from PyQt4.QtGui import QGraphicsDropShadowEffect [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsDropShadowEffect import setColor [as 别名]
def initialize(self, *args, **kwargs):
" Init Main Class "
super(Main, self).initialize(*args, **kwargs)
self.locator.get_service("menuApp").add_action(
QAction(QIcon.fromTheme("edit-select-all"), "Create Setup.py", self, triggered=lambda: self.get_dialog())
)
self.dialog, self.group0 = QDialog(), QGroupBox()
self.group0.setTitle(" Setup.py Creator ")
self.pkgname, self.version = QLineEdit(), QDoubleSpinBox()
self.urlproj, self.licence = QLineEdit("https://www."), QLineEdit("GPL")
self.authors, self.emails = QLineEdit(getuser()), QLineEdit("@mail.com")
self.descrip, self.button = QLineEdit(), QPushButton("Make Setup.py !")
self.choices, self.indents = QComboBox(), QSpinBox()
self.metada = QCheckBox("Use SheBang and Metadata")
self.nosetest = QCheckBox("Use Nose Tests Framework integration")
self.metada.setChecked(True)
self.chckbx1 = QCheckBox("Copy output to ClipBoard when done")
self.choices.addItems(["from distutils.core import setup", "import distutils.core"])
self.indents.setValue(4)
self.indents.setMaximum(8)
self.indents.setMinimum(0)
self.indents.setSingleStep(2)
self.version.setValue(0.1)
self.version.setMinimum(0.1)
self.version.setDecimals(1)
self.version.setSingleStep(0.1)
self.button.setMinimumSize(400, 50)
self.button.clicked.connect(self.make_setupy)
glow = QGraphicsDropShadowEffect(self)
glow.setOffset(0)
glow.setBlurRadius(99)
glow.setColor(QColor(99, 255, 255))
self.button.setGraphicsEffect(glow)
inf = QLabel(
"""<a href="http://guide.python-distribute.org/future.html"
><center><i>INFO: This is Deprecated Legacy Packaging.</a>"""
)
inf.setTextInteractionFlags(Qt.LinksAccessibleByMouse)
inf.setOpenExternalLinks(True)
vboxg0 = QVBoxLayout(self.group0)
for each_widget in (
QLabel("<b>Package Name"),
self.pkgname,
QLabel("<b>Version"),
self.version,
QLabel("<b>URL"),
self.urlproj,
QLabel("<b>Licence"),
self.licence,
QLabel("<b>Author"),
self.authors,
QLabel("<b>Mail"),
self.emails,
QLabel("<b>Description"),
self.descrip,
QLabel("<b>Imports"),
self.choices,
QLabel("<b>Indentation Spaces "),
self.indents,
self.metada,
self.chckbx1,
self.nosetest,
inf,
QLabel("<center><small><i>{}".format(HELPMSG)),
self.button,
):
vboxg0.addWidget(each_widget)
try:
each_widget.setToolTip(each_widget.text())
except:
pass
QVBoxLayout(self.dialog).addWidget(self.group0)
示例12: __init__
# 需要导入模块: from PyQt4.QtGui import QGraphicsDropShadowEffect [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsDropShadowEffect import setColor [as 别名]
def __init__(self, parent=None):
QMainWindow.__init__(self, parent)
self.configOptions, self.checkBoxList, self.configBool = {}, {}, None
# Check for root privileges
if geteuid() != 0:
msg = ("{} is not root. You need to run with root priviliges\n"
"Please use kdesudo, gksu or sudo/sux.").format(getuser())
QMessageBox.critical(self, __doc__ + "- Error", msg)
sys.exit(1)
else:
msg = "This tool is running with root priviliges."
QMessageBox.warning(self, __doc__ + "- Warning", msg)
# title, icon and sizes
self.setWindowTitle(__doc__)
self.setMinimumSize(600, 600)
self.setMaximumSize(2048, 2048)
self.resize(600, 600)
self.setWindowIcon(QIcon.fromTheme("preferences-system"))
self.menuBar().addMenu("&File").addAction("Exit", exit)
QShortcut("Ctrl+q", self, activated=lambda: self.close())
# main group
main_group = QGroupBox("Module configuration")
self.setCentralWidget(main_group)
self.layout = QVBoxLayout(main_group)
# scrollarea widgets
self.scrollArea, self.window = QScrollArea(), QWidget()
self.layout.addWidget(self.scrollArea)
self.vbox = QVBoxLayout(self.window)
# Graphic effect
glow = QGraphicsDropShadowEffect(self)
glow.setOffset(0)
glow.setBlurRadius(99)
glow.setColor(QColor(99, 255, 255))
self.scrollArea.setGraphicsEffect(glow)
glow.setEnabled(True)
# config loading stuff
self.findConfig(CONFIG_DIR)
for eachOption in tuple(self.configOptions.keys()):
self.readConfig(eachOption, self.configOptions)
self.subLayout = QHBoxLayout()
self.checkBoxName = "checkBox_" + eachOption
checkBoxList = QCheckBox(self.checkBoxName, self)
self.checkBoxList[self.checkBoxName] = checkBoxList
checkBoxList.setObjectName(self.checkBoxName)
checkBoxList.setText("Enable module {}".format(eachOption))
if self.tooltip is not '':
checkBoxList.setToolTip(self.tooltip)
else:
tooltip = "Configuration settings for {}".format(eachOption)
checkBoxList.setToolTip(tooltip)
if self.configBool:
checkBoxList.setChecked(True)
self.subLayout.addWidget(checkBoxList)
self.vbox.addLayout(self.subLayout)
self.scrollArea.setWidget(self.window)
# Bottom Buttons Bar
self.pushButtonSleep = QPushButton("Sleep")
self.pushButtonSleep.setToolTip("Trigger Suspend to RAM aka Sleep")
self.pushButtonSleep.clicked.connect(self.sleep)
self.pushButtonHibernate = QPushButton("Hibernate")
self.pushButtonHibernate.setToolTip("Trigger Suspend to Disk Hibernate")
self.pushButtonHibernate.clicked.connect(self.hibernate)
self.buttonBox = QDialogButtonBox()
self.buttonBox.setStandardButtons(
QDialogButtonBox.Ok | QDialogButtonBox.Close |
QDialogButtonBox.Help)
self.buttonBox.addButton(self.pushButtonHibernate,
QDialogButtonBox.ActionRole)
self.buttonBox.addButton(self.pushButtonSleep,
QDialogButtonBox.ActionRole)
self.layout.addWidget(self.buttonBox)
self.buttonBox.rejected.connect(exit)
self.buttonBox.accepted.connect(self.writeConfig)
self.buttonBox.helpRequested.connect(lambda: open_new_tab(WEBPAGE_URL))
示例13: initialize
# 需要导入模块: from PyQt4.QtGui import QGraphicsDropShadowEffect [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsDropShadowEffect import setColor [as 别名]
#.........这里部分代码省略.........
self.btn2 = QPushButton(QIcon.fromTheme("document-open"), ' Open ')
self.btn2.clicked.connect(lambda: self.igndir.setText(str(
QFileDialog.getExistingDirectory(self.dock,
'Please, Open a Ignore Directory...', path.expanduser("~")))))
vboxg1 = QVBoxLayout(self.group1)
for each_widget in (QLabel('<b>Target directory path: '), self.outdir,
self.btn1, self.btn1a, QLabel('<b>Ignore directory path: '),
self.ignckb, self.ignmor, self.igndir, self.btn2, ):
vboxg1.addWidget(each_widget)
self.group2 = QGroupBox()
self.group2.setTitle(' Output ')
self.outfle = QLineEdit(path.join(path.expanduser("~"), 'output.html'))
self.outfle.setPlaceholderText('Exclude directory')
self.outfle.setCompleter(self.completer)
self.btn3 = QPushButton(QIcon.fromTheme("document-save"), ' Save ')
self.btn3.clicked.connect(lambda: self.outfle.setText(
QFileDialog.getSaveFileName(self.dock, 'Save', path.expanduser("~"),
'XML(*.xml)' if self.xmlo.isChecked() is True else 'HTML(*.html)')))
vboxg2 = QVBoxLayout(self.group2)
for each_widget in (QLabel('<b>Output report file path:'),
self.outfle, self.btn3):
vboxg2.addWidget(each_widget)
self.group3 = QGroupBox()
self.group3.setTitle(' Options ')
self.group3.setCheckable(True)
self.group3.setGraphicsEffect(QGraphicsBlurEffect(self))
self.group3.graphicsEffect().setEnabled(False)
self.group3.toggled.connect(self.toggle_options_group)
self.qckb1, self.qckb2 = QCheckBox('Recursive'), QCheckBox('Time-less')
self.qckb3, self.qckb4 = QCheckBox('Force Diff'), QCheckBox('Fast Mode')
self.qckb5, self.tm = QCheckBox('Save a LOG file to target'), QLabel('')
self.xmlo = QCheckBox('XML Output instead of HTML')
self.opeo = QCheckBox('Open Clones Report when done')
self.chrt = QCheckBox('LOW CPU priority for Backend Process')
self.mdist, self.hdep, self.output = QSpinBox(), QSpinBox(), QTextEdit()
self.ign_func = QLineEdit('test, forward, backward, Migration')
self.mdist.setValue(5)
self.hdep.setValue(1)
self.mdist.setToolTip('''<b>Maximum amount of difference between pair of
sequences in clone pair (5 default).Larger value more false positive''')
self.hdep.setToolTip('''<b>Computation can be speeded up by increasing
this value, but some clones can be missed (1 default)''')
[a.setChecked(True) for a in (self.qckb1, self.qckb3, self.qckb5,
self.chrt, self.opeo)]
vboxg3 = QVBoxLayout(self.group3)
for each_widget in (self.qckb1, self.qckb2, self.qckb3, self.qckb4,
self.qckb5, self.chrt, self.xmlo, self.opeo,
QLabel('<b>Max Distance Threshold:'), self.mdist,
QLabel('<b>Max Hashing Depth:'), self.hdep,
QLabel('<b>Ignore code block prefix:'), self.ign_func):
vboxg3.addWidget(each_widget)
self.group4, self.auto = QGroupBox(), QComboBox()
self.group4.setTitle(' Automation ')
self.group4.setCheckable(True)
self.group4.setToolTip('<font color="red"><b>WARNING:Advanced Setting!')
self.group4.toggled.connect(lambda: self.group4.hide())
self.auto.addItems(['Never run automatically', 'Run when File Saved',
'Run when File Executed', 'Run when Tab Changed',
'Run when File Opened', 'Run before File Saved'])
self.auto.currentIndexChanged.connect(self.on_auto_changed)
QVBoxLayout(self.group4).addWidget(self.auto)
self.button = QPushButton(' Analyze for Clones ')
self.button.setMinimumSize(75, 50)
self.button.clicked.connect(self.run)
glow = QGraphicsDropShadowEffect(self)
glow.setOffset(0)
glow.setBlurRadius(99)
glow.setColor(QColor(99, 255, 255))
self.button.setGraphicsEffect(glow)
self.butkil = QPushButton(' Force Kill Clones ')
self.butkil.clicked.connect(lambda: self.process.kill())
class TransientWidget(QWidget):
' persistant widget thingy '
def __init__(self, widget_list):
' init sub class '
super(TransientWidget, self).__init__()
vbox = QVBoxLayout(self)
for each_widget in widget_list:
vbox.addWidget(each_widget)
tw = TransientWidget((QLabel('<i>D.R.Y. principle analyzer'),
self.group1, self.group2, self.group3, self.group4,
QLabel('<b>Backend Logs'), self.output, self.tm, self.button,
self.butkil))
self.scrollable, self.dock = QScrollArea(), QDockWidget()
self.scrollable.setWidgetResizable(True)
self.scrollable.setWidget(tw)
self.dock.setWindowTitle(__doc__)
self.dock.setStyleSheet('QDockWidget::title{text-align: center;}')
self.dock.setWidget(self.scrollable)
ExplorerContainer().addTab(self.dock, "Clones")
QPushButton(QIcon.fromTheme("help-about"), 'About', self.dock
).clicked.connect(lambda:
QMessageBox.information(self.dock, __doc__, HELPMSG))
示例14: Dial
# 需要导入模块: from PyQt4.QtGui import QGraphicsDropShadowEffect [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsDropShadowEffect import setColor [as 别名]
class Dial(QGraphicsItem):
"""
Dial
"""
def __init__(self):
super(Dial, self).__init__()
self.angle = 0
# Colors
self.color = QColor(120, 120, 120, 255)
self.notchColor = QColor(115, 115, 115, 255)
self.normalBorderColor = QColor( 255, 255, 255, 30 )
self.selectedBorderColor = QColor( 255, 191, 0, 102 )
self.textColor = QColor( 30, 30, 30, 255 )
self.shadowColor = QColor(0, 0, 0, 75)
self.selectedShadowColor = QColor( 100, 100, 100, 255 )
# Settings
self.width, self.height = 75, 75
# Drop Shadow
self.shadowBlurRadius = 8
self.shadow = QGraphicsDropShadowEffect()
self.shadow.setBlurRadius(self.shadowBlurRadius)
self.shadow.setOffset(0, 0.5)
self.shadow.setColor(self.shadowColor)
self.setGraphicsEffect(self.shadow)
# Painter Definitions
self.pen = QPen()
gradient = QRadialGradient(self.boundingRect().center() + QPointF(0, -20), 80)
gradient.setColorAt(0, self.color.lighter(117))
gradient.setColorAt(1, self.color)
self.brush = QBrush(gradient)
self.font = QFont()
self.pen.setWidth(1)
self.pen.setColor(self.normalBorderColor)
self.brush.setColor(self.color)
self.font.setPointSize(10)
# Nodegraph Definitions
self.dragPoint = None
self.dragAngle = 0
self.dragFactor = 0
# Notch Specifications
self.notch = DialNotch()
self.notch.setParentItem(self)
self.updateNotch()
def boundingRect(self):
"""
Overrides QGraphicsItem's boundingRect() virtual public function and
returns a valid bounding rect based on calculated width and height.
"""
return QRectF(0, 0, self.width, self.height).adjusted(
-self.shadowBlurRadius, -self.shadowBlurRadius,
self.shadowBlurRadius, self.shadowBlurRadius)
def paint(self, painter, option, widget):
"""
Overrides QGraphicsItem's paint() virtual public function.
"""
painter.setPen(self.pen)
painter.setBrush(self.brush)
painter.drawEllipse(self.boundingRect())
def mousePressEvent(self, event):
self.dragPoint = event.scenePos()
self.dragAngle = self.angle
part = self.height / 2
distance = event.pos().y() - part
if distance == 0:
self.dragFactor = 0
else:
self.dragFactor = part / distance
def mouseMoveEvent(self, event):
scenePos = event.scenePos()
d = scenePos - self.dragPoint
self.angle = self.dragAngle + d.x() * self.dragFactor
self.updateNotch()
def mouseReleaseEvent(self, event):
self.dragPoint = None
self.dragAngle = 0
def updateNotch(self):
f = 0.02
dx = (self.width - self.notch.width) / 2
dy = (self.height - self.notch.height) / 2
x = math.sin(math.radians(self.angle)) * dx + dx
y = math.cos(math.radians(self.angle)) * dy + dy
self.notch.setPos(x, y)
示例15: initialize
# 需要导入模块: from PyQt4.QtGui import QGraphicsDropShadowEffect [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsDropShadowEffect import setColor [as 别名]
def initialize(self, *args, **kwargs):
" Init Main Class "
super(Main, self).initialize(*args, **kwargs)
self.process = QProcess()
self.process.readyReadStandardOutput.connect(self.readOutput)
self.process.readyReadStandardError.connect(self.readErrors)
self.process.finished.connect(self._process_finished)
# self.process.error.connect(self._process_error)
self.sourceDirectory, self.outputDirectory = None, None
self.group2 = QGroupBox()
self.group2.setTitle(' Paths ')
self.inf = QLineEdit(path.expanduser("~"))
self.inf.setPlaceholderText(' /full/path/to/directory ')
self.out, self.fle = QLineEdit(path.expanduser("~")), QLineEdit()
self.out.setPlaceholderText(' /full/path/to/directory ')
self.fle.setPlaceholderText(' /full/path/to/single/file ')
self.completer, self.dirs = QCompleter(self), QDirModel(self)
self.dirs.setFilter(QDir.AllEntries | QDir.NoDotAndDotDot)
self.completer.setModel(self.dirs)
self.completer.setCaseSensitivity(Qt.CaseInsensitive)
self.completer.setCompletionMode(QCompleter.PopupCompletion)
self.inf.setCompleter(self.completer)
self.out.setCompleter(self.completer)
self.fle.setCompleter(self.completer)
self.open1 = QPushButton(QIcon.fromTheme("folder-open"), 'Open')
self.open1.setCursor(QCursor(Qt.PointingHandCursor))
self.open1.clicked.connect(lambda: self.inf.setText(str(
QFileDialog.getExistingDirectory(self.dock, "Open Source Directory",
path.expanduser("~")))))
self.open2 = QPushButton(QIcon.fromTheme("folder-open"), 'Open')
self.open2.setCursor(QCursor(Qt.PointingHandCursor))
self.open2.clicked.connect(lambda: self.out.setText(str(
QFileDialog.getExistingDirectory(self.dock, "Open Target Directory",
path.expanduser("~")))))
self.open3 = QPushButton(QIcon.fromTheme("folder-open"), 'Open')
self.open3.setCursor(QCursor(Qt.PointingHandCursor))
self.open3.clicked.connect(lambda: self.fle.setText(str(
QFileDialog.getOpenFileName(self.dock, "Open a Target File...",
path.expanduser("~"), ';;'.join(['{}(*.{})'.format(e.upper(), e)
for e in ['py', 'pyw', '*']])))))
vboxg2 = QVBoxLayout(self.group2)
for each_widget in (
QLabel('Source Directory Project:'), self.inf, self.open1,
QLabel(' Target Directory Outputs: '), self.out, self.open2,
QLabel(' Source Single File (Optional):'), self.fle, self.open3, ):
vboxg2.addWidget(each_widget)
self.group1 = QGroupBox()
self.group1.setTitle(' Options ')
self.chckbx1 = QCheckBox(' Inject Twitter Bootstrap CSS3 ')
self.chckbx1.toggled.connect(self.toggle_styles_group)
self.chckbx2 = QCheckBox(' Warn all missing references ')
self.chckbx3 = QCheckBox(' Open Docs when done building ')
self.chckbx4 = QCheckBox('Save Bash script to reproduce Sphinx Builds')
vboxg1 = QVBoxLayout(self.group1)
for each_widget in (self.chckbx1, self.chckbx2,
self.chckbx3, self.chckbx4):
vboxg1.addWidget(each_widget)
each_widget.setChecked(True)
self.group3 = QGroupBox()
self.group3.setTitle(' Styles ')
self.group3.setGraphicsEffect(QGraphicsBlurEffect(self))
self.group3.graphicsEffect().setEnabled(False)
self.basecss, self.fontcss = QComboBox(), QComboBox()
self.basecss.addItems(['slate', 'united', 'spacelab', 'superhero',
'simplex', 'journal', 'flatly', 'cyborg', 'cosmo', 'cerulean'])
self.fontcss.addItems(['Ubuntu Light', 'Oxygen', 'Roboto', 'Droid Sans',
'Open Sans', 'Pacifico', 'Rancho', 'Arvo', 'Fresca', 'Graduate'])
self.backcss = QComboBox()
self.backcss.addItems(['shattered', 'retina_wood', 'ricepaper',
'brickwall', 'sneaker_mesh_fabric', 'diagonales_decalees',
'noisy_grid', 'pw_pattern', 'escheresque', 'diamond_upholstery'])
vboxg3 = QVBoxLayout(self.group3)
for each_widget in (QLabel('<b>Twitter Bootstrap Theme'), self.basecss,
QLabel('<b>Fonts Family'), self.fontcss,
QLabel('<b>Background Seamless Tiled Pattern'), self.backcss):
vboxg3.addWidget(each_widget)
self.output = QTextEdit('''
My brain is something more than merely mortal; As time will show.
- Ada Lovelace ''')
self.output.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.button = QPushButton('Document My Code')
self.button.setCursor(QCursor(Qt.PointingHandCursor))
self.button.setMinimumSize(75, 50)
self.button.clicked.connect(self.build)
glow = QGraphicsDropShadowEffect(self)
glow.setOffset(0)
glow.setBlurRadius(99)
glow.setColor(QColor(99, 255, 255))
self.button.setGraphicsEffect(glow)
class TransientWidget(QWidget):
' persistant widget thingy '
def __init__(self, widget_list):
' init sub class '
#.........这里部分代码省略.........