title: Simple python GUI for raspberry pi development
body: <p>I need some help getting my gui to function how I intend to. So for my GUI I need two push buttons and a timer. The timer counts down on the press of start/pause, then pauses when pressed again. The other button reset should be easy as just resetting the Qtimer. </p>
  
  <p>I tried to use qtdesigner to confiure the layout of my gui and while that worked, I cannot seem to add the timer in/vice versa. (it just will not show based on which one is located higher up on the .py file). For the timer I've been messing around with a modified version of the answer in this question <a href="https://stackoverflow.com/questions/40994187/pyqt-showing-countdown-timer?rq=1">PyQt - showing countdown timer</a>. Any assistance on helping me get a countdown timer working with button interfacing would be very helpful. </p>
  
  <p>I made some changes to my code adding fixing my button slots I still cannot get the timer to display i get the error 'Ui_Form' object has no attribute 'setCentralWidget' which i cannot fix for the life of me. Please someone help me get the timer just on the gui I can configure where it goes latter.</p>
  
  <pre><code>import sys
  from PyQt5 import QtCore, QtWidgets
  #import pymongo
  #import socket
  #import json
  #from time import sleep
  
  DURATION_INT = 300
  state = "stopped"
  #connection = pymongo.MongoClient(host='192.168.4.2', port=27017)
  #db = connection.restdb
  
  class Ui_Form(object):
      def setupUi(self, Form):
          global state
          super().__init__()
          Form.setObjectName("Form")
          Form.resize(648, 561)
          self.pushButton_2 = QtWidgets.QPushButton(Form)
          self.pushButton_2.setGeometry(QtCore.QRect(170, 460, 93, 28))
          self.pushButton_2.setObjectName("pushButton_2")
          self.lineEdit = QtWidgets.QLineEdit(Form)
          self.lineEdit.setGeometry(QtCore.QRect(190, 110, 231, 101))
          self.lineEdit.setObjectName("lineEdit")
          self.lineEdit_2 = QtWidgets.QLineEdit(Form)
          self.lineEdit_2.setGeometry(QtCore.QRect(230, 270, 61, 51))
          self.lineEdit_2.setObjectName("lineEdit_2")
          self.textEdit = QtWidgets.QTextEdit(Form)
          self.textEdit.setGeometry(QtCore.QRect(290, 270, 21, 51))
          self.textEdit.setObjectName("textEdit")
          self.lineEdit_3 = QtWidgets.QLineEdit(Form)
          self.lineEdit_3.setGeometry(QtCore.QRect(310, 270, 61, 51))
          self.lineEdit_3.setObjectName("lineEdit_3")
          self.pushButton = QtWidgets.QPushButton(Form)
          self.pushButton.setGeometry(QtCore.QRect(360, 460, 93, 28))
          self.pushButton.setObjectName("pushButton")
          self.retranslateUi(Form)
          self.pushButton.clicked.connect(self.start_pause)
          self.pushButton_2.clicked.connect(self.reset)
   ######################################################       
          self.time_left_int = DURATION_INT
          self.widget_counter_int = 0
  
          central_widget = QtWidgets.QWidget()
          self.setCentralWidget(central_widget)
          vbox = QtWidgets.QVBoxLayout()
          central_widget.setLayout(vbox)
  
          self.pages_qsw = QtWidgets.QStackedWidget()
          vbox.addWidget(self.pages_qsw)
          self.time_passed_qll = QtWidgets.QLabel()
          vbox.addWidget(self.time_passed_qll)
  
          self.widget_one = QtWidgets.QLabel()
          self.pages_qsw.addWidget(self.widget_one)
          self.timer_start()
          self.update_gui()
  #####################################################
      def retranslateUi(self, Form):
          _translate = QtCore.QCoreApplication.translate
          Form.setWindowTitle(_translate("Form", "Form"))
          self.pushButton_2.setText(_translate("Form", "Reset"))
          self.pushButton.setText(_translate("Form", "Start/Pause"))
  
      def timer_start(self):
          self.time_left_int = DURATION_INT
          self.my_qtimer = QtCore.QTimer()
          self.my_qtimer.timeout.connect(self.timer_timeout)
          self.my_qtimer.start(1000)
          self.update_gui()
  
      def timer_timeout(self):
          self.time_left_int -= 1
  
          if  self.time_left_int == -1:
              self.widget_counter_int = (self.widget_counter_int + 1) % 4
              self.pages_qsw.setCurrentIndex(self.widget_counter_int)
              self.time_left_int = DURATION_INT
  
          self.update_gui()
  
      def update_gui(self):
          self.time_passed_qll.setText(str(self.time_left_int))    
  
      def start_pause(self):
          global state
          if (state == "stopped" or state == "paused"):
              state = "running"
              print(state)
              #for g in gameData.find():
              #    gameData.update({'_id' : g['_id']}, {'state': state})
  
          elif (state == "running"):
              state = "paused"
              print(state)
              #for g in gameData.find():
              #    gameData.update({'_id' : g['_id']}, {'state': state})
  
      def reset(self):
          global state
          state = "stopped"
          print(state)
          #for g in gameData.find():
          #    gameData.update({'_id' : g['_id']}, {'state': state})
  
  if __name__ == "__main__":
      app = QtWidgets.QApplication(sys.argv)
      Form = QtWidgets.QMainWindow()
      ui = Ui_Form()
      ui.setupUi(Form)
      Form.show()
      sys.exit(app.exec_())
  </code></pre>