How to make the windows icon bigger than 16×16?

I am having a problem not being able to make the window icon bigger than 16×16. It is awfully too small.

import os
import sys
import win32gui
import win32con
from PySide6.QtCore import Qt
from PySide6.QtGui import QIcon, QPixmap
from PySide6.QtWidgets import (
    QApplication, QMainWindow, QWidget, QVBoxLayout, QLabel, QSpacerItem, QSizePolicy, QHBoxLayout, QPushButton, QSlider
)


class Shax0(QMainWindow):
    """Shax0 main application with PyWin32 native title bar"""

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

        # Define the base path for resources
        self.base_path = os.path.join(os.getcwd(), "playback")

        # Central widget
        central_widget = QWidget()
        self.setCentralWidget(central_widget)

        # Main vertical layout
        self.vBoxLayout = QVBoxLayout(central_widget)

        # Create cover art label with updated style
        self.coverArtLabel = QLabel(self)
        self.coverArtLabel.setText("shax0")
        self.coverArtLabel.setStyleSheet("""
            background-color: #ECEFF4;  /* Slightly lighter gray color for cover art */
            border-radius: 15px;  /* Rounded corners for cover art */
            color: black;  /* Black text color */
            font-size: 24px;  /* Larger font size */
            font-family: 'Mononoki';  /* Mononoki font */
            font-weight: bold;
        """)
        self.coverArtLabel.setAlignment(Qt.AlignCenter)
        self.coverArtLabel.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)  # Make cover art expand

        # Media control bar with track navigation
        self.mediaControlBar = self.createMediaControlBar()

        # Add spacers and widgets
        self.vBoxLayout.addSpacerItem(QSpacerItem(0, 10, QSizePolicy.Minimum, QSizePolicy.Expanding))
        self.vBoxLayout.addWidget(self.coverArtLabel, alignment=Qt.AlignCenter)
        self.vBoxLayout.addSpacerItem(QSpacerItem(0, 10, QSizePolicy.Minimum, QSizePolicy.Expanding))
        self.vBoxLayout.addLayout(self.mediaControlBar)

        # Set up window properties
        self.setWindowTitle("shax0")
        self.setWindowIcon(QIcon(os.path.join(self.base_path, "gt.png")))

        # Set initial window size and center
        self.resize(400, 300)  # Adjusted window size for compact layout
        self.centerWindow()

        # Apply native Windows title bar
        self.enableNativeTitleBar()

        # Apply a translucent effect (for mini player)
        self.setWindowOpacity(0.9)  # Make the window slightly translucent
        self.setStyleSheet("""
            QWidget {
                background-color: #D8DEE9;  /* Slightly gray color for the window background */
                color: #2E3440;  /* Darker text color for readability */
                border-radius: 15px;  /* Rounded corners for the entire window */
                padding: 10px;
            }
            QLabel {
                color: black;  /* Black text for cover art */
            }
            QPushButton {
                background-color: transparent;  /* Transparent background for buttons */
                color: #4C566A;  /* Darker text color for buttons */
                border: none;  /* Remove button border */
                padding: 10px;
                border-radius: 5px;
            }
            QPushButton:hover {
                background-color: #A3BE8C;  /* Lighter Nord color for hover state */
            }
            QPushButton:pressed {
                background-color: #88C0D0;  /* Slightly darker color for pressed state */
            }
            QSlider {
                background-color: #E5E9F0; /* Background of the slider */
                height: 6px;
                border: none; /* Remove border */
                border-radius: 3px; /* Rounded corners */
            }
            QSlider::groove:horizontal {
                background-color: #D8DEE9;
                height: 6px;
                border-radius: 3px;
            }
            QSlider::handle:horizontal {
                background-color: #4C566A; /* Dark handle */
                border-radius: 6px;
                width: 14px;
                height: 14px;
            }
        """)

        # State for the shuffle button (0: Shuffle, 1: Repeat, 2: Repeat One)
        self.current_state = 0

    def enableNativeTitleBar(self):
        """Enable the native Windows title bar using PyWin32."""
        hwnd = self.winId().__int__()
        style = win32gui.GetWindowLong(hwnd, win32con.GWL_STYLE)
        style = style | win32con.WS_CAPTION | win32con.WS_THICKFRAME
        win32gui.SetWindowLong(hwnd, win32con.GWL_STYLE, style)
        win32gui.SetWindowPos(
            hwnd, None, 0, 0, 0, 0,
            win32con.SWP_NOMOVE | win32con.SWP_NOSIZE | win32con.SWP_NOZORDER | win32con.SWP_FRAMECHANGED
        )

    def createMediaControlBar(self):
        """Create a vertical layout for media controls with icons and track navigation."""
        mediaControlBar = QVBoxLayout()  # Vertical layout for two rows

        # First row: Track Navigation (progress bar, no time numbers)
        trackNavigationLayout = QHBoxLayout()  # Horizontal layout for progress bar only
        self.progressBar = QSlider(Qt.Horizontal)
        self.progressBar.setRange(0, 100)
        self.progressBar.setValue(0)

        trackNavigationLayout.addWidget(self.progressBar)

        # Second row: Buttons (play, rewind, stop, forward, shuffle, repeat, wave, terminal)
        buttonLayout = QHBoxLayout()

        buttons = [
            ("play.png", "Play"),
            ("rwd.png", "Rewind"),
            ("stop.png", "Stop"),
            ("fwd.png", "Forward"),
            ("shuffle.png", "Shuffle/Repeat/Repeat One"),
            ("wave.png", "Wave"),
            ("terminal.png", "Terminal")
        ]

        for icon_name, tooltip in buttons:
            button = self.createIconButton(icon_name, tooltip)
            if button:  # Only add the button if the icon exists
                buttonLayout.addWidget(button)

        # Add both rows to the media control bar
        mediaControlBar.addLayout(trackNavigationLayout)
        mediaControlBar.addLayout(buttonLayout)

        return mediaControlBar

    def createIconButton(self, icon_name, tooltip):
        """Create a QPushButton with an icon."""
        icon_path = os.path.join(self.base_path, icon_name)
        if os.path.exists(icon_path):
            button = QPushButton()
            button.setIcon(QIcon(icon_path))
            button.setToolTip(tooltip)
            button.setStyleSheet("font-size: 14px; padding: 5px;")
            # Connect the button to a slot that cycles the state for shuffle button
            if icon_name == "shuffle.png":
                button.clicked.connect(self.cycleState)
            return button
        else:
            print(f"Icon not found at: {icon_path}")  # Debug log
            # Optionally, set a default or error icon
            button = QPushButton(tooltip)
            button.setStyleSheet("font-size: 14px; color: red; padding: 5px;")
            return button

    def cycleState(self):
        """Cycle through Shuffle, Repeat, and Repeat One."""
        # Cycle state: 0 -> Shuffle, 1 -> Repeat, 2 -> Repeat One
        self.current_state = (self.current_state + 1) % 3

        if self.current_state == 0:  # Shuffle
            self.updateButtonState("shuffle.png", "Shuffle")
        elif self.current_state == 1:  # Repeat
            self.updateButtonState("repeat.png", "Repeat")
        elif self.current_state == 2:  # Repeat One
            self.updateButtonState("r1.png", "Repeat One")

    def updateButtonState(self, icon_name, tooltip):
        """Update button icon and tooltip."""
        button = self.sender()  # Get the button that was clicked
        icon_path = os.path.join(self.base_path, icon_name)
        if os.path.exists(icon_path):
            button.setIcon(QIcon(icon_path))
            button.setToolTip(tooltip)

    def centerWindow(self):
        """Center the window on the screen."""
        screen = self.screen().geometry()
        size = self.geometry()
        self.move(
            (screen.width() - size.width()) // 2,
            (screen.height() - size.height()) // 2
        )


