def __init__(self, parent=None): super().__init__(parent) self.setIcon(QIcon('./Icons/cross.png')) StyleSheet = ( "QPushButton {color:#0000CC;font: bold;background-color: qlineargradient( x1:0 y1:0, x2:1 y2:0, stop:0 #CC0000, stop:1 #FF8000);border-radius: 8px;}" "QPushButton:hover:!pressed {color:white;background-color: #660000;border-radius: 8px;}" "QPushButton:disabled {color:white;background-color: grey;border-radius: 8px;}" ) self.setStyleSheet(StyleSheet) self.setFixedHeight(32) self.setGraphicsEffect( QGraphicsDropShadowEffect(blurRadius=3, xOffset=2, yOffset=2)) self.setToolTip("Stop/Delete")
def __init__(self, parent=None): super().__init__(parent) self.setIcon(QIcon('./Icons/disconnect.png')) self.setStyleSheet( "QPushButton {color:black;background-color: qlineargradient( x1:0 y1:0, x2:1 y2:0, stop:0 #FF9999, stop:1 #FFCC99);border-radius: 8px;}" "QPushButton:hover:!pressed {color:white;background-color: #9999FF;border-radius: 8px;}" "QPushButton:disabled {color:white;background-color: grey;border-radius: 8px;}" ) self.setFixedHeight(30) self.setGraphicsEffect( QGraphicsDropShadowEffect(blurRadius=3, xOffset=2, yOffset=2)) self.setToolTip("Disconnect")
def must_glow(self, widget_list): """force apply an glow effect to the widget.""" if not widget_list and not len(widget_list): return for glow, each_widget in enumerate(widget_list): 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) each_widget.graphicsEffect().setEnabled( not each_widget.graphicsEffect().isEnabled())
def __init__(self, parent=None): super().__init__(parent) self.setIcon(QIcon('./Icons/generate.png')) StyleSheet = ( "QPushButton {color:#0000CC;font: bold;background-color: qlineargradient( x1:0 y1:0, x2:1 y2:0, stop:0 #39C0F0, stop:1 #CBF0FD);border-radius: 8px;}" "QPushButton:hover:!pressed {color:white;background-color: #9999FF;border-radius: 8px;}" "QPushButton:disabled {color:white;background-color: grey;border-radius: 8px;}" ) self.setStyleSheet(StyleSheet) self.setFixedHeight(32) self.setGraphicsEffect( QGraphicsDropShadowEffect(blurRadius=3, xOffset=2, yOffset=2)) self.setToolTip("Generate/Configure")
def __init__(self, parent=None): super(ChildButtonsetted, self).__init__(parent) self.shadow = QGraphicsDropShadowEffect() self.shadow.setBlurRadius(200) self.shadow.setColor(QColor(85, 123, 182)) self.shadow.setXOffset(0) self.shadow.setYOffset(0) self.shadow2 = QGraphicsDropShadowEffect() self.shadow2.setBlurRadius(5) self.shadow2.setXOffset(5) self.shadow2.setYOffset(5) self.setGraphicsEffect(self.shadow2) self.resize(340,640) self.wdt = QWidget() #self.wdt.setAttribute(Qt.WA_TranslucentBackground) self.wdt.setObjectName("tipWaitingWindow_back") self.wdt.setStyleSheet("#tipWaitingWindow_back{background:rgba(0,0,0,0.2)}") self.layout = QGridLayout(self) self.layout.addWidget(self.wdt) self.layout.setContentsMargins(10, 10, 10, 10) self.layout.setSpacing(10) #self.main_layout = QGridLayout(self) self.main_layout = QVBoxLayout(self) self.wdt.setLayout(self.main_layout) self.webEngineView = QWebEngineView() self.webEngineView.load(QUrl('file:///C://Users/admin/Desktop/college/senior/VE450/page_simple_layoutnew.html')) #self.webEngineView2.load(QUrl('file:///C://Users/admin/Desktop/college/senior/VE450/timeline_bar(1).html')) #self.webEngineView3.load(QUrl('file:///C://Users/admin/Desktop/college/senior/VE450/gauge.html')) #self.webEngineView4.load(QtCore.QUrl('timeline_bar(1).html')) #self.main_layout.addWidget(self.webEngineView,4,0,4,3) #self.main_layout.addWidget(self.webEngineView2,4,3,4,3) #self.main_layout.addWidget(self.webEngineView3,8,0,4,3) self.main_layout.addWidget(self.webEngineView)
def __init__(self, text, shadow=False, style=None, *args, **kwargs): super(Label, self).__init__(*args, **kwargs) self.text = QLabel(text) self.text.setStyleSheet(styles.label_style) layout = QVBoxLayout() layout.addWidget(self.text) self.setLayout(layout) if shadow: shadow = QGraphicsDropShadowEffect(blurRadius=3 * config.wr, xOffset=1 * config.wr, yOffset=1 * config.hr) self.setGraphicsEffect(shadow) if style: self.text.setStyleSheet(style)
def __init__(self, label="", parent=None): super().__init__(parent) # self.setIcon(QIcon("./Icons/Run_1.png")) StyleSheet = ( "QPushButton {color:#FFFFFF;font: bold;background-color: qlineargradient( x1:0 y1:0, x2:1 y2:0, stop:0 #39C0F0, stop:1 #6666FF);border-radius: 8px;}" "QPushButton:hover:!pressed {color:white;background-color: #9999FF;border-radius: 8px;}" "QPushButton:disabled {color:white;background-color: grey;border-radius: 8px;}" ) self.setStyleSheet(StyleSheet) self.setText(label) self.setFixedHeight(32) self.setIconSize(QSize(30, 30)) self.setGraphicsEffect( QGraphicsDropShadowEffect(blurRadius=3, xOffset=2, yOffset=2))
def __init__(self, label='', parent=None): super().__init__(parent) self.setIcon(QIcon('./Icons/clean.png')) StyleSheet = ( "QPushButton {color:#0000CC;font: bold;background-color: qlineargradient( x1:0 y1:0, x2:1 y2:0, stop:0 #DAECD7, stop:1 #CEECEE);border-radius: 8px;}" "QPushButton:hover:!pressed {color:white;background-color: #CCFFFF;border-radius: 8px;}" "QPushButton:disabled {color:white;background-color: grey;border-radius: 8px;}" ) self.setStyleSheet(StyleSheet) self.setText(label) self.setFixedHeight(32) self.setGraphicsEffect( QGraphicsDropShadowEffect(blurRadius=3, xOffset=2, yOffset=2)) self.setToolTip("Clear")
def setup_shadows(centre, shadow_items): """ Sets up the shadows for all widgets passed through. :param shadow_items: a name:type dictionary of widgets to give shadows :type shadow_items: dict :param centre: the centre widget that the passed widgets rest on :type centre: widget :return: the modified centre """ for item, obj in shadow_items.items(): shadow = QGraphicsDropShadowEffect() shadow.setBlurRadius(15) centre.findChild(obj, item).setGraphicsEffect(shadow) return centre
def __init__(self, node, view): super(QtNode, self).__init__() self._spacingConstant = 5.0 self._roundness = 3 self._labelColor = QColor(255, 255, 255) self._label = QGraphicsSimpleTextItem(self) self._label.setBrush(self._labelColor) self._label.setText(node.name) self._selectedColor = QColor(255, 255, 255) self._shapePen = QPen(Qt.NoPen) self._shapePen.setColor(self._selectedColor) self._shapePen.setWidthF(1.5) self._brush = QBrush(QColor(*COLOUR_THEMES[node.node_type])) self._dropShadowEffect = QGraphicsDropShadowEffect() self.setGraphicsEffect(self._dropShadowEffect) self._dropShadowEffect.setOffset(0.0, 10.0) self._dropShadowEffect.setBlurRadius(8.0) self._dropShadowEffect.setColor(QColor(0, 0, 0, 50)) self.setFlag(QGraphicsItem.ItemIsMovable) self.setFlag(QGraphicsItem.ItemIsSelectable) self.setAcceptHoverEvents(True) self.setToolTip(node.tooltip) self._name = node.name self._node = node self._view = weakref.ref(view) self._busy = False self._socketRows = OrderedDict() # Build IO pin socket rows for pin_name in node.pin_order: if pin_name in node.inputs: pin = node.inputs[pin_name] else: pin = node.outputs[pin_name] socket_row = SocketRow(self, pin) self._socketRows[pin_name] = socket_row self.updateLayout()
def open_modal(self, modal: QWidget): self.modal_container.setFixedSize(self.size()) self.modal_container.show() self.h.insertWidget(1, modal, 1) self.h.itemAt(1).widget().show() shadow = QGraphicsDropShadowEffect() shadow.setColor(QColor(0, 0, 0, 100)) shadow.setBlurRadius(50) shadow.setOffset(0, 10) modal.setGraphicsEffect(shadow) modal.setObjectName("modal")
def __init__(self, parent=None): super(MainWindow, self).__init__(parent=parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) # Drops title bar self.setWindowFlag(QtCore.Qt.FramelessWindowHint) self.setAttribute(QtCore.Qt.WA_TranslucentBackground) # Drop the shadow effect self.ui.shadow = QGraphicsDropShadowEffect(self) self.ui.shadow.setBlurRadius(80) self.ui.shadow.setXOffset(0) self.ui.shadow.setYOffset(0) self.ui.shadow.setColor(QColor(0, 0, 0, 60)) self.ui.dropShadowFrame.setGraphicsEffect(self.ui.shadow) # Variables self.timeout = 5 self.offset = None self.generatingInvoicesComplete = None # Initial checks self.initChecks() # MOST IMPORTANT FUNCTION IN THIS PROGRAM self.randomVin() # Assigning functions to buttons self.ui.button_GenerateInvoices.clicked.connect(self.startGenerating) # Keyboard shortcuts self.generateShortcut = QShortcut(QKeySequence('g'), self) self.generateShortcut.activated.connect(self.startGenerating) self.changeBigVin = QShortcut(QKeySequence('v'), self) self.changeBigVin.activated.connect(self.randomVin) self.exit_program = QShortcut(QKeySequence('esc'), self) self.exit_program.activated.connect(exit) self.mergeAllPdfFiles = QShortcut(QKeySequence('m'), self) self.mergeAllPdfFiles.activated.connect(self.mergeAllPdf) # icon name from the qta-browser icon = qta.icon("mdi.close") self.ui.button_exit.setIcon(icon) self.ui.button_exit.clicked.connect(exit) icon = qta.icon("fa.expand") self.ui.button_expand.setIcon(icon) icon = qta.icon("fa5.window-minimize") self.ui.button_minimise.setIcon(icon)
def keyPressEvent(self, e): if e.key() == Qt.Key_Up: self.rotate(30) elif e.key() == Qt.Key_Down: self.rotate(-30) elif e.key() == Qt.Key_Right: self.currentSlide += 1 if self.currentSlide >= len(self.slides): #Loop to beginning self.currentSlide = 0 self.text.setPlainText(self.slides[self.currentSlide]) self.adjustText() self.centerText() elif e.key() == Qt.Key_Left: self.currentSlide -= 1 if self.currentSlide < 0: #Loop to end self.currentSlide = len(self.slides) - 1 self.text.setPlainText(self.slides[self.currentSlide]) self.adjustText() self.centerText() elif e.key() == Qt.Key_B: shadow = QGraphicsBlurEffect() shadow.setBlurRadius(self.shadowSize) self.text.setGraphicsEffect(shadow) elif e.key() == Qt.Key_S: shadow = QGraphicsDropShadowEffect() shadow.setBlurRadius(self.shadowSize) shadow.setOffset(self.shadowOffset) self.text.setGraphicsEffect(shadow) elif e.key() == Qt.Key_C: self.text.setGraphicsEffect(QGraphicsColorizeEffect()) elif e.key() == Qt.Key_O: self.text.setGraphicsEffect(QGraphicsOpacityEffect()) elif e.key() == Qt.Key_N: self.text.setGraphicsEffect(None)
def __init__(self, *args, **kwargs): super(CColorPicker, self).__init__(*args, **kwargs) self.setObjectName('Custom_Color_Dialog') self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint) self.setAttribute(Qt.WA_TranslucentBackground, True) self.setStyleSheet(Stylesheet) self.mPos = None self.initUi() self.initSignals() # 添加阴影 effect = QGraphicsDropShadowEffect(self) effect.setBlurRadius(10) effect.setOffset(0, 0) effect.setColor(Qt.gray) self.setGraphicsEffect(effect)
def __init__(self, *args, **kwargs): super(ThreeDimenButton, self).__init__(*args, **kwargs) self.setMouseTracking(True) self.in_rect = False self.aop_w = self.width() / AOPER self.aop_h = self.height() / AOPER self.shadow_effect = QGraphicsDropShadowEffect(self) self.shadow_effect.setOffset(0, 0) self.shadow_effect.setColor(QColor(0x88, 0x88, 0x88, 0x64)) self.shadow_effect.setBlurRadius(10) self.setGraphicsEffect(self.shadow_effect) self.setJitterAni(False)
def __init__(self): super(MainWindow, self).__init__() ti = TrayIcon(self) ti.show() self.handler = Handle(self) self.m_flag = None self.m_Position = None self.setupUi(self) self.init_ui() self.click_handler() self.shadow = QGraphicsDropShadowEffect() self.shadow.setBlurRadius(15) self.shadow.setColor(QColor(0, 0, 0, 255)) self.shadow.setOffset(0, 0) self.shadow1 = QGraphicsDropShadowEffect() self.shadow1.setBlurRadius(15) self.shadow1.setOffset(0, 0) self.shadow1.setColor(QColor(0, 0, 0, 255)) self.shadow2 = QGraphicsDropShadowEffect() self.shadow2.setBlurRadius(15) self.shadow2.setOffset(0, 0) self.shadow2.setColor(QColor(0, 0, 0, 255)) self.widget_2.setGraphicsEffect(self.shadow) self.widget.setGraphicsEffect(self.shadow1) # 加阴影,更立体
def _initUI(self): self.setupUi(self) self.initToolBar() self.EXETitle.setText(config.ExeName + ' ' + config.Version) # 去除默认边框 self.setWindowFlags(Qt.FramelessWindowHint) # 背景透明(就是ui中黑色背景的那个控件) self.setAttribute(Qt.WA_TranslucentBackground, True) # 添加阴影 effect = QGraphicsDropShadowEffect(self) effect.setBlurRadius(12) effect.setOffset(0, 0) effect.setColor(Qt.gray) self.setGraphicsEffect(effect)
def __init__(self, tooltip=None, shadow=False, *args, **kwargs): super(UserInput, self).__init__(*args, **kwargs) self.layout = QHBoxLayout() self.layout.setContentsMargins(0, 0, 0, 0) self.layout.setSpacing(0) self.setLayout(self.layout) if shadow: shadow_effect = QGraphicsDropShadowEffect(blurRadius=2 * config.wr, xOffset=1 * config.wr, yOffset=1 * config.wr) self.setGraphicsEffect(shadow_effect) if tooltip is not None: self.setToolTip(tooltip)
def __init__(self,text='',parent=None): super().__init__(parent) # 换行标志位 self.isWordWrap = False # 实例化小部件 self.timer = QTimer(self) self.label = QLabel(text, self) self.all_h_layout = QHBoxLayout() self.dropShadowEffect = QGraphicsDropShadowEffect(self) # 初始化小部件 self.initLayout() self.initWidget() self.setText(text)
def replay_movie(self, _, event: QEvent): key_event = QKeyEvent(event) if key_event.type( ) == QKeyEvent.KeyPress and not key_event.isAutoRepeat(): self.movie.stop() self.movie.start() effect = QGraphicsDropShadowEffect() effect.setBlurRadius(20) effect.setXOffset(0) effect.setYOffset(0) effect.setColor(Qt.red) self.gif_progress_bar.setGraphicsEffect(effect) if key_event.type() == QKeyEvent.KeyRelease: self.gif_progress_bar.setGraphicsEffect(None)
def __init__(self, value, r=1, i=0, parent=None, parentKnot=None): self.left, self.right = None, None self.value = value self.parentKnot = parentKnot self.i, self.r = i, r self.parentWindow = parent s = QGraphicsDropShadowEffect() s.setColor(QColor("#000000")) s.setBlurRadius(5) s.setOffset(1,1) self.label = QLabel(str(self.value), self.parentWindow.frameTree) self.label.setAlignment(Qt.AlignCenter) self.label.setObjectName("Layer2") self.label.setFont(QFont("Arial", self.parentWindow.fontSize)) self.label.setGraphicsEffect(s)
def __init__(self, *args, **kwargs): super(AvatarWidget, self).__init__(*args, **kwargs) self.setCursor(Qt.PointingHandCursor) self._rotate = 0 self._radius = 0 self._step = 45 self._padding = 10 self._image = "" self._shadowColor = "#212121" self._pixmap = None self._direction = None # clockwise 顺时针 anticlockwise 逆时针 self._timer = QTimer(self, timeout=self.update) self._effect = QGraphicsDropShadowEffect(self) self._effect.setBlurRadius(self._padding * 2) self._effect.setOffset(0, 0)
def __init__(self, *args, **kwargs): super(Dialog, self).__init__(*args, **kwargs) self.setObjectName('Custom_Dialog') self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint) self.setAttribute(Qt.WA_TranslucentBackground, True) self.setWindowTitle("HWExplorer") self.login_mode = "user" # 用户模式为默认登陆选项 self.setStyleSheet(Stylesheet) self.initUi() # 添加阴影 effect = QGraphicsDropShadowEffect(self) effect.setBlurRadius(12) effect.setOffset(0, 0) effect.setColor(Qt.gray) self.setGraphicsEffect(effect)
def GUI_Labels(self): if (True): # Initializing. # Setting The Labels Data. Labels = [{ 'Text': 'QR', 'Left': self.Width * 0.05, 'Top': self.Height * -0.02, 'Font_Size': int(self.Height * 0.54), 'Text_Color': Hex_To_RGBA("#ffffff", 0.4) }, { 'Text': 'Code Generator', 'Left': self.Width * 0.07, 'Top': self.Height * 0.18, 'Font_Size': int(self.Height * 0.14), 'Text_Color': Hex_To_RGBA("#ffffff", 1) }, { 'Text': 'Turn any piece of text into a QR code.', 'Left': self.Width * 0.08, 'Top': self.Height * 0.35, 'Font_Size': int(self.Height * 0.03), 'Text_Color': Hex_To_RGBA("#ffffff", 1) }] if (True): # Creating The Labels. for Label_Data in Labels: StyleSheet = (''' QLabel{{ font-size: {Font_Size}px; font-family: Cabin; color: rgba{Text_Color}; }} ''').format(**Label_Data) Label = QLabel(Label_Data.get('Text'), self) # Creating A Label, With The Given Text. Label.setStyleSheet(StyleSheet) # Setting The StyleSheets. Label.move(Label_Data.get('Left'), Label_Data.get('Top')) # Moving The Label. Label.setGraphicsEffect( QGraphicsDropShadowEffect( blurRadius=5, xOffset=3, yOffset=3)) # Adding Shadow Effect. Label.show() # Showing The Label.
def initUi(self): """Arranges editors and buttons in the Dialog window""" style = """ QDialog { border-top: 0px; padding: 2px; margin: 0px; background-color: white;} """ self.setStyleSheet(style) # self.setWindowFlags(Qt.FramelessWindowHint | Qt.Dialog) self._titleBar = DialogTitleBar(parent=self, title=self.title) # setup contents container and scroll area self._contents = QWidget() self._contents_layout = self.createContentsLayout() self._contents_layout.setContentsMargins(50, 50, 50, 50) self._contents.setLayout(self._contents_layout) # setup scroll area for contents self._scroll = QScrollArea() self._scroll.setWidget(self._contents) self._scroll.setWidgetResizable(True) self._scroll.setFixedHeight(self.height() + 500) self._scroll.setObjectName('scroll') self._scroll.setStyleSheet( """QScrollArea#scroll {background-color: white;} """ ) # setup button_bar self._button_bar = self.createButtonBar() # setup layout self.layout = QVBoxLayout() self.layout.setSpacing(0) self.layout.setContentsMargins(0, 0, 0, 0) self.layout.addWidget(self._titleBar) self.layout.addWidget(self._scroll) self.setLayout(self.layout) shadow = QGraphicsDropShadowEffect() shadow.setOffset(0) shadow.setBlurRadius(50) self.setGraphicsEffect(shadow) self.adjustSize() self.setData(self.default_data)
def __init__(self, *args, **kwargs): super(LinkButton, self).__init__(*args, **kwargs) self.clicked.connect(self.onClicked) self.setCursor(Qt.PointingHandCursor) self._rotate = 0 self._radius = 0 self._step = 45 self._padding = 10 self._url = "" self._image = "" self._shadowColor = "#FFFFFF" self._direction = None # clockwise 顺时针 anticlockwise 逆时针 self._timer = QTimer(self, timeout=self.update) self._effect = QGraphicsDropShadowEffect(self) self._effect.setBlurRadius(self._padding * 2) self._effect.setOffset(0, 0)
def adaptEncoding(self, codedValue): ''' Adapt coded value to a QGraphicEffect value ''' adaptedValue = None if codedValue == 1: adaptedValue = QGraphicsBlurEffect() elif codedValue == 2: adaptedValue = QGraphicsDropShadowEffect() #print "Adapted graphic effect:", adaptedValue assert adaptedValue is None or isinstance(adaptedValue, QGraphicsEffect) return adaptedValue
def _setup_ui(self, label_text): ds_effect = QGraphicsDropShadowEffect() ds_effect.setOffset(5, 5) ds_effect.setColor(Qt.gray) ds_effect.setBlurRadius(10) self._widget = QWidget(self) self._widget.setGraphicsEffect(ds_effect) hl = QHBoxLayout(self) hl.addWidget(self._widget) self._label = QLabel(label_text, self._widget) self._progress_bar = QProgressBar(self._widget) self._pushbutton = QPushButton('取消', self._widget) gl = QGridLayout(self._widget) gl.addWidget(self._label, 0, 0, 1, 2) gl.addWidget(self._progress_bar, 1, 0, 1, 1) gl.addWidget(self._pushbutton, 1, 1, 1, 1)
def eventFilter(self, object, event): if event.type() == QEvent.Enter: radius = 20 elif event.type() == QEvent.Leave: radius = 0 else: return False shadow = QGraphicsDropShadowEffect(self, blurRadius=radius, color=QColor(255,255,255), offset=QPointF(0, 0)) shadow.setXOffset(0) shadow.setYOffset(0) self.setGraphicsEffect(shadow) return True
def set_shadow_effect(widget: QObject, color=Qt.gray, radius=20, visible=True): """ 设置控件阴影\n Args:\n widget: 控件对象 color: 阴影颜色 radius: 阴影半径,默认为0 visible: 是否可见,为False的时候 """ shadowEffect = QGraphicsDropShadowEffect() shadowEffect.setOffset(0, 0) if visible is True: shadowEffect.setColor(color) shadowEffect.setBlurRadius(radius) else: shadowEffect.setColor(Qt.white) shadowEffect.setBlurRadius(0) widget.setGraphicsEffect(shadowEffect)