-
-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to add widgets/buttons next to minimize button #55
Comments
If you are using class CustomTitleBar(StandardTitleBar):
""" Custom title bar """
def __init__(self, parent):
super().__init__(parent)
self.questionButton = SvgTitleBarButton('Question.svg', self)
# add button to layout
self.hBoxLayout.insertWidget(4, self.questionButton, Qt.AlignRight)
class Window(FramelessWindow):
def __init__(self, parent=None):
super().__init__(parent=parent)
# change the default title bar
self.setTitleBar(CustomTitleBar(self)) The code of <?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" height="32" width="46" viewBox="0 0 46 32">
<g>
<path id="path1" transform="rotate(0,23,16) translate(16.5,10) scale(0.125,0.125) " fill="#000000" d="M42,90L48,90 48,96 42,96 42,90z M45,0L48.6386680603027,0.240234375 52.1484375,0.9609375 55.4824180603027,2.12109375 58.59375,3.6796875 64.078125,7.921875 68.3203125,13.40625 69.87890625,16.517578125 71.0390625,19.8515625 71.759765625,23.361328125 72,27 71.7421875,30.7500019073486 70.96875,34.125 68.25,39.9609375 64.40625,44.859375 60,49.21875 55.59375,53.4140625 51.75,57.84375 49.03125,62.90625 48.2578125,65.7890625 48,69 48,78 42,78 42,69 42.2578125,65.25 43.03125,61.875 45.75,56.0390625 49.59375,51.1640625 54,46.828125 58.40625,42.609375 62.25,38.15625 64.96875,33.09375 65.7421875,30.2109375 66,27 65.583984375,22.775390625 64.3359375,18.8203125 62.3789024353027,15.24609375 59.8359375,12.1640625 56.7539024353027,9.62109375 53.1796875,7.6640625 49.2246055603027,6.416015625 45,6 40.775390625,6.416015625 36.8203125,7.6640625 33.24609375,9.62109375 30.1640625,12.1640625 27.6210918426514,15.24609375 25.6640625,18.8203125 24.416015625,22.775390625 24,27 18,27 18.240234375,23.361328125 18.9609375,19.8515625 20.12109375,16.517578125 21.6796875,13.40625 25.921875,7.921875 31.40625,3.6796875 34.517578125,2.12109375 37.8515625,0.9609375 41.361328125,0.240234375 45,0z" />
</g>
</svg> If you want to add many buttons to title bar, then you can use class CustomTitleBar(StandardTitleBar):
""" Custom title bar """
def __init__(self, parent):
super().__init__(parent)
self.questionButton = SvgTitleBarButton('Question.svg', self)
self.pinButton = SvgTitleBarButton('Pin.svg', self)
layout = QHBoxLayout()
self.hBoxLayout.insertLayout(4, layout)
layout.addWidget(self.pinButton, 0, Qt.AlignRight)
layout.addWidget(self.questionButton, 0, Qt.AlignRight)
class Window(FramelessWindow):
def __init__(self, parent=None):
super().__init__(parent=parent)
# change the default title bar
self.setTitleBar(CustomTitleBar(self)) The code of <?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" height="32" width="46" viewBox="0 0 46 32">
<g>
<path id="path1" transform="rotate(0,23,16) translate(15,10) scale(0.02734375,0.02734375) " fill="#000000" d="M224,129.75L224,350.25 233.953125,347.53125 243.312484741211,343.625 252.078109741211,338.53125 260.25,332.25 267.578125,325 273.8125,317 278.953125,308.25 283,298.75 286.75,288 450,288 455.875,297.5 458.875,301.78125 462.125,305.625 465.71875,309.09375 469.75,312.25 474.437469482422,315 480,317.25 480,162.75 474.437469482422,165 469.75,167.75 465.71875,170.90625 462.125,174.375 458.875,178.21875 455.875,182.5 450,192 286.75,192 283,181.25 278.953125,171.75 273.8125,163.000015258789 267.578125,155.000015258789 260.25,147.75 252.078109741211,141.46875 243.312484741211,136.375 233.953125,132.46875 224,129.75z M192,96L208,96 216.054672241211,96.28125 223.968734741211,97.125 231.7421875,98.53125 239.375,100.5 246.8125,102.984375 254,105.9375 260.9375,109.359375 267.625,113.25 274.0234375,117.6015625 280.09375,122.40625 285.8359375,127.664070129395 291.25,133.375 296.28125,139.492202758789 300.875,145.968765258789 305.03125,152.804702758789 308.75,160 432.25,160 438.40625,152.8046875 445.124969482422,146.46875 452.406219482422,140.9921875 460.25,136.375 468.578125,132.710952758789 477.3125,130.09375 486.453125,128.5234375 496,128 512,128 512,352 496,352 486.453125,351.4765625 477.3125,349.90625 468.578125,347.2890625 460.25,343.625 452.406219482422,339.0078125 445.124969482422,333.53125 438.40625,327.1953125 432.25,320 308.75,320 305.03125,327.1953125 300.875,334.03125 296.28125,340.5078125 291.25,346.625 285.8359375,352.3359375 280.09375,357.59375 274.0234375,362.3984375 267.625,366.75 260.9375,370.640625 254,374.0625 246.8125,377.015625 239.375,379.5 231.7421875,381.46875 223.968734741211,382.875 216.054672241211,383.71875 208,384 192,384 192,256 32,256 0,240 32,224 192,224 192,96z" />
</g>
</svg> |
Thank you @zhiyiYo. Using index value of
|
Describe the bug
Not a bug, but more a feature
Environment
As the title says, how do i add buttons/widgts next to minize button, as show in the screeshot below.
Screenshots
Any help is appreciated.
The text was updated successfully, but these errors were encountered: