PyQt(+PySide) Frameless Window
Project description
pyqt-frameless-window
PyQt(+PySide) Frameless Window
Feature
-
Frameless
-
Using Windows API (for Windows OS effect - shadow, rounded, animation, etc.)
-
Supports PyQt5, PySide2, PySide6
-
User can make it enable/disable to move, resize
-
Supports QWidget, QDialog, QMainWindow
-
Support title bar (very basic-looking buttons in v0.0.73)
Note
I have no macOS and Linux to test so i couldn't manage to support them as well.
Maybe i can use the virtual machine or something to do it.
I strongly recommend legacy version if your OS is not Windows.
Requirements
-
PyQt5 - Use QtWinExtras to use Windows API feature in Qt (Qt6 doesn't support QtWinExtras anymore, sadly)
-
qtpy - To use PyQt5, PySide2(Qt version 5), PySide6(Qt version 6)
-
pywin32 - For using Windows API feature
Setup
New version (using Windows API)
python -m pip install pyqt-frameless-window
(For new version) Recommend to clone rather than installing with pip. Still working!
Legacy version
python -m pip install pyqt-frameless-window==0.0.61
Class Overview
-
FramelessWidget - frameless QWidget
-
FramelessDialog - frameless QDialog
-
FramelessMainWindow - frameless QMainWindow
Method Overview
For Windows & The Others
-
setResizable(f: bool)
- Set resizable/none-resizable -
isResizable() -> bool
- Check if window is resizable or not -
setPressToMove(f: bool)
- Set movable/non-movable -
isPressToMove() -> bool
- Check if window is movable or not
The Others
-
setMargin(margin: int)
- Set the margin which allows cursor to change its shape to resize form -
setFrameColor(color)
- Set the background color. color argument type can be both QColor and str. -
getFrameColor
-> QColor - Get the background color. -
setVerticalExpandedEnabled(f: bool)
- Make it able to expand vertically when double-clicking the top or bottom edges of the window.
Example
PyQt5 Code Sample
import sys
# IMPORTANT!!!!!!!!!
# to prevent the "QWidget: Must construct a QApplication before a QWidget" error, you should put the code below
from PyQt5.QtCore import Qt
from pyqt_frameless_window import FramelessDialog
from PyQt5.QtWidgets import QApplication, QVBoxLayout, \
QTextBrowser
from pyqt_frameless_window.windows.titleBar import TitleBar
class Window(FramelessDialog):
def __init__(self):
super().__init__()
self.__initUi()
def __initUi(self):
self.setWindowTitle('Basic Window Example')
titleBar = TitleBar(self) # for showing title bar as one of the widget. If you don't want the title bar, don't include this.
lay = QVBoxLayout()
lay.addWidget(titleBar)
lay.addWidget(QTextBrowser())
self.setLayout(lay)
if __name__ == "__main__":
app = QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec())
PySide6 Code Sample
import sys
# IMPORTANT!!!!!!!!!
# to prevent the "QWidget: Must construct a QApplication before a QWidget" error, you should put the code below
from PySide6.QtCore import Qt
from pyqt_frameless_window import FramelessDialog
from PySide6.QtWidgets import QApplication, QVBoxLayout, \
QTextBrowser
from pyqt_frameless_window.windows.titleBar import TitleBar
class Window(FramelessDialog):
def __init__(self):
super().__init__()
self.__initUi()
def __initUi(self):
self.setWindowTitle('Basic Window Example')
titleBar = TitleBar(self) # for showing title bar as one of the widget. If you don't want the title bar, don't include this.
lay = QVBoxLayout()
lay.addWidget(titleBar)
lay.addWidget(QTextBrowser())
self.setLayout(lay)
if __name__ == "__main__":
app = QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec())
Result
Try to move and resize it.
Note: I tested in Windows 11, PySide6.
See Also
Legacy version(0.0.61) README - not using Windows API, qtpy, just good old PyQt5. Enable to resize and move as always. (clunky in Windows though)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pyqt-frameless-window-0.0.73.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 434bba9dddb7202a9a3ffecd4d1459112bc74d02fc4d27da103ba7f17bcad1c2 |
|
MD5 | dccdfd243ca85f6d25a2392290e77e27 |
|
BLAKE2b-256 | 7271f373d75a3940f56e1b2e593baef12239549089fb3dc20a9c0d136675f89f |
Hashes for pyqt_frameless_window-0.0.73-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1e9b87146be05d0f86223fd7e1f3f2126c59b1f94d6ab0d47ffa80be39ec6f7 |
|
MD5 | d0bb29d6b9cfb22ac6e068eae56708a6 |
|
BLAKE2b-256 | 434b656788b5f3eb53dbee5ec57005db906e9a3df43bd21336a4b845d50aeaa5 |