PyQt custom titlebar setter (movable/resizable, etc.)
Project description
pyqt-custom-titlebar-setter
PyQt custom titlebar setter.
This is movable/resizable.
When resizing, cursor shape will be automatically changed depends on the direction of edge where the cursor is hovering over.
For example, you want to resize the window horizontally, cursor shape will be changed like "⇿".
You can set the title, and icon which should be SVG type.
You can set the min/max/close buttons separately.
This package supports full-screen. If your app has full screen, this custom titlebar can perfectly deal with it. So there's no need to do another chore for full-screen.
Requirements
- PyQt5 >= 5.15 - This package is using startSystemMove, startSystemResize which were both introduced in Qt 5.15.
Setup
python -m pip install pyqt-custom-titlebar-setter
Included Packages
Usage
CustomTitlebarSetter.getCustomTitleBarWindow(main_window: QWidget, icon_filename: str = '', style='windows', hint=['min', 'max', 'close']) -> CustomTitlebarWindow
-main_window
is your widget.icon_filename
should be svg file.
Example
1. Very basic text editor
Code Sample
from PyQt5.QtWidgets import QApplication, QWidget, QGridLayout, QTextEdit
from pyqt_custom_titlebar_setter import CustomTitlebarSetter
class TextEditor(QWidget):
def __init__(self):
super().__init__()
self.__initUi()
def __initUi(self):
self.setWindowTitle('Text Editor')
lay = QGridLayout()
lay.addWidget(QTextEdit())
self.setLayout(lay)
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
widget = TextEditor()
window = CustomTitlebarSetter.getCustomTitleBarWindow(main_window=widget, icon_filename='dark-notepad.svg')
window.show()
sys.exit(app.exec_())
Result
How about dark theme?
If you want to set dark theme, install the pyqt-style-setter, then write code like this.
...
widget = TextEditor()
StyleSetter.setWindowStyle(widget, theme='dark') # write it at this spot, BEFORE calling getCustomTitleBarWindow.
window = CustomTitlebarSetter.getCustomTitleBarWindow(main_window=widget, icon_filename='dark-notepad.svg')
...
By the way, you can clearly see the title label and min/max/close button color changed based on background's color automatically.
Now let's apply this to some of the applications.
※ From now on, examples below are using dark theme. Of course, you don't have to use this.
2. pyqt-dark-notepad - DarkNotepadApp
class
Code Sample
from PyQt5.QtWidgets import QApplication
from pyqt_dark_gray_theme.darkGrayTheme import *
from pyqt_dark_notepad import DarkNotepad
from pyqt_style_setter import StyleSetter
from pyqt_custom_titlebar_setter import CustomTitlebarSetter
class DarkNotepadApp(QApplication):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
mainWindow = DarkNotepad()
StyleSetter.setWindowStyle(mainWindow, theme='dark') # you don't need this. this is just for adding style.
self.__titleBarWindow = CustomTitlebarSetter.getCustomTitleBarWindow(mainWindow,
icon_filename='ico/dark-notepad.svg')
self.__titleBarWindow.show()
Result
3. pyqt-dark-calculator - CalculatorApp
class
Code Sample
from PyQt5.QtWidgets import QApplication, QAbstractButton
from pyqt_dark_gray_theme.darkGrayTheme import *
from pyqt_dark_calculator.calculator import Calculator
from pyqt_style_setter import StyleSetter
from pyqt_custom_titlebar_setter import CustomTitlebarSetter
class CalculatorApp(QApplication):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
mainWindow = Calculator()
StyleSetter.setWindowStyle(mainWindow, theme='dark', exclude_type_lst=[QAbstractButton])
self.__titleBarWindow = CustomTitlebarSetter.getCustomTitleBarWindow(mainWindow,
icon_filename='ico/calculator.svg')
self.__titleBarWindow.show()
Result
4. pyqt-comic-viewer - ComicBookViewerApp
class
Code Sample
from PyQt5.QtWidgets import QApplication
from pyqt_dark_gray_theme.darkGrayTheme import *
from pyqt_comic_viewer.comicBookViewer import ComicBookViewer
from pyqt_style_setter import StyleSetter
from pyqt_custom_titlebar_setter import CustomTitlebarSetter
class ComicBookViewerApp(QApplication):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
mainWindow = ComicBookViewer()
StyleSetter.setWindowStyle(mainWindow, theme='dark')
self.__titleBarWindow = CustomTitlebarSetter.getCustomTitleBarWindow(mainWindow, icon_filename='ico/book.svg')
self.__titleBarWindow.show()
Result
Project details
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-custom-titlebar-setter-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72ab70c253d2b256899827da44af3b5437881230cda1326d3f59beecd16b3318 |
|
MD5 | 0399217ec2baef3861339d44844d220a |
|
BLAKE2b-256 | 822b426629ba870ba14bf9f189d2fcdab1a585041ff45336fd16ddda1089335c |
Hashes for pyqt_custom_titlebar_setter-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a16e267fe36852a39a86971234eebe2f2c09ead1f5a26dc26ebe217f8488eec5 |
|
MD5 | 18b3d37b5712d8e89af071d0edcf5514 |
|
BLAKE2b-256 | 9328e7b40f48d30589b93c9434ddbe052fb1c833cfa063562930d5749314d92c |