Git Product home page Git Product logo

pyqt-frameless-window's People

Contributors

alexzhu2001 avatar cheukfung avatar parhamoyan avatar zhiyiyo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyqt-frameless-window's Issues

How to remove the titlebar completely ?

I am developing a Desktop Widget on Windows using this library, which is great for me. But when I try to dide the buttons or just delete the titlebar, it always got a fixed padding left on the right side. I can't drag the window in this area, I can't also make the window size smaller than this padding. Is it a bug or it is just me have to do some tweaks?

可否支持pyside6

自己尝试改了改(hpyculator项目里面改了改,引用了代码(还没在pypi上发布之前引用的)),
win这边切换到pyside6非常快捷(改import)
但是linux部分的切换到pyside6有个库在pyside6找不到对应
,不得不说博客和代码都很棒

QWebEngineView Breaks Acrylic window

When using the QWebEngineView widget, it makes the acrylic effect stop working and just show a black screen

Code:

import sys
from PyQt5 import QtWidgets, QtCore,QtGui
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWebEngineWidgets import *  
import time
from qframelesswindow import AcrylicWindow

class MainWindow(AcrylicWindow):
    def __init__(self, parent=None):
        super().__init__(parent=parent)
        #self.windowEffect.setAcrylicEffect(self.winId(), True)
        self.webview = QWebEngineView(parent=self)
        self.webview.load(QUrl("https://google.com"))
        self.webview.setGeometry(QRect(0,100,self.width(), 100))

if __name__ == '__main__':
    app = QApplication(sys.argv)
    mw = MainWindow()
    mw.show()
    sys.exit(app.exec_())

FramelessWindow 隐藏titleBar 后 设置QSS样式后出现titleBar

20

import sys
from PyQt5 import QtCore
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication, QLabel
from qframelesswindow import FramelessWindow


class ResLabel(QLabel, FramelessWindow):
    def __init__(self, *args, **kwargs):
        super(ResLabel, self).__init__(*args, **kwargs)
        self.titleBar.hide()

        self.setWordWrap(True)
        self.setAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop)
        self.setWindowFlags(Qt.WindowStaysOnTopHint)

        self.setStyleSheet('''QLabel{background:rgba(10,10,255,0.1);border:3px solid rgba(255, 0, 0,0.5);
	                                }''')
        self.setText('我想学C++' * 9)


if __name__ == '__main__':
    app = QApplication(sys.argv)
    demo = ResLabel()
    demo.show()
    sys.exit(app.exec_())

拖动会卡顿

不知道从什么时候开始,Win10上拖动位置窗口会慢慢悠悠的移动过去?

Dialog在macOS下有bug

感谢更新三大按钮样式定制!
再次反馈一个bug
之前我用多继承实现无边框dialog的时候,就发现在macOS下,仍然会有一个没有关闭按钮的边框,不过我的软件用户都是windows用户,所以没多想,后来发现作者更新了无边框Dialog,试了下,依然不行。
image
image

Can we make/customize a frameless dialog ?

Hello @zhiyiYo ,

Can you please help me with making a frameless Dialog, instead of a window ?

