# pyqt-custom-titlebar-window
PyQt custom titlebar window(resizable, movable, minimize/maximize/close).
User can set modernized and customized frame surrounding the widget you made.
You can set the title bar separately or set the menu bar as title bar.
Basic buttons like min/max/close are automatically set by user's OS.
You can set your customized buttons(e.g. min/max/close).
You can drag title bar or menu bar on widget to move the window, double-click it to show maximize/normal.
This also makes the application's font look much better by setting the font family to 'Arial'(which looks modern and commonly used), antialiasing the font.
The range of font size is set to 9~12 which is not too big, not too small.
If you want to set custom titlebar easily than use <a href="https://github.com/yjg30737/pyqt-custom-titlebar-setter.git">pyqt-custom-titlebar-setter</a>.
If you want to use this in various ways than use this directly. see the example below.
## Table of Contents
* [Requirements](#requirements)
* [Setup](#setup)
* [Included Packages](#included-packages)
* [Feature](#feature)
* [Example](#example)
* [Code Sample (Menu bar only)](#code-sample-menu-bar-only)
* [Code Sample (Including title bar)](#code-sample-including-title-bar)
## Requirements
PyQt5 >= 5.15 - This package is using <a href="https://doc.qt.io/qt-5/qwindow.html#startSystemMove">startSystemMove</a>, <a href="https://doc.qt.io/qt-5/qwindow.html#startSystemResize">startSystemResize</a> which were both introduced in Qt 5.15.
## Setup
`python -m pip install pyqt-custom-titlebar-window`
## Included Packages
* <a href="https://pypi.org/project/pyqt-frameless-window/0.0.61/">pyqt-frameless-window (v0.0.61, Legacy)</a> - To import parent class `FramelessWindow`
## Feature
* If you drag the frame, window will be resized.
* If you drag the title bar(menu bar if there is no title bar) of inner widget, window will be moved.
* If you double-click the menu bar, window will be maximized/normalized.
* Set the window title by itself if you set your inner widget's title with `setWindowTitle`. It also catches the `windowTitleChanged` signal of your inner widget.
* Support close event(QCloseEvent) of inner widget.
* Support full screen feature. When you turn the full screen feature on, top title bar will disappear, become unable to resize and move. Turn it off to make title bar reappear and make it enable to move and resize.
* Set minimum size based on inner widget's size by default.
* `CustomTitlebarWindow(CustomizedWidgetByUser())` - Constructor.
* `setTopTitleBar(self, title: str = '', icon_filename: str = '', font: QFont = QFont('Arial', 14), align=Qt.AlignCenter, bottom_separator=False)` to set title bar on the top of the window.
* `setButtons(btnWidget=None, align=Qt.AlignRight)` to add buttons(e.g. min/max/close) on the top right/left corner of title/menu bar. If `btnWidget` is set to None, buttons' style are automatically set to your platform/OS friendly style. Basically you can give `btnWidget` to your customized buttons(<a href= "https://github.com/yjg30737/pyqt-titlebar-buttons-widget.git">pyqt-titlebar-buttons-widget</a>). I will explain it better. Sorry for weak explanation.
* `setButtonHint(hint)` to set hints of buttons. There are three options available(close, min/close, min/max/close). Default value is min/max/close.
* `setMenuAsTitleBar(self, title: str = '', icon_filename: str = '', font: QFont = QFont('Arial', 9))` to set the icon and title not only on the left side of menu bar, but also set it as window icon and title.
Note: using this function, `macOS` button will be positioned to right which is unorthodox.
* Frame's color synchronizes with the `QMenuBar`'s background color or inner `QWidget`'s color if inner widget is not `QMainWindow`.
* `getCornerWidget()` to get corner widget of `QMenuBar` easily
* `getInnerWidget()` to get inner widget easily
## Example
### Code Sample (Menu bar only)
```python
from PyQt5.QtWidgets import QApplication
from pyqt_custom_titlebar_window import CustomTitlebarWindow
from pyqt_dark_calculator import Calculator
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
customTitlebarWindow = CustomTitlebarWindow(Calculator())
customTitlebarWindow.setMenuAsTitleBar(icon_filename='calculator.svg')
# customTitlebarWindow.setButtonHint(hint=['close'])
customTitlebarWindow.setButtons()
customTitlebarWindow.show()
app.exec_()
```
In the code sample, <a href="https://github.com/yjg30737/pyqt-dark-calculator.git">pyqt-dark-calculator</a> is being used as inner widget.
### Result

Here's another example with <a href="https://github.com/yjg30737/pyqt-dark-notepad.git">pyqt-dark-notepad</a>.

As you see, existing corner widget doesn't matter.
### Code Sample (Including title bar)
```python
from PyQt5.QtWidgets import QApplication
from pyqt_custom_titlebar_window import CustomTitlebarWindow
from pyqt_dark_notepad import DarkNotepad
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
window = DarkNotepad()
customTitlebarWindow = CustomTitlebarWindow(window)
customTitlebarWindow.setTopTitleBar(icon_filename='dark-notepad.svg')
# customTitlebarWindow.setButtonHint(['close'])
customTitlebarWindow.setButtons()
customTitlebarWindow.show()
app.exec_()
```
### Result

Raw data
{
"_id": null,
"home_page": "https://github.com/yjg30737/pyqt-custom-titlebar-window.git",
"name": "pyqt-custom-titlebar-window",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "Jung Gyu Yoon",
"author_email": "yjg30737@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/6d/ca/7dc1a5d549bbf54807325c7085319f4dd600031346b13a653ce5f31575d2/pyqt_custom_titlebar_window-0.1.0.tar.gz",
"platform": null,
"description": "\r\n# pyqt-custom-titlebar-window\r\n\r\n\r\n\r\nPyQt custom titlebar window(resizable, movable, minimize/maximize/close). \r\n\r\n\r\n\r\nUser can set modernized and customized frame surrounding the widget you made.\r\n\r\n\r\n\r\nYou can set the title bar separately or set the menu bar as title bar.\r\n\r\n\r\n\r\nBasic buttons like min/max/close are automatically set by user's OS.\r\n\r\n\r\n\r\nYou can set your customized buttons(e.g. min/max/close).\r\n\r\n\r\n\r\nYou can drag title bar or menu bar on widget to move the window, double-click it to show maximize/normal.\r\n\r\n\r\n\r\nThis also makes the application's font look much better by setting the font family to 'Arial'(which looks modern and commonly used), antialiasing the font.\r\n\r\n\r\n\r\nThe range of font size is set to 9~12 which is not too big, not too small.\r\n\r\n\r\n\r\nIf you want to set custom titlebar easily than use <a href=\"https://github.com/yjg30737/pyqt-custom-titlebar-setter.git\">pyqt-custom-titlebar-setter</a>.\r\n\r\n\r\n\r\nIf you want to use this in various ways than use this directly. see the example below.\r\n\r\n\r\n\r\n## Table of Contents\r\n\r\n* [Requirements](#requirements)\r\n\r\n* [Setup](#setup)\r\n\r\n* [Included Packages](#included-packages)\r\n\r\n* [Feature](#feature)\r\n\r\n* [Example](#example)\r\n\r\n * [Code Sample (Menu bar only)](#code-sample-menu-bar-only)\r\n\r\n * [Code Sample (Including title bar)](#code-sample-including-title-bar)\r\n\r\n\r\n\r\n## Requirements\r\n\r\nPyQt5 >= 5.15 - This package is using <a href=\"https://doc.qt.io/qt-5/qwindow.html#startSystemMove\">startSystemMove</a>, <a href=\"https://doc.qt.io/qt-5/qwindow.html#startSystemResize\">startSystemResize</a> which were both introduced in Qt 5.15.\r\n\r\n\r\n\r\n## Setup\r\n\r\n`python -m pip install pyqt-custom-titlebar-window`\r\n\r\n\r\n\r\n## Included Packages\r\n\r\n* <a href=\"https://pypi.org/project/pyqt-frameless-window/0.0.61/\">pyqt-frameless-window (v0.0.61, Legacy)</a> - To import parent class `FramelessWindow`\r\n\r\n\r\n\r\n## Feature\r\n\r\n* If you drag the frame, window will be resized.\r\n\r\n* If you drag the title bar(menu bar if there is no title bar) of inner widget, window will be moved.\r\n\r\n* If you double-click the menu bar, window will be maximized/normalized.\r\n\r\n* Set the window title by itself if you set your inner widget's title with `setWindowTitle`. It also catches the `windowTitleChanged` signal of your inner widget.\r\n\r\n* Support close event(QCloseEvent) of inner widget.\r\n\r\n* Support full screen feature. When you turn the full screen feature on, top title bar will disappear, become unable to resize and move. Turn it off to make title bar reappear and make it enable to move and resize.\r\n\r\n* Set minimum size based on inner widget's size by default.\r\n\r\n* `CustomTitlebarWindow(CustomizedWidgetByUser())` - Constructor.\r\n\r\n* `setTopTitleBar(self, title: str = '', icon_filename: str = '', font: QFont = QFont('Arial', 14), align=Qt.AlignCenter, bottom_separator=False)` to set title bar on the top of the window.\r\n\r\n* `setButtons(btnWidget=None, align=Qt.AlignRight)` to add buttons(e.g. min/max/close) on the top right/left corner of title/menu bar. If `btnWidget` is set to None, buttons' style are automatically set to your platform/OS friendly style. Basically you can give `btnWidget` to your customized buttons(<a href= \"https://github.com/yjg30737/pyqt-titlebar-buttons-widget.git\">pyqt-titlebar-buttons-widget</a>). I will explain it better. Sorry for weak explanation.\r\n\r\n* `setButtonHint(hint)` to set hints of buttons. There are three options available(close, min/close, min/max/close). Default value is min/max/close.\r\n\r\n* `setMenuAsTitleBar(self, title: str = '', icon_filename: str = '', font: QFont = QFont('Arial', 9))` to set the icon and title not only on the left side of menu bar, but also set it as window icon and title.\r\n\r\n\r\n\r\nNote: using this function, `macOS` button will be positioned to right which is unorthodox.\r\n\r\n* Frame's color synchronizes with the `QMenuBar`'s background color or inner `QWidget`'s color if inner widget is not `QMainWindow`.\r\n\r\n* `getCornerWidget()` to get corner widget of `QMenuBar` easily\r\n\r\n* `getInnerWidget()` to get inner widget easily\r\n\r\n\r\n\r\n## Example\r\n\r\n### Code Sample (Menu bar only)\r\n\r\n\r\n\r\n```python\r\n\r\nfrom PyQt5.QtWidgets import QApplication\r\n\r\nfrom pyqt_custom_titlebar_window import CustomTitlebarWindow\r\n\r\nfrom pyqt_dark_calculator import Calculator\r\n\r\n\r\n\r\nif __name__ == \"__main__\":\r\n\r\n import sys\r\n\r\n\r\n\r\n app = QApplication(sys.argv)\r\n\r\n customTitlebarWindow = CustomTitlebarWindow(Calculator())\r\n\r\n customTitlebarWindow.setMenuAsTitleBar(icon_filename='calculator.svg')\r\n\r\n # customTitlebarWindow.setButtonHint(hint=['close'])\r\n\r\n customTitlebarWindow.setButtons()\r\n\r\n customTitlebarWindow.show()\r\n\r\n app.exec_()\r\n\r\n```\r\n\r\n\r\n\r\nIn the code sample, <a href=\"https://github.com/yjg30737/pyqt-dark-calculator.git\">pyqt-dark-calculator</a> is being used as inner widget. \r\n\r\n\r\n\r\n### Result\r\n\r\n \r\n\r\n\r\n\r\n\r\n\r\nHere's another example with <a href=\"https://github.com/yjg30737/pyqt-dark-notepad.git\">pyqt-dark-notepad</a>.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\nAs you see, existing corner widget doesn't matter.\r\n\r\n\r\n\r\n### Code Sample (Including title bar)\r\n\r\n\r\n\r\n```python\r\n\r\nfrom PyQt5.QtWidgets import QApplication\r\n\r\nfrom pyqt_custom_titlebar_window import CustomTitlebarWindow\r\n\r\nfrom pyqt_dark_notepad import DarkNotepad\r\n\r\n\r\n\r\nif __name__ == \"__main__\":\r\n\r\n import sys\r\n\r\n\r\n\r\n app = QApplication(sys.argv)\r\n\r\n window = DarkNotepad()\r\n\r\n customTitlebarWindow = CustomTitlebarWindow(window)\r\n\r\n customTitlebarWindow.setTopTitleBar(icon_filename='dark-notepad.svg')\r\n\r\n # customTitlebarWindow.setButtonHint(['close'])\r\n\r\n customTitlebarWindow.setButtons()\r\n\r\n customTitlebarWindow.show()\r\n\r\n app.exec_()\r\n\r\n```\r\n\r\n\r\n\r\n### Result\r\n\r\n\r\n\r\n\r\n\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "PyQt custom titlebar window (resizable, movable, minimize/maximize/close, etc.)",
"version": "0.1.0",
"project_urls": {
"Homepage": "https://github.com/yjg30737/pyqt-custom-titlebar-window.git"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "452aa580e6700d5d2cd6766bbace46642e3c24823edbafab42a6a2e0a8fe6fb6",
"md5": "2e307fb67a5829e70ee32efe2f3a9da3",
"sha256": "712df532c5c3dbdf069396f8cac6c505780d213fc28985922c9a4eb6e5cf39b5"
},
"downloads": -1,
"filename": "pyqt_custom_titlebar_window-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2e307fb67a5829e70ee32efe2f3a9da3",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 21067,
"upload_time": "2024-09-05T13:31:24",
"upload_time_iso_8601": "2024-09-05T13:31:24.875781Z",
"url": "https://files.pythonhosted.org/packages/45/2a/a580e6700d5d2cd6766bbace46642e3c24823edbafab42a6a2e0a8fe6fb6/pyqt_custom_titlebar_window-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6dca7dc1a5d549bbf54807325c7085319f4dd600031346b13a653ce5f31575d2",
"md5": "f320c242d8fe078de13c488cb9ba299b",
"sha256": "275258ba4c849060b5c916037715e41bf9aebee85fc1908d95d79502820156bc"
},
"downloads": -1,
"filename": "pyqt_custom_titlebar_window-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "f320c242d8fe078de13c488cb9ba299b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 16759,
"upload_time": "2024-09-05T13:31:26",
"upload_time_iso_8601": "2024-09-05T13:31:26.480123Z",
"url": "https://files.pythonhosted.org/packages/6d/ca/7dc1a5d549bbf54807325c7085319f4dd600031346b13a653ce5f31575d2/pyqt_custom_titlebar_window-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-05 13:31:26",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "yjg30737",
"github_project": "pyqt-custom-titlebar-window",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "pyqt-custom-titlebar-window"
}