Created
June 27, 2020 14:35
-
-
Save jeakwon/383feeeb07e73748745b6b2c583b75ff to your computer and use it in GitHub Desktop.
toorbar example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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