My current code is as follows:

    from qframelesswindow import FramelessWindow
    class MainWindow(QMainWindow, FramelessWindow):
          def __init__(self):
              super().__init__()
              self.setWindowTitle("My App")
              button = QPushButton("Press me for a dialog!")
              button.clicked.connect(self.button_clicked)
              self.setCentralWidget(button)
      
          def button_clicked(self):
              dlg = QDialog(self, Qt.WindowTitleHint | Qt.WindowCloseButtonHint)
              dlg.setWindowFlags(Qt.FramelessWindowHint | Qt.Dialog)
              # dlg_layout = QVBoxLayout()
              form = QFormLayout()
      
              self.track_id = QSpinBox()
              self.track_id.setRange(0, 2147483647)
              self.track_id.setDisabled(True)
              self.name = QLineEdit()
              self.album = QComboBox()
              self.media_type = QComboBox()
              self.genre = QComboBox()
              self.composer = QLineEdit()
      
              self.milliseconds = QSpinBox()
              self.milliseconds.setRange(0, 2147483647)  # <1>
              self.milliseconds.setSingleStep(1)
      
              self.bytes = QSpinBox()
              self.bytes.setRange(0, 2147483647)
              self.bytes.setSingleStep(1)
      
              self.unit_price = QDoubleSpinBox()
              self.unit_price.setRange(0, 999)
              self.unit_price.setSingleStep(0.01)
              self.unit_price.setPrefix("$")
      
              form.addRow(QLabel("Track ID"), self.track_id)
              form.addRow(QLabel("Track name"), self.name)
              form.addRow(QLabel("Composer"), self.composer)
              form.addRow(QLabel("Milliseconds"), self.milliseconds)
              form.addRow(QLabel("Bytes"), self.bytes)
              form.addRow(QLabel("Unit Price"), self.unit_price)
              dlg.setWindowTitle("Add User")
              layout = QVBoxLayout()
              layout.addLayout(form)
              dlg.setLayout(layout)
              dlg.exec()
      
             app = QApplication(sys.argv)
             window = MainWindow()
             window.show()
              app.exec()

I tried with setting the following flags

dlg.setWindowFlags(Qt.FramelessWindowHint | Qt.Dialog)

But as we know, that flag completely removes the title bar.

Really thank full to you for this package.

AcrylicWindow不显示标题?

Win11,代码就是给的acrylic的demo代码
那个标题不显示?
image
标题和图标不显示,这是正常现象吗?

add support to pass widget object as title bar

