хорошо .. вы изменили вопрос. Я оставляю свой ответ на ваш предыдущий вопрос. Я надеюсь, что это полезно.
Вы можете использовать PyQt5.
У меня есть папка с этим:
|-Project/
|--- images/
|----- 1.png
|------2.png
|--- app.py
Есть две кнопки, например, значок «кулачок» и значок «пользователь»:
from PyQt5 import QtCore, QtGui, QtWidgets
import os
class Ui_Example(QtWidgets.QMainWindow):
def __init__(self, parent=None):
super(Ui_Example, self).__init__(parent)
width = 350
height = 180
self.resize(width,height)
self.setMaximumSize(width,height)
self.setMinimumSize(width,height)
self.setWindowTitle("Example")
self.path = os.path.join(os.path.dirname(os.path.abspath(__file__)),'images') #icons path
### icons
usericon = QtGui.QIcon()
usericon.addPixmap(QtGui.QPixmap(os.path.join(self.path, '2.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off)
camicon = QtGui.QIcon()
camicon.addPixmap(QtGui.QPixmap(os.path.join(self.path, '1.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off)
# Button user
self.btnuser = QtWidgets.QPushButton(self)
self.btnuser.setGeometry(QtCore.QRect(20,20,150,100))
self.btnuser.setIcon(usericon)
self.btnuser.setStyleSheet("background-color:transparent;")
self.btnuser.clicked.connect(self.ExecUserCode)
# Button cam
self.btncam = QtWidgets.QPushButton(self)
self.btncam.setGeometry(QtCore.QRect(180, 20, 150, 100))
self.btncam.setIcon(camicon)
self.btncam.setStyleSheet("background-color:transparent;")
self.btncam.clicked.connect(self.ExecCamCode)
# Button..
# ...
def ExecUserCode(self):
print("User Code here")
def ExecCamCode(self):
print("Cam Code here")
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MW = Ui_Example()
MW.show()
sys.exit(app.exec_())
Результат:
![enter image description here](https://i.stack.imgur.com/Hm9dw.png)