-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathui_order_set.py
98 lines (96 loc) · 4.02 KB
/
ui_order_set.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
from ui_order import Ui_Order
from PyQt4 import QtGui, QtCore
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from diffpy.pyfullprof.refine import Constraint
from run import Run
from paramlist import ParamList
import paramgroup
from auto import autorun
import os
import com
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
_fromUtf8 = lambda s: s
class Ui_order(QtGui.QDialog):
def __init__(self, parent=None):
super(Ui_order, self).__init__(parent)
self.pcr_yorn=False
self.ui = Ui_Order()
self.ui.setupUi(self)
self.button_up=self.ui.button_up
self.button_down=self.ui.button_down
self.buttonreset=self.ui.buttonreset
self.table=self.ui.table
self.table.setColumnWidth(0,self.table.width()/1.5)
self.table.setColumnWidth(1,self.table.width()/3)
QtCore.QObject.connect(self.button_up,QtCore.SIGNAL(_fromUtf8("clicked()")),self.up)
QtCore.QObject.connect(self.button_down,QtCore.SIGNAL(_fromUtf8("clicked()")),self.down)
QtCore.QObject.connect(self.buttonreset,QtCore.SIGNAL(_fromUtf8("clicked()")),self.reset)
QtCore.QObject.connect(self.ui.button_configure,QtCore.SIGNAL(_fromUtf8("clicked()")),self.set_configure)
QtCore.QObject.connect(self.ui.button_configure_s,QtCore.SIGNAL(_fromUtf8("clicked()")),self.configure_strategy)
QtCore.QObject.connect(self.ui.button_save,QtCore.SIGNAL(_fromUtf8("clicked()")),self.set_save)
QtCore.QObject.connect(self.ui.combobox_job,QtCore.SIGNAL(_fromUtf8("currentIndexChanged(int)")),self.job_changed);
self.init(0)
def init(self,job):
self.job=job
self.Pg=paramgroup.Pgs[job]
self.list=self.Pg.Param_Order_Group_Name
self.order=range(0,len(self.list))
self.update_table()
self.set_save()
self.editor=com.run_set.setjson["editor"]
def set_configure(self):
edit=self.editor
os.system(edit+" "+os.path.join(com.root_path,"setting.txt"))
def configure_strategy(self):
edit=self.editor
os.system(edit+" "+os.path.join(com.root_path,"strategy/"+"strategy_"+paramgroup.Pgs_type[self.job]+".py"))
def reset(self):
self.order=range(0,len(self.list))
self.update_table()
def update_table(self):
tablep=self.table
tablep.setRowCount(0)
for i in self.order:
print self.list[i]
rowcount = tablep.rowCount()
print rowcount
tablep.insertRow(rowcount)
tablep.setCellWidget(rowcount,0,QtGui.QLabel(self.list[i]))
tablep.setCellWidget(rowcount,1,QtGui.QLabel("parameter"))
def up(self):
current_rowcount=self.table.currentIndex().row()
tmp=self.order[current_rowcount-1]
print current_rowcount
self.order[current_rowcount-1]=self.order[current_rowcount]
self.order[current_rowcount]=tmp
self.update_table()
def down(self):
current_rowcount=self.table.currentIndex().row()
next=current_rowcount+1
if(next>=len(self.list)):next=0
tmp=self.order[next]
print current_rowcount
self.order[next]=self.order[current_rowcount]
self.order[current_rowcount]=tmp
self.update_table()
def set_save(self):
com.run_set.load_setting(path=os.path.join(com.root_path,"setting.txt"))
self.ui.text_origin_path.setText(com.run_set.origin_path)
com.origin_path=com.run_set.origin_path
self.ui.text_asylim.setText(str(com.run_set.AsymLim))
self.ui.spinbox_ncy.setValue(com.run_set.NCY)
self.ui.spinbox_eps.setValue(com.run_set.eps*100)
self.ui.text_fp2k_path.setText(com.run_set.fp2k_path)
paramgroup.load_strategy()
self.Pg=paramgroup.Pgs[self.job]
self.list=self.Pg.Param_Order_Group_Name
self.order=range(0,len(self.list))
self.update_table()
def job_changed(self,job):
if job>= len(paramgroup.Pgs):
job=0;
self.init(job)
self.job=job