if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = Shax0()
    window.show()
    sys.exit(app.exec())

Using pywin32 and pyside6 to make my own titlebar without qfluentwidgets.

I have tried custom titlebars but it didn’t work and the customs close buttons looks fake, so I’m using pywin32 for the windows style ones.

Please help. It’s 16×16 and the icon in the titlebar is too small. How to make it bigger without breaking the titlebar?

New contributor

garaw-wx is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

5

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

How to make the windows icon bigger than 16×16?

I am having a problem not being able to make the window icon bigger than 16×16. It is awfully too small.

import os
import sys
import win32gui
import win32con
from PySide6.QtCore import Qt
from PySide6.QtGui import QIcon, QPixmap
from PySide6.QtWidgets import (
    QApplication, QMainWindow, QWidget, QVBoxLayout, QLabel, QSpacerItem, QSizePolicy, QHBoxLayout, QPushButton, QSlider
)


class Shax0(QMainWindow):
    """Shax0 main application with PyWin32 native title bar"""

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

        # Define the base path for resources
        self.base_path = os.path.join(os.getcwd(), "playback")

        # Central widget
        central_widget = QWidget()
        self.setCentralWidget(central_widget)

        # Main vertical layout
        self.vBoxLayout = QVBoxLayout(central_widget)

        # Create cover art label with updated style
        self.coverArtLabel = QLabel(self)
        self.coverArtLabel.setText("shax0")
        self.coverArtLabel.setStyleSheet("""
            background-color: #ECEFF4;  /* Slightly lighter gray color for cover art */
            border-radius: 15px;  /* Rounded corners for cover art */
            color: black;  /* Black text color */
            font-size: 24px;  /* Larger font size */
            font-family: 'Mononoki';  /* Mononoki font */
            font-weight: bold;
        """)
        self.coverArtLabel.setAlignment(Qt.AlignCenter)
        self.coverArtLabel.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)  # Make cover art expand

        # Media control bar with track navigation
        self.mediaControlBar = self.createMediaControlBar()

        # Add spacers and widgets
        self.vBoxLayout.addSpacerItem(QSpacerItem(0, 10, QSizePolicy.Minimum, QSizePolicy.Expanding))
        self.vBoxLayout.addWidget(self.coverArtLabel, alignment=Qt.AlignCenter)
        self.vBoxLayout.addSpacerItem(QSpacerItem(0, 10, QSizePolicy.Minimum, QSizePolicy.Expanding))
        self.vBoxLayout.addLayout(self.mediaControlBar)

        # Set up window properties
        self.setWindowTitle("shax0")
        self.setWindowIcon(QIcon(os.path.join(self.base_path, "gt.png")))

        # Set initial window size and center
        self.resize(400, 300)  # Adjusted window size for compact layout
        self.centerWindow()

        # Apply native Windows title bar
        self.enableNativeTitleBar()

        # Apply a translucent effect (for mini player)
        self.setWindowOpacity(0.9)  # Make the window slightly translucent
        self.setStyleSheet("""
            QWidget {
                background-color: #D8DEE9;  /* Slightly gray color for the window background */
                color: #2E3440;  /* Darker text color for readability */
                border-radius: 15px;  /* Rounded corners for the entire window */
                padding: 10px;
            }
            QLabel {
                color: black;  /* Black text for cover art */
            }
            QPushButton {
                background-color: transparent;  /* Transparent background for buttons */
                color: #4C566A;  /* Darker text color for buttons */
                border: none;  /* Remove button border */
                padding: 10px;
                border-radius: 5px;
            }
            QPushButton:hover {
                background-color: #A3BE8C;  /* Lighter Nord color for hover state */
            }
            QPushButton:pressed {
                background-color: #88C0D0;  /* Slightly darker color for pressed state */
            }
            QSlider {
                background-color: #E5E9F0; /* Background of the slider */
                height: 6px;
                border: none; /* Remove border */
                border-radius: 3px; /* Rounded corners */
            }
            QSlider::groove:horizontal {
                background-color: #D8DEE9;
                height: 6px;
                border-radius: 3px;
            }
            QSlider::handle:horizontal {
                background-color: #4C566A; /* Dark handle */
                border-radius: 6px;
                width: 14px;
                height: 14px;
            }
        """)

        # State for the shuffle button (0: Shuffle, 1: Repeat, 2: Repeat One)
        self.current_state = 0

    def enableNativeTitleBar(self):
        """Enable the native Windows title bar using PyWin32."""
        hwnd = self.winId().__int__()
        style = win32gui.GetWindowLong(hwnd, win32con.GWL_STYLE)
        style = style | win32con.WS_CAPTION | win32con.WS_THICKFRAME
        win32gui.SetWindowLong(hwnd, win32con.GWL_STYLE, style)
        win32gui.SetWindowPos(
            hwnd, None, 0, 0, 0, 0,
            win32con.SWP_NOMOVE | win32con.SWP_NOSIZE | win32con.SWP_NOZORDER | win32con.SWP_FRAMECHANGED
        )

    def createMediaControlBar(self):
        """Create a vertical layout for media controls with icons and track navigation."""
        mediaControlBar = QVBoxLayout()  # Vertical layout for two rows

        # First row: Track Navigation (progress bar, no time numbers)
        trackNavigationLayout = QHBoxLayout()  # Horizontal layout for progress bar only
        self.progressBar = QSlider(Qt.Horizontal)
        self.progressBar.setRange(0, 100)
        self.progressBar.setValue(0)

        trackNavigationLayout.addWidget(self.progressBar)

        # Second row: Buttons (play, rewind, stop, forward, shuffle, repeat, wave, terminal)
        buttonLayout = QHBoxLayout()

        buttons = [
            ("play.png", "Play"),
            ("rwd.png", "Rewind"),
            ("stop.png", "Stop"),
            ("fwd.png", "Forward"),
            ("shuffle.png", "Shuffle/Repeat/Repeat One"),
            ("wave.png", "Wave"),
            ("terminal.png", "Terminal")
        ]

        for icon_name, tooltip in buttons:
            button = self.createIconButton(icon_name, tooltip)
            if button:  # Only add the button if the icon exists
                buttonLayout.addWidget(button)

        # Add both rows to the media control bar
        mediaControlBar.addLayout(trackNavigationLayout)
        mediaControlBar.addLayout(buttonLayout)

        return mediaControlBar

    def createIconButton(self, icon_name, tooltip):
        """Create a QPushButton with an icon."""
        icon_path = os.path.join(self.base_path, icon_name)
        if os.path.exists(icon_path):
            button = QPushButton()
            button.setIcon(QIcon(icon_path))
            button.setToolTip(tooltip)
            button.setStyleSheet("font-size: 14px; padding: 5px;")
            # Connect the button to a slot that cycles the state for shuffle button
            if icon_name == "shuffle.png":
                button.clicked.connect(self.cycleState)
            return button
        else:
            print(f"Icon not found at: {icon_path}")  # Debug log
            # Optionally, set a default or error icon
            button = QPushButton(tooltip)
            button.setStyleSheet("font-size: 14px; color: red; padding: 5px;")
            return button

    def cycleState(self):
        """Cycle through Shuffle, Repeat, and Repeat One."""
        # Cycle state: 0 -> Shuffle, 1 -> Repeat, 2 -> Repeat One
        self.current_state = (self.current_state + 1) % 3

        if self.current_state == 0:  # Shuffle
            self.updateButtonState("shuffle.png", "Shuffle")
        elif self.current_state == 1:  # Repeat
            self.updateButtonState("repeat.png", "Repeat")
        elif self.current_state == 2:  # Repeat One
            self.updateButtonState("r1.png", "Repeat One")

    def updateButtonState(self, icon_name, tooltip):
        """Update button icon and tooltip."""
        button = self.sender()  # Get the button that was clicked
        icon_path = os.path.join(self.base_path, icon_name)
        if os.path.exists(icon_path):
            button.setIcon(QIcon(icon_path))
            button.setToolTip(tooltip)

    def centerWindow(self):
        """Center the window on the screen."""
        screen = self.screen().geometry()
        size = self.geometry()
        self.move(
            (screen.width() - size.width()) // 2,
            (screen.height() - size.height()) // 2
        )


if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = Shax0()
    window.show()
    sys.exit(app.exec())

Using pywin32 and pyside6 to make my own titlebar without qfluentwidgets.

I have tried custom titlebars but it didn’t work and the customs close buttons looks fake, so I’m using pywin32 for the windows style ones.

Please help. It’s 16×16 and the icon in the titlebar is too small. How to make it bigger without breaking the titlebar?

New contributor

garaw-wx is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

5

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật