def main(): root = TkinterDnD.Tk() root.withdraw() root.title(u"翻译工具") viewtool.center_window(root, 650, 680) # tv.pack(anchor = tk.W) # pv.pack(anchor = tk.W) tabframe = views.TabsView(master=root) tabframe.pack(anchor=tk.W) tabs = { u'翻译': views.TransView, u'提取': views.PickView, u'更新': views.UpdateView, u'繁体': views.TwView, u'工具': views.ToolsView } for tabname in tabs: tabframe.add(tabname, tabs[tabname]) logpanel = views.LogPanel(root) logpanel.pack(expand=True, fill=tk.BOTH) sytlog.log_panel = logpanel # tk.Button(master=root, text="test",command = lambda:logpanel.print("hahaha")).pack() with open('config.json', 'r', encoding='UTF-8') as f: cfg = json.load(f) config.setcfg(cfg) menu = tk.Menu(root) item = tk.Menu(menu, tearoff=False) v = tk.StringVar(value=config.CN) config.choose(config.CN) for vsn, vsncfg in cfg.items(): item.add_radiobutton(label=vsncfg['name'], value=vsn, variable=v, command=lambda: config.choose(v.get())) menu.add_cascade(label=u"版本", menu=item) root.config(menu=menu) # logpanel.dnd_bind() root.update_idletasks() root.deiconify() root.mainloop()
def cblas(): ''' Searches for CBLAS library, first in already found BLAS library, then in -lcblas. Use blas() first to find BLAS library. ''' print_header( 'CBLAS library' ) choices = [ ['CBLAS routines (cblas_ddot) available', {}], ['CBLAS routines (cblas_ddot) in -lcblas', {'LIBS': '-lcblas'}], ] passed = [] for (label, env) in choices: (rc, out, err) = config.compile_run( 'config/cblas.cc', env, label ) if (rc == 0): passed.append( (label, env) ) break # end labels = map( lambda c: c[0], passed ) i = config.choose( 'Choose CBLAS library:', labels ) config.environ.merge( passed[i][1] ) config.environ.append( 'CXXFLAGS', '-DHAVE_CBLAS' )
def lapacke_uncommon(): ''' ESSL doesn't include all of LAPACKE, so needs -llapacke added. Cholesky with pivoting (LAPACKE_pstrf) is one from LAPACK >= 3.4 that ESSL excludes. ''' choices = [ ('Uncommon routines (LAPACKE_dpstrf) available', {}), ] if ('-llapacke' not in config.environ['LIBS']): choices.append( ['Uncommon routines (LAPACKE_dpstrf) in -llapacke', {'LIBS': '-llapacke'}] ) passed = [] for (label, env) in choices: (rc, out, err) = config.compile_run( 'config/lapacke_pstrf.cc', env, label ) if (rc == 0): passed.append( (label, env) ) break # end labels = map( lambda c: c[0], passed ) i = config.choose( 'Choose LAPACKE library:', labels ) config.environ.merge( passed[i][1] )
def lapacke(): ''' Search for LAPACKE in existing BLAS/LAPACK libraries, found with blas() and lapack(), then in -llapacke. ''' print_header( 'LAPACKE library' ) choices = [ ['LAPACKE routines (LAPACKE_dpotrf) available', {}], ['LAPACKE routines (LAPACKE_dpotrf) in -llapacke', {'LIBS': '-llapacke'}], ] passed = [] for (label, env) in choices: (rc, out, err) = config.compile_run( 'config/lapacke_potrf.cc', env, label ) if (rc == 0): passed.append( (label, env) ) break # end labels = map( lambda c: c[0], passed ) i = config.choose( 'Choose LAPACKE library:', labels ) config.environ.merge( passed[i][1] ) config.environ.append( 'CXXFLAGS', '-DHAVE_LAPACKE' )
def blas(): ''' Searches for BLAS in default libraries, MKL, ACML, ESSL, OpenBLAS, and Accelerate. Checks FORTRAN_ADD_, FORTRAN_LOWER, FORTRAN_UPPER. Checks int (LP64) and int64_t (ILP64). Setting one or more of: blas=mkl, blas=acml, blas=essl, blas=openblas, blas=accelerate; fortran_mangling=add_, fortran_mangling=lower, fortran_mangling=upper; lp64=1, ilp64=1 in the environment or on the command line, limits the search space. ''' print_header( 'BLAS library' ) print_msg( 'Also detects Fortran name mangling and BLAS integer size.' ) # Warn about obsolete settings. if (config.environ['mkl']): print_warn('Variable `mkl` is obsolete; use blas=mkl') if (config.environ['acml']): print_warn('Variable `acml` is obsolete; use blas=acml') if (config.environ['essl']): print_warn('Variable `essl` is obsolete; use blas=essl') if (config.environ['openblas']): print_warn('Variable `openblas` is obsolete; use blas=openblas') if (config.environ['accelerate']): print_warn('Variable `accelerate` is obsolete; use blas=accelerate') test_mkl = ('mkl' in config.environ['blas']) test_acml = ('acml' in config.environ['blas']) test_essl = ('essl' in config.environ['blas']) test_openblas = ('openblas' in config.environ['blas']) test_accelerate = ('accelerate' in config.environ['blas']) # otherwise, test all test_all = not (test_mkl or test_acml or test_essl or test_openblas or test_accelerate) # build list of choices to test choices = [] if (test_all): # sometimes BLAS is in default libraries (e.g., on Cray) choices.extend([ ['Default', {}], ]) # end if (test_all or test_mkl): choices.extend([ # each pair has Intel conventions, then GNU conventions # int, threaded ['Intel MKL (int, Intel conventions, threaded)', {'LIBS': '-lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -lpthread -lm', 'CXXFLAGS': '-fopenmp', 'LDFLAGS': '-fopenmp'}], ['Intel MKL (int, GNU conventions, threaded)', {'LIBS': '-lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core -lpthread -lm', 'CXXFLAGS': '-fopenmp', 'LDFLAGS': '-fopenmp'}], # int64_t, threaded ['Intel MKL (int64_t, Intel conventions, threaded)', {'LIBS': '-lmkl_intel_ilp64 -lmkl_intel_thread -lmkl_core -lpthread -lm', 'CXXFLAGS': '-fopenmp -DMKL_ILP64', 'LDFLAGS': '-fopenmp'}], ['Intel MKL (int64_t, GNU conventions, threaded)', {'LIBS': '-lmkl_gf_ilp64 -lmkl_gnu_thread -lmkl_core -lpthread -lm', 'CXXFLAGS': '-fopenmp -DMKL_ILP64', 'LDFLAGS': '-fopenmp'}], # int, sequential ['Intel MKL (int, Intel conventions, sequential)', {'LIBS': '-lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lm', 'CXXFLAGS': ''}], ['Intel MKL (int, GNU conventions, sequential)', {'LIBS': '-lmkl_gf_lp64 -lmkl_sequential -lmkl_core -lm', 'CXXFLAGS': ''}], # int64_t, sequential ['Intel MKL (int64_t, Intel conventions, sequential)', {'LIBS': '-lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -lm', 'CXXFLAGS': '-DMKL_ILP64'}], ['Intel MKL (int64_t, GNU conventions, sequential)', {'LIBS': '-lmkl_gf_ilp64 -lmkl_sequential -lmkl_core -lm', 'CXXFLAGS': '-DMKL_ILP64'}], ]) # end if (test_all or test_essl): choices.extend([ ['IBM ESSL', {'LIBS': '-lessl'}], ]) # end if (test_all or test_openblas): choices.extend([ ['OpenBLAS', {'LIBS': '-lopenblas'}], ]) # end if (test_all or test_accelerate): path = '/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers' inc = '-I' + path if (os.path.exists( path )) else '' choices.extend([ ['MacOS Accelerate', {'LIBS': '-framework Accelerate', 'CXXFLAGS': inc}], ]) # end #-------------------- # Deprecated libraries last. if (test_all or test_acml): choices.extend([ ['AMD ACML (threaded)', {'LIBS': '-lacml_mp'}], ['AMD ACML (sequential)', {'LIBS': '-lacml'}], ]) # end manglings = get_fortran_manglings() int_sizes = get_int_sizes() passed = [] for (label, env) in choices: title = label if ('LIBS' in env): title += '\n ' + env['LIBS'] print_subhead( title ) (rc, out, err, env2) = compile_with_manglings( 'config/blas.cc', env, manglings, int_sizes ) if (rc == 0): passed.append( (label, env2) ) if (not config.interactive()): break # end labels = map( lambda c: c[0], passed ) i = config.choose( 'Choose BLAS library:', labels ) config.environ.merge( passed[i][1] ) config.environ.append( 'CXXFLAGS', '-DHAVE_BLAS' )