Python PyQt5.QtCore.Qt.WA_TranslucentBackground() Examples

The following are 23 code examples of PyQt5.QtCore.Qt.WA_TranslucentBackground(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PyQt5.QtCore.Qt , or try the search function .
Example #1
Source File: lyric.py    From FeelUOwn with GNU General Public License v3.0 7 votes vote down vote up
def __init__(self):
        super().__init__(parent=None)
        self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint)
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.c = Container(self)
        self._layout = QVBoxLayout(self)
        self._layout.setContentsMargins(0, 0, 0, 0)
        self._layout.setSpacing(0)
        self._layout.addWidget(self.c)

        self._old_pos = None

        QShortcut(QKeySequence.ZoomIn, self).activated.connect(self.zoomin)
        QShortcut(QKeySequence.ZoomOut, self).activated.connect(self.zoomout)
        QShortcut(QKeySequence('Ctrl+='), self).activated.connect(self.zoomin)
        QShortcut(QKeySequence.Cancel, self).activated.connect(self.hide)

        self.setToolTip('''
* 右键可以弹出设置菜单
* Ctrl+= 或者 Ctrl++ 可以增大字体
* Ctrl+- 可以减小字体
* 鼠标前进后退键可以播放前一首/下一首
''') 
Example #2
Source File: player.py    From MusicBox with MIT License 6 votes vote down vote up
def __init__(self, parent=None):
        super(DesktopLyric, self).__init__()
        self.lyric = QString('Lyric Show.')
        self.intervel = 0
        self.maskRect = QRectF(0, 0, 0, 0)
        self.maskWidth = 0
        self.widthBlock = 0
        self.t = QTimer()
        self.screen = QApplication.desktop().availableGeometry()
        self.setObjectName(_fromUtf8("Dialog"))
        self.setWindowFlags(Qt.CustomizeWindowHint | Qt.FramelessWindowHint | Qt.Dialog | Qt.WindowStaysOnTopHint | Qt.Tool)
        self.setMinimumHeight(65)
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.handle = lyric_handle(self)
        self.verticalLayout = QVBoxLayout(self)
        self.verticalLayout.setSpacing(0)
        self.verticalLayout.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
        self.font = QFont(_fromUtf8('微软雅黑, verdana'), 50)
        self.font.setPixelSize(50)
        # QMetaObject.connectSlotsByName(self)
        self.handle.lyricmoved.connect(self.newPos)
        self.t.timeout.connect(self.changeMask) 
Example #3
Source File: CDrawer.py    From CustomWidgets with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, *args, stretch=1 / 3, direction=0, widget=None, **kwargs):
        super(CDrawer, self).__init__(*args, **kwargs)
        self.setWindowFlags(self.windowFlags(
        ) | Qt.FramelessWindowHint | Qt.Popup | Qt.NoDropShadowWindowHint)
        self.setAttribute(Qt.WA_StyledBackground, True)
        self.setAttribute(Qt.WA_TranslucentBackground, True)
        # 进入动画
        self.animIn = QPropertyAnimation(
            self, duration=500, easingCurve=QEasingCurve.OutCubic)
        self.animIn.setPropertyName(b'pos')
        # 离开动画
        self.animOut = QPropertyAnimation(
            self, duration=500, finished=self.onAnimOutEnd,
            easingCurve=QEasingCurve.OutCubic)
        self.animOut.setPropertyName(b'pos')
        self.animOut.setDuration(500)
        self.setStretch(stretch)        # 占比
        self.direction = direction      # 方向
        # 半透明背景
        self.alphaWidget = QWidget(
            self, objectName='CDrawer_alphaWidget',
            styleSheet='#CDrawer_alphaWidget{background:rgba(55,55,55,100);}')
        self.alphaWidget.setAttribute(Qt.WA_TransparentForMouseEvents, True)
        self.setWidget(widget)          # 子控件 
Example #4
Source File: interSubs.py    From interSubs with MIT License 5 votes vote down vote up
def subtitles_base(self):
		self.subtitles = QFrame()
		self.subtitles.setAttribute(Qt.WA_TranslucentBackground)
		self.subtitles.setWindowFlags(Qt.X11BypassWindowManagerHint)
		self.subtitles.setStyleSheet(config.style_subs)

		self.subtitles_vbox = QVBoxLayout(self.subtitles)
		self.subtitles_vbox.setSpacing(config.subs_padding_between_lines)
		self.subtitles_vbox.setContentsMargins(0, 0, 0, 0) 
