我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用tkMessageBox.showinfo()。
def print_info(self, object_name, object_type): if object_type == "AP": tkMessageBox.showinfo(Global_Access_Points[object_name].mssid, ( "Mac address: " + Global_Access_Points[object_name].mmac + "\nEncryption: " + Global_Access_Points[object_name].menc + "\nChannel: " + Global_Access_Points[object_name].mch + "\nVendor: " + Global_Access_Points[object_name].mven + "\nSignal strength: " + str(Global_Access_Points[object_name].msig) + "\nBeacons: " + str(Global_Access_Points[object_name].mbeacons)) ) else: tkMessageBox.showinfo("Client Info", ("Mac address: "+Global_Clients[object_name].mmac+ "\nAccess Point Mac: "+Global_Access_Points[Global_Clients[object_name].mbssid].mmac+ "\nNoise: "+str(Global_Clients[object_name].mnoise)+ "\nSignal Strength: "+str(Global_Clients[object_name].msig)+ "\nAccess Point Name: "+Global_Access_Points[Global_Clients[object_name].mbssid].mssid) ) print(object_name)
def execute(self, button): #print 'You clicked on', result if button in ('OK','Apply'): validation_passed = self.validate() if validation_passed: self.apply() self.changes_flag = True if button not in ('Apply',): if self.changes_flag: tkMessageBox.showinfo("Restart PyKeylogger", "You must restart PyKeylogger for " "the new settings to take effect.", parent=self.dialog.interior()) self.dialog.destroy() else: if button not in ('Apply','OK'): self.dialog.destroy()
def sdk_compile(plugin_dir): makefile_dir = plugin_dir + "/Debug/" print(makefile_dir) make_clean_process = subprocess.Popen(["make", "clean"], cwd=makefile_dir, stdout=subprocess.PIPE) while True: line = make_clean_process.stdout.readline() if line != "": print (line) else: break make_all_process = subprocess.Popen(["make", "all"], cwd=makefile_dir, stdout=subprocess.PIPE) while True: line = make_all_process.stdout.readline() if line != "": print (line) else: break plugin_built = check_if_sdk_file_built(plugin_dir) if not plugin_built: tkMessageBox.showinfo("Build result", "Build Failed") else: tkMessageBox.showinfo("Build result", "Build Successful")
def get_next_request(self): self.current_request = \ self.annotation_state.get_next_annotation_request() if self.current_request is None: tkMessageBox.showinfo("End of Document", "The end of the document has been reached. No more annotations are possible.") return predicted_counts = Counter(self.current_request.original_annotations) prediction_strings = [] for item, count in sorted( predicted_counts.items(), key=lambda e: (e[1], e[0])): prediction_strings.append("{} ({})".format(item, count)) self.prediction_string_value.set( "Predicted: " + ", ".join(prediction_strings)) self.present_token(self.current_request.token)
def connect(self): dial = GAsk(self.root) opt = dial.get() if not opt: return ip, port, nick = opt try: self.host.connect(ip, port, nick) self.running = True self.caller() except: showinfo('Information', 'Connection was refused !')
def extract(): try: print filename except NameError: tkMessageBox.showerror(title='File Selection', message='No PKG File Selected.') try: print outputFolder except NameError: global outputFolder outputFolder = os.path.dirname(filename) print outputFolder if sys.platform.__contains__("linux"): os.system("./pkg_dec '"+filename+"' '"+outputFolder+"/output'") os.remove("out.bin") tkMessageBox.showinfo(title='File Selection', message='Extraction Complete!') if sys.platform.__contains__("win"): os.system("pkg_dec.exe '"+filename+"' '"+outputFolder+"/output'") os.remove("out.bin") tkMessageBox.showinfo(title='File Selection', message='Extraction Complete!') sys.stdout.flush() openFolder(outputFolder + "/output")
def renewPressCommand(self): if self.debug: print "Action Track: renewPressCommand" seq = 0 new_dict = {} listLength = len(self.labelEntryList) delete_num = 0 for key in sorted(self.pressCommand): label = self.labelEntryList[seq].get() if len(label) > 0: new_dict[key] = label else: delete_num += 1 seq += 1 self.pressCommand = new_dict for idx in range(1, delete_num+1): self.labelEntryList[listLength-idx].delete(0,END) self.shortcutLabelList[listLength-idx].config(text="NON= ") with open(self.configFile, 'wb') as fp: pickle.dump(self.pressCommand, fp) self.setMapShow() tkMessageBox.showinfo("Remap Notification", "Shortcut map has been updated!\n\nConfigure file has been saved in File:" + self.configFile) ## show shortcut map
def _UpdateFirmwareCmd(self): q = tkMessageBox.showwarning('Update Fimware','Warning! Interrupting firmare update may lead to non functional PiJuice HAT.', parent=self.frame) if q: print 'Updating fimware' inputFile = '/usr/share/pijuice/data/firmware/PiJuice.elf.binary' curAdr = pijuice.config.interface.GetAddress() if curAdr: adr = format(curAdr, 'x') ret = 256 - subprocess.call(['pijuiceboot', adr, inputFile])#subprocess.call([os.getcwd() + '/stmboot', adr, inputFile]) print 'firm res', ret if ret == 256: tkMessageBox.showinfo('Firmware update', 'Finished succesfully!', parent=self.frame) else: errorStatus = self.firmUpdateErrors[ret] if ret < 11 else ' UNKNOWN' msg = '' if errorStatus == 'I2C_BUS_ACCESS_ERROR': msg = 'Check if I2C bus is enabled.' elif errorStatus == 'INPUT_FILE_OPEN_ERROR': msg = 'Firmware binary file might be missing or damaged.' elif errorStatus == 'STARTING_BOOTLOADER_ERROR': msg = 'Try to start bootloader manualy. Press and hold button SW3 while powering up RPI and PiJuice.' tkMessageBox.showerror('Firmware update failed', 'Reason: ' + errorStatus + '. ' + msg, parent=self.frame) else: tkMessageBox.showerror('Firmware update', 'Unknown pijuice I2C address', parent=self.frame)
def show_popup_message(self, popup_type="warning", title_to_show="ALLERT", message_to_show="THIS IS AN ALLERT MESSAGE", parent_window=None, refresh=True): """ Displays error or warning messages and refreshes the sequence window. """ # show_error_message # show_warning_message if parent_window == None: parent_window = self.main_window if popup_type == "error": tkMessageBox.showerror(title_to_show, message_to_show, parent=parent_window) elif popup_type == "info": tkMessageBox.showinfo(title_to_show, message_to_show, parent=parent_window) elif popup_type == "warning": tkMessageBox.showwarning(title_to_show, message_to_show, parent=parent_window) if refresh: self.gridder()
def run(self, ss): if not self.matrix.matrix == self.matrix.matrix_o: self.score = self.score + int(ss) self.m.set("Score:" + str(self.score)) if self.matrix.gamewin == True: self.matrix.draw() message = tkMessageBox.showinfo("??????????", "????: %d" % self.score) if message == 'ok': self.initial() else: self.matrix.void() self.matrix.generate() for i in range(0, 4): for j in range(0, 4): self.matrix.matrix_o[i][j] = self.matrix.matrix[i][j] self.matrix.draw() else: v = self.matrix.void() if v < 1: message = tkMessageBox.showinfo("???/(?o?)/~~", "????: %d" % self.score) if message == 'ok': self.initial()
def restore_config(self): config = SafeConfigParser() configpath = expanduser("~/.dockerproxy.conf") logging.debug("### Checking for config") if not os.path.isfile(configpath): tkMessageBox.showinfo("Error", "Config file does not exist") return config.read(configpath) # Assuming same for all httphandler = config.get('browser','httphandler') if self.DEBUG: logging.debug("### Setting original configuration") LSSetDefaultRoleHandlerForContentType("public.html", 0x00000002, httphandler) LSSetDefaultRoleHandlerForContentType("public.xhtml", 0x00000002, httphandler) LSSetDefaultHandlerForURLScheme("http", httphandler) LSSetDefaultHandlerForURLScheme("https", httphandler) sys.exit(0)
def notification(self, heading, message, icon=None, time=None, sound=None): """ notification(heading, message[, icon, time, sound])--Show a Notification alert. heading : string - dialog heading. message : string - dialog message. icon : [opt] string - icon to use. (default xbmcgui.NOTIFICATION_INFO) time : [opt] integer - time in milliseconds (default 5000) sound : [opt] bool - play notification sound (default True) Builtin Icons: - xbmcgui.NOTIFICATION_INFO - xbmcgui.NOTIFICATION_WARNING - xbmcgui.NOTIFICATION_ERROR example: - dialog = xbmcgui.Dialog() - dialog.notification('Movie Trailers', 'Finding Nemo download finished.', xbmcgui.NOTIFICATION_INFO, 5000) """ root = self.root tkMessageBox.showinfo('Notification', message, parent=root) root.destroy()
def ok(self, heading, line1, line2=None, line3=None): """Show a dialog 'OK'. heading: string or unicode - dialog heading. line1: string or unicode - line #1 text. line2: string or unicode - line #2 text. line3: string or unicode - line #3 text. Note: Returns True if 'Ok' was pressed, else False. Example: dialog = xbmcgui.Dialog() ok = dialog.ok('XBMC', 'There was an error.') """ root = self.root prompt = [elem for elem in [line1, line2, line3] if elem] message = '\n'.join(prompt) tkMessageBox.showinfo(heading, message, parent=root) root.destroy() return True
def showHelp(self): helpstr=''' %s\n\n - Export PDFs: Bulk export PDFs.\n - Extract highlights: Extract highlighted texts and output to txt files.\n - Extract notes: Extract notes and output to txt files.\n - Export .bib: Export meta-data and annotations to .bib files.\n - Export .ris: Export meta-data and annotations to .ris files.\n - For import to Zotero: Exported .bib and/or .ris files have suitable format to import to Zotero.\n - Save separately: If on, save each PDF's annotations to a separate txt.\n - Use custom annotation template: Use a custom template to format the exported annotations. See annotation_template.py for details. - See README.md for more info.\n ''' %self.title tkMessageBox.showinfo(title='Help', message=helpstr) #print(self.menfolder.get())
def btn_solve_on_click(self): if self.grp is None or self.img is None: tkMessageBox.showerror("Error", "Please load a maze first!") return self.perform_process(lambda: self.traverse_graph(), "Traversing graph...") self.perform_process(lambda: self.write_to_file(), "Writing to file...") tkMessageBox.showinfo("Info", "Solved the maze in " + str(self.steps) + " steps!\n" + "Path length:\t\t%d\n" % self.graph_traverser.path_length + "Graph loading time:\t\t%.5lfs\n" % self.exec_time + "Graph traverse time:\t\t%.5lfs\n" % (self.traverse_time_end - self.traverse_time_start) + "File writing time:\t\t%.5lfs\n" % (self.imgwrite_time_end - self.imgwrite_time_start) + "Total execution time:\t\t%.5lfs" % (self.exec_time + (self.imgwrite_time_end - self.traverse_time_start)) ) if self.show_solution.get() == True: # Showing solution in new window if sys.platform.startswith('linux'): subprocess.call(["xdg-open", self.output_path]) else: os.startfile(self.output_path)
def show_help(self): tkMessageBox.showinfo("Info", "This is a simple program that takes maze input in form of " + "an image and solves it using the algorithm of your choice.\n" + "The program outputs an image with drawn exit path (if the maze is valid).\n" + "Rules for a valid maze:" + "\n 1. Everything that is not white will be interpreted as a wall." + "\n 2. The maze must have one starting point on top, and one exit point in the bottom" + "\n (if there are multiple entry/exit points, only the first will be used)" + "\n 3. The maze must be surrounded by walls (i.e. must be \"closed\")" + "\n 4. It is advisable for the corridors to be 1px wide, but it is not mandatory" + "\n (the output will be correct for Dijkstra and A*, but not for DFS or BFS)" ) # About window
def check_inputs(self): self.inputs = {'quit':self.quit_var.get(),'data_dir':self.data_dir.get(),\ 'plots_dir':self.plots_dir.get(),'calib_dir':self.calib_dir.get(),\ 'inbase':self.inbase.get(),'targets':self.targets.get(),\ 'phscals':self.phscals.get(),'fluxcal':self.fluxcal.get(),\ 'bpcal':self.bpcal.get(),'ptcal':self.ptcal.get(),'refant':self.refant.get(),\ 'run_importfits':self.run_importfits.get(),'hanning':self.hanning.get(),\ 'autoflag':self.autoflag.get(),'rfigui':self.rfigui.get(),\ 'ms2mms':self.ms2mms.get(),'do_prediag':self.do_prediag.get(),\ 'do_delay':self.solve_delays.get(),'do_initial_bandpass':self.do_initial_bandpass.get()} print self.inputs input_key=self.inputs.keys() input_values = self.inputs.values() lines = [] for i in range(len(input_key)): lines = lines + [str(input_key[i])+':'+str(input_values[i])] tkMessageBox.showinfo('Summary',"\n".join(lines))
def ok_pressed(self): self.currentSelection = self.GameListBox.curselection() if ( len(self.filtered_list) <= 0 ): self.filtered_list = self.pgn_item_list if ( len(self.filtered_list) <= 0): return print(self.currentSelection) if ( len(self.currentSelection) <= 0 ): tkMessageBox.showinfo(" Please","select a game ") return else: self.currentSelection = int( self.currentSelection[0] ) self.parentUI.pgn_file.seek(self.filtered_list[self.currentSelection].offset) self.parentUI.pgnGame = chess.pgn.read_game(self.parentUI.pgn_file) self.parentUI.currentGameNode = self.parentUI.pgnGame self.parentUI.chessBoard = self.parentUI.pgnGame.board() self.current_pgn_index = 0 self.parentUI.draw_main_board() self.parentUI.txtPgn.config(state=NORMAL) self.parentUI.txtPgn.delete(1.0,END) self.parentUI.txtPgn.insert(END,str(self.parentUI.pgnGame)) self.parentUI.txtPgn.config(state=DISABLED) self.parentUI.set_info(self.filtered_list[self.currentSelection].header) self.pgnFrame.destroy()
def authenticate(username , password): soc.send( str( username.get()) + " " + str(password.get()) ) result = soc.recv(100) if result == "200": # 200 code refers that login was successful #saving username f=open('login_id.txt','w') f.write( str( username.get() )) f.close() login_window.destroy() thread.start_new_thread(start_cliet_reciever,("ok",)) #os.system('python client_reciever.py') start(soc) else:# 201 for wrong tkMessageBox.showinfo("alert", "Wrong id/password combination !!") pass
def debugbutton(self): width = 8 msg = '' for row in range(len(self.root.data[0])): for column in range(len(self.root.data)): element = str(self.root.data[column][row]) if len(element) < width: element += ' ' * (width - len(element)) msg += element if column == len(self.root.data) - 1: msg += '\n' #messagebox.showinfo(message=msg) #messagebox.showinfo(message=str(serial.Serial.inWaiting(self.root.ser))) #messagebox.showinfo(message=self.root.ani) #If this script is executed, just run the main script
def check_terminal(self): """ Check if stdout is read by a terminal, for warning about UTF-8 support """ if sys.platform == 'win32' and sys.stdin.isatty(): if self.fn or os.path.exists(POPUP_DISPLAYED_PATH): return try: import Tkinter import tkMessageBox root = Tkinter.Tk() root.withdraw() tkMessageBox.showinfo("Malstrings One-time popup", TERM_MSG) with open(POPUP_DISPLAYED_PATH, 'w') as writer: writer.write('True') except Exception: pass
def paneltoenergy(): panellength=length.get() panelwidth=width.get() #Total energy from sun is 1850 watts per square meter size = panellength*panelwidth raw_energy = size*1850 #assuming that half of the energy is lost into the atmosphere energy_output = raw_energy/2 #calorimitry begins here Q = energy_output m = Q/(4.184*80) tkMessageBox.showinfo("Results", "You can boil " + str(m) +" Litres of room temperature water.")
def infoBox(self, title, message): self.topLevel.update_idletasks() MessageBox.showinfo(title, message) self.__bringToFront()
def info(self, title, message): messagebox.showinfo(title, message) # Display a warning box pop up
def __init__(self): Tk.__init__(self) self.responsive_button = Button(self, text="It's responsive", command = lambda:tkMessageBox.showinfo("alert window", "It's responsive!")) self.responsive_button.pack()
def onPrint(): MB.showinfo('FYI','Make sure your printer is turned on and ready!\nThen press OK ;-)\n\nTested with hp f340') l = [(canvas.type(obj),canvas.coords(obj)) for obj in canvas.find_all()] print l print_canvas(l)
def main(key): 'Delete key and all empty parent keys.' Tkinter.Tk().withdraw() try: key, parent = delete(*key.rsplit('\\', 1)) while empty(parent): key, parent = delete(*key.rsplit('\\', 1)) tkMessageBox.showinfo('Info', 'Uninstall passed!') except: tkMessageBox.showerror('Error', traceback.format_exc())
def quitProgram(): tkMessageBox.showinfo(productName, coremeraco.constructExitStatement()) if sound: sound.stop() sys.exit() # Just running exit() doesn't work with PyInstaller
def apply(self): # this is where we write out the config file to disk self.settings.write() tkMessageBox.showinfo("Restart PyKeylogger", "You must restart PyKeylogger for the new settings to take effect.")
def pass_alert(): tkMessageBox.showinfo("Password Alert","Please enter a password.")
def enc_success(imagename): tkMessageBox.showinfo("Success","Encrypted Image: " + imagename)
def anunciar_ganador(self, data): messagebox.showinfo("¡Atención!", message=data) # Handle Events
def MsgBox(title, text, style): box = [ msg.showinfo, msg.showwarning, msg.showerror, msg.askquestion, msg.askyesno, msg.askokcancel, msg.askretrycancel, ]; tk.Tk().withdraw(); #Hide Main Window. if style in range(7): return box[style](title, text)
def click_change_city(current_city, city_name, window): global curr_weather for city in weather.city_list: if city[2].decode('utf8') == city_name: current_city.set(city_name) curr_weather = weather.query_city(city_name) update_weather() window.destroy() return tkMessageBox.showinfo('??', '???????')
def showHelp(self): helpstr=dgbk('''\n\n ?????\n 1. ??/pad????\n 1?û?itunesapp???š???š??iDoc?\n 2?û????ting??\n 2. ximaexport-gui.exe\n ting.sqlite???1?? ting.sqlite. ?\n ???????á\n ???????All\n ?? ''') tkMessageBox.showinfo(title='Help', message=helpstr) #print(self.menfolder.get())
def add_friend(): def send_message(): msgcontent = '?:'+ time.strftime("%Y-%m-%d %H:%M:%S",time.localtime()) + '\n ' text_msglist_child.insert(END, msgcontent, 'green') text_msglist_child.insert(END, text_msg_child.get('0.0', END)) data=text_msg_child.get('0.0', END) text_msg_child.delete('0.0', END) data2='03#'+temp+'#'+data+'#' ADDR = ('202.114.196.97', 11560) udpCliSock.sendto(data2.encode('utf-8'), ADDR) data3, ADDR = udpCliSock.recvfrom(1024) text_msglist_child.insert(END,'????'+data3+'\n') temp=friend_account.get() if temp=='': tkMessageBox.showinfo('??','??????????') return friend_account.set('') #??? child=Toplevel() child.title(temp) frame_left_top = Frame(child,width=380, height=270, bg='white') frame_left_center = Frame(child,width=380, height=50, bg='white') frame_left_top.grid(row=0, column=0, padx=2, pady=5) frame_left_center.grid(row=1, column=0, padx=2, pady=5) frame_left_top.grid_propagate(0) frame_left_center.grid_propagate(0) text_msglist_child= Text(frame_left_top) text_msg_child= Text(frame_left_center) text_msglist_child.grid() text_msg_child.grid() Button(child, text='??',command=send_message).grid(row=2,column=0,sticky=W)
def Register(): def onsure(): data='01#'+top_account.get()+'#'+top_password.get()+'#'+pass_word_sure.get()+'#' ADDR = ('202.114.196.97',11560) udpCliSock.sendto(data, ADDR) data, ADDR = udpCliSock.recvfrom(1024) if data=='01:01': tkMessageBox.showinfo('??','?????') elif data=='01:02': tkMessageBox.showinfo('????','???????') elif data=='01:03': tkMessageBox.showinfo('????','??????') else: tkMessageBox.showinfo('????','??????') top.destroy() #??? top=Toplevel() top.title('????') #?????? top_account=StringVar() top_password=StringVar() Label(top,text='???',width=8).grid(row=0,column=0) Entry(top,textvariable=top_account).grid(row=0,column=1) Label(top,text='???',width=8).grid(row=1,column=0) Entry(top,textvariable=top_password,show='*').grid(row=1,column=1) Label(top,text='?????',width=8).grid(row=2,column=0) pass_word_sure=StringVar() Entry(top,textvariable=pass_word_sure,show='*').grid(row=2,column=1) Button(top,text='????',width=8,command=onsure).grid(row=3) #??
def Login(): if cin_account.get()=='' or cin_password.get()=='': tkMessageBox.showinfo('??','?????????') return data='02#'+cin_account.get()+'#'+cin_password.get()+'#' ADDR = ('202.114.196.97',11560) udpCliSock.sendto(data, ADDR) data, ADDR = udpCliSock.recvfrom(1024) if data=='02:01': tkMessageBox.showinfo('??','?????') root.destroy() root2=Tk() root2.title('QQ???') frame_left_top = Frame(root2,width=300, height=200, bg='white') frame_left_top.grid(row=0, column=0, padx=2, pady=5) frame_left_top.grid_propagate(0) global text_msglist text_msglist = Text(frame_left_top) text_msglist.grid() Label(root2,text='???',width=8).grid(row=1,column=0) global friend_account friend_account=StringVar() Entry(root2,textvariable=friend_account).grid(row=2,column=0) Button(root2, text='????',command=add_friend).grid(row=3,column=0) #???? thread.start_new_thread(send,()) elif data=='02:02': tkMessageBox.showinfo('????','?????') elif data=='02:03': tkMessageBox.showinfo('????','??????') elif data=='02:04': tkMessageBox.showinfo('??','??????') #??????????? temp='06#' udpCliSock.sendto(temp, ADDR) data2, ADDR = udpCliSock.recvfrom(1024) if data2=='06:01': tkMessageBox.showinfo('??','?????') else: tkMessageBox.showinfo('??','???????')
def Register(): def onsure(): data='01#'+top_account.get()+'#'+top_password.get()+'#'+pass_word_sure.get()+'#' #ADDR=("localhost",11567) ADDR = ('202.114.196.97',11560) udpCliSock.sendto(data, ADDR) data, ADDR = udpCliSock.recvfrom(1024) #udpCliSock.close() if data=='01:01': tkMessageBox.showinfo('??','?????') elif data=='01:02': tkMessageBox.showinfo('????','???????') elif data=='01:03': tkMessageBox.showinfo('????','??????') else: tkMessageBox.showinfo('????','??????') top.destroy() #??? top=Toplevel() top.title('????') Label(top,text='???',width=8).grid(row=0,column=0) Entry(top,textvariable=top_account).grid(row=0,column=1) Label(top,text='???',width=8).grid(row=1,column=0) Entry(top,textvariable=top_password,show='*').grid(row=1,column=1) Label(top,text='?????',width=8).grid(row=2,column=0) pass_word_sure=StringVar() Entry(top,textvariable=pass_word_sure,show='*').grid(row=2,column=1) Button(top,text='????',width=8,command=onsure).grid(row=3) #??
def Login(): if cin_account.get()=='' or cin_password.get()=='': tkMessageBox.showinfo('??','?????????') return data='02#'+cin_account.get()+'#'+cin_password.get()+'#' #udpCliSock = socket(AF_INET, SOCK_DGRAM) ADDR = ('202.114.196.97',11560) udpCliSock.sendto(data, ADDR) data, ADDR = udpCliSock.recvfrom(1024) if data=='02:01': tkMessageBox.showinfo('??','?????') #udpCliSock.close() main(udpCliSock) root.destroy() elif data=='02:02': tkMessageBox.showinfo('????','?????') elif data=='02:03': tkMessageBox.showinfo('????','??????') elif data=='02:04': tkMessageBox.showinfo('??','??????') #??????????? temp='06#' udpCliSock.sendto(temp, ADDR) data2, ADDR = udpCliSock.recvfrom(1024) if data2=='06:01': tkMessageBox.showinfo('??','?????') else: tkMessageBox.showinfo('??','???????') #udpCliSock.close() #???????? #grid:?????????
def show_info(self, title, message): return messagebox.showinfo(title, message)
def HistoryParser(): tkMessageBox.showinfo("", "History Parser") Histclass.HistParser()