Heya

I'm quite new to PyQt. I'm trying to find some examples as to how to use savestate but so far I come up empty handed with python examples. Maybe I'm missing the elephant in the room so maybe point me out to it please. Most of my QT code learning experience come from zetcode and few other tutorials. Also I use pyuic4 to convert QT code to python and then study it. Now if some one could either point me to a way to set up savestate in QT Creator - then I could pyuic4 and back learn it and its all good but if Its not doable in creator here is my piece of code. If some1 could be so kind to show me few examples how I can add save/load states to it it would be great!

Qt Code:
  1. import os
  2. import sys
  3. from PyQt4.QtCore import *
  4. from PyQt4.QtGui import *
  5. from subprocess import Popen, PIPE, STDOUT
  6. import subprocess
  7. global loc
  8. global des
  9. def main():
  10. app = QApplication(sys.argv)
  11. w = MyWindow()
  12. w.show()
  13. sys.exit(app.exec_())
  14. class MyWindow(QMainWindow):
  15. def __init__(self, *args):
  16. QMainWindow.__init__(self, *args)
  17. #Window Main Settings
  18. MainWindow = self.setWindowTitle('Data')# Name
  19. self.centralwidget = QWidget(MainWindow) # Create Widget
  20. self.gridLayout = QGridLayout(self.centralwidget) # Create Grid Layout
  21. self.gridLayout.setSpacing(2)
  22. self.gridLayout.setMargin(2)
  23. self.setStyleSheet("""
  24. *
  25. {
  26. background-color: rgb(65,65,65);
  27. color : rgb(210,210,210);
  28. }
  29. QMenuBar::item
  30. {
  31. background-color: rbg(100,0,100);
  32. }
  33. QMenuBar::item:selected
  34. {
  35. background-color: rbg(0,0,255);
  36. }
  37. QMenuBar::item:pressed
  38. {
  39. background-color: rgb(100,100,100);
  40. }
  41. """)
  42. #Create Menu and status info
  43. self.menubar = QMenuBar(MainWindow) # Create Menu Bar
  44. self.menubar.setGeometry(QRect(0, 0, 800, 21)) # Menubar Settings
  45. self.setMenuBar(self.menubar)
  46. self.statusbar = QStatusBar(MainWindow) # Create Status Bar
  47. self.setStatusBar(self.statusbar)
  48. #Create Labels
  49. self.l_dirLoc = QLabel('Location Dir',self)
  50. #Create Buttons
  51. self.pb_getDir = QPushButton('...',self.centralwidget)
  52. #Create Q Line Edits
  53. self.q_fileType = QLineEdit('Type File',self.centralwidget)
  54. #Create List Views
  55. self.lv_list = QListView(self.centralwidget)
  56. #Create Check Box
  57. self.bx_Display = QCheckBox('Display Data',self)
  58.  
  59. #Create Text Edit
  60. self.te_dbrList = QTextEdit('',self)
  61.  
  62. #Menubar Action
  63. exitAction = QAction(QIcon('exit.png'), '&Exit', self)
  64. exitAction.setShortcut('Ctrl+Q')
  65. exitAction.setStatusTip('Exit application')
  66. exitAction.triggered.connect(qApp.quit)
  67. menubar = self.menuBar()
  68. file_menu = menubar.addMenu('&File')
  69. file_menu.addAction(exitAction)
  70.  
  71. #Layout Order
  72. self.gridLayout.addWidget(self.l_dirLoc)
  73. self.gridLayout.addWidget(self.pb_getDir)
  74. self.gridLayout.addWidget(self.q_fileType)
  75. self.gridLayout.addWidget(self.lv_list)
  76. self.gridLayout.addWidget(self.bx_Display)
  77. self.gridLayout.addWidget(self.te_dbrList)
  78. self.gridLayout.addItem(QSpacerItem(0,0, QSizePolicy.Minimum, QSizePolicy.Expanding))
  79. self.setCentralWidget(self.centralwidget)
  80.  
  81. if __name__ == "__main__":
  82. main()
To copy to clipboard, switch view to plain text mode