def dropShadow(): effect = QGraphicsDropShadowEffect() effect.setBlurRadius(15) effect.setXOffset(0) effect.setYOffset(3) effect.setColor(QColor(0, 0, 0, 30)) return effect
def __init__(self, user_name, is_current_user, is_admin, certified_on, is_revoked, current_user_is_admin): super().__init__() self.setupUi(self) self.current_user_is_admin = current_user_is_admin self.is_admin = is_admin self.is_revoked = is_revoked self._is_revoked = is_revoked self.certified_on = certified_on self.is_current_user = is_current_user self.user_name = user_name self.label_username.setText(user_name) self.user_icon.apply_style() self.setContextMenuPolicy(Qt.CustomContextMenu) self.customContextMenuRequested.connect(self.show_context_menu) self.label_created_on.setText( format_datetime(self.certified_on, full=True)) self.label_role.setText( _("TEXT_USER_ROLE_ADMIN") if self. is_admin else _("TEXT_USER_ROLE_CONTRIBUTOR")) if self.is_current_user: self.label_user_is_current.setText("({})".format( _("TEXT_USER_IS_CURRENT"))) effect = QGraphicsDropShadowEffect(self) effect.setColor(QColor(0x99, 0x99, 0x99)) effect.setBlurRadius(10) effect.setXOffset(2) effect.setYOffset(2) self.setGraphicsEffect(effect)
def initUI(self): self.qGroupBox = QGroupBox("Tokens Lexemes") self.qGroupBox.setStyleSheet("background-color: #222222;") hBox = QHBoxLayout() for tokenType in self.data[Parser.CONTENT]: childGroup = QGroupBox(tokenType[Parser.TOKEN_TYPE]) vbox = QVBoxLayout() # print(tokenType[Parser.VALUES]) for val in tokenType[Parser.VALUES]: lexemeLabel = QLabel(val[Parser.LEXEME]) lineLabel = QLabel(f"in line {val[Parser.LINE] + 1}") toolTipText = f""" <html> <body> <div style="padding: 10px"> <h2> Line </h2> <p> {self.input_lines[val[Parser.LINE]]} </p> </div> </body> </html> """ lineLabel.setToolTip(toolTipText) lexemeLabel.setToolTip(toolTipText) lexemeLabel.setCursor(QCursor(QtCore.Qt.PointingHandCursor)) lineLabel.setCursor(QCursor(QtCore.Qt.PointingHandCursor)) f = QFont("Helvetica [Cronyx]", 20, QFont.Bold) lexemeLabel.setFont(f) lineLabel.setFont(f) lineLabel.setStyleSheet("border-radius: 8px; font-size: 14px") lexemeLabel.setStyleSheet( "border-radius: 8px; font-size: 14px") vboxChild = QVBoxLayout() childHbox = QHBoxLayout() childHbox.addWidget(lexemeLabel) childHbox.addStretch() childHbox.addWidget(lineLabel) vboxChild.addLayout(childHbox) sh = QGraphicsDropShadowEffect() sh.setBlurRadius(15) sh.setOffset(0, 10.) sh.setColor(QColor(255, 255, 255, 15)) ll = QLabel("------------------------------") ll.setGraphicsEffect(sh) ll.setStyleSheet( """color: rgba(255, 255, 255, 0.6); padding: 2px; border-radius: 6px; min-width: 100%; border: none;""" ) vboxChild.addWidget(ll) vbox.addLayout(vboxChild) vbox.addStretch() childGroup.setLayout(vbox) childGroup.setStyleSheet( """margin: 3px; padding: 6px; margin-top: 5px; border: .5px solid #eee; border-radius: 6px;""" ) hBox.addWidget(childGroup) hBox.addStretch() self.qGroupBox.setLayout(hBox)
def __init__(self, idx, **kwargs): super(WavesTask, self).__init__(idx, **kwargs) N = 10 # number of waves in base set num_sum = 3 # maximum number of elements in sum of waves env = DiscreteWaves(N, num_sum) observation = env.reset() x = np.linspace(0, 5, 1000) task = Task(len(env.base_graph), num_sum, **kwargs) self.layout().addWidget(task) for slot in task.slot_list: slot.slot_changed.connect(self.on_slot_changed) # Set Task Preview shadow = QGraphicsDropShadowEffect() shadow.setBlurRadius(10) shadow.setColor(QColor(0, 0, 255, 128)) shadow.setOffset(0, 0) self.preview.setGraphicsEffect(shadow) self.preview.ax.plot(x, observation["target"]) # Set Base Waves for wave, canvas in zip(observation["waves"], task.base_canvas_list): canvas.ax.plot(x, wave) task.result_canvas.ax.plot(x, observation["target"], "r") self.result_canvas = task.result_canvas self.slot_list = task.slot_list self.observation = observation self.env = env self.shadow = shadow
def dropShadowUp(): effect = QGraphicsDropShadowEffect() effect.setBlurRadius(10) effect.setXOffset(0) effect.setYOffset(-3) effect.setColor(QColor(0, 0, 0, 25)) return effect
def setup_ui(self): """ Inicjalizacja interfejsu użytkownika. """ self.setStyleSheet(Styles.label_background) self.setMinimumHeight(32) self.setContentsMargins(0, 0, 0, 0) shadow = QGraphicsDropShadowEffect() shadow.setOffset(1.0, 1.0) shadow.setColor(QColor(127, 127, 127, 255)) font = QFont() font.setPointSize(14) font.setBold(True) self.header = QLabel() self.header.setFont(font) self.header.setStyleSheet(Styles.label_background) self.header.setGraphicsEffect(shadow) self.header.setAlignment(Qt.AlignCenter) self.header.setMinimumHeight(self.minimumHeight()) self.layout = QVBoxLayout(self) self.layout.addWidget(self.header) self.layout.setContentsMargins(0, 0, 0, 0) self.layout.setSpacing(0)
def generate_shadow(self, button): #used to generate the standard black shadow for buttons shadow = QGraphicsDropShadowEffect(button) shadow.setBlurRadius(15) shadow.setColor(QColor(0, 0, 0, 180)) shadow.setOffset(0, 0) button.setGraphicsEffect(shadow)
def enterEvent(self, event): if self.is_shadow: shadow_effect = QGraphicsDropShadowEffect(self) shadow_effect.setBlurRadius(5) shadow_effect.setOffset(QPoint(0, 0)) shadow_effect.setColor(QColor(0, 0, 0)) self.setGraphicsEffect(shadow_effect)
class MyFrame(QFrame): enter_signal = pyqtSignal() leave_signal = pyqtSignal() def __init__(self): super().__init__() self._radius = 0 self.shadow_op = QGraphicsDropShadowEffect(self) def enterEvent(self, *args): self.enter_signal.emit() return super().enterEvent(*args) def leaveEvent(self, *args): self.leave_signal.emit() return super().leaveEvent(*args) @pyqtProperty(float) def radius(self): return self._radius @radius.setter def radius(self, r): self.shadow_op.setColor(Qt.gray) self.shadow_op.setOffset(0, r / 20 * 5) self.shadow_op.setBlurRadius(r) self.setGraphicsEffect(self.shadow_op) self._radius = r
def __init__(self, doc_root, db_connector): super().__init__() CustomBase().__init__() self.doc_root = doc_root self.db_conn = db_connector self.ui = Ui_MainWindow() self.ui.setupUi(self) self.active_wishes_list = self.ui.wish_list.layout() self.executed_wishes_list = self.ui.executed_wish_list.layout() self.active_wishes_mapping = {} self.executed_wishes_mapping = {} self.ACTIVE = 'active_wishes' self.EXECUTED = 'executed_wishes' self.ui.scrollArea.setStyleSheet("QScrollArea { border: 0px; }") self.ui.scrollArea_2.setStyleSheet("QScrollArea { border: 0px; }") self.ui.add_wish_btn.setIcon( QIcon(QPixmap('{}assets/icons/add-icon.svg'.format( self.doc_root)))) self.ui.add_wish_btn.setIconSize(QSize(40, 40)) self.ui.add_wish_btn.setFont(self.buttons_font) shadow = QGraphicsDropShadowEffect() shadow.setColor(QColor(0, 0, 0, 255 * 0.5)) shadow.setBlurRadius(15) shadow.setOffset(0) self.ui.add_wish_btn.setGraphicsEffect(shadow) self.init_wishes_list(self.ACTIVE) self.init_wishes_list(self.EXECUTED)
def enterEvent(self, evt: QtCore.QEvent) -> None: shadow = QGraphicsDropShadowEffect(self) shadow.setBlurRadius(8) shadow.setColor(QtGui.QColor(76, 35, 45).lighter()) shadow.setOffset(4) self.setGraphicsEffect(shadow) super(SwitchButton, self).enterEvent(evt)
def initUI(self): self.setViewMode(QListView.IconMode) for item in self.menus: widgetItem = QListWidgetItem(self) widgetItem.metadata = item widgetItem.setText(item['title']) widgetItem.setToolTip(item.get('description', '')) widgetItem.setIcon(QIcon(item['icon'])) self.addItem(widgetItem) self.setCurrentRow(0) self.setIconSize(QSize(32, 32)) self.setMovement(QListView.Static) self.setUniformItemSizes(True) # self.setSize() self.setStyleSheet("""QListWidget::Item { padding-left: 10px; padding-right: 10px; padding-bottom: 5px; }""") shadow = QGraphicsDropShadowEffect(self) shadow.setColor(Qt.black) shadow.setBlurRadius(10) shadow.setOffset(0, 0) self.setGraphicsEffect(shadow)
def __init__(self, workspace_name, is_owner, creator, files, shared_with=None, *args, **kwargs): super().__init__(*args, **kwargs) self.setupUi(self) self.is_owner = is_owner self.creator = creator self.shared_with = shared_with or [] self.name = workspace_name if not len(files): self.label_empty.show() self.widget_files.hide() else: for i, (f, is_dir) in enumerate(files.items(), 1): if i > 4: break label = getattr(self, "line_edit_file{}".format(i)) label.clicked.connect(self.open_clicked_file) label.setText(f) label.setIsDir(is_dir) label.setCursorPosition(0) self.label_empty.hide() effect = QGraphicsDropShadowEffect(self) effect.setColor(QColor(164, 164, 164)) effect.setBlurRadius(10) effect.setXOffset(4) effect.setYOffset(4) self.setGraphicsEffect(effect) self.button_details.clicked.connect(self.button_details_clicked) self.button_share.clicked.connect(self.button_share_clicked) self.button_delete.clicked.connect(self.button_delete_clicked) self.button_rename.clicked.connect(self.button_rename_clicked) if not self.is_owner: self.label_owner.hide() if not self.shared_with: self.label_shared.hide()
def __init__(self, alphaSelection: bool, movableWindow: bool, saveAnimation_signal: pyqtSignal, playAnimation_signal: pyqtSignal, *args, **kwargs): super(CToolBox_Animator, self).__init__(*args, **kwargs) self.alphaON = alphaSelection self.movableON = movableWindow self.saveAnimation_signal = saveAnimation_signal self.playAnimation_signal = playAnimation_signal self.animationFPS = 24 self.setObjectName('Custom_Color_Dialog') #self.setAttribute(Qt.WA_TranslucentBackground, True) self.setStyleSheet(Stylesheet) self.mPos = None self.initUi() # 添加阴影 effect = QGraphicsDropShadowEffect(self) effect.setBlurRadius(10) effect.setOffset(0, 0) effect.setColor(Qt.gray) self.setGraphicsEffect(effect)
def init_ui(self): """ initializes the ui elements in main window :return: """ # resize this window to fit the innner image self.resize(self.pix.size()) # set the window to frameless and keep it always on top self.setWindowFlags(Qt.Tool | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint) # self.setWindowFlags( Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint) # set the background invisible self.setAttribute(Qt.WA_TranslucentBackground) # sets this for MacOS (keep tool on top and hides the rocket icon) if sys.platform == 'darwin': self.setAttribute(Qt.WA_MacAlwaysShowToolWindow) # now sets the image to label self.label.setPixmap(self.pix) # add that label into our main widget self.layout.addWidget(self.label) self.setLayout(self.layout) # sets the shadow effect around it effect = QGraphicsDropShadowEffect(self) effect.setBlurRadius(12) effect.setOffset(0, 0) effect.setColor(Qt.gray) self.setGraphicsEffect(effect)
def shadow() -> QGraphicsDropShadowEffect: s = QGraphicsDropShadowEffect() s.setBlurRadius(10) s.setXOffset(2) s.setYOffset(2) s.setColor(QColor(200, 200, 200)) return s
def __init__(self, *args, **kwargs): super(PreviewImage, self).__init__(*args, **kwargs) layout = QHBoxLayout(self) self.leftButton = QPushButton(self, objectName="leftButton", cursor=Qt.PointingHandCursor, visible=False) layout.addWidget(self.leftButton) # 上一个 layout.addItem( QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)) self.imageLabel = QLabel(self) # 图片 # 边缘阴影效果 effect = QGraphicsDropShadowEffect(self.imageLabel) effect.setBlurRadius(40) effect.setOffset(0, 0) effect.setColor(Qt.gray) self.imageLabel.setGraphicsEffect(effect) layout.addWidget(self.imageLabel) layout.addItem( QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)) self.rightButton = QPushButton(self, objectName="rightButton", cursor=Qt.PointingHandCursor, visible=False) layout.addWidget(self.rightButton) # 下一个
def initUI(self): fontPath = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'font/Audiowide-Regular.ttf') font_id = QFontDatabase.addApplicationFont(fontPath) families = QFontDatabase.applicationFontFamilies(font_id) font = QFont("Audiowide") self.setFont(font) self.btnAction = QPushButton('Download Engine', self) self.btnAction.clicked.connect(self.OnBtnClick) self.btnAction.resize(self.btnAction.sizeHint()) self.btnAction.move(20, 145) self.btnAction.setFont(font) self.lblStatus = QLabel('Status label', self) self.lblStatus.resize(self.btnAction.sizeHint()) self.lblStatus.setText("") self.lblStatus.setContentsMargins(0,0,0,0); self.lblStatus.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) self.lblStatus.move(190, 150) self.lblStatus.setFont(font) #self.lblStatus.setStyleSheet("border: 1px solid black;"); dse = QGraphicsDropShadowEffect(self) dse.setBlurRadius(10) dse.setColor(QColor("#FFEEEE")) dse.setOffset(4,4) self.lblStatus.setGraphicsEffect(dse) self.pbDownload = QProgressBar(self) self.pbDownload.setGeometry(30, 40, 400, 25) self.step = 0 self.setGeometry(300, 300, 550, 250) self.setStyleSheet("QMainWindow {border-image: url(data/background.jpg) 0 0 0 0 stretch stretch;}") self.setObjectName("Window") self.setWindowTitle(self.config.game_title) self.show() self.dl = SpringDownloader() self.dl.downloadStarted.connect(self.OnDownloadStarted) self.dl.downloadFinished.connect(self.OnDownloadFinished) self.dl.downloadFailed.connect(self.OnDownloadFailed) self.dl.downloadProgress.connect(self.OnDownloadProgress) self.launcher = EngineLauncher() self.launcher.lobbyClosed.connect(self.OnLobbyClosed) self.games = copy.deepcopy(self.config.games) self.maps = copy.deepcopy(self.config.maps) self.engines = copy.deepcopy(self.config.engines) if self.engines and len(self.engines) > 0: self.launcher.VERSION_STRING = self.engines[0] self.actions = ["autoupdate", "packages", "start"] if self.config.no_downloads: self.actions = ["start"] self.DisplayNextAction() if self.config.auto_download: self.btnAction.setEnabled(False) self.MaybeNextStep()
class FloatingTextWidget(QGraphicsWidget): def __init__(self, parent=None, anchor="center"): QGraphicsWidget.__init__(self, parent) assert anchor in {"center", "corner"} self.anchor = anchor self._label = QGraphicsSimpleTextItem(self) self._label.setBrush(QColor(255, 255, 255)) # Add drop shadow 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._spacingConstant = 5.0 def updateLayout(self): width = self._label.boundingRect().width() height = self._label.boundingRect().height() width = self._spacingConstant + width + self._spacingConstant height = self._spacingConstant + height + self._spacingConstant self._label.setPos(self._spacingConstant, self._spacingConstant) self.resize(width, height) self.update() def paint(self, painter, option, widget): shape = QPainterPath() shape.addRoundedRect(self.rect(), 1, 1) painter.setBrush(QBrush(QColor(0, 0, 0))) painter.drawPath(shape) # painter.setPen(self._pen) # painter.drawPath(self._path) def onUpdated(self, center_position, text): self._label.setText(text) self.updateLayout() rect = self.rect() x_pos = center_position.x() y_pos = center_position.y() if self.anchor == "center": x_pos -= rect.width() / 2 y_pos -= rect.height() / 2 else: y_pos -= rect.height() self.setPos(x_pos, y_pos)
class MyWindow(QWidget, Ui_Form): def __init__(self, parent=None): super(MyWindow, self).__init__(parent) self.mPos = None self.setupUi(self) self.shadow = QGraphicsDropShadowEffect() self.shadow.setBlurRadius(16) self.shadow.setColor(QColor(0, 0, 0, 80)) self.shadow.setOffset(-1, 3) self.pushButtonLogin.setGraphicsEffect(self.shadow) self.setAttribute(Qt.WA_TranslucentBackground, True) self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint) # effect = QGraphicsDropShadowEffect(self) # effect.setBlurRadius(12) # effect.setOffset(0, 0) # effect.setColor(Qt.gray) # self.setGraphicsEffect(effect) def mousePressEvent(self, event): if event.button() == Qt.LeftButton: self.m_drag = True self.m_DragPosition = event.globalPos() - self.pos() event.accept() self.setCursor(QCursor(Qt.OpenHandCursor)) def mouseMoveEvent(self, QMouseEvent): if Qt.LeftButton and self.m_drag: self.move(QMouseEvent.globalPos() - self.m_DragPosition) QMouseEvent.accept() def mouseReleaseEvent(self, QMouseEvent): self.m_drag = False self.setCursor(QCursor(Qt.ArrowCursor)) def paintEvent(self, event): path = QtGui.QPainterPath() path.setFillRule(QtCore.Qt.WindingFill) path.addRect(20, 20, self.width() - 40, self.height() - 40) painter = QtGui.QPainter(self) painter.setPen(Qt.white) painter.setBrush(Qt.white) painter.setRenderHint(painter.Antialiasing, True) painter.drawRoundedRect(10, 10, self.width() - 20, self.height() - 20, 8, 8) painter.drawPath(path) painter.fillPath(path, QtGui.QBrush(QtCore.Qt.white)) color = QtGui.QColor(60, 60, 60, 30) for i in range(0, 10): path = QtGui.QPainterPath() path.setFillRule(QtCore.Qt.WindingFill) painter.setRenderHint(painter.Antialiasing, True) painter.setBrush(Qt.transparent) painter.drawRoundedRect(10 - i, 10 - i, self.width() - (10 - i) * 2, self.height() - (10 - i) * 2, 8, 8) color.setAlpha(150 - math.sqrt(i) * 60) painter.setPen(color) painter.drawPath(path)
def __init__(self, parent): super().__init__(parent, Qt.WindowFlags()) self.setAutoFillBackground(True) effect = QGraphicsDropShadowEffect() effect.setBlurRadius(10) effect.setColor(QColor(0, 0, 0, 160)) effect.setOffset(0.0) self.setGraphicsEffect(effect)
def setHalo(self, color: Union[DisplayColor, QColor, str]): if isinstance(color, DisplayColor): color = color.value # TODO: ▼ convert this to Chain() statement effect = QGraphicsDropShadowEffect() effect.setOffset(0) effect.setBlurRadius(BLUR_RADIUS) effect.setColor(QColor(color)) self.owner.setGraphicsEffect(effect)
def enterEvent(self, QEvent): #generate white highlight if self.isEnabled(): shadow = QGraphicsDropShadowEffect(self) shadow.setBlurRadius(50) shadow.setColor(QColor(255, 255, 255, 255)) shadow.setOffset(0, 0) self.setGraphicsEffect(shadow)
def create_shadow(self): shadow = QGraphicsDropShadowEffect() shadow.setBlurRadius(15) shadow.setOffset(4, 2) c = QColor(0, 0, 0) c.setAlpha(100) shadow.setColor(c) return shadow
def _frame(self): # 边框 self.setWindowFlags(Qt.FramelessWindowHint) self.setAttribute(Qt.WA_TranslucentBackground, True) # 阴影 effect = QGraphicsDropShadowEffect(blurRadius=12, xOffset=0, yOffset=0) effect.setColor(QColor(25, 25, 25, 170)) self.mainFrame.setGraphicsEffect(effect)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) effect = QGraphicsDropShadowEffect(self) effect.setColor(QColor(164, 164, 164)) effect.setBlurRadius(4) effect.setXOffset(2) effect.setYOffset(2) self.setGraphicsEffect(effect)
def __init__(self, core_config, *args, **kwargs): super().__init__(*args, **kwargs) self.setupUi(self) self.menu = MenuWidget(parent=self) self.widget_menu.layout().addWidget(self.menu) self.mount_widget = MountWidget(parent=self) self.mount_widget.reset_taskbar.connect(self.reset_taskbar) self.widget_central.layout().insertWidget(0, self.mount_widget) self.users_widget = UsersWidget(parent=self) self.widget_central.layout().insertWidget(0, self.users_widget) self.devices_widget = DevicesWidget(parent=self) self.widget_central.layout().insertWidget(0, self.devices_widget) self.settings_widget = SettingsWidget(core_config=core_config, parent=self) self.widget_central.layout().insertWidget(0, self.settings_widget) self.notification_center = NotificationCenterWidget(parent=self) self.button_notif = TaskbarButton( icon_path=":/icons/images/icons/menu_settings.png") self.widget_notif.layout().addWidget(self.notification_center) self.notification_center.hide() effect = QGraphicsDropShadowEffect(self) effect.setColor(QColor(100, 100, 100)) effect.setBlurRadius(4) effect.setXOffset(-2) effect.setYOffset(2) self.widget_notif.setGraphicsEffect(effect) self.menu.button_files.clicked.connect(self.show_mount_widget) self.menu.button_users.clicked.connect(self.show_users_widget) self.menu.button_settings.clicked.connect(self.show_settings_widget) self.menu.button_devices.clicked.connect(self.show_devices_widget) self.menu.button_logout.clicked.connect(self.logout_requested.emit) self.button_notif.clicked.connect(self.show_notification_center) self.connection_state_changed.connect( self._on_connection_state_changed) self.notification_center.close_requested.connect( self.close_notification_center) # self.notification_center.add_notification( # "ERROR", "An error message to test how it looks like." # ) # self.notification_center.add_notification( # "WARNING", "Another message but this time its a warning." # ) # self.notification_center.add_notification( # "INFO", "An information message, because we gotta test them all." # ) # self.notification_center.add_notification( # "ERROR", # "And another error message, but this one will be a little bit longer just " # "to see if the GUI can handle it.", # ) self.reset()
def __init__(self): super().__init__() self.setWindowTitle("Login") self.setGeometry(350, 45, 771, 681) vLayout = QVBoxLayout() self.vWidgetLayout = QVBoxLayout() container_widget = QWidget() shadow = QGraphicsDropShadowEffect() shadow.setBlurRadius(3) shadow.setColor(QColor("#010101")) shadow.setXOffset(3) shadow.setYOffset(3) username_label = QLabel("Username") username_label.setStyleSheet("border: none; font-size: 15px;") username_input = QLineEdit() username_input.setStyleSheet( "background: none; border-top: none; border-left: none; border-right: none; border-bottom: 1px solid #010101; font-size: 14px;" ) username_input.setFixedWidth(200) password_label = QLabel("Password") password_label.setStyleSheet("border: none; font-size: 15px;") password_input = QLineEdit() password_input.setEchoMode(QLineEdit.Password) password_input.setStyleSheet( "border-top: none; border-left: none; border-right: none; border-bottom: 1px solid #010101; font-size: 14px;" ) password_input.setFixedWidth(200) self.login_btn = QPushButton("Login") self.login_btn.setStyleSheet( "QPushButton { border-radius: 3px; font-size: 12px; }" "QPushButton:pressed { background: black; color: white; }") self.login_btn.setFixedWidth(50) self.login_btn.setFixedHeight(25) self._addWidgets(username_label, username_input, password_label, password_input, self.login_btn) container_widget.setStyleSheet( "background: white; border: 0.5px solid #010101; border-radius: 10px; font-family: Lucida Console, Monaco, monospace; font-weight: bold;" ) container_widget.setLayout(self.vWidgetLayout) container_widget.setFixedHeight(200) container_widget.setFixedWidth(300) container_widget.setGraphicsEffect(shadow) self.vWidgetLayout.setSpacing(20) self.vWidgetLayout.setAlignment(Qt.AlignCenter) vLayout.addWidget(container_widget) vLayout.setAlignment(Qt.AlignCenter) self.setLayout(vLayout)
def enterEvent(self, evt: QtCore.QEvent) -> None: #self.setIconSize(QSize(math.floor(self._size.width() * 1.2),math.floor(self._size.height() * 1.2))) shadow = QGraphicsDropShadowEffect(self) shadow.setBlurRadius(8) #shadow.setColor(QtGui.QColor(76,35,45).lighter()) shadow.setColor(QtGui.QColor(76, 35, 45).lighter()) shadow.setOffset(4) self.setGraphicsEffect(shadow) super(ImageButton, self).enterEvent(evt)
class SplashScreen(QMainWindow): """SpalshScreen-ul de inceput""" def __init__(self): QMainWindow.__init__(self) self.main_win = MainWindow() self.ui = Ui_SplashScreen() self.ui.setupUi(self) # REMOVE TITLE BAR self.setWindowFlag(Qt.FramelessWindowHint) self.setAttribute(Qt.WA_TranslucentBackground) # DROP SHADOW EFFECT self.shadow = QGraphicsDropShadowEffect(self) self.shadow.setBlurRadius(40) self.shadow.setXOffset(0) self.shadow.setYOffset(0) self.shadow.setColor(QColor(0, 0, 0, 60)) self.ui.dropShadowFrame.setGraphicsEffect(self.shadow) # INITIAL TEXT self.ui.label_loading.setText("loading...") # CHANGE LOADING DOTS QTimer.singleShot(750, lambda: self.ui.label_loading.setText("loading.")) QTimer.singleShot(1500, lambda: self.ui.label_loading.setText("loading..")) QTimer.singleShot(2250, lambda: self.ui.label_loading.setText("loading...")) QTimer.singleShot(3000, lambda: self.ui.label_loading.setText("loading.")) QTimer.singleShot(3750, lambda: self.ui.label_loading.setText("loading..")) QTimer.singleShot(4500, lambda: self.ui.label_loading.setText("loading...")) # PROGRESS BAR TIMER self.time = QTimer() self.time.timeout.connect(self.progress) self.time.start(35) self.show() def progress(self): global counter # UPDATE PROGRESS BAR self.ui.progressBar.setValue(counter) # STOP THE TIMER if counter > 100: self.time.stop() self.main_win.show() self.close() counter += 5
def initObj(self): self.ellipse.setPos(self.posX, self.posY) self.ellipse.setPen(QPen(Qt.transparent, 1)) self.ellipse.setBrush(QBrush(Qt.darkGreen)) self.ellipse.setZValue(0) self.ellipse.setOpacity(1) effect = QGraphicsDropShadowEffect(self.parent) effect.setBlurRadius(15) effect.setColor(Qt.black) self.ellipse.setGraphicsEffect(effect) self.stand.append(self.sheet.copy(10, 15, 100, 120)) self.stand.append(self.sheet.copy(130, 15, 100, 120)) self.stand.append(self.sheet.copy(250, 15, 100, 120)) self.pix = self.parent.m_scene.addPixmap(self.stand[0]) self.pix.setPos(self.posX, self.posY) self.pix.setOffset(-20, -56) self.pix.setZValue(2) self.pix.setScale(1)
def __init__(self, parent=None): """Init class.""" super(MainWindow, self).__init__() self.setWindowTitle(__doc__.strip().capitalize()) self.statusBar().showMessage(" Choose one App and move the sliders !") self.setMinimumSize(480, 240) self.setMaximumSize(640, 2048) self.setWindowIcon(QIcon.fromTheme("preferences-system")) self.center() QShortcut("Ctrl+q", self, activated=lambda: self.close()) self.menuBar().addMenu("&File").addAction("Exit", exit) windowMenu = self.menuBar().addMenu("&Window") windowMenu.addAction("Minimize", lambda: self.showMinimized()) windowMenu.addAction("Maximize", lambda: self.showMaximized()) windowMenu.addAction("Restore", lambda: self.showNormal()) windowMenu.addAction("FullScreen", lambda: self.showFullScreen()) windowMenu.addAction("Center", lambda: self.center()) windowMenu.addAction("Top-Left", lambda: self.move(0, 0)) windowMenu.addAction("To Mouse", lambda: self.move_to_mouse_position()) windowMenu.addSeparator() windowMenu.addAction( "Increase size", lambda: self.resize(self.size().width() * 1.4, self.size().height() * 1.4)) windowMenu.addAction("Decrease size", lambda: self.resize( self.size().width() // 1.4, self.size().height() // 1.4)) windowMenu.addAction("Minimum size", lambda: self.resize(self.minimumSize())) windowMenu.addAction("Maximum size", lambda: self.resize(self.maximumSize())) windowMenu.addAction("Horizontal Wide", lambda: self.resize( self.maximumSize().width(), self.minimumSize().height())) windowMenu.addAction("Vertical Tall", lambda: self.resize( self.minimumSize().width(), self.maximumSize().height())) windowMenu.addSeparator() windowMenu.addAction("Disable Resize", lambda: self.setFixedSize(self.size())) windowMenu.addAction("Set Interface Font...", lambda: self.setFont(QFontDialog.getFont()[0])) helpMenu = self.menuBar().addMenu("&Help") helpMenu.addAction("About Qt 5", lambda: QMessageBox.aboutQt(self)) helpMenu.addAction("About Python 3", lambda: open_new_tab('https://www.python.org')) helpMenu.addAction("About" + __doc__, lambda: QMessageBox.about(self, __doc__, HELP)) helpMenu.addSeparator() helpMenu.addAction( "Keyboard Shortcut", lambda: QMessageBox.information(self, __doc__, "<b>Quit = CTRL+Q")) helpMenu.addAction("View Source Code", lambda: call('xdg-open ' + __file__, shell=True)) helpMenu.addAction("View GitHub Repo", lambda: open_new_tab(__url__)) helpMenu.addAction("Report Bugs", lambda: open_new_tab( 'https://github.com/juancarlospaco/pyority/issues?state=open')) helpMenu.addAction("Check Updates", lambda: Downloader(self)) container, child_container = QWidget(), QWidget() container_layout = QVBoxLayout(container) child_layout = QHBoxLayout(child_container) self.setCentralWidget(container) # widgets group0 = QGroupBox("My Apps") group1, group2 = QGroupBox("CPU Priority"), QGroupBox("HDD Priority") child_layout.addWidget(group0) child_layout.addWidget(group1) child_layout.addWidget(group2) container_layout.addWidget(child_container) # table self.table = QTableWidget() self.table.setColumnCount(1) self.table.verticalHeader().setVisible(True) self.table.horizontalHeader().setVisible(False) self.table.setShowGrid(False) self.table.setAlternatingRowColors(True) self.table.setIconSize(QSize(64, 64)) self.table.setSelectionMode(QAbstractItemView.SingleSelection) self.table.setEditTriggers(QAbstractItemView.NoEditTriggers) # Graphic effect glow = QGraphicsDropShadowEffect(self) glow.setOffset(0) glow.setBlurRadius(9) glow.setColor(QColor(99, 255, 255)) self.table.setGraphicsEffect(glow) glow.setEnabled(True) processes = self.generate_process_list() self.table.setRowCount(len(processes)) for index, process in enumerate(processes): item = QTableWidgetItem( QIcon.fromTheme(process.name().split()[0].split('/')[0]), process.name().split()[0].split('/')[0].strip()) item.setData(Qt.UserRole, process) item.setToolTip("{}, {}, {}, {}".format( process.name(), process.nice(), process.ionice()[1], process.pid)) self.table.setItem(index, 0, item) self.table.clicked.connect(lambda: self.sliderhdd.setDisabled(False)) self.table.clicked.connect(lambda: self.slidercpu.setDisabled(False)) self.table.clicked.connect(lambda: self.slidercpu.setValue( int(tuple(self.table.currentItem().toolTip().split(","))[1]))) self.table.clicked.connect(lambda: self.sliderhdd.setValue( int(tuple(self.table.currentItem().toolTip().split(","))[2]))) self.table.resizeColumnsToContents() # self.table.resizeRowsToContents() # sliders self.slidercpu = QSlider() self.slidercpu.setRange(0, 19) self.slidercpu.setSingleStep(1) self.slidercpu.setTickPosition(3) self.slidercpu.setDisabled(True) self.slidercpu.setInvertedAppearance(True) self.slidercpu.setInvertedControls(True) self.slidercpu.valueChanged.connect(self.set_cpu_value) self.slidercpu.valueChanged.connect( lambda: self.slidercpu.setToolTip(str(self.slidercpu.value()))) # Timer to start self.slidercpu_timer = QTimer(self) self.slidercpu_timer.setSingleShot(True) self.slidercpu_timer.timeout.connect(self.on_slidercpu_timer_timeout) QLabel(self.slidercpu).setPixmap( QIcon.fromTheme("list-add").pixmap(16)) QVBoxLayout(group1).addWidget(self.slidercpu) self.sliderhdd = QSlider() self.sliderhdd.setRange(0, 7) self.sliderhdd.setSingleStep(1) self.sliderhdd.setTickPosition(3) self.sliderhdd.setDisabled(True) self.sliderhdd.setInvertedAppearance(True) self.sliderhdd.setInvertedControls(True) self.sliderhdd.valueChanged.connect(self.set_hdd_value) self.sliderhdd.valueChanged.connect( lambda: self.sliderhdd.setToolTip(str(self.sliderhdd.value()))) # Timer to start self.sliderhdd_timer = QTimer(self) self.sliderhdd_timer.setSingleShot(True) self.sliderhdd_timer.timeout.connect(self.on_sliderhdd_timer_timeout) QLabel(self.sliderhdd).setPixmap( QIcon.fromTheme("list-add").pixmap(16)) QVBoxLayout(group2).addWidget(self.sliderhdd) QVBoxLayout(group0).addWidget(self.table)
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(400, 400) 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))
class MainWindow(QMainWindow): """Voice Changer main window.""" def __init__(self, parent=None): super(MainWindow, self).__init__() self.statusBar().showMessage("Move Dial to Deform Microphone Voice !.") self.setWindowTitle(__doc__) self.setMinimumSize(240, 240) self.setMaximumSize(480, 480) self.resize(self.minimumSize()) self.setWindowIcon(QIcon.fromTheme("audio-input-microphone")) self.tray = QSystemTrayIcon(self) self.center() QShortcut("Ctrl+q", self, activated=lambda: self.close()) self.menuBar().addMenu("&File").addAction("Quit", lambda: exit()) self.menuBar().addMenu("Sound").addAction( "STOP !", lambda: call('killall rec', shell=True)) windowMenu = self.menuBar().addMenu("&Window") windowMenu.addAction("Hide", lambda: self.hide()) windowMenu.addAction("Minimize", lambda: self.showMinimized()) windowMenu.addAction("Maximize", lambda: self.showMaximized()) windowMenu.addAction("Restore", lambda: self.showNormal()) windowMenu.addAction("FullScreen", lambda: self.showFullScreen()) windowMenu.addAction("Center", lambda: self.center()) windowMenu.addAction("Top-Left", lambda: self.move(0, 0)) windowMenu.addAction("To Mouse", lambda: self.move_to_mouse_position()) # widgets group0 = QGroupBox("Voice Deformation") self.setCentralWidget(group0) self.process = QProcess(self) self.process.error.connect( lambda: self.statusBar().showMessage("Info: Process Killed", 5000)) self.control = QDial() self.control.setRange(-10, 20) self.control.setSingleStep(5) self.control.setValue(0) self.control.setCursor(QCursor(Qt.OpenHandCursor)) self.control.sliderPressed.connect( lambda: self.control.setCursor(QCursor(Qt.ClosedHandCursor))) self.control.sliderReleased.connect( lambda: self.control.setCursor(QCursor(Qt.OpenHandCursor))) self.control.valueChanged.connect( lambda: self.control.setToolTip(f"<b>{self.control.value()}")) self.control.valueChanged.connect( lambda: self.statusBar().showMessage( f"Voice deformation: {self.control.value()}", 5000)) self.control.valueChanged.connect(self.run) self.control.valueChanged.connect(lambda: self.process.kill()) # Graphic effect self.glow = QGraphicsDropShadowEffect(self) self.glow.setOffset(0) self.glow.setBlurRadius(99) self.glow.setColor(QColor(99, 255, 255)) self.control.setGraphicsEffect(self.glow) self.glow.setEnabled(False) # Timer to start self.slider_timer = QTimer(self) self.slider_timer.setSingleShot(True) self.slider_timer.timeout.connect(self.on_slider_timer_timeout) # an icon and set focus QLabel(self.control).setPixmap( QIcon.fromTheme("audio-input-microphone").pixmap(32)) self.control.setFocus() QVBoxLayout(group0).addWidget(self.control) self.menu = QMenu(__doc__) self.menu.addAction(__doc__).setDisabled(True) self.menu.setIcon(self.windowIcon()) self.menu.addSeparator() self.menu.addAction( "Show / Hide", lambda: self.hide() if self.isVisible() else self.showNormal()) self.menu.addAction("STOP !", lambda: call('killall rec', shell=True)) self.menu.addSeparator() self.menu.addAction("Quit", lambda: exit()) self.tray.setContextMenu(self.menu) self.make_trayicon() def run(self): """Run/Stop the QTimer.""" if self.slider_timer.isActive(): self.slider_timer.stop() self.glow.setEnabled(True) call('killall rec ; killall play', shell=True) self.slider_timer.start(3000) def on_slider_timer_timeout(self): """Run subprocess to deform voice.""" self.glow.setEnabled(False) value = int(self.control.value()) * 100 command = f'play -q -V0 "|rec -q -V0 -n -d -R riaa bend pitch {value} "' print(f"Voice Deformation Value: {value}") print(f"Voice Deformation Command: {command}") self.process.start(command) if self.isVisible(): self.statusBar().showMessage("Minimizing to System TrayIcon", 3000) print("Minimizing Main Window to System TrayIcon now...") sleep(3) self.hide() def center(self): """Center Window on the Current Screen,with Multi-Monitor support.""" window_geometry = self.frameGeometry() mousepointer_position = QApplication.desktop().cursor().pos() screen = QApplication.desktop().screenNumber(mousepointer_position) centerPoint = QApplication.desktop().screenGeometry(screen).center() window_geometry.moveCenter(centerPoint) self.move(window_geometry.topLeft()) def move_to_mouse_position(self): """Center the Window on the Current Mouse position.""" window_geometry = self.frameGeometry() window_geometry.moveCenter(QApplication.desktop().cursor().pos()) self.move(window_geometry.topLeft()) def make_trayicon(self): """Make a Tray Icon.""" if self.windowIcon() and __doc__: self.tray.setIcon(self.windowIcon()) self.tray.setToolTip(__doc__) self.tray.activated.connect( lambda: self.hide() if self.isVisible() else self.showNormal()) return self.tray.show()