def listTut(): print (''' +++++++++++++++++++++++++++++++++++ ++++++ Available Tutorials +++++ +++++++++++++++++++++++++++++++++++ ''') # check for empty list if len(tutList) == 0: title = 'No tutorials found.' msg = 'No tutorials found. Did you fetch?\nTry fetching afresh.' print msg eg.msgbox(msg, title, image=imgErr) return # do the thing dispList = [] print 'ID Title' for idx, tut in enumerate(tutList): dispList.append( ' '.join( (str(x).rjust(2), tut.getInfo().encode('ascii', 'ignore')) ) ) print dispList[-1] title = 'Available Tutorials' msg = 'This is the list of available tutorials.\n(Note the ID for custom downloads)' text = '\n'.join(dispList) eg.textbox(msg, title, text)
def relatorio_projeto(): projetos = [x.titulo for x in MProjeto.select().order_by(MProjeto.titulo)] msg = "Selecione o projeto para gerar o relatório." title = "Relatório - Projeto" projeto = choicebox(msg, title, projetos) if projeto == None: return projeto = MProjeto.get(MProjeto.titulo == projeto) relatorio = "Titulo: " + projeto.titulo + "\n\n" relatorio += "Coordenador: " + projeto.coordenador + "\n\n" relatorio += "Resumo: " + projeto.resumo + "\n\n" relatorio += "Palavras-chave: " + projeto.keywords + "\n\n" participantes = [ x.participante for x in MParticipante.select() .where(MParticipante.projeto == projeto.titulo) .order_by(MParticipante.participante) ] if participantes: relatorio += "Participantes: \n" for i in participantes: relatorio += i + "\n" relatorio += "\n\n" textbox("Relatório de Projeto", "Relatorio - Projeto", (relatorio)) return
def main2(jso): for short_name, details in jso["formattedResults"]["ruleResults"].items(): full_name = details["localizedRuleName"] score = details["ruleScore"] impact = details["ruleImpact"] # if score == 100: # continue print "\n%s (%d)" % (full_name, score) if "urlBlocks" in details: for index, block in enumerate(details["urlBlocks"]): header = block["header"] summary = header["format"] if not "args" in header: print summary else: for index, arg in enumerate(header["args"]): summary = summary.replace("$%d" % (index + 1), arg["value"]) print summary if not "urls" in block: continue for index, url in enumerate(block["urls"]): message = url["result"]["format"] for index, arg in enumerate(url["result"]["args"]): message = message.replace("$%d" % (index + 1), arg["value"]) print " - %s " % message eg.textbox(msg='', title=' ', text='Wep site title : %s\n Web site score : %s' %(full_name, score), codebox=0) return
def view(self): easygui.textbox(title="Chat Log", text=[str(entry) + "\n" for entry in self.world.chat_log.view()]) msg = easygui.enterbox("Chat Msg") if msg and len(msg) > 0: return self.redirect_result(ChatPostAction(msg)) else: return self.redirect_result(PortViewAction())
def search(input_cid,level): box = 0 if cid.data.has_key(input_cid): box = cid.data[input_cid] else: easygui.msgbox("没有查找到此ID!") choose() return ans = [] if box.has_key('itemSetInfo'): ans.extend(itemSetInfo(box['itemSetInfo'][0],level)) if box.has_key('itemBoxInfo'): ans.extend(itemBoxInfo(box['itemBoxInfo'][0],level)) if box.has_key('needReMapBonusId'): if box['needReMapBonusId']: try: allBonus = bbmd.data[input_cid] for bonus in allBonus: tstr = "" if bonus.has_key('sex'): if bonus['sex'][0] == 1: tstr += "性别:男 " if bonus['sex'][0] == 2: tstr += "性别:女 " if bonus.has_key('school'): tstr += "门派:%s " % school[bonus['school'][0]] if bonus.has_key('bodyType'): try: tstr += "体形:%d" % bonus['bodyType'] except TypeError: pass ans.append(tstr) if bonus.has_key('bonusBoxId'): ans.extend(itemBoxInfo(bonus['bonusBoxId'],level)) except KeyError: easygui.msgbox("特殊宝箱数据内没有此数据!") str = "" for a in range(0,ans.__len__()): # ans[a] = ans[a].encode("utf-8","ignore") str += ans[a]+"\n" boxname = id.data[input_cid]['name'] title = "默认全等级结果" if level != -1: title = "人物为%d级时结果" % level if cid.data.has_key(input_cid) and cid.data[input_cid].has_key('useLimit'): boxname += "(使用间隔为 %s ,使用次数为 %d 次)" % (limitInterval[cid.data[input_cid]['useLimit'][0][0]],cid.data[input_cid]['useLimit'][0][1]) easygui.textbox("编号为%d,名字为 %s 的物品宝箱查询到以下结果" % (input_cid,boxname),title,str,codebox=1) choose()
def listAll(data): names = data.keys() names.sort() text = [] for title in names: text.append("%s %s" %(title.strip(), " [%d]" %data[title].year if data[title].year else '' ) ) easygui.textbox(msg="All Movies", title=PROGRAM_TITLE, text=text)
def GuiHashRange(): """ Retrieve records with a given range when database type is hash. Just a proof of concept, doesn't return anything readable or write to the answer file yet, but it does work. """ # Take input values msg = "Please enter the range search key values." title = "Ranged Search" fieldNames = ["Lower Bound", "Upper Bound"] fieldValues = [] fieldValues = eg.multenterbox(msg, title, fieldNames) if fieldValues == None: eg.msgbox('Operation cancelled') return lowerKey = fieldValues[0] upperKey = fieldValues[1] # Check that lower key < upper key. if upperKey <= lowerKey: eg.msgbox("Error! Upper bound must be larger than lower bound.") return # Change the key from string to bytes: lowbyte_key = lowerKey.encode('utf-8') upperbyte_key = upperKey.encode('utf-8') current = cur.first() # Iterate through the database, taking time before and after resultlist = [] i = 0 time_before = time.time() while i < len(DATABASE): if lowbyte_key <= current[0] <= upperbyte_key: resultlist.append((current[0], current[1])) current = cur.next() i += 1 time_after = time.time() # Get time in microseconds runtime = (time_after - time_before) * 1000000 # Results found if (resultlist): for item in resultlist: answers.write(item[0].decode('utf-8')) answers.write('\n') answers.write(item[1].decode('utf-8')) answers.write('\n') answers.write('\n') else: text = ("No results found for the following key range:\n{}\n{}\nTime: {} microseconds".format(lowerKey, upperKey, runtime)) msg = "Results:" title = "Retrieve With Key" eg.textbox(msg, title, "Number of records: {} in {} microseconds\n{}".format(len(resultlist), runtime, resultlist))
def GuiRetrieveWithData(): """ Retrieve records with a given data """ msg = "Please enter the data you would like to search for" title = "Retrieve key with given data" searchdata = eg.enterbox(msg, title) if searchdata == None: eg.msgbox("Operation cancelled.") return # Change the data from string to bytes: bytes_data = searchdata.encode('utf-8') time_before = time.time() first = cur.first() data = first[1] i = 1 while data != bytes_data and i < len(DATABASE): next_record = cur.next() data = next_record[1] i += 1 if data == bytes_data: key = next_record[0] else: key = 0 time_after = time.time() # Get time in microseconds runtime = (time_after - time_before) * 1000000 # Results found if (key): # Open answers file. answers = open('answers','a') # Convert from bytes to a string. key = key.decode('utf-8') # Append to answers file. answers.write(key) answers.write('\n') answers.write(searchdata) answers.write('\n') answers.write('\n') text = ("Data input: \n{} \nKey value found: \n{} \nNumber of records retrieved: 1 \nTime: {} microseconds.".format(searchdata, key, runtime)) # No results else: text = ("No results found for the following data: \n{} \nNumber of records retrieved: 0 \nTime: {} microseconds".format(searchdata, runtime)) msg = "Results:" title = "Retrieve With Data" eg.textbox(msg, title, text)
def show_data(): data = open("cal_data.txt", "r") easygui.textbox("Here is the data recorded so far:", "Get the data!", data) print(data) if easygui.ynbox("Do you want to enter more information?", "Get the data!"): input_data() else: pass
def show_unlock_msg(msg): text = dedent(_get_xl_vb_project.__doc__) # try: # from tkinter import messagebox as msgbox # except ImportError: # import tkMessageBox as msgbox # msgbox.showinfo(title="Excel Permission Denied!", message=msg) easygui.textbox(title="Excel Permission Denied!", msg=msg, text=text) return msg
def _get_amino_acid_fasta(self): geneinfo = self.accumulated_data['geneinfo'] text = '>%s %s\n%s\n' %(geneinfo[0], geneinfo[9], geneinfo[11]) easygui.textbox(text=text) output_file = self._save_file_dialogs(extension="fasta") if output_file is not None: self._save_text(text, output_file) self._success_dialog(output_file) return True
def about(self): license = open('LICENSE', 'r').read() text = [ 'Version ' + self.version + ' by [email protected]\n', 'https://github.com/alex4108/scLikesDownloader\n', 'For support, please open an issue on GitHub @ https://github.com/alex4108/scLikesDownloader/issues/new\n', 'OR: Email, [email protected]', '\n', '\n', str(license) ] eg.textbox(msg="About SoundCloud Likes Downloader " + str(self.version), title=self.title, text=text) self.mainMenu()
def J8(): #Make any number into a palendrome. #URL: http://www.reddit.com/r/dailyprogrammer/comments/38yy9s/20150608_challenge_218_easy_making_numbers/ number=gui.enterbox(title=__name__,msg='Input a number and I will make it a palindrome') invnumber=int(number[::-1]) number=int(number) i=1 while True: number=invnumber+number invnumber=int(str(number)[::-1]) if invnumber==number: gui.textbox(title='Output',text=('It took '+str(i)+' iterations. Final #: '+number)) break i=i+1
def display(header, results): """Display header string and list of result lines """ try: import easygui except ImportError: #Print to console print 'EasyGUI not installed - printing output to console\n' print header print '-----------------' print '\n'.join(results) else: # Pop the stuff up in a text box title = 'Waveform properties' easygui.textbox(header, title, '\n'.join(results))
def __init__(self,*args): if not args: ip_address=easygui.textbox(msg='Enter ip address', title = 'ip') ip_address=ip_address[:-1] port=easygui.textbox(msg='Enter port number (32701)', title = 'port (32701)') port=port[:-1] port=int(port) else: ip_address=args[0] port=args[1] self.ip_address=ip_address self.port=port self.server_address = (ip_address, port)
def inputStory(): title = easygui.enterbox("Title of story:") url_title = "".join(char for char in title if char.isalnum()).lower() content = easygui.textbox().replace("\n", "<br>") content = wrapWithTag(title, "h1") + "\n\n" + wrapWithTag(DATE, "h3") + "\n<br><br>\n" + content return title, url_title, content
def GuiRetrieveWithKey(): """ Retrieve records with a given key. """ msg = "Please enter the key you wish to search for" title = "Retrieve data with given key" searchkey = eg.enterbox(msg, title) if searchkey == None: eg.msgbox("Operation cancelled.") return # >>>> Enable the following 2 lines for testing: <<<<<< # searchkey = Testing(1) # print (searchkey) # Change the key from string to bytes: bytes_key = searchkey.encode('utf-8') # Run the query, taking time before and after. time_before = time.time() data = cur.set(bytes_key) time_after = time.time() # Get time in microseconds runtime = (time_after - time_before) * 1000000 # Results found if (data): # Get the data portion of the <key,data> pair strdata = data[1] # Convert from bytes to a string. strdata = strdata.decode('utf-8') # Append to answers file. answers.write(searchkey) answers.write('\n') answers.write(strdata) answers.write('\n') answers.write('\n') text = ("Key input: \n{} \nData value found: \n{} \nNumber of records retrieved: 1 \nTime: {} microseconds.".format(searchkey, strdata, runtime)) # No results else: text = ("No results found for the following key: \n{} \nNumber of records retrieved: 0 \nTime: {} microseconds".format(searchkey, runtime)) msg = "Results:" title = "Retrieve With Key" eg.textbox(msg, title, text)
def _get_cluster_fasta(self, amino=True): r2c = self.accumulated_data['run_to_cluster'] clusterid = self._getClusterId() genelist = getGenesInCluster(self.accumulated_data['runid'], clusterid, self.sqlite_cursor) geneinfo = getGeneInfo(genelist, self.sqlite_cursor) if amino: idx = 11 else: idx = 10 text = '' for gi in geneinfo: text += '>%s %s\n%s\n'%(gi[0], gi[9], gi[idx]) easygui.textbox(text=text) output_file = self._save_file_dialogs(extension="fasta") if output_file is not None: self._save_text(text, output_file) self._success_dialog(output_file) return True
def _make_crude_tree(self, replacename = True): # Create tree and make human-readable. (nwk_file, nwk_fname) = self._createTemporaryFile(delete=True) cluster = self._getClusterId() if replacename: cmd = 'makeTabDelimitedRow.py %s %s | db_makeClusterAlignment.py -m mafft_linsi -n | Gblocks_wrapper.py | FastTreeMP -wag -gamma | db_replaceGeneNameWithAnnotation.py -a -o > %s 2> /dev/null' \ %(self.accumulated_data['runid'], cluster, nwk_fname) else: cmd = 'makeTabDelimitedRow.py %s %s | db_makeClusterAlignment.py -m mafft_linsi -n | Gblocks_wrapper.py | FastTreeMP -wag -gamma > %s 2> /dev/null' \ %(self.accumulated_data['runid'], cluster, nwk_fname) print cmd os.system(cmd) text = ''.join( [ line for line in nwk_file ] ) easygui.textbox(text=text) output_file = self._save_file_dialogs(extension="nwk") if output_file is not None: self._save_text(text, output_file) self._success_dialog(output_file) return True
def GuiIndexData(): """ Retrieve records with a given data """ msg = "Please enter the data you would like to search for" title = "Retrieve key with given data" searchdata = eg.enterbox(msg, title) if searchdata == None: eg.msgbox("Operation cancelled.") return # Change the data from string to bytes: bytes_data = searchdata.encode('utf-8') time_before = time.time() key = sec_cur.set(bytes_data) time_after = time.time() # Get time in microseconds runtime = (time_after - time_before) * 1000000 # Results found if (key): # Append to answers file. answers.write(key[1].decode('utf-8')) answers.write('\n') answers.write(key[0].decode('utf-8')) answers.write('\n') answers.write('\n') text = ("Data input: \n{} \nKey value found: \n{} \nNumber of records retrieved: 1 \nTime: {} microseconds.".format(key[1].decode('utf-8'), key[0].decode('utf-8'), runtime)) # No results else: text = ("No results found for the following data: \n{} \nNumber of records retrieved: 0 \nTime: {} microseconds".format(searchdata, runtime)) msg = "Results:" title = "Retrieve With Data" eg.textbox(msg, title, text)
def __init__(self,*args): if not args: # popup a windows and ask for it! path_to_watch=easygui.diropenbox() file_regex=easygui.textbox(msg='Enter Regular Expression', title = 'regex') file_regex=file_regex[:-1] else: path_to_watch=args[0] file_regex=args[1] # store it in the instance.. self.file_regex = file_regex self.path_to_watch = path_to_watch self.before = dict ([(f, None) for f in os.listdir (self.path_to_watch)])
def ShowSelectedSectionText(SectionChoice): """shows the text associated with the selected section""" section, sectionText = ConvertSectionToListOfLines(SectionChoice) title = "Beckman Research Application" msg = '' # for x in sectionText: # msg = msg + x + '\n' #eg.textbox('', title, sectionText,codebox=0) text = 'Last 100 letters of section for refrence:\n' + ''.join(section.text[-100:]) #get next section title global SECTIONS choice = SectionChoice[14:] #print('Choice: ' ,choice) for section in SECTIONS: counter = 0 if choice in section.title: index = SECTIONS.index(section) + 1 nextSectionTitle = SECTIONS[index].title text = text + '\nNext section title for ref in case section ending does not seem correct: ' \ + nextSectionTitle eg.textbox("", title, text, codebox=0)
if fieldValues[1]: for word in words: if not len(word)>int(fieldValues[1]): words.remove(word) if fieldValues[2]: for word in words: if word[0] != fieldValues[2]: words.remove(word) if fieldValues[3]: for word in words: if word[-1] != fieldValues[3]: words.remove(word) if fieldValues[4]: for word in words: if fieldValues[4] not in word: words.remove(word) f.close() eg.textbox("Generated words using letters '%s'" % fieldValues[0], "Anagram Results", words) msg = "Do you want to generate more anagrams?" title = "Please confirm" if eg.ccbox(msg, title): pass else: sys.exit(0)
soup = BeautifulSoup(urldata, "html5lib") # print "OK it's Working" print soup.title.string return soup.title.string except: print "Not resolving" return #title() try: load_time = s_loader(url, check) t = title(url) #eg.msgbox("Web page Speed test %s\n Site Title: %s" %(load_time, t)) #eg.exceptionbox(msg="You entered %s" % t,title="Web Page Speed v 1.0" ) eg.textbox(msg='', title=' ', text='Wep site title : %s\n Web site load speed : %s' %(t, load_time), codebox=0) except: title1 = title(url) # check again after 5 sec if it reaaly down print "can not check sleep for 8 sec 'n try again" sleep(8) try: print "try for second time Domain Error : %s" % (title1) load_time = s_loader(url, check) #suspended(url) except: sleep(10) try: print "try for the next time" load_time = s_loader(url, check) title()
try: if(assignment[0][-4:] == '.rar'): rarc = UnRAR2.RarFile(zip_file_path) rarc.extract('*', folder_path + '/' + cur_name + '_extracted', True, True) else: Archive(zip_file_path).extractall(folder_path + '/' + cur_name + '_extracted') report.append(cur_name + ": Is ready\n") print cur_name + ": Is ready\n" except Exception as inst: report.append(cur_name + ": Failed\n") print cur_name + ": Failed\n" #other files else: if(assignment[0][-4:] == 'docx'): notzip_file = folder_path + '/' + cur_name + '.docx' else: notzip_file = folder_path + '/' + cur_name + assignment[0][-4:] notzip = open(notzip_file, 'wb') notzip.write(page.content) notzip.close() report.append(cur_name + ": Is ready\n") print cur_name + ": Is ready\n" report.append("\n\nThank you for using edu_download_helper.\nFor bug reports or improvement ideas, please talk to your rakaz :)\n") easygui.textbox( msg = 'download report', title = 'edu_download_helper', text = report )
'''INPUT SCOPE''' scope = easygui.integerbox(msg="Enter estimated scope",title="Scope Input",default="",lowerbound=0,upperbound=999) if scope == None: #if user hits cancel break elif scope =="": easygui.msgbox(msg="Please enter a scope.",title="Enter a Scope",ok_button="OK") continue else: print 'Estimated Scope: '+str(scope) '''RUN FUNCTIONS''' #Convert Input Key to Coordinates coords = coordcalc(key) print 'Initial X,Y,modifiers: '+str(coords) xylist = plotter(coords,scope,imgdim) print 'Coordinates: '+str(xylist) #Read Pixels decodedtext = decoder(xylist,pix,scope) '''RETURN MESSAGE''' easygui.textbox(msg='Message:',title='Message',text=decodedtext,codebox=0) sys.exit(0) if imgpath == None: #if user hits cancel, quit sys.exit(0) elif choice == 'Quit': sys.exit(0)
def main(gen): if gen=='RS': while True: times=easygui.choicebox("What do you want to do?","Generating sentences: Choose an option",['Generate 1','Generate 10','Generate 20','Generate 50','Generate 100','Generate 200','Generate 500','Generate 1000','Generate 10000(Not recommended)','Generate Functions','Exit','View all generated this session','View all ever generated',]) if times=='Generate 1': times=1 elif times=='Generate 10': times=10 elif times=='Generate 20': times=20 elif times=='Generate 50': times=50 elif times=='Generate 100': times=100 elif times=='Generate 200': times=200 elif times=='Generate 500': times=500 elif times=='Generate 1000': times=1000 elif times=='Generate 10000(Not recommended)': times=10000 elif times=='View all generated this session': times='VA' elif times=='View all ever generated': times='VAG' elif times=='Generate Functions': main('VN') else: exit() stuffs='' if times=='e': exit() elif times=='VA': for i in range(len(save)): stuffs=stuffs+save[i-1]+'\n' elif times=='VAG': for i in range(len(saver1)): stuffs=stuffs+saver1[i][:-1]+'\n' else: for i in range(times): adjn=randint(0,len(adj)-1) adju=adj[adjn][0] nounn=randint(0,len(nouns)-1) nounu=nouns[nounn][0] artu=art[randint(0,1)] verbn=randint(0,len(verbs)-1) verbu=verbs[verbn][0] pron=randint(0,len(pro)-1) prou=pro[pron] advn=randint(0,len(adv)-1) advu=adv[advn] if verbs[verbn][1] == 'p': prep=True else: prep=False if prep==True: preu=pre[randint(0,len(pre)-1)] sentence=prou+' '+advu+' '+verbu+' '+preu+' '+artu+' '+adju+' '+nounu+'.' else: sentence=prou+' '+advu+' '+verbu+' '+artu+' '+adju+' '+nounu+'.' stuffs=stuffs+sentence+'\n' save.append(sentence) savef1.write(sentence+'\n') saver1.append(sentence) easygui.textbox('Your sentences:','The sentences',stuffs) else: while True: times=easygui.choicebox("What do you want to do?","Generating functions: Choose an option",['Generate 1','Generate 10','Generate 20','Generate 50','Generate 100','Generate 200','Generate 500','Generate 1000','Generate 10000(Not recommended)','Generate Sentences','Exit','View all generated this session','View all ever generated']) if times=='Generate 1': times=1 elif times=='Generate 10': times=10 elif times=='Generate 20': times=20 elif times=='Generate 50': times=50 elif times=='Generate 100': times=100 elif times=='Generate 200': times=200 elif times=='Generate 500': times=500 elif times=='Generate 1000': times=1000 elif times=='Generate 10000(Not recommended)': times=10000 elif times=='View all generated this session': times='VA' elif times=='View all ever generated': times='VAG' elif times=='Generate Sentences': main('RS') else: exit() stuffs='' if times=='e': exit() elif times=='VA': for i in range(len(save)): stuffs=stuffs+save[i-1]+'\n' elif times=='VAG': for i in range(len(saver)): stuffs==stuffs+saver[i][:-1]+'\n' else: for i in range(times): verb=verbVN[randint(0,len(verbVN)-1)] noun=nounVN[randint(0,len(nounVN)-1)] randomVN=verb + " " + noun save.append(randomVN) stuffs=stuffs+randomVN+'\n' savef.write(randomVN+'\n') saver.append(randomVN) easygui.textbox('Your functions:','The functions',stuffs)
def setup(): msg = ("Welcome to the new employee notification tool.\n" "The tool allows you to send customized automated emails " "that contain information about all ActiveDirectory users " "created within the last 24h.\n" "You will be asked several questions and config filters. " "Searches may take a few seconds to complete.\n" ) msg2 = ("\nPlease create a new filter or load an existing filter " "which you can then modify." ) cfgs = os.listdir(cfgdir) if len(cfgs)==0: msg2 = '' easygui.msgbox(msg,__app__) pick='New Config' else: pick = easygui.buttonbox(msg+msg2, __app__, ['New Config','Load Existing', 'Cancel']) if pick == 'Cancel': return False if pick != 'New Config': config = easygui.choicebox("Select an existing config:",__app__,cfgs) if not config: return False cfg = Settings(os.path.join(cfgdir,config)) cfg.restore else: config='' while config == '': config = easygui.enterbox('Saving this filter. Please enter a name for this notification.', __app__) if not config: sys.exit() config=config.replace(' ','_') if not config.endswith('.txt'): config=config+'.txt' cfg = Settings(os.path.join(cfgdir,config)) cfg.store() # persist the settings msg = ("Please select employee information you would like to filter.\n" "For example if you want to know about new staff in specific departments " "please pick 'Departments'. If you want to know about new users " "reporting to specific managers please pick 'Managers'. " "If you'd like to check for new users in specific Divisions and optionally " "filter by certain job titles please pick 'Divisions/Jobtitles'" ) choi = [ "Departments", "Managers", "Divisions/Jobtitles" ] choival = [ "department", "manager", "division" ] pick = easygui.buttonbox(msg, __app__, choi) if not pick: return False idx = choi.index(pick) cfg.filter1=getUserAttrList (choival[idx]) cfg.filter1_attr=choival[idx] cfg.filter1=easygui.multchoicebox(msg,"Select values from %s" % pick,cfg.filter1) if cfg.filter1_attr == 'division': alist=getUserAttrList ('title') filter2_attr='title' filter2=easygui.multchoicebox(msg,"Select values from 'Jobtitile'",alist) else: cfg.filter2_attr='' cfg.filter2='' msg = ("Please enter one or multiple email addresses (separated by comma) " "to which you want to send a notification when new users arrive" ) cfg.to = easygui.enterbox(msg, __app__,cfg.to) msg = ("Please enter the email body you want to use for your notification " "email. A list of new users will be added below this text." ) cfg.mailbody = easygui.textbox(msg, __app__, cfg.mailbody, codebox=False) msg = ("Optional: Please enter the command line of a script including full path " "and command options. This script will be executed when new users arrive.\n" "(Please leave this line empty to not execute anything.)" ) cfg.run = easygui.enterbox(msg, __app__,cfg.run) cfg.store() # persist the settings testdate='' out='' while True: if easygui.boolbox('Do you want to test this configuration (again) ?', __app__, ('Yes', 'No')): msg = ("If you want to test this config, please enter the creation date " "(format: YYYYMMDD) you would like to test." ) testdate = easygui.enterbox(msg, __app__,testdate) if not testdate: break if testdate != '': exe=getMyFile() try: out=subprocess.check_output( '"%s" --debug --search-date %s %s' % (exe,testdate,config), stderr=subprocess.STDOUT, shell=True) except : print "likely subproces CalledProcessError.output " easygui.codebox('Please see debugging output below:', __app__, out) else: break cmdline = '%s %s' % (getMyFile(),config) easygui.codebox('Please activate this command via cron:' , __app__,cmdline)
def textBox(self): g.textbox(self.msg3, self.title, self.text)
import easygui as g import os # 获得打开文件路径 file_path = g.fileopenbox(default='*.txt') with open(file_path) as old_file: # 获得文件名 title = os.path.basename(file_path) msg = '文件【%s】的内容如下:' % title text = old_file.read() # 显示窗体,传入文件头、文件名、文件内容,最后返回文件内容 text1 = g.textbox(msg, title, text) print(text1, text) # 模拟文件被修改 if text1 != text[:-1]: msg = '检测到文件内容发生改变,请选择以下操作:' tilte = '警告' # 选择框 choise = g.buttonbox(msg, title, choices=('保存', '放弃保存', '另保存...')) if choise == '保存': with open(file_path, 'w') as old_file: old_file.write(text1[:-1]) if choise == '放弃保存': pass if choise == '另保存...': another_path = g.filesavebox(default='*.txt') if os.path.splitext(another_path)[1] != '.txt': another_path += '.txt'
import easygui as g import os file_path = g.fileopenbox(default="*.txt") with open(file_path) as old_file: title = os.path.basename(file_path) msg = "文件【%s】的内容如下:" % title text = old_file.read() text_after = g.textbox(msg, title, text) if text != text_after[:-1]: # textbox 的返回值会追加一个换行符 choice = g.buttonbox("检测到文件内容发生改变,请选择以下操作:", "警告", ("覆盖保存", "放弃保存", "另存为...")) if choice == "覆盖保存": with open(file_path, "w") as old_file: old_file.write(text_after[:-1]) if choice == "放弃保存": pass if choice == "另存为...": another_path = g.filesavebox(default=".txt") if os.path.splitext(another_path)[1] != '.txt': another_path += '.txt' with open(another_path, "w") as new_file: new_file.write(text_after[:-1])
def inputMessage(): message = eg.textbox(msg="输入要生成的信息", title="输入") return message
def lessons_view_screen(curr, class_name): title = "Мененджер расписаний" msg = class_name easygui.textbox(msg, title, "\n".join([i + ": " + curr[i] for i in curr.keys()]))
def run(self): while self.player.hp > 0: text = "You are at {}.\n".format(self.room) monsterstext, monstercount = self.show_monsters() if monsterstext != "": text += "\nThese monsters are here:\n{}\n".format(monsterstext) boxestext = self.show_boxes() if boxestext != "": text += "\nThese boxes are here:\n" text += boxestext itemtext = self.show_items() if itemtext != "": text += "\n\nThese items are here:\n" text += itemtext rooms = [] if monstercount == 0: text += "\n\nWhere do you want to go?" rooms = Game.rooms[self.room] if boxestext != "": rooms.append("Open box") else: rooms.append("Fight") #rooms.append("Navi") rooms.extend(("Navi", "Inventory", "Equip/unequip")) status = "HP: {} XP: {}".format(self.player.hp, self.player.points) potions = [p for p in Game.items.values() if p.carrier == 1] status += " Potions: {}".format(len(potions)) command = easygui.buttonbox(text, title=status, choices=rooms) rooms.remove("Navi") rooms.remove("Inventory") rooms.remove("Equip/unequip") if "Fight" in rooms: rooms.remove("Fight") if "Open box" in rooms: rooms.remove("Open box") if command == "Navi": self.navi() continue if command == "Equip/unequip": self.equip() continue if command == "Fight": self.fight() continue if command == "Open box": self.riddle() continue if command == "Inventory": x = self.inventory() if x is None: continue if x in Game.items: if (Game.items[x].carrier is None and Game.items[x].room == self.room): # pick up item Game.items[x].room = None Game.items[x].carrier = self.player.number easygui.msgbox( "You have picked up an item. It is now in your inventory!" ) elif Game.items[x].carrier == self.player.number: Game.items[x].use() easygui.msgbox("You used an item!") for k in list(Game.items.keys()): if Game.items[k].destroyed: del Game.items[k] elif -x in Game.items: #print("found", -x) Game.items[-x].carrier = None Game.items[-x].room = self.room easygui.msgbox( "You have dropped an item. It is now on the floor!") continue if self.room not in self.explored: self.explored.append(self.room) self.room = command easygui.textbox("Game over!", text=Game.log)
# multenterbox(①如果用户输入的值比选项少,返回列表中的值用空字符串填充②如果用户输入的值比选项多,返回列表中的值将截断为选项的数量③如果用户取消操作,则返回域中的列表值或None值) list1 = ['用户名:', '密码:'] g.multenterbox('请输入用户名和密码', '登录', fields=(list1)) ## ## 用户输入密码(*********) # passwordbox g.passwordbox('请输入密码:') # multpasswordbox(最后一个输入框显示为*********) g.multpasswordbox('请输入用户名和密码', '登录', fields=(list1)) ## ## 显示文本 # textbox g.textbox('文件内容如下:', '显示文件内容', ['1\n', '2\n', '3\n']) g.textbox('文件内容如下:', '显示文件内容', text=open('C:\\Users\\DamienZ\\Desktop\\python练习\\文件读写操作例子.txt')) # codebox相当于textbox(codebox=1) g.codebox('文件内容如下:', '显示文件内容', ['1\n', '2\n', '3\n']) ## ## 目录与文件 # diropenbox(返回用户选择的目录名,带完整路径) g.diropenbox(default='C:\\') # fileopenbox(返回用户选择的文件名,带完整路径) g.fileopenbox(default='C:/Users/DamienZ/Desktop/python练习/*.py', filetypes=['*.py', ['*.txt', '*.py']])
return soup.title.string except: print "Not resolving" return #title() try: load_time = s_loader(url, check) t = title(url) #eg.msgbox("Web page Speed test %s\n Site Title: %s" %(load_time, t)) #eg.exceptionbox(msg="You entered %s" % t,title="Web Page Speed v 1.0" ) eg.textbox(msg='', title=' ', text='Wep site title : %s\n Web site load speed : %s' % (t, load_time), codebox=0) except: title1 = title(url) # check again after 5 sec if it reaaly down print "can not check sleep for 8 sec 'n try again" sleep(8) try: print "try for second time Domain Error : %s" % (title1) load_time = s_loader(url, check) #suspended(url) except: sleep(10) try: print "try for the next time"
__author__ = 'Robert' """ from: http://stackoverflow.com/questions/27393751/converting-text-to-binary-2-part-issue """ import sys sys.path.append('..') import easygui Plain = easygui.textbox(msg='Enter Message', title='OTP', text=u'Hi', codebox=1) print(repr(Plain)) #If there is no trailing newline, its OK
text = f.read().decode('gbk') print text f.close() return text def savefile(path, text): f = open(path, 'w') f.write(text.encode('gbk')) f.close() dir_path = g.fileopenbox('请选择文件', title='显示文件内容') text = openfile(dir_path) gtext = g.textbox(msg=u'文件[%s]内容如下:' % dir_path, title=u'显示文件内容', text=text, codebox=0) if text != gtext and gtext != None: gbutton = g.buttonbox(msg='检查到文件发生改变,请选择以下操作', title='警告', choices=['覆盖保存', '放弃保存', '另存为...']) if gbutton == '覆盖保存': savefile(dir_path, gtext) elif gbutton == '另存为...': gfilesave = g.filesavebox(msg='请输入保存文件名', title='文件另存为', default='*.txt') savefile(gfilesave, gtext)
print_mutliples(i, rows) gangestring += ("\n") def format_clock(cpu_time): print("Clock2 - Clock 1 = : " + str(cpu_time)) cpu_time = cpu_time * 1.0e4 print("CPU-time * 10 000 = " + str(cpu_time)) purge = cpu_time % 1.0 # This is where the magic happens :) print("This is behind the comma: " + str(purge)) cpu_time = cpu_time - purge print("This is what is left after the purge: " + str(cpu_time)) cpu_time = cpu_time / 10 print("This is in milliseconds: " + str(cpu_time)) return cpu_time gangestring = "" clock1 = time.clock() # Tidtaking punkt 1 print_gangetabell(inn_tall) clock2 = time.clock() # Tidtaking punkt 2 cpu_time = clock2 - clock1 tid = format_clock(cpu_time) cpu_timestring = ("CPU time " + (str(tid)) + " ms !") easygui.msgbox("Prosessoren brukte " + cpu_timestring, "MULTGANGETABELL") gangestring = easygui.textbox(gangestring)
def download(): # 选择模式 mode_list = [ '输入酷狗码', '根据歌曲名称下载', '根据哈希值下载', '导入文件批量下载', '转换utf-8为gbk', '更新cookies' ] mode = easygui.choicebox(msg='请选择下载模式', title='选择模式', choices=mode_list) if mode == '输入酷狗码': code = easygui.enterbox('请输入酷狗码', '输入酷狗码') code_return = kugou_code(code) # print(type(code_return)) if str(type(code_return)) == "<class 'list'>": # 写入数据 with open("数据/歌单列表.txt", "w", encoding="utf-8") as f: with open("数据/歌单哈希值列表.txt", "w") as d: num = 1 song_list = [] song_choice_list = [] for i in code_return: song_name = i['filename'] song_hash = i['hash'] f.write(song_name + '\n') d.write(song_hash + '\n') song_list.append(str(num) + ' ' + song_name) num += 1 song_choice_name = easygui.multchoicebox( msg='选择你要下载的歌曲(可多选,按Cancel退出下载操作)', title='选择歌曲', choices=song_list) if song_choice_name == None: pass else: for i in song_choice_name: song_choice_list.append(int(i.split(' ')[0]) - 1) lyrics_mode = easygui.boolbox(msg='是否需要一键下载全部歌词?', choices=['是', '否']) for i in song_choice_list: print( song_download.download_main( code_return[i]['hash'], lyrics_mode)) time.sleep(1) else: lyrics_mode = easygui.boolbox('是否下载歌词?', choices=['是', '否']) easygui.msgbox(msg=song_download.download_main( code_return, lyrics_mode), ok_button='继续') elif mode == '根据歌曲名称下载': song_name = easygui.enterbox(msg='请输入歌曲名称') song_name_json = song_download.download_name(song_name) i = 1 song_list = [] for song in song_name_json['data']['lists']: file_name = str(i) + ' ' + song['FileName'].replace( '<em>', '').replace('</em>', '').replace('<\\/em>', '') song_list.append(file_name) i += 1 num = int( easygui.choicebox(msg='请在以上结果中选择你要下载的歌曲', choices=song_list).split(" ")[0]) lyrics_mode = easygui.boolbox('是否下载歌词?', choices=['是', '否']) easygui.msgbox(msg=song_download.download_main( song_name_json['data']['lists'][num - 1]['FileHash'], lyrics_mode), ok_button='继续') elif mode == '根据哈希值下载': song_hash = easygui.enterbox(msg='输入哈希值', title='哈希值') lyrics_mode = easygui.boolbox('是否下载歌词?', choices=['是', '否']) song_download.download_main(song_hash, lyrics_mode) elif mode == '导入文件批量下载': with open('数据/歌单哈希值列表.txt', 'r') as f: song_hash_list = f.read().split() lyrics_mode = easygui.boolbox(msg='是否需要一键下载全部歌词?', choices=['是', '否']) for i in song_hash_list: print(song_download.download_main(i, lyrics_mode)) time.sleep(1) elif mode == '更新cookies': with open('数据/cookies.txt', 'r') as f: cookies_old = f.read() cookies = easygui.textbox( '输入cookies,可在浏览器酷狗音乐页面按f12寻找\n下面的是原来的cookies,请删除后更改', '更新cookies', cookies_old) if cookies: with open('数据/cookies.txt', 'w') as f: f.write(cookies) else_mode = easygui.choicebox(msg='本次操作已完成,是否进行其他操作', choices=['继续使用', '打开文件夹', '关闭程序']) if else_mode == '继续使用': # 循环调用 download() elif else_mode == '打开文件夹': os.system("explorer 音乐\n")
def getPost(): title = easygui.enterbox("Title", "UberShit blog updater") content = easygui.textbox("Content of blog post") return title, content
""" kursor.execute(pytanie) # wyłuskać nazwy kolumn z odpowiedzi do listy naglowek naglowek = [] for i in range(len(kursor.description)): naglowek.append( kursor.description[i][0] ) odpowiedz = kursor.fetchall() kursor.close() polaczenie.close() if easygui.ynbox('Odpowiedź otrzymano. Czy pokazać wyniki?', 'Zapytanie do bazy'): tekst = naglowek[0] + '\t' + naglowek[1] + '\t' + naglowek[2] + '\n' for wpis in odpowiedz: tekst += wpis[0]+'\t'+str(wpis[1])+'\t'+str(wpis[2])+'\n' easygui.textbox('Treść zapytania:\n' + pytanie, 'Wyniki', tekst) del(tekst) nazwapliku = easygui.filesavebox(None, 'Gdzie zapisać wyniki?', 'dane/*.txt') if nazwapliku: plik = open(nazwapliku, 'w') plik.write('# ' + naglowek[0] + '\t' + naglowek[1] + '\t' + naglowek[2] + '\n') for wpis in odpowiedz: plik.write(wpis[0].encode('utf-8')+'\t'+str(wpis[1])+'\t'+str(wpis[2])+'\n') plik.close() del(odpowiedz)
return self.sql def textBox(self): g.textbox(self.msg3, self.title, self.text) e = easyGui() m = pyMySQl.JsonDataFile() e.msgBox() e_sql = e.enterBox() m.writeSqlStatement() m.sql = e_sql m.closeDatabases() m.getData() m.jsonDataDict() with open(r"C:\Users\zhangyi\Desktop\json.txt", "w", encoding = "utf-8") as f: f.write(m.jsonData_dict) f.close() with open(r"C:\Users\zhangyi\Desktop\json.txt", "r", encoding = "utf-8") as f: json_msg = os.path.basename(r"C:\Users\zhangyi\Desktop\json.txt") msg = "文件【%s】的内容如下:" % json_msg text = f.read() g.textbox(msg, e.title, text) # select * from es_member where mobile = '15502043438';
import easygui as ui import os filename = ui.fileopenbox() with open(filename) as f: text = f.read() newtext = ui.textbox(msg='文件“' + os.path.split(filename)[1] + '”的内容如下:', text=text) choices = ['覆盖保存', '不保存', '另存为'] if text != newtext[:-1]: #textbox返回的文本 case = ui.buttonbox(msg='文件发生改变,是否要保存?', choices=choices) if case == choices[0]: with open(filename, 'w') as f: f.writelines(newtext) elif case == choices[2]: with open(ui.filesavebox(default='.txt'), 'w') as f: f.writelines(newtext) else: pass
def show_log(battles, vtext, log): if battles == 0: easygui.msgbox("no battles yet !") return # do nothing and return easygui.textbox(vtext, "combat log", log) # show box and return
import webbrowser import easygui as eg eg.msgbox( msg= "Tell me what you would like in a project and I shall search Google for you. This will trigger 3 pop up windows", title="InPIration", ok_button="Inspire Me!") things = [] suggestion = [] for i in range(3): things.append(eg.enterbox(msg="READY >>> ")) inspiration = str(things[0] + " " + things[1] + " " + things[2]) print(inspiration) #Debug for item in search(inspiration, tld="co.uk", num=3, stop=1, pause=2): print(item) suggestion.append(item) for i in range(len(suggestion)): links = "\n".join(suggestion[0:]) eg.textbox( msg= "Hey I found these that might be of interest, I'll open one at random after you close this message", text=links) webbrowser.open(choice(suggestion))
import easygui easygui.textbox('接收区','Net助手','')
def get_fst(name): syms = ofst.SymbolTable.read_text(FST_PATH + 'symbols.txt') fst = ofst.Fst.read(FST_PATH + name.lower() + '.fst') return fst, ofst.Compiler(isymbols=syms, osymbols=syms, acceptor=True), syms # In[74]: def run(input_string): matches = "" found = False for i in rules: match = transduce(get_fst(i), input_string) if '+' in match: return match.replace("^", "").replace("+", "") if found == False: return input_string # In[82]: a = easygui.enterbox(title="Enter intermediate form") if a != None: results = run(a) if len(results) > 0: easygui.textbox(text=results) else: easygui.textbox(text="No match!")
import datetime as d import time import easygui as g while True: time = tuple() time = d.datetime.now() year, month, day, hour, minute, second = time.year, time.month, time.day, time.hour, time.minute, time.second output = f"Year:{year} Month:{month} day:{day} Time: {hour}:{minute}:{second}" g.textbox(msg="time", title="time", text=output)
import atbash_encoder as ae import XOR_encoder as Xe answer = eg.buttonbox('What cipher you need today, sir?', choices=['Atbash', 'Caesar', 'XOR']) if answer == 'Caesar': caesar_mode = eg.buttonbox('Encrypt or decrypt', choices=['encrypt', 'decrypt']) if caesar_mode == 'encrypt': input_text = str(eg.enterbox('write some text pls')) shift = int(eg.enterbox('enter shift (0-25)')) encrypted_text = ce.encrypt(input_text, shift) eg.textbox('Encrypted text, sir', text=encrypted_text) else: input_text = str(eg.enterbox('enter text for decryption')) reverse_shift = int(eg.enterbox('enter shift (0-25)')) decrypted_text = ce.decrypt(input_text, reverse_shift) eg.textbox('Decrypted text, sir', text=decrypted_text) elif answer == 'Atbash': input_text = str(eg.enterbox('enter text for operation')) crypt_text = ae.crypt(input_text) eg.textbox('Crypted text, sir', text=crypt_text) else: input_text = str(