Example #5
Source File: DreamTree.py    From PyQt with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        super(Window, self).__init__(*args, **kwargs)

        self.setAttribute(Qt.WA_TranslucentBackground, True)  # 设置父控件Widget背景透明
        self.setWindowFlags(Qt.FramelessWindowHint)  # 去掉边框
        palette = self.palette()
        palette.setBrush(QPalette.Base, Qt.transparent)  # 父控件背景透明
        self.setPalette(palette)

        layout = QVBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)

        #         QWebSettings.globalSettings().setAttribute(
        #             QWebSettings.DeveloperExtrasEnabled, True)# web开发者工具

        self.webView = QWebView(self)  # 网页控件
        layout.addWidget(self.webView)
        self.webView.setContextMenuPolicy(Qt.NoContextMenu)  # 去掉右键菜单
        self.mainFrame = self.webView.page().mainFrame()

        self.mainFrame.setScrollBarPolicy(
            Qt.Vertical, Qt.ScrollBarAlwaysOff)  # 去掉滑动条
        self.mainFrame.setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff)

        # 最大化
        rect = app.desktop().availableGeometry()
        self.resize(rect.size())
        self.webView.resize(rect.size()) 
Example #6
Source File: FramelessWindow.py    From PyQt with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        super(FramelessWindow, self).__init__(*args, **kwargs)
        self._pressed = False
        self.Direction = None
        # 背景透明
        self.setAttribute(Qt.WA_TranslucentBackground, True)
        # 无边框
        self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint)
        # 鼠标跟踪
        self.setMouseTracking(True)
        # 布局
        layout = QVBoxLayout(self, spacing=0)
        # 预留边界用于实现无边框窗口调整大小
        layout.setContentsMargins(
            self.Margins, self.Margins, self.Margins, self.Margins)
        # 标题栏
        self.titleBar = TitleBar(self)
        layout.addWidget(self.titleBar)
        # 信号槽
        self.titleBar.windowMinimumed.connect(self.showMinimized)
        self.titleBar.windowMaximumed.connect(self.showMaximized)
        self.titleBar.windowNormaled.connect(self.showNormal)
        self.titleBar.windowClosed.connect(self.close)
        self.titleBar.windowMoved.connect(self.move)
        self.windowTitleChanged.connect(self.titleBar.setTitle)
        self.windowIconChanged.connect(self.titleBar.setIcon) 
Example #7
Source File: FramelessDialog.py    From PyQt with GNU General Public License v3.0 5 votes vote down vote up
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.setStyleSheet(Stylesheet)
        self.initUi()
        # 添加阴影
        effect = QGraphicsDropShadowEffect(self)
        effect.setBlurRadius(12)
        effect.setOffset(0, 0)
        effect.setColor(Qt.gray)
        self.setGraphicsEffect(effect) 
Example #8
Source File: Notification.py    From PyQt with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        super(NotificationWindow, self).__init__(*args, **kwargs)
        self.setSpacing(20)
        self.setMinimumWidth(412)
        self.setMaximumWidth(412)
        QApplication.instance().setQuitOnLastWindowClosed(True)
        # 隐藏任务栏,无边框,置顶等
        self.setWindowFlags(self.windowFlags() | Qt.Tool |
                            Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint)
        # 去掉窗口边框
        self.setFrameShape(self.NoFrame)
        # 背景透明
        self.viewport().setAutoFillBackground(False)
        self.setAttribute(Qt.WA_TranslucentBackground, True)
        # 不显示滚动条
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        # 获取屏幕高宽
        rect = QApplication.instance().desktop().availableGeometry(self)
        self.setMinimumHeight(rect.height())
        self.setMaximumHeight(rect.height())
        self.move(rect.width() - self.minimumWidth() - 18, 0) 
