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)
python类showinfo()的实例源码
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 _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 _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 _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 _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 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 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()