def open(self, ssnew=None): ''' Open new session from file ssnew or after user asking ''' if not _checkAPI(): return # in_dir = app.app_path(app.APP_DIR_DATA) sscur = app.app_path(app.APP_FILE_SESSION) sscur_save = app.app_proc(app.PROC_SAVE_SESSION, sscur) pass #LOG and log('sscur_save={}',(sscur_save)) if sscur_save == False: return if ssnew is None: ssnew = app.dlg_file( is_open=True, filters=DLG_ALL_FILTER, init_filename='!' # '!' to disable check "filename exists" , init_dir='') if ssnew is None: return if ssnew.endswith(SWSESS_EXT) and os.path.isfile(ssnew): # Import from Syn sssyn = ssnew sscud = ssnew[:-len(SWSESS_EXT)] + CDSESS_EXT if os.path.isfile(sscud): sscud = app.dlg_file(is_open=False, filters=DLG_CUD_FILTER, init_filename=os.path.basename(sscud), init_dir=os.path.dirname(sscud)) if not sscud: return if not import_syn_sess(sssyn, sscud): return ssnew = sscud pass #LOG and log('ssnew={}',(ssnew)) ssnew = apx.icase(False, '', ssnew.endswith(CDSESS_EXT), ssnew, os.path.isfile(ssnew), ssnew, True, ssnew + CDSESS_EXT) pass #LOG and log('ssnew={}',(ssnew)) if os.path.isfile(ssnew): # Open # app.app_proc(app.PROC_SAVE_SESSION, sscur) ssnew_load = app.app_proc(app.PROC_LOAD_SESSION, ssnew) pass #LOG and log('ssnew_load={}',(ssnew_load)) if ssnew_load == False: return app.app_proc(app.PROC_SET_SESSION, ssnew) app.msg_status(OPENED.format(stem=juststem(ssnew))) self.top_sess(ssnew) else: # New if app.ID_NO == app.msg_box( CREATE_ASK.format(stem=juststem(ssnew)), app.MB_YESNO): return # app.app_proc(app.PROC_SAVE_SESSION, sscur) app.ed.cmd(cmds.cmd_FileCloseAll) app.app_proc(app.PROC_SET_SESSION, ssnew) app.app_proc(app.PROC_SAVE_SESSION, ssnew) app.msg_status(CREATED.format(stem=juststem(ssnew))) self.top_sess(ssnew)
def dlg_export(self): ''' Show dlg for export some macros. ''' if app.app_api_version()<FROM_API_VERSION: return app.msg_status(_('Need update CudaText')) if 0==len(self.macros): return app.msg_status(_('No macros for export')) exp_file= app.dlg_file(False, '', '', 'Cuda macros|*.cuda-macros') exp_file= '' if exp_file is None else exp_file exp_file= exp_file+('' if ''==exp_file or exp_file.endswith('.cuda-macros') else '.cuda-macros') (WD_LST ,HT_LST)= (500 ,500) lmcrs = len(self.macros) crt,sels= '0', ['0'] * lmcrs while True: pass; LOG and log('sels={}',sels) cnts = ([ dict( tp='lb' ,tid='file' ,l=GAP ,w=70 ,cap=_('Export &to') ) ,dict(cid='file' ,tp='ed' ,t=GAP ,l=GAP+70 ,r=GAP+WD_LST-35 ,en='0' ) ,dict(cid='brow' ,tp='bt' ,tid='file' ,l=GAP+HT_LST-35 ,r=GAP+WD_LST ,cap=_('&...') ) ,dict(cid='mcrs' ,tp='ch-lbx',t=35 ,h=HT_LST ,l=GAP ,w= WD_LST ,items=[mcr['nm'] for mcr in self.macros]) ,dict(cid='ch-a' ,tp='bt' ,t=GAP+35+HT_LST ,l=GAP*1 ,w=100 ,cap=_('Check &all') ) ,dict(cid='ch-n' ,tp='bt' ,t=GAP+35+HT_LST ,l=GAP*2+100 ,w=100 ,cap=_('U&ncheck all') ) ,dict(cid='expo' ,tp='bt' ,t=GAP+35+HT_LST ,l= WD_LST-70*2 ,w=70 ,cap=_('&Export') ,props='1' ) # default ,dict(cid='-' ,tp='bt' ,t=GAP+35+HT_LST ,l=GAP+WD_LST-70*1 ,w=70 ,cap=_('Close') ) ]) vals = dict( file=exp_file ,mcrs=(crt, sels) ) btn, \ vals, \ chds = dlg_wrapper(_('Export macros') ,GAP+WD_LST+GAP, GAP*5+HT_LST+25*2-GAP, cnts, vals, focus_cid='mrcs') if btn is None or btn=='-': return crt,sels= vals['mcrs'] pass; LOG and log('sels={}',sels) if False:pass elif btn=='brow': #ans_s=='file': new_exp_file= app.dlg_file(False, '', '', 'Cuda macros|*.cuda-macros') if new_exp_file is not None: exp_file = new_exp_file exp_file = exp_file+('' if ''==exp_file or exp_file.endswith('.cuda-macros') else '.cuda-macros') elif btn=='ch-a': #ans_s=='all': sels = ['1'] * lmcrs elif btn=='ch-n': #ans_s=='no': sels = ['0'] * lmcrs elif btn=='expo': #ans_s=='exp': if '1' not in sels: app.msg_box(_('Select some names'), app.MB_OK) continue self.export_to_file(exp_file, [mcr for (ind, mcr) in enumerate(self.macros) if sels[ind]=='1']) return
def saveAs(self): ''' Save cur session to new file ''' if not _checkAPI(): return sscur = app.app_path(app.APP_FILE_SESSION) sscur_save = app.app_proc(app.PROC_SAVE_SESSION, sscur) if sscur_save == False: return pass app.msg_status(sscur) (ssdir, ssfname) = os.path.split(sscur) ssfname = ssfname.replace('.json', '') ssnew = app.dlg_file(is_open=False, filters=DLG_CUD_FILTER, init_filename=ssfname, init_dir=ssdir) pass app.msg_status(str(ssnew)) if ssnew is None: return ssnew = apx.icase(False, '', ssnew.endswith(CDSESS_EXT), ssnew, os.path.isfile(ssnew), ssnew, True, ssnew + CDSESS_EXT) if os.path.normpath(sscur) == os.path.normpath(ssnew): return # app.app_proc(app.PROC_SAVE_SESSION, sscur) app.app_proc(app.PROC_SAVE_SESSION, ssnew) app.app_proc(app.PROC_SET_SESSION, ssnew) app.msg_status(SAVED.format(stem=juststem(ssnew))) self.top_sess(ssnew)
def dlg_import_choose_mcrs(self): l,lt = '\n', '\n ' while True: imp_file= app.dlg_file(True, '', '', 'Cuda macros|*.cuda-macros|All file|*.*') if imp_file is None: return (None, None) vers_mcrs = apx._json_loads(open(imp_file).read()) if vers_mcrs is None: if app.ID_OK != app.msg_box('No macros in file\n '+imp_file+'\n\nChoose another file?' ,app.MB_OKCANCEL): return (None, None) continue #while vers = vers_mcrs.get('vers', {}) if (app.app_api_version() < vers.get('ver-api', app.app_api_version()) and app.ID_OK != app.msg_box( 'Macros from' +lt+imp_file +l+ 'are recorded in CudaText with version' +lt+ '"{}"' +l+ 'Your CudaText has older version' +lt+ '"{}"' +l+ '' +l+ 'No guarantee of correct working!' +l+ '' +l+ 'Continue import?'.format(vers['ver-app'], app.app_exe_version()) , app.MB_OKCANCEL)): return (None, None) mcrs = vers_mcrs.get('macros', []) if 0!=len(mcrs): break #while if app.ID_OK != app.msg_box('No macros in file\n '+imp_file+'\n\nChoose another file?' ,app.MB_OKCANCEL): return (None, None) #while True: return (imp_file, mcrs)
def dlg_import_choose_mcrs(self): l, lt = '\n', '\n ' while True: imp_file = app.dlg_file(True, '', '', 'Cuda macros|*.cuda-macros|All file|*.*') if imp_file is None: return (None, None) vers_mcrs = apx._json_loads(open(imp_file).read()) if vers_mcrs is None: if app.ID_OK != app.msg_box( 'No macros in file\n ' + imp_file + '\n\nChoose another file?', app.MB_OKCANCEL): return (None, None) continue #while vers = vers_mcrs.get('vers', {}) if (app.app_api_version() < vers.get('ver-api', app.app_api_version()) and app.ID_OK != app.msg_box( 'Macros from' + lt + imp_file + l + 'are recorded in CudaText with version' + lt + '"{}"' + l + 'Your CudaText has older version' + lt + '"{}"' + l + '' + l + 'No guarantee of correct working!' + l + '' + l + 'Continue import?'.format( vers['ver-app'], app.app_exe_version()), app.MB_OKCANCEL)): return (None, None) mcrs = vers_mcrs.get('macros', []) if 0 != len(mcrs): break #while if app.ID_OK != app.msg_box( 'No macros in file\n ' + imp_file + '\n\nChoose another file?', app.MB_OKCANCEL): return (None, None) #while True: return (imp_file, mcrs)
def saveAs(self): ''' Save cur session to new file ''' if not _checkAPI(): return sscur = app.app_path(app.APP_FILE_SESSION) pass; app.msg_status(sscur) (ssdir ,ssfname) = os.path.split(sscur) ssfname = ssfname.replace('.json', '') ssnew = app.dlg_file(is_open=False, filters=DLG_CUD_FILTER , init_filename=ssfname , init_dir= ssdir ) pass; app.msg_status(str(ssnew)) if ssnew is None: return ssnew = apx.icase(False,'' , ssnew.endswith(CDSESS_EXT) , ssnew , os.path.isfile(ssnew) , ssnew , True , ssnew+CDSESS_EXT ) if os.path.normpath(sscur)==os.path.normpath(ssnew): return app.app_proc(app.PROC_SAVE_SESSION, sscur) app.app_proc(app.PROC_SAVE_SESSION, ssnew) app.app_proc(app.PROC_SET_SESSION, ssnew) app.msg_status(SAVED.format(stem=juststem(ssnew))) self.top_sess(ssnew)
def open(self, ssnew=None): ''' Open new session from file ssnew or after user asking ''' if not _checkAPI(): return # in_dir = app.app_path(app.APP_DIR_DATA) sscur = app.app_path(app.APP_FILE_SESSION) if ssnew is None: ssnew = app.dlg_file(is_open=True, filters=DLG_ALL_FILTER , init_filename='!' # '!' to disable check "filename exists" , init_dir= '' ) if ssnew is None: return if ssnew.endswith(SWSESS_EXT) and os.path.isfile(ssnew): # Import from Syn sssyn = ssnew sscud = ssnew[:-len(SWSESS_EXT)]+CDSESS_EXT if os.path.isfile(sscud): sscud = app.dlg_file(is_open=False, filters=DLG_CUD_FILTER , init_filename=os.path.basename(sscud) , init_dir= os.path.dirname( sscud) ) if not sscud: return if not import_syn_sess(sssyn, sscud): return ssnew = sscud ssnew = apx.icase(False,'' , ssnew.endswith(CDSESS_EXT) , ssnew , os.path.isfile(ssnew) , ssnew , True , ssnew+CDSESS_EXT ) if os.path.isfile(ssnew): # Open app.app_proc(app.PROC_SAVE_SESSION, sscur) app.app_proc(app.PROC_LOAD_SESSION, ssnew) app.app_proc(app.PROC_SET_SESSION, ssnew) app.msg_status(OPENED.format(stem=juststem(ssnew))) self.top_sess(ssnew) else: # New if app.ID_NO==app.msg_box(CREATE_ASK.format(stem=juststem(ssnew)), app.MB_YESNO): return app.app_proc(app.PROC_SAVE_SESSION, sscur) app.ed.cmd(cmds.cmd_FileCloseAll) app.app_proc(app.PROC_SET_SESSION, ssnew) app.app_proc(app.PROC_SAVE_SESSION, ssnew) app.msg_status(CREATED.format(stem=juststem(ssnew))) self.top_sess(ssnew)
def compare_with(self): fn0 = ct.ed.get_filename() if not fn0: ct.msg_status('Cannot compare untitled document') return if ct.ed.get_prop(ct.PROP_MODIFIED): ct.msg_status('Cannot compare modified document, save it first') return fn = ct.dlg_file(True, '!', '', '') if not fn: return self.set_files(fn0, fn)
def save_and_open(path): fvdata['fv_tab'] = tabs fvdata['fv_files'] = files fvdata['fv_projs'] = projs fvdata['fv_fold' ] = fold fvdata['fv_last' ] = last save_fav_data(fvdata) if os.path.isdir( path): path= app.dlg_file(True, '', path, '') if not path: return False app.file_open(path) return True
def select_env(): items = list(jedi.find_system_environments()) names = [repr(i).replace('Environment:', 'Python') for i in items] names.append('Other...') i = ct.dlg_menu(ct.MENU_LIST, names, caption='Select Python interpreter') if i is None: return elif i == len(names) - 1: filters = 'Executables|*.exe' if IS_NT else '' fn = ct.dlg_file(True, '!', '', filters) if not fn: return else: fn = items[i].executable env = create_env(fn) if env: ct.ini_write(cfg_file, cfg_section, cfg_opt_env, fn) return env
def dlg_export(self): ''' Show dlg for export some macros. ''' if app.app_api_version()<FROM_API_VERSION: return app.msg_status('Need update CudaText') if 0==len(self.macros): return app.msg_status('No macros for export') exp_file= app.dlg_file(False, '', '', 'Cuda macros|*.cuda-macros') exp_file= '' if exp_file is None else exp_file exp_file= exp_file+('' if ''==exp_file or exp_file.endswith('.cuda-macros') else '.cuda-macros') (WD_LST ,HT_LST)= (500 ,500) lmcrs = len(self.macros) crt,sels= '0', ['0'] * lmcrs while True: pass; LOG and log('sels={}',sels) ans = app.dlg_custom('Export macros' ,GAP+WD_LST+GAP, GAP*5+HT_LST+25*2, '\n'.join([] +[C1.join(['type=label' ,POS_FMT(l=GAP, t=GAP+3, r=GAP+70, b=0) ,'cap=Export &to' ] # i=0 )] +[C1.join(['type=edit' ,POS_FMT(l=GAP+70, t=GAP, r=GAP+WD_LST-35,b=0) ,'val={}'.format(exp_file) ] # i=1 )] +[C1.join(['type=button' ,POS_FMT(l=GAP+HT_LST-35, t=GAP-2, r=GAP+WD_LST, b=0) ,'cap=&...' ] # i=2 )] +[C1.join(['type=checklistbox' ,POS_FMT(l=GAP, t=GAP*2+30, r=GAP+WD_LST, b=GAP+25+HT_LST) ,'items=' +'\t'.join([mcr['nm'] for mcr in self.macros]) ,'val=' + crt+';'+','.join(sels) ] # i=3 )] +[C1.join(['type=button' ,POS_FMT(l=GAP*1, t=GAP*3+25+HT_LST, r=GAP*1+80*1, b=0) ,'cap=Check &all' ] # i=4 )] +[C1.join(['type=button' ,POS_FMT(l=GAP*2+80, t=GAP*3+25+HT_LST, r=GAP*2+80*2, b=0) ,'cap=U&ncheck all' ] # i=5 )] +[C1.join(['type=button' ,POS_FMT(l= WD_LST-60*2, t=GAP*3+25+HT_LST, r= WD_LST-60*1, b=0) ,'cap=&Export' ] # i=6 )] +[C1.join(['type=button' ,POS_FMT(l=GAP+WD_LST-60*1, t=GAP*3+25+HT_LST, r=GAP+WD_LST-60*0, b=0) ,'cap=&Close' ] # i=7 )] ), 3) # start focus pass; LOG and log('ans={}',ans) if ans is None: break #while (ans_i ,vals) = ans ans_s = apx.icase(False,'' ,ans_i==2, 'file' ,ans_i==4, 'all' ,ans_i==5, 'no' ,ans_i==6, 'exp' ,ans_i==7, 'close' ) if ans_s=='close': break #while v_3 = vals.splitlines()[3] crt,sels= v_3.split(';') sels = sels.strip(',').split(',') pass; LOG and log('sels={}',sels) if False:pass elif ans_s=='file': new_exp_file= app.dlg_file(False, '', '', 'Cuda macros|*.cuda-macros') if new_exp_file is not None: exp_file = new_exp_file exp_file = exp_file+('' if ''==exp_file or exp_file.endswith('.cuda-macros') else '.cuda-macros') elif ans_s=='all': sels = ['1'] * lmcrs elif ans_s=='no': sels = ['0'] * lmcrs elif ans_s=='exp': if '1' not in sels: app.msg_box('Select some names', app.MB_OK) continue self.export_to_file(exp_file, [mcr for (ind, mcr) in enumerate(self.macros) if sels[ind]=='1']) return
def dlg(self): if app.app_api_version()<'1.0.146': return app.msg_status(_("Need update CudaText")) # dlg_custom: "type=tabs" pass; #LOG and log('=',()) fvdata = get_fav_data() tab_nms = fvdata.get('fv_tabs', [_('Fi&les'), _('Pro&jects')]) tabs = fvdata.get('fv_tab', 0) files = fvdata.get('fv_files', []) projs = fvdata.get('fv_projs', []) fold = fvdata.get('fv_fold', True) last = fvdata.get('fv_last', 0) fvrs_h = _('Choose file to open.') brow_h = _('Choose file to append.' '\r Shift+Click to choose folder' ) def n2c(n): if 1<=n<=10: return str(n%10) if 11<=n<=11+ord('Z')-ord('A'): return chr(n-11+ord('A')) return ' ' while True: paths = files if tabs==0 else projs last = min(max(0, last), len(paths)-1) hasf = bool(paths) itms = [f('{}: {}{}' , n2c(1+nf) , os.path.basename(fn) if os.path.isfile(fn) else '['+os.path.basename(fn)+']' if os.path.isdir(fn) else '? '+os.path.basename(fn) , ' ('+os.path.dirname(fn)+')' if fold else '' ) for nf,fn in enumerate(paths)] itms = itms if itms else [' '] aid,vals,chds = dlg_wrapper(_('Favorites'), 500+10,300+10, [ # dict( tp='lb' ,t=5 ,l=5 ,w=400 ,cap=_('&Files:') ,hint=fvrs_h ) # &f dict(cid='tabs',tp='tabs' ,t=5,h=30 ,l=5 ,w=400-3 ,items=tab_nms ,act='1' ) # ,dict(cid='fvrs',tp='lbx' ,t=5+23,h=240 ,l=5 ,w=400-5 ,items=itms ,en=hasf) ,dict(cid='open',tp='bt' ,t=5+20 ,l=5+400 ,w=100 ,cap=_('&Open') ,props='1' ,en=hasf) # default ,dict(cid='addc',tp='bt' ,t=5+65 ,l=5+400 ,w=100 ,cap=_('&Add opened') ,en=(tabs==0)) # &a ,dict(cid='brow',tp='bt' ,t=5+90 ,l=5+400 ,w=100 ,cap=_('Add&...') ,hint=brow_h ) # &. ,dict(cid='delt',tp='bt' ,t=5+135 ,l=5+400 ,w=100 ,cap=_('&Delete') ,en=hasf) # &d ,dict(cid='fvup',tp='bt' ,t=5+180 ,l=5+400 ,w=100 ,cap=_('Move &up') ,en=hasf) # &u ,dict(cid='fvdn',tp='bt' ,t=5+205 ,l=5+400 ,w=100 ,cap=_('Move do&wn') ,en=hasf) # &w ,dict(cid='fold',tp='ch' ,tid='-' ,l=5 ,w=120 ,cap=_('Show &paths') ,act='1' ) # &p ,dict(cid='help',tp='bt' ,t=5+300-53 ,l=5+500-100 ,w=100 ,cap=_('&Help') ) # &h ,dict(cid='-' ,tp='bt' ,t=5+300-28 ,l=5+500-100 ,w=100 ,cap=_('Close') ) ]+ [dict(cid='act'+str(n),tp='bt',cap='&'+str((n+1)%10),t=0,l=0,w=0) for n in range(10)] # &1 - &0 , dict(fvrs=last ,tabs=tabs ,fold=fold), focus_cid='fvrs') if aid is None or aid=='-': return None scam = app.app_proc(app.PROC_GET_KEYSTATE, '') if aid=='help': dlg_wrapper(_('Help for "Favorites"'), 410, 310, [dict(cid='htxt',tp='me' ,t=5 ,h=300-28,l=5 ,w=400 ,props='1,0,1' ) # ro,mono,border ,dict(cid='-' ,tp='bt' ,t=5+300-23 ,l=5+400-80 ,w=80 ,cap=_('&Close')) ], dict(htxt=_( '• Quick opening.' '\rUse Alt+1, Alt+2, ..., Alt+9, Alt+0' '\rto direct open file' '\r"1: *", "2: *",..., "9: *", "0: *"' '\r ' '\r• Import. ' '\rSelect "SynFav.ini" for "Add..." to import Favorites from SynWrite.' '\rSee "SynFav.ini" in folder "SynWrite/Settings".' ) ), focus_cid='htxt') continue#while fold = vals['fold'] last = vals['fvrs'] tabs = vals['tabs'] def save_and_open(path): fvdata['fv_tab'] = tabs fvdata['fv_files'] = files fvdata['fv_projs'] = projs fvdata['fv_fold' ] = fold fvdata['fv_last' ] = last save_fav_data(fvdata) if os.path.isdir( path): path= app.dlg_file(True, '', path, '') if not path: return False app.file_open(path) return True #def save_and_open if aid=='open' and paths and last>=0: if save_and_open(paths[last]): break#while if aid[0:3]=='act' and paths: nf = int(aid[3]) if nf<len(paths) and save_and_open(paths[nf]): break#while if aid=='tabs': pass; #LOG and log('tabs={}',(tabs)) continue#while # Modify store_b = 'fold' in chds if False:pass elif aid=='addc': fn = ed.get_filename() if fn and not any([os.path.samefile(fn, f) for f in paths]): paths += [fn] store_b = True # elif aid=='brow' and scam=='s': # # Ask dir # dr = dlg_dir('') # if dr elif aid=='brow': # Ask file fn = app.dlg_dir('') if scam=='s' else app.dlg_file(True, '', '', '') if fn and os.path.basename(fn).upper()=='SynFav.ini'.upper(): store_b = import_SynFav(fn, paths) elif fn and not any([os.path.samefile(fn, f) for f in paths]): paths += [fn] store_b = True elif aid=='delt' and paths and last>=0: del paths[last] last = min(max(0, last), len(paths)-1) store_b = True elif aid in ('fvup', 'fvdn') and paths: newp = last + (-1 if aid=='fvup' else +1) if 0<=newp<len(paths): paths[last], paths[newp] = paths[newp], paths[last] last = newp store_b = True # Store if store_b: fvdata['fv_tab'] = tabs fvdata['fv_files'] = files fvdata['fv_projs'] = projs fvdata['fv_fold' ] = fold fvdata['fv_last' ] = last save_fav_data(fvdata)
def dlg_export(self): ''' Show dlg for export some macros. ''' if app.app_api_version() < FROM_API_VERSION: return app.msg_status('Need update CudaText') if 0 == len(self.macros): return app.msg_status('No macros for export') exp_file = app.dlg_file(False, '', '', 'Cuda macros|*.cuda-macros') exp_file = '' if exp_file is None else exp_file exp_file = exp_file + ('' if '' == exp_file or exp_file.endswith('.cuda-macros') else '.cuda-macros') (WD_LST, HT_LST) = (500, 500) lmcrs = len(self.macros) crt, sels = '0', ['0'] * lmcrs while True: pass LOG and log('sels={}', sels) ans = app.dlg_custom( 'Export macros', GAP + WD_LST + GAP, GAP * 5 + HT_LST + 25 * 2, '\n'.join([] + [ C1.join([ 'type=label', POS_FMT(l=GAP, t=GAP + 3, r=GAP + 70, b=0), 'cap=Export &to' ] # i=0 ) ] + [ C1.join([ 'type=edit', POS_FMT(l=GAP + 70, t=GAP, r=GAP + WD_LST - 35, b=0), 'val={}'.format(exp_file) ] # i=1 ) ] + [ C1.join([ 'type=button', POS_FMT(l=GAP + HT_LST - 35, t=GAP - 2, r=GAP + WD_LST, b=0), 'cap=&...' ] # i=2 ) ] + [ C1.join([ 'type=checklistbox', POS_FMT(l=GAP, t=GAP * 2 + 30, r=GAP + WD_LST, b=GAP + 25 + HT_LST), 'items=' + '\t'.join([mcr['nm'] for mcr in self.macros]), 'val=' + crt + ';' + ','.join(sels) ] # i=3 ) ] + [ C1.join([ 'type=button', POS_FMT(l=GAP * 1, t=GAP * 3 + 25 + HT_LST, r=GAP * 1 + 80 * 1, b=0), 'cap=Check &all' ] # i=4 ) ] + [ C1.join([ 'type=button', POS_FMT(l=GAP * 2 + 80, t=GAP * 3 + 25 + HT_LST, r=GAP * 2 + 80 * 2, b=0), 'cap=U&ncheck all' ] # i=5 ) ] + [ C1.join([ 'type=button', POS_FMT(l=WD_LST - 60 * 2, t=GAP * 3 + 25 + HT_LST, r=WD_LST - 60 * 1, b=0), 'cap=&Export' ] # i=6 ) ] + [ C1.join([ 'type=button', POS_FMT(l=GAP + WD_LST - 60 * 1, t=GAP * 3 + 25 + HT_LST, r=GAP + WD_LST - 60 * 0, b=0), 'cap=&Close' ] # i=7 ) ]), 3) # start focus pass LOG and log('ans={}', ans) if ans is None: break #while (ans_i, vals) = ans ans_s = apx.icase(False, '', ans_i == 2, 'file', ans_i == 4, 'all', ans_i == 5, 'no', ans_i == 6, 'exp', ans_i == 7, 'close') if ans_s == 'close': break #while v_3 = vals.splitlines()[3] crt, sels = v_3.split(';') sels = sels.strip(',').split(',') pass LOG and log('sels={}', sels) if False: pass elif ans_s == 'file': new_exp_file = app.dlg_file(False, '', '', 'Cuda macros|*.cuda-macros') if new_exp_file is not None: exp_file = new_exp_file exp_file = exp_file + ('' if '' == exp_file or exp_file.endswith('.cuda-macros') else '.cuda-macros') elif ans_s == 'all': sels = ['1'] * lmcrs elif ans_s == 'no': sels = ['0'] * lmcrs elif ans_s == 'exp': if '1' not in sels: app.msg_box('Select some names', app.MB_OK) continue self.export_to_file(exp_file, [ mcr for (ind, mcr) in enumerate(self.macros) if sels[ind] == '1' ]) return
def open_2_file(self, id_dlg, id_ctl, data='', info=''): f = ct.dlg_file(True, '', '', '') ct.dlg_proc(self.h, ct.DLG_CTL_PROP_SET, name='f2_combo', prop={'val': f})