Hi, thank you for great works, its perfect and exactly what I wanted
but I think one think can make it even better, I mean it will be very good if we can pass a QWidget (or maybe QFrame) to it, in order to use it as a title bar
in this way we can create our title bar as a part of the whole program in Qt Designer, and then just use it as a title bar by passing widget of it... (in this way we also need to pass the 3 minimize, maximize and close button to it too (or we can leave it to user to handle them)


and one other thing, please consider commenting your code in english 😅

如何显示系统的标题栏菜单

在一个默认的标题栏中
点击窗口图标、右键标题栏(弹出菜单):
图片
图片
双击窗口图标(关闭窗口):
图片

如何实现这些功能?双击窗口图标关闭窗口应该不难,但是这个菜单该如何调用

多屏会出现鼠标一直为拖动状态的问题

当有双屏时,由于 xPos 极大,所以会导致出现 rx 一直为 True。这时鼠标会一直为拖动状态,将 xPos 对 65536 取余或者减去都可以。

在 nativeEvent 里

xPos = win32api.LOWORD(msg.lParam) - self.frameGeometry().x() % 65536
#
# if xPos > 65536:
#     xPos -= 65536

How to add statusbar to the Framewless window ?

When i try to inherit from QMainWindow so that i can use QStatusBar. My window layout gets messed up.

The code i am using is


class Home(QMainWindow, FramelessWindow):

        def __init__(self, hook, parent=None):
            super().__init__(parent=parent)
            self.add_statusbar()

       def add_statusbar:
       # statusbar code
            statusBar = QStatusBar()
            self.setStatusBar(statusBar)

            statusBar.addWidget(QLabel("message left 1"))
            statusBar.addWidget(QLabel("message left 2"))
            statusBar.addWidget(QLabel("message to right end"))

Can you please tell me how can i use QStatusBar with PyQt-Frameless

Thank you for helping me.

多个显示屏时拖动窗口切换所在显示屏或高DPI时无法正常拖拽窗口大小

如标题

这是自己写的修复方案:

 def nativeEvent(self, eventType, message):
        """ 处理windows消息 """
        msg = MSG.from_address(message.__int__())
        if msg.message == win32con.WM_NCHITTEST:
            # 解决多屏下会出现鼠标一直为拖动状态的问题
            Pos = QCursor.pos()
            xPos, yPos = Pos.x() - self.x(), Pos.y() - self.y()

            w, h = self.width(), self.height()
            lx = xPos < self.BORDER_WIDTH
            rx = xPos + 3 > w - self.BORDER_WIDTH
            ty = yPos < self.BORDER_WIDTH
            by = yPos > h - self.BORDER_WIDTH

            if lx and ty:
                return True, win32con.HTTOPLEFT
            elif rx and by:
                return True, win32con.HTBOTTOMRIGHT
            elif rx and ty:
                return True, win32con.HTTOPRIGHT
            elif lx and by:
                return True, win32con.HTBOTTOMLEFT
            elif ty:
                return True, win32con.HTTOP
            elif by:
                return True, win32con.HTBOTTOM
            elif lx:
                return True, win32con.HTLEFT
            elif rx:
                return True, win32con.HTRIGHT

--snip--

“显示强调色”的问题

开了“显示强调色”以后出现了好多问题……😫
图片
正常情况下边框会显示主题色,但是用WindowEffect以后只会显示默认的边框,不会变色
图片
图片
而且有一个很奇怪的问题,如果使用云母特效,它会强制在标题栏的位置加一个有主题色的背景(就很离谱)
图片

在有多个屏幕的情况下,窗口的控件元素出现重复,resize后现象消失

您好:
首先非常感谢您的开源,解决了我调用windows api 的问题。这两天我在使用过程中发现了一个问题。就是当你把你的界面拖拽到第二个扩展屏幕上的,界面上元素会出现重复。resize后,界面恢复正常,似乎他无法在两个分辨率中进行调整,只有当你调用了他的resizeEvent后,进行强制刷新界面才行。我有尝试过QApplication.processEvents(),self.update()等方法。都不行。
bug
normal

MainWindow无法使用windowEffect

win11 python3.10.5
就是我试图去将我的FramelessWindow转为QMainWindow,然后发现不能使用AcrylicEffect和MicaEffect了
image
这两种写法都不行,是不是必须得改qframelesswindow里的源码的继承关系,把继承从QtWidget改为QMainWindow啊?(我个人觉得如果没有必要,就不要改第三方库的代码)

No size-grips on FramelessMainWindow after closing FramelessDialog

Describe the bug
The size-grips (the little arrows that let you resize a window) disappear on FramelessMainWindow after creating and closing a FramelessDialog.

Environment

  • OS: Windows10
  • DPI scaling: e.g. 175%
  • Python: 3.10.6 64 bit
  • PyQt5: 5.15.6

To Reproduce
Steps to reproduce the behavior:

  1. Run main_window.py and open the help dialog
  2. Close the dialog and try to resize the main window (only the size-grip in the bottom right corner will work)

Expected behavior
The main window keeps its size-grips on all four sides.

More info
Calling self.winID() on the initialization of the FramelessDialog seems to remove the size-grips from the main window.
This problem only occurs when you call self.setCentralWidget or self.setLayout on the main window.

大佬,有C++版的QT 无边框吗

大佬,有C++版的QT 无边框窗口吗,我测试了下,效果很好。但是经常用 C++ QT ,请问您这个有没有C++ 版本的

为什么主窗口继承 QWidget 而不是 QMainWindow?

qframelesswindow/windows/init.py 中的 class WindowsFramelessWindow(QWidget) 继承了QWidget,而不是QMainWindow。请问这样是有什么特别的需求吗?因为使用QWidget就不能直接使用 比如 addDockWidget 之类的函数了。已经点赞收藏,谢谢博主的作品。

最大化窗口后边缘光标问题

demo.py 正常,最大化时候不会出现
acrylic_demo.py 最大化以后下边、右下边、右边仍可以缩放窗口
我始终不理解,为什么demo不会这样,acrylic_demo却会这样

1670290135562.mp4

关于DPI缩放

启用DPI缩放后

    QGuiApplication.setHighDpiScaleFactorRoundingPolicy(Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)
    QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
    QCoreApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
    app = QApplication(sys.argv)
    demo = Window()
    demo.show()
    sys.exit(app.exec_())

系统Win10, 系统缩放125%
动画

似乎这个地方乘以缩放因子就ok了?
image

关于qmediawidget播放视频无法拉伸窗口的问题

你好,你的代码让我受益匪浅,最近尝试练习制作一个媒体播放器,发现一旦使用了qt里的setVideoOutput方法,让一个widget作为视频显示的界面之后,鼠标移动到窗口边缘就不再出现箭头了,原因好像是无法获取到windows发出的消息,但其他效果均无影响。实在不懂win32这块,希望能帮忙解决一下,小白在此跪谢!

自动切换主题

最近想写一个软件,希望可以
①自定义窗口标题栏
②软件的主题可以跟随系统主题自动切换白天、黑暗模式
这个项目很好的解决了第一个问题,对于第二个问题我发现有一个开源项目实现了自动切换主题的项目PyQtDarkTheme ,但是不知道如何结合这两个项目一起使用,开发大佬可以指点一下吗?

Thanks.

i use pyside6 not work

error message

root@minto-Lenovo-V145-14AST:/home/minto/belajar/pysidepro/pyframe# python3 main.py 
Traceback (most recent call last):
  File "/home/minto/belajar/pysidepro/pyframe/main.py", line 8, in <module>
    from qframelesswindow import FramelessWindow, TitleBar
  File "/usr/local/lib/python3.10/dist-packages/qframelesswindow/__init__.py", line 9, in <module>
    from .titlebar import UnixTitleBar as TitleBar
  File "/usr/local/lib/python3.10/dist-packages/qframelesswindow/titlebar/__init__.py", line 13, in <module>
    from ..utils.linux_utils import LinuxMoveResize
  File "/usr/local/lib/python3.10/dist-packages/qframelesswindow/utils/linux_utils.py", line 5, in <module>
    from PySide6 import sip
ImportError: cannot import name 'sip' from 'PySide6' (/usr/local/lib/python3.10/dist-packages/PySide6/__init__.py)

my code

# coding:utf-8
import sys

from PySide6.QtCore import Qt
from PySide6.QtGui import QColor, QPixmap
from PySide6.QtWidgets import QApplication, QLabel

from qframelesswindow import FramelessWindow, TitleBar


class CustomTitleBar(TitleBar):
    """ Custom title bar """

    def __init__(self, parent):
        super().__init__(parent)
        # add title label
        self.titleLabel = QLabel(self)
        self.titleLabel.setStyleSheet("QLabel{font: 13px 'Segoe UI'; margin: 9px}")
        self.window().windowTitleChanged.connect(self.setTitle)

        # customize the style of title bar button
        self.minBtn.setHoverColor(Qt.white)
        self.minBtn.setHoverBackgroundColor(QColor(0, 100, 182))
        self.minBtn.setPressedColor(Qt.white)
        self.minBtn.setPressedBackgroundColor(QColor(54, 57, 65))

        # use qss to customize title bar button
        self.maxBtn.setStyleSheet("""
            TitleBarButton {
                qproperty-hoverColor: white;
                qproperty-hoverBackgroundColor: rgb(0, 100, 182);
                qproperty-pressedColor: white;
                qproperty-pressedBackgroundColor: rgb(54, 57, 65);
            }
        """)

    def setTitle(self, title):
        self.titleLabel.setText(title)
        self.titleLabel.adjustSize()


class Window(FramelessWindow):

    def __init__(self, parent=None):
        super().__init__(parent=parent)
        # change the default title bar if you like
        self.setTitleBar(CustomTitleBar(self))

        self.label = QLabel(self)
        self.label.setScaledContents(True)
        self.label.setPixmap(QPixmap("screenshot/shoko.png"))
        self.setWindowTitle("PyQt Frameless Window")
        self.setStyleSheet("background:white")

        self.titleBar.raise_()

    def resizeEvent(self, e):
        # don't forget to call the resizeEvent() of super class
        super().resizeEvent(e)
        length = min(self.width(), self.height())
        self.label.resize(length, length)
        self.label.move(
            self.width() // 2 - length // 2,
            self.height() // 2 - length // 2
        )


if __name__ == "__main__":
    # enable dpi scale
    QApplication.setHighDpiScaleFactorRoundingPolicy(
        Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)
    QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
    QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)

    # run app
    app = QApplication(sys.argv)
    demo = Window()
    demo.show()
    sys.exit(app.exec_())

