Package: pyqt-custom-titlebar-window
pyqt-custom-titlebar-windowPyQt 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 usepyqt-custom-titlebar-setter.If you want to use this in various ways than use this directly. see the example below.Table of ContentsRequirementsSetupIncluded PackagesFeatureExampleCode Sample (Menu bar only)Code Sample (Including title bar)RequirementsPyQt5 >= 5.15 - This package is usingstartSystemMove,startSystemResizewhich were both introduced in Qt 5.15.Setuppython -m pip install pyqt-custom-titlebar-windowIncluded Packagespyqt-frameless-window (v0.0.61, Legacy)- To import parent classFramelessWindowpyqt-windows-buttons-widget- To provide Windows 10 OS style min/max/close buttons with menu barpyqt-mac-buttons-widget- To provide macOS style of min/max/close buttons with menu barpyqt-top-titlebar-widget- For adding top title bar featurepyqt-svg-label- For setting icon/title to menu bar if user shows menu bar onlyFeatureIf 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 withsetWindowTitle. It also catches thewindowTitleChangedsignal 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. IfbtnWidgetis set to None, buttons' style are automatically set to your platform/OS friendly style. Basically you can givebtnWidgetto your customized buttons(pyqt-titlebar-buttons-widget). 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,macOSbutton will be positioned to right which is unorthodox.Frame's color synchronizes with theQMenuBar's background color or innerQWidget's color if inner widget is notQMainWindow.getCornerWidget()to get corner widget ofQMenuBareasilygetInnerWidget()to get inner widget easilyExampleCode Sample (Menu bar only)fromPyQt5.QtWidgetsimportQApplicationfrompyqt_custom_titlebar_windowimportCustomTitlebarWindowfrompyqt_dark_calculatorimportCalculatorif__name__=="__main__":importsysapp=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,pyqt-dark-calculatoris being used as inner widget.ResultHere's another example withpyqt-dark-notepad.As you see, existing corner widget doesn't matter.Code Sample (Including title bar)fromPyQt5.QtWidgetsimportQApplicationfrompyqt_custom_titlebar_windowimportCustomTitlebarWindowfrompyqt_dark_notepadimportDarkNotepadif__name__=="__main__":importsysapp=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