{"id":14982713,"url":"https://github.com/yjg30737/pyqt-svg-button","last_synced_at":"2025-09-08T03:31:30.621Z","repository":{"id":57677832,"uuid":"459017205","full_name":"yjg30737/pyqt-svg-button","owner":"yjg30737","description":"PyQt button which supports svg icon","archived":false,"fork":false,"pushed_at":"2025-07-18T08:09:35.000Z","size":78,"stargazers_count":6,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-02T07:20:56.835Z","etag":null,"topics":["pyqt","pyqt-examples","pyqt5","pyqt5-examples","pyqt5-tutorial","python","python3","python37","qapp","qpushbutton","qt","qt-example","qt-gui","qt5","svg-button","svg-icon-button"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yjg30737.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-02-14T04:37:53.000Z","updated_at":"2025-07-18T08:09:40.000Z","dependencies_parsed_at":"2022-08-31T05:40:16.654Z","dependency_job_id":null,"html_url":"https://github.com/yjg30737/pyqt-svg-button","commit_stats":null,"previous_names":["yjg30737/pyqt-svg-icon-pushbutton"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/yjg30737/pyqt-svg-button","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yjg30737%2Fpyqt-svg-button","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yjg30737%2Fpyqt-svg-button/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yjg30737%2Fpyqt-svg-button/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yjg30737%2Fpyqt-svg-button/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yjg30737","download_url":"https://codeload.github.com/yjg30737/pyqt-svg-button/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yjg30737%2Fpyqt-svg-button/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274128216,"owners_count":25226967,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-08T02:00:09.813Z","response_time":121,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pyqt","pyqt-examples","pyqt5","pyqt5-examples","pyqt5-tutorial","python","python3","python37","qapp","qpushbutton","qt","qt-example","qt-gui","qt5","svg-button","svg-icon-button"],"created_at":"2024-09-24T14:05:54.097Z","updated_at":"2025-09-08T03:31:30.608Z","avatar_url":"https://github.com/yjg30737.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pyqt-svg-button\nPyQt button which supports svg icon\n\nQt's `setIcon` of button widget doesn't help that much in terms of setting SVG image as an icon. It's just another good old fashioned pixmap icon. \n\nSo i overrided the method to set SVG icon with the power of CSS.\n\nBy the way, parent class of this is `QPushButton` and \u003ca href=\"https://github.com/yjg30737/pyqt-svg-abstractbutton.git\"\u003e`SvgAbstractButton`\u003c/a\u003e. (Multiple inheritance)\n\n(the repo/package name has changed on 2022/05/18 from pyqt-svg-icon-pushbutton)\n\nDefault background color of this is transparent.\n\nIf you want to use svg supporting `QToolButton` instead of `QPushButton`, use \u003ca href=\"https://github.com/yjg30737/pyqt-svg-toolbutton.git\"\u003epyqt-svg-toolbutton\u003c/a\u003e. \n\nNote: Don't use this to PySide project. It doesn't take multiple inheritance well. Besides, you don't have to use this to PySide6 at all because i find that PySide6 or PyQt6(if you will) can automatically turn png into svg icon, or make it smoother. Correct me if i'm wrong.   \n\n## Requirements\n* PyQt6 \u003e= 6.5.0\n\n## Setup\n`python -m pip install pyqt-svg-button`\n\n## Usage\n* `SvgButton(base_widget: QWidget = None)` - Constructor. Base widget is the widget that the button's background color based of when button get hovered/pressed by mouse cursor. If value is default(`None`), background color of button which is getting hovered/pressed will set to #DDDDDD, #FFFFFF. \n* `setIcon(icon: str)` - set the icon. Icon should be a SVG file's name. This is overriding method.\n* `setPadding(padding: int)` - set the button's padding.\n* `setBorderRadius(border_radius: int)`\n* `setBackground(background=None)` - you can give `background` argument's value either 'transparent' or 6-digits or 3-digits hex color string or color's name like 'red', 'green'. If you don't give any arguments(`None`), background will automatically be set based on base widget's color if you give base widget argument to `SvgButton` constructor. \n* `setAsCircle()` - set button's shape as circle.\n\n## Included Packages\n* \u003ca href=\"https://github.com/yjg30737/pyqt-svg-abstractbutton.git\"\u003epyqt-svg-abstractbutton\u003c/a\u003e\n\n## Example\nCode Sample\n\n```python\nfrom PyQt6.QtWidgets import QWidget, QApplication, QHBoxLayout\n\nfrom pyqt_svg_button.svgButton import SvgButton\n\n\nclass SvgButtonExample(QWidget):\n    def __init__(self):\n        super().__init__()\n        self.__initUi()\n\n    def __initUi(self):\n        newButton = SvgButton()\n        newButton.setIcon('new.svg')\n\n        openButton = SvgButton()\n        openButton.setIcon('open.svg')\n\n        saveButton = SvgButton()\n        saveButton.setIcon('save.svg')\n\n        lay = QHBoxLayout()\n        lay.addWidget(newButton)\n        lay.addWidget(openButton)\n        lay.addWidget(saveButton)\n\n        self.setLayout(lay)\n\n\nif __name__ == \"__main__\":\n    import sys\n\n    app = QApplication(sys.argv)\n    ex = SvgButtonExample()\n    ex.show()\n    sys.exit(app.exec_())\n```\n\nResult\n\nhttps://user-images.githubusercontent.com/55078043/153802219-ae019e5b-f603-4aad-93ce-035d33edd9a8.mp4\n\nSorry for the video quality.\n\n![image](https://user-images.githubusercontent.com/55078043/153802633-5517f7ac-3d86-4d7f-b2de-40dbc10a19f8.png)\n\nImage quality is not perfect, but much better than video. Image above is slightly bigger than actual size.\n\n## See Also\n\u003ca href=\"https://github.com/yjg30737/pyqt-svg-toolbutton.git\"\u003epyqt-svg-toolbutton\u003c/a\u003e - QToolButton version of this\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyjg30737%2Fpyqt-svg-button","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyjg30737%2Fpyqt-svg-button","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyjg30737%2Fpyqt-svg-button/lists"}