黑暗模式下窗口按钮颜色更新问题

感谢作者的开源!
我自己的软件,做了两套qss,来适配dark mode,由于三大按钮是黑色,导致在黑暗模式下,直接消失看不到。
看了下源码,发现可以用updatestyle来更新按钮颜色。
"normal": { "color": (0, 0, 0), 'background': (0, 0, 0, 26) }
然后发现关闭按钮无法更新,再次看源码,发现关闭按钮是svg,而另外两个按钮是画的。
建议作者把另外两个图标都用svg,这样高分屏下面图标一致性好一点,在高分屏下,最小化最大化的图标和关闭按钮明显不一致,并且使用update style的时候也不会感到疑惑。

再次感谢作者的开源

Method _isDragRegion ignores hidden buttons from FramelessDialog

Describe the bug
The method qframelesswindow.titlebar.TitleBar._isDragRegion ignores hidden buttons from FramelessDialog because the code expects three buttons with a width of 46px each.

To Reproduce
Steps to reproduce the behavior:

  1. Create a FramelessDialog
  2. Try to drag it from a few pixels left from the close button (where usually minBtn and maxBtn are placed)
  3. Window is not draggable until you start dragging from a 'valid' position

Code

# Minimum code to reproduce the error
import sys

from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication, QLabel, QHBoxLayout
# from qframelesswindow.titlebar import TitleBar
from qframelesswindow import FramelessDialog


