33
44from __future__ import print_function
55
6- from collections import OrderedDict
6+ import collections as col
77import json
8+ import os
89import sys
910
10- from PyQt4 import QtCore , QtGui , uic
11+ from PySide import QtCore , QtGui , QtUiTools
1112
1213
1314# Python 3 compatibility
@@ -22,18 +23,29 @@ class Config(QtGui.QDialog):
2223 Parses the configuration the user applies
2324 """
2425
25- def __init__ (self ):
26- super (Config , self ).__init__ ()
26+ def __init__ (self , * args , ** kwargs ):
27+ super (Config , self ).__init__ (* args , ** kwargs )
28+ self .modal = True
2729
28- self .config = OrderedDict ()
30+ self .config = col . OrderedDict ()
2931
30- self .ui = uic .loadUi ("config.ui" )
31- self .ui .show ()
32+ #self.setLayout(QtGui.QVBoxLayout())
33+ self .ui = QtUiTools .QUiLoader ().load ("config.ui" )
34+ #self.layout().addWidget(self.ui)
35+
36+ print (dir (self ))
37+ print (dir (self .ui ))
3238
33- btn = self .ui .buttonBox .button (
39+ btn_box = self .ui .buttonBox
40+ ok_btn = btn_box .button (
3441 QtGui .QDialogButtonBox .Ok
3542 )
36- btn .clicked .connect (self .accept )
43+ ok_btn .clicked .connect (self .accept )
44+
45+ def show (self ):
46+ self .ui .show ()
47+ self .ui .activateWindow ()
48+ self .ui .raise_ ()
3749
3850 def accept (self ):
3951 table = self .ui .tableWidget
@@ -50,12 +62,19 @@ def accept(self):
5062 "" ,
5163 "*.json"
5264 )
65+ # PySide gives us a tuple.
66+ # The actual filename is first
67+ if isinstance (filename , tuple ):
68+ filename = filename [0 ]
5369 with open (filename , "w" ) as f :
5470 json .dump (self .config , f , indent = True )
5571
5672def main (* argv ):
5773 app = QtGui .QApplication (sys .argv )
5874 window = Config ()
75+ window .show ()
76+ window .activateWindow ()
77+ window .raise_ ()
5978 return app .exec_ ()
6079
6180if __name__ == "__main__" :
0 commit comments