Example #9
Source File: widget.py    From IDArling with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, plugin):
        super(StatusWidget, self).__init__()
        self._plugin = plugin

        # Create the sub-widgets
        def new_label():
            widget = QLabel()
            widget.setAutoFillBackground(False)
            widget.setAttribute(Qt.WA_PaintOnScreen)
            widget.setAttribute(Qt.WA_TranslucentBackground)
            return widget

        self._servers_text_widget = new_label()
        self._servers_icon_widget = new_label()
        self._invites_text_widget = new_label()
        self._invites_icon_widget = new_label()
        self._users_text_widget = new_label()
        self._users_icon_widget = new_label()

        # Set a custom context menu policy
        self.setContextMenuPolicy(Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(self._context_menu)

        # Timer signaling it is time to update the widget
        self._timer = QTimer()
        self._timer.setInterval(1000)
        self._timer.timeout.connect(self.refresh) 
Example #10
Source File: TestCTitleBar.py    From CustomWidgets with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        super(TestCTitleBarBase, self).__init__(*args, **kwargs)
        self.resize(500, 400)
        # 设置背景透明
        self.setAttribute(Qt.WA_TranslucentBackground, True)
        # 设置无边框
        self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint)
        layout = QVBoxLayout(self)
        layout.setSpacing(0)
        # 添加自定义标题栏
        layout.addWidget(CTitleBar(self, title='CTitleBar'))
        # 底部空白占位
        layout.addWidget(QWidget(self, objectName='bottomWidget')) 
Example #11
Source File: CFramelessWidget.py    From CustomWidgets with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        super(CFramelessBase, self).__init__(*args, **kwargs)
        self.dragParams = {'type': 0, 'x': 0,
                           'y': 0, 'margin': 0, 'draging': False}
        self.originalCusor = None
        self.setMouseTracking(True)
        # 设置背景透明
        self.setAttribute(Qt.WA_TranslucentBackground, True)
        # 设置无边框
        self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint) 
Example #12
Source File: CColorPicker.py    From CustomWidgets with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #13
Source File: custom_dialogs.py    From parsec-cloud with GNU Affero General Public License v3.0 5 votes vote down vote up
def __init__(self, center_widget, title, parent, hide_close=False):
        super().__init__(None)
        self.setupUi(self)
        self.setModal(True)
        self.setObjectName("GreyedDialog")
        self.setWindowModality(Qt.ApplicationModal)
        self.button_close.apply_style()
        if platform.system() == "Windows":
            # SplashScreen on Windows freezes the Window
            self.setWindowFlags(Qt.FramelessWindowHint)
        else:
            # FramelessWindowHint on Linux (at least xfce) is less pretty
            self.setWindowFlags(Qt.SplashScreen)
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.center_widget = center_widget
        self.main_layout.addWidget(center_widget)
        if not title and hide_close:
            self.widget_title.hide()
        if title:
            self.label_title.setText(title)
        if hide_close:
            self.button_close.hide()
        main_win = ParsecApp.get_main_window()
        if main_win:
            if main_win.isVisible():
                self.setParent(main_win)
                self.resize(main_win.size())
            else:
                self.showMaximized()
            self.move(0, 0)
        else:
            logger.error("GreyedDialog did not find the main window, this is probably a bug")
        self.setFocus()
        self.accepted.connect(self.on_finished)
        self.rejected.connect(self.on_finished) 
Example #14
Source File: lrcwindow.py    From QMusic with GNU Lesser General Public License v2.1 5 votes vote down vote up
def mouseMoveEvent(self, event):
        if hasattr(self, "dragPosition"):
            if event.buttons() == Qt.LeftButton:
                self.move(event.globalPos() - self.dragPosition)
                event.accept()
                self.setAttribute(Qt.WA_TranslucentBackground, False) 
Example #15
Source File: lrcwindow.py    From QMusic with GNU Lesser General Public License v2.1 5 votes vote down vote up
def __init__(self, parent=None):
        super(FMoveableWidget, self).__init__(parent)
        self.setAttribute(Qt.WA_TranslucentBackground, True)
        self.setAttribute(Qt.WA_Hover, True)
        self.setWindowFlags(Qt.SubWindow | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint)

        self.installEventFilter(self)
        self.boderFlag = False

        self.isSideClicked = False
        self.isCusorLeftSide = False
        self.isCusorRightSide = False
        self.isCusorDownSide = False 