def _isDragRegion(self, pos):
    """ *monkey patch*\
    Check whether the pressed point belongs to the area where dragging is allowed """
    no_drag = 0
    for button in (self.minBtn, self.maxBtn, self.closeBtn):
        if not button.isHidden():
            no_drag += button.width()
    return 0 < pos.x() < self.width() - no_drag


class Dialog(FramelessDialog):

    def __init__(self, parent=None):
        super().__init__(parent=parent)
        # TitleBar._isDragRegion = _isDragRegion # monkey patching
        self.setLayout(QHBoxLayout())
        self.layout().addWidget(QLabel('Try to drag me from left of the close button'), 0, Qt.AlignCenter)
        self.titleBar.raise_()


app = QApplication(sys.argv)
window = Dialog()
window.show()
app.exec()

Expected behavior
Dragging the titlebar next to the close button on a FramelessDialog with the minimize and maximize button hidden should work.

Desktop:

  • OS: Windows10
  • DPI scaling: 175%

How I fixed it:

  1. Add this function (calculate sum of the actual width of buttons that are not hidden) to my project:
    def _isDragRegion(self, pos):
        """ *monkey patch*\
        Check whether the pressed point belongs to the area where dragging is allowed """
        no_drag = 0
        for button in (self.minBtn, self.maxBtn, self.closeBtn):
            if not button.isHidden():
                no_drag += button.width()
        return 0 < pos.x() < self.width() - no_drag
  2. Monkey patch _isDragRegion:
    from qframelesswindow.titlebar import TitleBar
    # ...other imports
    class Dialog(FramelessDialog):
        # ...
        TitleBar._isDragRegion = _isDragRegion # monkey patching
        # ...

To make this even better you could iterate over all visible children of the titlebar that do not have a click/hover event and are visible.

自定义标题栏颜色异常

你好,我在调试demo.py时,希望可以自定义标题栏颜色,通过setStyleSheet设置了TitleBar的颜色为白色,同时修改了CloseButton、MinimizeButton默认背景颜色为白色,但是执行后,显示如下图所示,开始跟中间部分显示异常,麻烦大佬帮忙看下还有哪里设置不对,谢谢
image

How to change acrylic transparency and degree of blur?

如图,用 Acrylic 效果感觉背景模糊不够透,即使在参数里设置的颜色是 01010100 也只是让背景变黑了。有一篇博客园上的文章讲了在UWP上通过自定义 AcrylicBrush 解决这种问题。

screenshot

网上的另一个项目 Countboard 用到了你的代码,好奇为啥这个显得就没那么黑。

Countboard

Windows 7 Bugs

