def detect_bemoss(self):
cwd = os.getcwd()
ui_path = cwd.replace('bemoss_gui','bemoss_web_ui')
cassandra_path = cwd.replace('bemoss_gui','cassandra')
env_path = cwd.replace('bemoss_gui','bemoss_os/env/bin')
bemoss_is_installed = os.path.isdir(ui_path) and os.path.isdir(cassandra_path) and os.path.isdir(env_path)
if bemoss_is_installed is False:
tmp = tkMessageBox.askokcancel(title='Please install BEMOSS at first',
message='You computer does not have BEMOSS installed, do you want to install BEMOSS right now?',
parent=root)
if tmp is True:
self.install_bemoss()
return
else:
return False
else:
return True
python类askokcancel()的实例源码
def file_window(self):
file_name = askopenfilename(parent=self.root, title='????', \
filetypes=[('FEN Records', '*.fen'), ('Text Files', '*.txt'), ('All Files', '*.*')],
initialdir='Resourses/', \
initialfile='example.fen')
# self.file = open(file_name, 'r')
# self.play()
# '''
try:
self.file = open(file_name, 'r')
self.play()
except IOError:
if askokcancel('?????', '???????'):
self.file_window()
else:
self.root.destroy()
# '''
def file_window(self):
file_name = askopenfilename(parent=self.root, title='????', \
filetypes=[('FEN Records', '*.fen'), ('Text Files', '*.txt'), ('All Files', '*.*')],
initialdir='Resourses/', \
initialfile='example.fen')
# self.file = open(file_name, 'r')
# self.play()
# '''
try:
self.file = open(file_name, 'r')
self.play()
except IOError:
if askokcancel('?????', '???????'):
self.file_window()
else:
self.root.destroy()
# '''
def okBox(self, title, message):
self.topLevel.update_idletasks()
return MessageBox.askokcancel(title, message)
def quit(self):
ans = askokcancel('Verify exit', "Really quit?")
if ans: Frame.quit(self)
def okBox(self, title, message):
self.topLevel.update_idletasks()
return MessageBox.askokcancel(title, message)
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 on_closing():
if msg.askokcancel("Warning", "Do you want to quit?"):
background.destroy()
rospy.signal_shutdown("")
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 ask_ok_cancel(self, title, message):
return messagebox.askokcancel(title, message)
def ask_ok_cancel(self, title, message):
return messagebox.askokcancel(title, message)
def ask_quit():
global proc
if tkMessageBox.askokcancel("Quit", "You want to leave me? *sniff*"):
try:
proc.terminate()
except:
pass
sys.exit()
#root.destroy()
#-----------------------------------------
def message_ask_ok_cancel(title, mess):
if VERSION == 3:
result=tkinter.messagebox.askokcancel(title, mess)
else:
result=tkMessageBox.askokcancel(title, mess)
return result
################################################################################
# Startup Application #
################################################################################
def menu_newTheme(self):
""" callback for new_theme menu item """
sure = tkMessageBox.askokcancel(title='New Theme', message='sure?')
if sure:
self.newTheme()
def menu_loadTheme(self):
""" callback for load_theme menu item """
newTheme = tkFileDialog.askopenfilename(initialdir=self.themeRootPath, filetypes=[('Theme', '*.json')], title='Open Theme')
if newTheme and not newTheme.startswith(self.themeRootPath):
tkMessageBox.showerror(message='Theme not in root folder: '+self.themeRootPath)
print newTheme, self.themeRootPath
return
if not newTheme or (self.theme and not tkMessageBox.askokcancel(title='Loading theme', message='current theme will be lost. continue?')):
return
pathname, filename = os.path.split(newTheme)
basename, themename = os.path.split(pathname)
self.loadTheme(themename)
def close(self):
"Extend EditorWindow.close()"
if self.executing:
response = tkMessageBox.askokcancel(
"Kill?",
"Your program is still running!\n Do you want to kill it?",
default="ok",
parent=self.text)
if response is False:
return "cancel"
self.stop_readline()
self.canceled = True
self.closing = True
return EditorWindow.close(self)
def ask_save_dialog(self):
msg = "Source Must Be Saved\n" + 5*' ' + "OK to Save?"
confirm = tkMessageBox.askokcancel(title="Save Before Run or Check",
message=msg,
default=tkMessageBox.OK,
parent=self.editwin.text)
return confirm
def close(self):
"Extend EditorWindow.close()"
if self.executing:
response = tkMessageBox.askokcancel(
"Kill?",
"Your program is still running!\n Do you want to kill it?",
default="ok",
parent=self.text)
if response is False:
return "cancel"
self.stop_readline()
self.canceled = True
self.closing = True
return EditorWindow.close(self)
def ask_save_dialog(self):
msg = "Source Must Be Saved\n" + 5*' ' + "OK to Save?"
confirm = tkMessageBox.askokcancel(title="Save Before Run or Check",
message=msg,
default=tkMessageBox.OK,
parent=self.editwin.text)
return confirm
def request_next_annotation(self, *arg):
value = self.user_tag_value.get()
if value == "":
self.root.bell()
return
if value not in self.annotation_state.parser_predictions.value_set:
res = tkMessageBox.askokcancel(
"New Tag",
"You are about to introduce the new tag '{}'. Proceed?".format(value))
if res is False:
return
else:
self.combobox.configure(values=sorted(
list(self.annotation_state.parser_predictions.value_set) + [value]))
self.annotation_state.process_annotation(self.current_request, value)
comment_value = self.comment_box.get("1.0", END).strip()
if len(comment_value) > 0:
self.write_comment(self.current_request.token,
comment_value, value)
self.comment_box.delete("1.0", END)
if self.autosave:
self.save_state()
self.get_next_request()
def message_ask_ok_cancel(title, mess):
if VERSION == 3:
result=tkinter.messagebox.askokcancel(title, mess)
else:
result=tkMessageBox.askokcancel(title, mess)
return result
############################################################################
# routine takes an x and a y coords and does a coordinate transformation #
# to a new coordinate system at angle from the initial coordinate system #
# Returns new x,y tuple #
############################################################################
def message_ask_ok_cancel(title, mess):
if VERSION == 3:
result=tkinter.messagebox.askokcancel(title, mess)
else:
result=tkMessageBox.askokcancel(title, mess)
return result
############################################################################
# routine takes an x and a y coords and does a coordinate transformation #
# to a new coordinate system at angle from the initial coordinate system #
# Returns new x,y tuple #
############################################################################
def message_ask_ok_cancel(title, mess):
if VERSION == 3:
result=tkinter.messagebox.askokcancel(title, mess)
else:
result=tkMessageBox.askokcancel(title, mess)
return result
############################################################################
# routine takes an x and a y coords and does a coordinate transformation #
# to a new coordinate system at angle from the initial coordinate system #
# Returns new x,y tuple #
############################################################################
def message_ask_ok_cancel(title, mess):
if VERSION == 3:
result=tkinter.messagebox.askokcancel(title, mess)
else:
result=tkMessageBox.askokcancel(title, mess)
return result
############################################################################
# routine takes an x and a y coords and does a coordinate transformation #
# to a new coordinate system at angle from the initial coordinate system #
# Returns new x,y tuple #
############################################################################
def message_ask_ok_cancel(title, mess):
if VERSION == 3:
result=tkinter.messagebox.askokcancel(title, mess)
else:
result=tkMessageBox.askokcancel(title, mess)
return result
############################################################################
# routine takes an x and a y coords and does a coordinate transformation #
# to a new coordinate system at angle from the initial coordinate system #
# Returns new x,y tuple #
############################################################################
def message_ask_ok_cancel(title, mess):
if VERSION == 3:
result=tkinter.messagebox.askokcancel(title, mess)
else:
result=tkMessageBox.askokcancel(title, mess)
return result
############################################################################
# routine takes an x and a y coords and does a coordinate transformation #
# to a new coordinate system at angle from the initial coordinate system #
# Returns new x,y tuple #
############################################################################
def message_ask_ok_cancel(title, mess):
if VERSION == 3:
result=tkinter.messagebox.askokcancel(title, mess)
else:
result=tkMessageBox.askokcancel(title, mess)
return result
############################################################################
# routine takes an x and a y coords and does a coordinate transformation #
# to a new coordinate system at angle from the initial coordinate system #
# Returns new x,y tuple #
############################################################################
def message_ask_ok_cancel(title, mess):
if VERSION == 3:
result=tkinter.messagebox.askokcancel(title, mess)
else:
result=tkMessageBox.askokcancel(title, mess)
return result
############################################################################
# routine takes an x and a y coords and does a coordinate transformation #
# to a new coordinate system at angle from the initial coordinate system #
# Returns new x,y tuple #
############################################################################
def message_ask_ok_cancel(title, mess):
if VERSION == 3:
result=tkinter.messagebox.askokcancel(title, mess)
else:
result=tkMessageBox.askokcancel(title, mess)
return result
############################################################################
# routine takes an x and a y coords and does a coordinate transformation #
# to a new coordinate system at angle from the initial coordinate system #
# Returns new x,y tuple #
############################################################################
def _ResetToDefaultConfigCmd(self):
q = tkMessageBox.askokcancel('Reset Configuration','Warning! This action will reset PiJuice HAT configuration to default settings.', parent=self.frame)
if q:
status = pijuice.config.SetDefaultConfiguration()
if status['error'] != 'NO_ERROR':
tkMessageBox.showerror('Reset to default configuration', status['error'], parent=self.frame)