Example #16
Source File: message_area.py    From CHATIMUSMAXIMUS with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent=None):
        super(MessageArea, self).__init__(parent)
        self.setReadOnly(True)
        self.sender_format = _StandardTextFormat(Qt.gray, self.fontWeight())
        self.time_format = _StandardTextFormat(Qt.gray, self.fontWeight())
        self.text_format = _StandardTextFormat()

        # styling
        self.setWindowFlags(Qt.FramelessWindowHint)
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.viewport().setAutoFillBackground(False)
        self.name_formats = {}

        self.listeners = []
        sound_filepath = path.join(path.dirname(__file__),
                                   'resources',
                                   'click.wav')

        # sound_filepath = path.abspath(sound_filepath)
        sound_filepath = QtCore.QUrl.fromLocalFile(sound_filepath)

        self.sound = QtMultimedia.QSoundEffect()
        self.sound.setSource(sound_filepath)
        self.sound.setVolume(0.5)
        self.sound.setLoopCount(1) 
Example #17
Source File: interSubs.py    From interSubs with MIT License 5 votes vote down vote up
def popup_base(self):
		self.popup = QFrame()
		self.popup.setAttribute(Qt.WA_TranslucentBackground)
		self.popup.setWindowFlags(Qt.X11BypassWindowManagerHint)
		self.popup.setStyleSheet(config.style_popup)

		self.popup_inner = QFrame()
		outer_box = QVBoxLayout(self.popup)
		outer_box.addWidget(self.popup_inner)

		self.popup_vbox = QVBoxLayout(self.popup_inner)
		self.popup_vbox.setSpacing(0) 
Example #18
Source File: interSubs.py    From interSubs with MIT License 5 votes vote down vote up
def subtitles_base2(self):
		self.subtitles2 = QFrame()
		self.subtitles2.setAttribute(Qt.WA_TranslucentBackground)
		self.subtitles2.setWindowFlags(Qt.X11BypassWindowManagerHint)
		self.subtitles2.setStyleSheet(config.style_subs)

		self.subtitles_vbox2 = QVBoxLayout(self.subtitles2)
		self.subtitles_vbox2.setSpacing(config.subs_padding_between_lines)
		self.subtitles_vbox2.setContentsMargins(0, 0, 0, 0)

		if config.pause_during_translation_B:
			self.subtitles2.enterEvent = lambda event : [mpv_pause(), setattr(config, 'block_popup', False)][0]
			self.subtitles2.leaveEvent = lambda event : [mpv_resume(), setattr(config, 'block_popup', True)][0] if not config.avoid_resuming else [setattr(config, 'avoid_resuming', False), setattr(config, 'block_popup', True)][0] 
Example #19
Source File: CColorStraw.py    From CustomWidgets with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self, *args, **kwargs):
        super(ScaleWindow, self).__init__(*args, **kwargs)
        self.setWindowFlags(Qt.Tool | Qt.FramelessWindowHint |
                            Qt.WindowStaysOnTopHint)
        self.setAttribute(Qt.WA_TranslucentBackground, True)
        self.resize(1, 1)
        self.move(1, 1)
        self._image = None 
Example #20
Source File: Widgets.py    From Jade-Application-Kit with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self, config):
        super().__init__()
        self.config = config
        if config["window"]["backgroundImage"]:
            # Transparency must be set to True
            self.label = QLabel(self)
            self.setObjectName("JAKWindow")
            self.setBackgroundImage(config["window"]["backgroundImage"])
        self.video_corner = False
        self.center = getScreenGeometry().center()
        self.setWindowTitle(config['window']["title"])
        self.setWindowFlags(config['window']["setFlags"])
        self.setWAttribute(Qt.WA_DeleteOnClose)
        for attr in config['window']["setAttribute"]:
            self.setWAttribute(attr)

        if config['window']["state"]:
            self.setWindowState(config['window']["state"])

        if config['window']["icon"] and os.path.isfile(config['window']["icon"]):
            self.icon = QIcon(config['window']["icon"])
        else:
            print(f"icon not found: {config['window']['icon']}")
            print("loading default icon:")
            self.icon = QIcon.fromTheme("applications-internet")

        view = Instance.retrieve("view")
        if view:
            self.view = view
            self.setCentralWidget(self.view)
            self.view.iconChanged.connect(self._icon_changed)
            if config['webview']["online"]:
                self.view.page().titleChanged.connect(self.status_message)

        if config['window']["transparent"]:
            # Set Background Transparency
            self.setWAttribute(Qt.WA_TranslucentBackground)
            self.setAutoFillBackground(True)

        if config['webview']["online"]:
            # Do not display toolbar or system tray offline
            if config['window']["toolbar"]:
                self.toolbar = JToolbar(self, config['window']["toolbar"], self.icon, config['window']["title"])
                self.addToolBar(self.toolbar)
            self.setMenuBar(Menu(self, config['window']["menus"]))
        else:
            if config['window']["showHelpMenu"]:
                self.setMenuBar(Menu(self, config['window']["menus"]))
                self.view.page().titleChanged.connect(self.status_message)

        if config['window']["SystemTrayIcon"]: 
            self.system_tray = SystemTrayIcon(self.icon, self, config)
                
        if config["debug"]:
            self.showInspector()                       
        self._set_icons() 