record.webm
如视频,在非Aero模式时按钮发生鬼畜(?
record 2.webm
在压克力模式下倒没什么问题,只是没有压克力效果罢了
record3.webm
两者在 Aero 模式下压克力模式表现良好,一般模式的 Hover 令人迷惑

标题栏按钮高度太小

因为我觉得窗口的titlebar太细了,但是如果直接设置height就会使得最小化和最大化两个的paintEvent画的偏移了位置,也没有改变大小。
新手研究了半天发现只有closebutton是继承了svgtitlebarbutton, 这个就可以直接放大缩小。
希望能增加这个放大缩小的功能。或者能不能教一下怎么修改那个paintEvent,谢谢

How to add widgets/buttons next to minimize button

Describe the bug
Not a bug, but more a feature

Environment

  • OS: [e.g. Windows10]
  • DPI scaling: [e.g. 125%]
  • Python: [e.g. 3.8.6 64-bit]
  • PyQt5: [e.g. 5.15.2]

As the title says, how do i add buttons/widgts next to minize button, as show in the screeshot below.

Screenshots
mnCPxg46qG

Any help is appreciated.

Mica Title bar on Latest windows update

When i test my app on the latest windows update, a title bar shows up, i was wondering if there was a way to make this transparent, as it ruins some past apps, thanks.
Screenshot_20230209_091241

import sys
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication
from qframelesswindow import AcrylicWindow


class Window(AcrylicWindow):

    def __init__(self, parent=None):
        super().__init__(parent=parent)
        self.setWindowTitle("Acrylic Window")
        self.titleBar.raise_()
        self.windowEffect.setMicaEffect(self.winId(), True)


if __name__ == '__main__':
    app = QApplication(sys.argv)
    demo = Window()
    demo.show()
    sys.exit(app.exec_())

边框圆角问题

你好,我翻了您的代码,想询问下您是怎么解决边框圆角的呢?

ValueError: Procedure called with not enough arguments

  • OS: [e.g. Win 11]
  • Python [e.g. 3.6.2 X32]
  • PyQt5 [e.g. 5.15.2]
  • PyCharm 2022.2.4

When I try the domos in example folders, all of them are not aviliable for me, it occurs the same error as below:

Traceback (most recent call last):
  File "C:/Program Files/JetBrains/PyCharm Community Edition 2022.2.4/plugins/python-ce/helpers/pydev/pydevd.py", line 1496, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2022.2.4\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "D:\PyQt-Frameless-Window\examples\main_window.py", line 69, in <module>
    window = MainWindow()
  File "D:\PyQt-Frameless-Window\examples\main_window.py", line 13, in __init__
    super().__init__()
  File "D:\PyQt-Frameless-Window\qframelesswindow\__init__.py", line 36, in __init__
    super().__init__(parent)
  File "D:\PyQt-Frameless-Window\qframelesswindow\windows\__init__.py", line 41, in __init__
    self.windowEffect.addShadowEffect(self.winId())
  File "D:\PyQt-Frameless-Window\qframelesswindow\windows\window_effect.py", line 166, in addShadowEffect
    self.DwmExtendFrameIntoClientArea(hWnd, byref(margins))
ValueError: Procedure called with not enough arguments (8 bytes missing) or wrong calling convention
python-BaseException

Use QMainWindow Instead of QWidget as a parent class

The following code won't work

class Window(FramelessWindow):

    def __init__(self, parent=None):
        super().__init__(parent=parent)
        self.setMinimumSize(400, 400)
        self.te = QTextEdit(self)
        self.te.move(10, 30)
        self.te.resize(380, 380)
        self.te.setText("Hello World!")
        self.te.raise_()
        self.setCentralWidget(self.te)
        self.show()

The error is at self.setCentralWidget(self.te):

class Window(FramelessWindow):

    def __init__(self, parent=None):
        super().__init__(parent=parent)
        self.setMinimumSize(400, 400)
        self.te = QTextEdit(self)
        self.te.move(10, 30)
        self.te.resize(380, 380)
        self.te.setText("Hello World!")
        self.te.raise_()
        self.setCentralWidget(self.te) <<<-----------
        self.show()

Because FramelessWindow inherits QWidget, not QMainWindow
I changed QWidget to QMainWindow and this is the result
image
Notice the window 🗕🗗🗙 are not showing up. (Sady I STILL havent found a solution for this 😕)

关于windowEffect

您好,使用您的windowEffect解决方案时,我发现,控件只能以窗口的形式存在(效果很满意)。我想将图片作为背景有亚克力效果,有点像音乐播放器的歌手作为背景,上面可以显示歌词那种(AppleMusic)效果,我尝试了很多次,都不能将windowEffect使用到背景图片上,您有好的解决办法吗,十分感谢。

如何使用WindowChrome?

看到了一篇文章,介绍了WPF如何允许鼠标在窗口阴影处进行窗口缩放,和给窗口添加系统主题色边框
如果有这两个细节……感觉会更好一点……
那篇文章里的对比图:
图片
他里面说要用到“WindowChrome”,但是不知道他这个WindowChrome是怎么用的,请问大佬知道怎么用嘛……
希望能加入这两个细节

Adding addStretch() to layout makes the layout overlap the titlebar

Describe the bug
When using addStretch() at the end of the layout is used, the layout is pulled up, over the titlebar.

Environment

  • OS: [e.g. Windows10]
  • DPI scaling: [e.g. 125%]
  • Python: [e.g. 3.8.6 64-bit]
  • PyQt5: [e.g. 5.15.2]

To Reproduce
Steps to reproduce the behavior(you can use GIF to demonstrate :):
adding addStretch() to bottom any layout using FramelessDialog or FramelessWindow, causes the layout to overlap the titlebar
01_02_2023_19_25_086

Code

# Minimum code to reproduce the error
import sys
from PyQt5.QtWidgets import QVBoxLayout, QPushButton
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication
from qframelesswindow import FramelessDialog, StandardTitleBar


class CustomTitleBar(StandardTitleBar):
    """ Custom title bar """

    def __init__(self, parent):
        super().__init__(parent)

        # customize the style of title bar button
        self.closeBtn.setHoverColor(Qt.white)
        self.closeBtn.setHoverBackgroundColor(Qt.white)
        self.closeBtn.setPressedColor(Qt.white)
        self.closeBtn.setPressedBackgroundColor(Qt.white)
        self.closeBtn.setHoverBackgroundColor(Qt.white)
        # use qss to customize title bar button
        self.maxBtn.setStyleSheet("""
            TitleBarButton {
                qproperty-hoverColor: white;
                qproperty-hoverBackgroundColor: rgb(0, 100, 182);
                qproperty-pressedColor: white;
                qproperty-pressedBackgroundColor: rgb(54, 57, 65);
            }
        """)


class myWindow(FramelessDialog):

    def __init__(self, parent=None):
        super().__init__(parent=parent)
        myLayout = QVBoxLayout(self)
        Button = QPushButton('Resize')
        myLayout.addWidget(Button)
        self.setFixedWidth(300)
        self.setMinimumHeight(200)
        self.setMaximumHeight(400)
        myLayout.addStretch()


if __name__ == "__main__":
    app = QApplication(sys.argv)
    app.setApplicationName('myApp')
    dialog = myWindow()
    dialog.resize(200, 100)
    dialog.show()
    sys.exit(app.exec_())

Expected behavior
The titlebar should behave uniformly

Screenshots
If applicable, add screenshots to help explain your problem.

Full screen and maximized improvement

Hi, I noticed that when the window is maximized or in full screen (f11 behavior), the close button is not accessible when the mouse cursor is in the upper right corner of the screen.

I have made some changes to your code to suit my needs:

On line 118 of the init.py file in the windows folder

            self.BORDER_WIDTH = 5 
            if isMax or isFull: 
                self.BORDER_WIDTH = -win_utils.getResizeBorderThickness(msg.hWnd) - self.BORDER_WIDTH 

Also, I saw that the title bar is always dragging in full screen, the following changes in the canDrag function of the titleBar module work well for me:

def canDrag(self, pos):
        """ whether the position is draggable """
        if not self.window().isFullScreen():
            return self._isDragRegion(pos) and not self._hasButtonPressed()
        return False

I hope this will be useful to you, have a nice day! 🙂

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.