Skip to content

Instantly share code, notes, and snippets.

@jeakwon
Created June 27, 2020 14:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeakwon/383feeeb07e73748745b6b2c583b75ff to your computer and use it in GitHub Desktop.
Save jeakwon/383feeeb07e73748745b6b2c583b75ff to your computer and use it in GitHub Desktop.
toorbar example
import sys
from PySide2.QtCore import *
from PySide2.QtGui import *
from PySide2.QtWidgets import *
class tooldemo(QMainWindow):
def __init__(self, parent = None):
super(tooldemo, self).__init__(parent)
layout = QVBoxLayout()
tb = self.addToolBar("File")
new = QAction(QIcon("new.bmp"),"new",self)
tb.addAction(new)
open = QAction(QIcon("open.bmp"),"open",self)
tb.addAction(open)
save = QAction(QIcon("save.bmp"),"save",self)
tb.addAction(save)
tb.actionTriggered[QAction].connect(self.toolbtnpressed)
self.setLayout(layout)
self.setWindowTitle("toolbar demo")
def toolbtnpressed(self,a):
print("pressed tool button is", a.text())
def main():
app = QApplication(sys.argv)
ex = tooldemo()
ex.show()
sys.exit(app.exec_())
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment