PYQT5 Exiting Problem

I'm trying to access the PYQT code that PyCharm created.  I've got the following code.

from PyQt5 import QtCore, QtGui, QtWidgets


class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(585, 321)
self.label = QtWidgets.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(250, 50, 61, 21))
self.label.setMinimumSize(QtCore.QSize(41, 0))
self.label.setAlignment(QtCore.Qt.AlignCenter)
self.label.setWordWrap(True)
self.label.setObjectName("label")
self.pushButton = QtWidgets.QPushButton(Dialog)
self.pushButton.setGeometry(QtCore.QRect(266, 98, 31, 23))
self.pushButton.setObjectName("pushButton")
font = QtGui.QFont()
font.setPointSize(12)

self.retranslateUi(Dialog)
self.pushButton.clicked.connect(Dialog.SB_UP_click)
QtCore.QMetaObject.connectSlotsByName(Dialog)

def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.label.setText(_translate("Dialog", "SOUTH"))
self.pushButton.setText(_translate("Dialog", "UP"))
from PyQt5 import QtCore, QtGui, QtWidgets
from My_Window import Ui_Dialog
import sys


class MainWindow(QtWidgets.QMainWindow, Ui_Dialog):
def __init__(self):
super(MainWindow, self).__init__()
self.ui = Ui_Dialog()
self.ui.setupUi(self)


def SB_UP_click(self):
print("SB UP")
self.label_2.setText("HI")
print("got here")


def main():
app = QtWidgets.QApplication([])
window = MainWindow()
window.show()

sys.exit(app.exec_())


if __name__ == '__main__':
main()

The problem is that when I click the button it exits out on the self.label.settext line and never printe "got here".  "SB_Up" is printed though.  Any idea on what I've done wrong?

0
1 comment

The problem is that l can't figure out how to access the label widget from within the connection SB_UP_click when the push button is clicked.  Any help would be appreciative. 

0

Please sign in to leave a comment.