Guest User

PyQt4 Help

a guest
Jan 28th, 2016
154
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import sys
  2. from PyQt4 import QtCore, QtGui, uic
  3. form_class = uic.loadUiType("main.ui")[0] # Load the UI & class definition for the main window
  4. b = 0 #values keep track of path
  5. a = 0
  6. #text_edit = QPlainTextEdit() #Determine purpose
  7. class MyWindowClass(QtGui.QMainWindow, form_class):
  8. def __init__(self, parent=None):
  9. QtGui.QMainWindow.__init__(self, parent)
  10. self.setupUi(self)
  11. self.choicea1.clicked.connect(self.choicea1_clicked) #event handler for button being pushed
  12. self.choiceb1.clicked.connect(self.choiceb1_clicked)
  13. self.menuExit.triggered.connect(self.menuExit_selected)
  14. self.restartBegin.triggered.connect(self.restartBegin_selected)
  15. #text_edit.setPlainText(text) #Determine purpose
  16.  
  17. def menuExit_selected(self):
  18. self.close()
  19.  
  20. def restartBegin_selected(self):
  21. pass #make it restart somehow
  22.  
  23. def choicea1_clicked(self): #defines what happens when the button is pushed
  24. global a
  25. a+=1
  26. mainTextEdit.insertPlainText('a1')
  27. #x=open('a1.txt', 'r')
  28. #self.lines = x.readlines()
  29. #print self.lines
  30. #text=open('a1.txt').read()
  31. #text=open('a1.txt').read() #troubleshoot
  32. #pass #Shift to next part of the story
  33.  
  34. def choiceb1_clicked(self):
  35. global b
  36. b+=1
  37. mainTextEdit.insertPlainText('b1')
  38. #x=open('b1.txt', 'r')
  39. #self.lines = x.readlines()
  40. #print self.lines
  41. #print x
  42. #pass #Shift to next part of the story
  43.  
  44.  
  45. app = QtGui.QApplication(sys.argv) # PtQt program to show our window
  46. myWindow = MyWindowClass() # Make an instance of the window class
  47. myWindow.show() # Start the program and
  48. app.exec_() # display the GUI window
RAW Paste Data