Example #21
Source File: Widgets.py    From Jade-Application-Kit with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self, config):
        super().__init__()
        self.config = config
        if config["window"]["backgroundImage"]:
            # Transparency must be set to True
            self.label = QLabel(self)
            self.setObjectName("JAKWindow")
            self.setBackgroundImage(config["window"]["backgroundImage"])
        self.video_corner = False
        self.center = getScreenGeometry().center()
        self.setWindowTitle(config['window']["title"])
        self.setWindowFlags(config['window']["setFlags"])
        self.setWAttribute(Qt.WA_DeleteOnClose)
        for attr in config['window']["setAttribute"]:
            self.setWAttribute(attr)

        if config['window']["state"]:
            self.setWindowState(config['window']["state"])

        if config['window']["icon"] and os.path.isfile(config['window']["icon"]):
            self.icon = QIcon(config['window']["icon"])
        else:
            print(f"icon not found: {config['window']['icon']}")
            print("loading default icon:")
            self.icon = QIcon.fromTheme("applications-internet")

        view = Instance.retrieve("view")
        if view:
            self.view = view
            self.setCentralWidget(self.view)
            self.view.iconChanged.connect(self._icon_changed)
            if config['webview']["online"]:
                self.view.page().titleChanged.connect(self.status_message)

        if config['window']["transparent"]:
            # Set Background Transparency
            self.setWAttribute(Qt.WA_TranslucentBackground)
            self.setAutoFillBackground(True)

        if config['webview']["online"]:
            # Do not display toolbar or system tray offline
            if config['window']["toolbar"]:
                self.toolbar = JToolbar(self, config['window']["toolbar"], self.icon, config['window']["title"])
                self.addToolBar(self.toolbar)
            self.setMenuBar(Menu(self, config['window']["menus"]))
        else:
            if config['window']["showHelpMenu"]:
                self.setMenuBar(Menu(self, config['window']["menus"]))
                self.view.page().titleChanged.connect(self.status_message)

        if config['window']["SystemTrayIcon"]: 
            self.system_tray = SystemTrayIcon(self.icon, self, config)
                
        if config["debug"]:
            self.showInspector()                       
        self._set_icons() 
Example #22
Source File: ProbeWindow.py    From PyQt with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self, *args, **kwargs):
        super(FrameWidget, self).__init__(*args, **kwargs)
        self.setWindowFlags(Qt.Tool | Qt.FramelessWindowHint |
                            Qt.WindowStaysOnTopHint)
        self.setAttribute(Qt.WA_TranslucentBackground, True)
        self.showFullScreen()  # 全屏
        self._rect = QRect()  # 被探测的窗口的矩形位置 
Example #23
Source File: pkwidgets.py    From pkmeter with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
def __init__(self, etree, style, pkmeter, parent=None):
        PKWidget.__init__(self, etree, pkmeter, parent)
        self.pkmeter = pkmeter
        self.setStyleSheet(style)
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.setWindowFlags(
            Qt.Tool |
            Qt.FramelessWindowHint |
            Qt.WindowStaysOnBottomHint |
            Qt.NoDropShadowWindowHint |
            Qt.CustomizeWindowHint)
        self.layout().setContentsMargins(0,0,0,0)
        self.layout().setSpacing(0)
        self._init_menu()
        pkmixins.DraggableMixin.__init__(self)