Есть оформление, вот код, который созданный в Qt Designer
:
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(800, 600)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 21))
self.menubar.setObjectName("menubar")
self.menu = QtWidgets.QMenu(self.menubar)
self.menu.setObjectName("menu")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.action1 = QtWidgets.QAction(MainWindow)
self.action1.setObjectName("action1")
self.action2 = QtWidgets.QAction(MainWindow)
self.action2.setObjectName("action2")
self.action3 = QtWidgets.QAction(MainWindow)
self.action3.setObjectName("action3")
self.action4 = QtWidgets.QAction(MainWindow)
self.action4.setObjectName("action4")
self.action5 = QtWidgets.QAction(MainWindow)
self.action5.setObjectName("action5")
self.action6 = QtWidgets.QAction(MainWindow)
self.action6.setObjectName("action6")
self.action7 = QtWidgets.QAction(MainWindow)
self.action7.setObjectName("action7")
self.action8 = QtWidgets.QAction(MainWindow)
self.action8.setObjectName("action8")
self.action9 = QtWidgets.QAction(MainWindow)
self.action9.setObjectName("action9")
self.action10 = QtWidgets.QAction(MainWindow)
self.action10.setObjectName("action10")
self.menu.addAction(self.action1)
self.menu.addAction(self.action2)
self.menu.addAction(self.action3)
self.menu.addAction(self.action4)
self.menu.addAction(self.action5)
self.menu.addAction(self.action6)
self.menu.addAction(self.action7)
self.menu.addAction(self.action8)
self.menu.addAction(self.action9)
self.menu.addAction(self.action10)
self.menubar.addAction(self.menu.menuAction())
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.menu.setTitle(_translate("MainWindow", "Выбрать снимок"))
self.action1.setText(_translate("MainWindow", "1 снимок"))
self.action2.setText(_translate("MainWindow", "2"))
self.action3.setText(_translate("MainWindow", "3"))
self.action4.setText(_translate("MainWindow", "4"))
self.action5.setText(_translate("MainWindow", "5"))
self.action6.setText(_translate("MainWindow", "6"))
self.action7.setText(_translate("MainWindow", "7"))
self.action8.setText(_translate("MainWindow", "8"))
self.action9.setText(_translate("MainWindow", "9"))
self.action10.setText(_translate("MainWindow", "10"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
Как добавить открытие фотографии в этой программе, при нажатии на клавиши?
Вот есть код, который открывает в программе фотографию, как реализовать этот функционал в 1 программе?
import sys
from PyQt5.QtWidgets import (QWidget, QHBoxLayout, QLabel, QApplication)
from PyQt5.QtGui import QPixmap
class Example(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
hbox = QHBoxLayout(self)
pixmap = QPixmap("0.bmp")
lbl = QLabel(self)
lbl.setPixmap(pixmap)
hbox.addWidget(lbl)
self.setLayout(hbox)
self.move(100, 200)
self.setWindowTitle('Red Rock')
self.show()
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())