Igram se z grafičnim vmesnikom.
Problem imam, ko želim narediti, da gumb spremeni text v QLabel. Namreč gumb ne spremeni text-a ampak zapre program.
import sys
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
class Window(QMainWindow):
def __init__(self):
super(Window, self).__init__()
self.setFixedSize(650, 500)
self.home()
def home(self):
#Prikaz gumba
gumb = QPushButton(self)
gumb.setText('Izračunaj')
gumb.setFont(QFont('SansSerif', 11))
gumb.setFixedSize(100, 50)
gumb.move(275, 260)
gumb.clicked.connect(self.printaj)
#Prikaz texta
poves = QLabel('Poves =', self)
poves.move(250, 363)
self.show()
#Akcija na gumbu
def printaj(self):
sender = self.sender()
if sender is self.gumb():
self.label.setText('A')
print("Whoooooa")
def run():
app = QApplication(sys.argv)
GUI = Window()
sys.exit(app.exec_())
run()