' %image
self.txt_tool.append('\t\t%s ' %(href, target, image_txt))
self.colspan += 1
self.txt_tool.append('\t\t%%%s%% ' %(href, target, display))
def tl_solve(self):
href = "solve"
target = "Solve the Structure"
display = "Solve"
if image:
self.colspan += 1
image_txt = '' %image
self.txt_tool.append('\t\t%s ' %(href, target, image_txt))
self.colspan += 1
self.txt_tool.append('\t\t%%%s%% ' %(href, target, display))
def _make_tool_line(self):
self.txt.append(' ')
self.txt.append('\t')
self.txt.append('\t\t' %image)
self.txt.append('\t ')
self.txt.append('\t' %self.colspan)
for item in self.txt_tool:
self.txt.append(item + "\n")
self.txt.append('\t ')
self.txt.append(' ')
self.txt.append('')
def make_Tool_Solve(self):
name = "solve"
self.txt = []
self.txt_tool = []
self.txt.append(r'')
self.colspan = 1
self.tl_reset()
self.tl_solve()
self.make_tool_line()
self.write_tool(name)
OlexVFS.write_to_olex(r"%s/etc/gui/%s.htm" %(basedir, self.tbx), self.tool_txt, 0)
self.txt.append(r'')
def box(self, box_d):
box_d.setdefault('font-size',OV.GetVar(HtmlFontSizeControls))
box_d.setdefault('label', 'Label')
box_d.setdefault('width', 40)
box_d.setdefault('height', 18)
box_d.setdefault('type', 'text')
box_d.setdefault('value', '')
box_d.setdefault('image', '')
box_d.setdefault('name', 'NoName')
box_d.setdefault('items', "")
box_d.setdefault('readonly',"")
box_d.setdefault('label',"")
box_d.setdefault('checked',"")
box_d.setdefault('onchange', "")
box_d.setdefault('onclick', "")
box_d.setdefault('ondown', "")
box_d.setdefault('onup', "")
box_d.setdefault('colspan', 1)
box_d.setdefault('oncheck', "")
box_d.setdefault('onuncheck', "")
# box_d.setdefault('sep_on', "" %box_d)
# box_d.setdefault('sep_off', " ")
# if box_d['colspan'] == 0:
box_d['sep_on'] = ""
box_d['sep_off'] = ""
# #this used to be first line of next block
box = '''
%(sep_on)s
%(sep_off)s
'''%box_d
return box
def gui_def_refine(self):
g = glob.glob(r"%s\*.hkl" %olx.FilePath())
g.sort()
reflection_files = ""
try:
a = olx.HKLSrc()
except:
a = ""
if a[:1] == "'":
a = a[1:-1]
if os.path.isfile(a):
most_recent_reflection_file = a.split('\\')[-1]
show_refl_date = time.strftime(r"%d/%b/%Y %H:%M", time.localtime(os.path.getctime(olx.HKLSrc())))
else:
if g:
most_recent_reflection_file = g[0]
show_refl_date = time.strftime(r"%d/%b/%Y %H:%M", time.localtime(os.path.getctime(g[0])))
else:
print("There is no reflection file or the reflection file is not accessible")
self.abort = True
return
most_recent_reflection_file = ""
for item in g:
reflection_files+="%s<-%s;" %(item.split("\\")[-1], item)
try:
weight =olx.Ins('weight')
weight1 = olx.Ins('weight1')
except:
weight = r"n/a"
weight1 = r"n/a"
if OV.FindValue('auto_weight') == "True":
autoweight = 'checked'
else:
autoweight = ''
lsm_items = 'L.S.;CGLS;cctbx'
#if OV.FindValue('anis') == "True":
# anis = 'checked'
#else:
# anis = ''
lines = ['refine_shelx', 'reflection_files', 'WGHT_scheme', 'formula', 'edit_files']
tools_refine_shelx = ['refine_shelx', 'set_method', 'set_iterations', 'set_PLAN']
tools_reflection_files = ['reflection_files', 'reflection_date']
tools_WGHT_sheme = ['set_WGHT']
tools_edit_files = ['edit_ins', 'edit_res', 'edit_lst', 'edit_cif']
tools_formula = ['formula', 'fixunit']
tbx = {"refine":
{"category":'work',
'tbx_li':lines
}
}
tbx_li = {'refine_shelx':{"category":'work',
'tools':tools_refine_shelx
},
'reflection_files':{"category":'work',
'tools':tools_reflection_files
},
'WGHT_scheme':{"category":'work',
'tools':tools_WGHT_sheme
},
'edit_files':{"category":'work',
'tools':tools_edit_files
},
'formula':{"category":'work',
'tools':tools_formula
},
}
tools = {'refine_shelx':
{'category':'work-shelx',
'colspan':1,
'colwidth':'20%',
'before':self.box({'type':'button',
'width':50,
'name':'cmd_refine',
'image':'btn-refine-on.png',
'value':'%Refine%',
'onclick':'ls html.GetValue(set_method) html.GetValue(set_iterations)>>refine -1 html.GetValue(set_PLAN)',
}),
},
'set_method':
{'category':'work-shelx',
'colspan':1,
'colwidth':'23%',
'before':self.box({'type':'combo',
'width':50,
'name':'set_method',
'value':'lsm()',
'items':lsm_items,
'label':'',
'onchange':'ls html.GetValue(set_method) html.GetValue(set_iterations)',
'readonly':'readonly'}),
},
'set_iterations':
{'category':'work-shelx',
'colspan':1,
'colwidth':'33%',
'before':self.box({'type':'spin',
'width':42,
'name':'set_iterations',
'value':'Ins(LS)',
'label':'Cycles '}),
},
'set_PLAN':
{'category':'work-shelx',
'colspan':1,
'colwidth':'25%',
'before':self.box({'type':'spin',
'width':42,
'name':'set_PLAN',
'value':'Ins(PLAN)',
'label':'Q '}),
},
'reflection_files':
{'category':'work',
'colspan':2,
'before':self.box({'type':'combo',
'width':105,
'name':'Reflections',
'items':reflection_files,
'onchange':'HKLSrc(html.GetValue(Reflections))',
'value':'FileName(HKLSrc())',
'label':'',
'readonly':'readonly'}),
},
'reflection_date':
{'category':'work',
'colspan':2,
'after':"%s" %show_refl_date,
},
'set_WGHT':
{'category':'work',
'colspan':3,
'before':"WGHT: %s -> %s." % (weight,weight1),
'after':self.box({'type':'checkbox',
'name':'AUTO_WGHT',
'checked':autoweight,
'oncheck':'SetVar(auto_weight,True)',
'onuncheck':'SetVar(auto_weight,False)',
'value':''})
},
'Q_WGHT_CUTOFF':
{'category':'work',
'colspan':1,
'before':self.box({'type':'spin',
'width':40,
'name':'WGHT_Q_cutoff_box',
'onchange':'SetVar(WGHT_Q_cutoff, html.GetValue(WGHT_Q_cutoff_box))',
'value':'GetVar(WGHT_Q_cutoff)',
'label':'Q-cut'})
},
'AUTO_WGHT':
{'category':'work',
'colspan':1,
'before':self.box({'type':'checkbox',
'name':'AUTO_WGHT',
'checked':'checked',
'value':''})
},
'edit_ins':
{'category':'work',
'colspan':1,
'display':'ins',
'href':'edit ins',
},
'edit_res':
{'category':'work',
'colspan':1,
'display':'res',
'href':'edit res',
},
'edit_lst':
{'category':'work',
'colspan':1,
'display':'lst',
'href':'edit lst',
},
'edit_cif':
{'category':'work',
'colspan':1,
'display':'cif',
'href':'edit cif',
},
'formula':
{'category':'work-shelx',
'colspan':3,
'before':self.box({'type':'text',
'width':145,
'name':'set_formula',
'value':'xf.GetFormula()',
'label':'Formula '}),
},
'fixunit':
{'category':'work-shelx',
'colspan':1,
'target':'Changes the formula to that of the current model',
'href':'fixunit>>html.Update',
'display':'Fix',
},
}
return {"tbx":tbx,"tbx_li":tbx_li,"tools":tools}
def gui_def_solve(self):
# g = glob.glob(r"%s\*.hkl" %olx.FilePath())
# g.sort()
# reflection_files = ""
# a = olx.HKLSrc()
# if a[:1] == "'":
# a = a[1:-1]
#
# if os.path.isfile(a):
# most_recent_reflection_file = a.split('\\')[-1]
# show_refl_date = time.strftime(r"%d/%b/%Y %H:%M", time.localtime(os.path.getctime(olx.HKLSrc())))
# else:
# if g:
# most_recent_reflection_file = g[0]
# show_refl_date = time.strftime(r"%d/%b/%Y %H:%M", time.localtime(os.path.getctime(g[0])))
# else:
# print "There is no reflection file or the reflection file is not accessible"
# self.abort = True
# return
# most_recent_reflection_file = ""
# for item in g:
# reflection_files+="%s<-%s;" %(item.split("\\")[-1], item)
lines = ['solve', 'space_group', 'formula']
tbx = {"solve":
{"category":'work',
'tbx_li':lines
}
}
tbx_li = {'solve':{"category":'work',
'tools':['cmd_solve', 'solve_method', 'more_solve', 'cmd_more_solve']
},
'space_group':{"category":'work',
'tools':['space_group']
},
'formula':{"category":'work',
'tools':['formula','fixunit']
},
}
tools = {'cmd_solve':
{'category':'work-shelx',
'colspan':1,
'colwidth':'25%',
'before':self.box({'type':'button',
'width':50,
'image':'btn-solve-on.png',
'name':'cmd_solve',
'value':'%Solve%',
'onclick':'reset html.GetValue(set_solve_method) -c=\'html.GetValue(set_formula)\' -s=html.GetValue(set_space_group)>>solve',
}),
},
'solve_method':
{'category':'work-shelx',
'colspan':1,
'colwidth':'25%',
'before':self.box({'type':'combo',
'width':50,
'name':'set_solve_method',
'value':'TREF',
'items':'TREF;PATT',
'label':'',
'onchange':'""',
'readonly':'readonly'
}),
},
'more_solve':
{'category':'work-shelx',
'colspan':1,
'colwidth':'30%',
'align':'center',
'after':self.box({'type':'spin',
'width':42,
'name':'more_solve_tref',
'value':'5',
'label':'Next '
}),
},
'cmd_more_solve':
{'category':'work-shelx',
'colspan':1,
'colwidth':'20%',
'align':'center',
'href':'tref html.GetValue(more_solve_tref)',
'display':'Show'
},
'space_group':
{'category':'work-shelx',
'colspan':4,
'before':self.box({'type':'combo',
'width':65,
'name':'set_space_group',
'items':'SGList()',
'label':'Please input or select Space Group ',
'value':'sg(%n)',
}),
},
'formula':
{'category':'work-shelx',
'colspan':3,
'before':self.box({'type':'text',
'width':145,
'name':'set_formula',
'value':'xf.GetFormula()',
'label':'Formula '}),
},
'fixunit':
{'category':'work-shelx',
'colspan':1,
'target':'Changes the formula to that of the current model',
'href':'fixunit>>html.Update',
'display':'Fix',
},
'tidy':
{'category':'work',
'colspan':1,
'before':self.box({'type':'checkbox',
'name':'tidy',
'oncheck':'echo Check',
'onuncheck':'SetVar(tidy,false)',
'checked':'checked',
'value':''})
},
}
return {"tbx":tbx,"tbx_li":tbx_li,"tools":tools}
def make_program_choice_box(prg_type, prg_det, scope):
if prg_det == 'program':
func = 'Prgs'
if prg_det == 'method':
func = 'Methods'
d = {'prg_type':prg_type, #refinement, solution
'PRG_TYPE':prg_type.upper(), #REFINEMENT, SOLUTION
'Prg_Type':prg_type.title(), #REFINEMENT, SOLUTION
'prg_det':prg_det, #program, method
'PRG_DET':prg_det.upper(), #PROGRAM, METHOD
'Prg_Det':prg_det.title(), #PROGRAM, METHOD
'scope':scope,
'SCOPE':scope.upper(),
'func':func,
'func_arg':"",
'func_arg2':"",
}
if prg_det == 'method':
func_arg = 'spy.GetParam(%(scope)s.%(prg_type)s.program)' %d
func_arg2 = 'html.GetValue(SET_%(SCOPE)s_%(PRG_TYPE)s_PROGRAM),html.GetValue(SET_%(SCOPE)s_%(PRG_TYPE)s_METHOD)' %d
if prg_det == 'program':
func_arg = 'html.GetValue(SET_%(SCOPE)s_%(PRG_TYPE)s_PROGRAM)'
func_arg2 = 'html.GetValue(SET_%(SCOPE)s_%(PRG_TYPE)s_PROGRAM),html.GetValue(SET_%(SCOPE)s_%(PRG_TYPE)s_METHOD)' %d
d['func_arg'] = func_arg
d['func_arg2'] = func_arg2
txt = '''
''' %d
return txt
OV.registerFunction(make_program_choice_box)
#if __name__ == "__main__":
#a = timage(size = 290, basedir = basedir)
#a.run()
calculate_chn = {}
calculate_chn.setdefault('href', 'calcCHN')
calculate_chn.setdefault('display', 'Calculate CHN')
calculate_chn.setdefault('target', 'Calculate CHN Analysis for current Structure')
calculate_isotopePattern = {}
calculate_isotopePattern.setdefault('href', 'calcms')
calculate_isotopePattern.setdefault('display', 'Calculate MS')
calculate_isotopePattern.setdefault('target', 'Calculate Molecular Isotope Pattern (Mass Spectrum)')