本文整理汇总了Python中tkinter.messagebox.showerror函数的典型用法代码示例。如果您正苦于以下问题:Python showerror函数的具体用法?Python showerror怎么用?Python showerror使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了showerror函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: goto_file_line
def goto_file_line(self, event=None):
if self.file_line_progs is None:
l = []
for pat in self.file_line_pats:
l.append(re.compile(pat, re.IGNORECASE))
self.file_line_progs = l
# x, y = self.event.x, self.event.y
# self.text.mark_set("insert", "@%d,%d" % (x, y))
line = self.text.get("insert linestart", "insert lineend")
result = self._file_line_helper(line)
if not result:
# Try the previous line. This is handy e.g. in tracebacks,
# where you tend to right-click on the displayed source line
line = self.text.get("insert -1line linestart",
"insert -1line lineend")
result = self._file_line_helper(line)
if not result:
tkMessageBox.showerror(
"No special line",
"The line you point at doesn't look like "
"a valid file name followed by a line number.",
parent=self.text)
return
filename, lineno = result
edit = self.flist.open(filename)
edit.gotoline(lineno)
开发者ID:3lnc,项目名称:cpython,代码行数:26,代码来源:outwin.py
示例2: play_game
def play_game(game):
result = ""
while not result:
print_game(game)
choice = input("Cell[1-9 or q to quit]: ")
if choice.lower()[0] == "q":
save = mb.askyesno("Save game", "Save game before quitting?")
if save:
oxo_logic.save_game(game)
quit_game()
else:
try:
cell = int(choice) - 1
if not (0 <= cell <= 8): # check range
raise ValueError
except ValueError:
print("Choose a number between 1 and 9 or 'q' to quit ")
continue
try:
result = oxo_logic.user_move(game, cell)
except ValueError:
mb.showerror("Invalid cell", "Choose an empty cell")
continue
if not result:
result = oxo_logic.computer_move(game)
if not result:
continue
elif result == "D":
print_game(game)
mb.showinfo("Result", "It's a draw")
else:
print_game(game)
mb.showinfo("Result", "Winner is {}".format(result))
开发者ID:L1nwatch,项目名称:Mac-Python-3.X,代码行数:34,代码来源:oxo_dialog_ui.py
示例3: gui_login
def gui_login():
items = map(int, w.acc_list.curselection())
for idx in items:
try:
login_manager.login(w.acc_list.get(idx)) # TODO: write console cbs
except URLError as e:
messagebox.showerror("Error", e.msg)
开发者ID:SpeedProg,项目名称:PveLauncher,代码行数:7,代码来源:mainwindow_support.py
示例4: _onExecButton
def _onExecButton( self ):
'''
**Private Method**
Handler for Execute Button pressed.
Checks that test file(s) have been selected.
Resets the data in the GUI Interface class and the GUI fields.
Disables the Execute Button widget.
Initiates a new thread to run the Regression Test Suite.
:return: n/a:
'''
# Test that we have files to test
f = SetupConfig().getTestFiles()
if(
isinstance( f, list ) == False or
len( f ) < 1
):
messagebox.showerror( 'Uh-oh', 'No File(s) to test specified' )
return
self._execButton.configure( state = 'disabled', bg = 'light gray' )
GuiIF().reset()
self._updateResults()
ExecThread().start()
开发者ID:agacek,项目名称:jkindRegression,代码行数:27,代码来源:mainframe.py
示例5: setloggingoptions
def setloggingoptions():
while True:
if os.path.exists("data//logs") == True:
try:
logfilename = 'data//logs//log_gui ({}).log'.format(time.strftime("%d-%m-%Y"))
handler = logging.FileHandler(logfilename)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
if bLoggingenabled == 0:
logging.basicConfig()
else:
logging.basicConfig(filename=logfilename, level=logging.DEBUG)
logger.addHandler(handler)
logger.handlers.pop()
logger.debug('Started %s at %s on %s', appname, time.strftime("%H:%M:%S"), time.strftime("%d/%m/%Y"))
logger.info('Running on {} version {} {}.'.format(platform.system(), platform.release(), platform.machine()))
# cx_freeze?
if appfrozen == True:
logger.info("Currently running the frozen version. Compiled by cx_freeze.")
else:
logger.info("Currently running from the Python script.")
logger.info("%s version (%s %s) started in directory: %s", appname, version, release, currentdir)
break
except Exception as e:
messagebox.showerror("Error", "Cannot create log.\n Exception: %s\nTrying to create logs folder..." % (str(e)))
try:
os.mkdir("data//logs")
except Exception as e:
messagebox.showerror("Error", "Cannot create logs folder.\n Exception: %s" % (str(e)))
else:
os.mkdir("data//logs")
开发者ID:ZanyLeonic,项目名称:LeonicBinaryTool,代码行数:31,代码来源:ConverterGUI.py
示例6: stop_parsing
def stop_parsing(self):
"""Stop the results process"""
if self.parser._scoreboard_parser is not None:
messagebox.showwarning("Warning", "Parsing cannot be stopped while results a scoreboard.")
return
self.parsing_control_button.config(state=tk.DISABLED)
self.parsing_control_button.update()
if self.minimap_enabled.get() is True and self.minimap is not None:
self.minimap.destroy()
self.close_overlay()
self.parser.stop()
self.parsing_control_button.config(text="Start Parsing", command=self.start_parsing)
time.sleep(0.1)
try:
self.parser.join(timeout=2)
except Exception as e:
messagebox.showerror("Error", "While real-time results, the following error occurred:\n\n{}".format(e))
raise
self.watching_stringvar.set("Watching no file...")
print("[RealTimeFrame] RealTimeParser reference count: {}".format(sys.getrefcount(self.parser)))
self.parser = None
self.close_overlay()
DiscordClient().send_recent_files(self.window)
self.window.update_presence()
self.parsing_control_button.config(state=tk.NORMAL)
self.data.set(self.DATA_STR_BASE.format("Not real-time results\n"))
开发者ID:RedFantom,项目名称:GSF-Parser-Public,代码行数:26,代码来源:realtime.py
示例7: connector
def connector(event):
print(self.hostname)
if self.ping(self.hostname):
tkConnect.config(state='disabled')
tkUsername.config(state='disabled')
tkPassword.config(state='disabled')
tkHostname.config(state='disabled')
tkConnect.unbind("<ButtonRelease-1>")
tkDisConnect.config(state='active')
tkDisConnect.bind("<ButtonRelease-1>", disconnector)
hostnamesaver(event)
usernamesaver(event)
tkLog.insert(0, 'Connected!' + " - Time: " + str(datetime.datetime.now().time()))
tkCommandLine.config(state='normal')
try:
self.connectButton()
tkLog.insert(0, str(datetime.datetime.now().time()) + " - INFO: Host is valid!")
except:
print("Host nem elérhető!")
else:
messagebox.showerror(title="Host error", message="Host doesn't found on network!")
tkLog.insert(0, str(datetime.datetime.now().time()) + " - ERROR: Host doesn't found!")
disconnector(self)
try:
if SC.get_transport().is_active():
print('Connection is still alive. - ' + str(datetime.datetime.now().time()))
else:
print('Connection is NOT alive. - ' + str(datetime.datetime.now().time()))
self.disconnectButton(self)
tkLog.insert(0, "ERROR: Host doesn't found!")
except:
print("ERROR! during get_transport().isalive()")
disconnector(event)
messagebox.showerror(title="Host error", message="Host doesn't found on network!")
tkLog.insert(0, "INFO: Host is not valid!")
开发者ID:M0Rph3U56031769,项目名称:kaja,代码行数:35,代码来源:ssh2.py
示例8: runUpdate
def runUpdate() :
'''
Call the xrandr command line tool to implement the changes
'''
cmd = ["xrandr"]
for x in self.displayObjs :
cmd.append("--output")
cmd.append(x.display)
if x.enabled == True : cmd.append("--auto")
else :
cmd.append("--off")
continue
if x.primary == True and UI.getPrimary() != x.display : cmd.append("--primary")
if x.resolution != "Default" :
cmd.append("--mode")
cmd.append(x.resolution)
if self.mirror.get() == False and x.position[1] != "None" :
pos = x.position
if pos[0] == "Left of" : cmd.append("--left-of")
elif pos[0] == "Right of" : cmd.append("--right-of")
elif pos[0] == "Above" : cmd.append("--above")
else : cmd.append("--below")
cmd.append(x.position[1])
error = Popen(cmd, stderr = PIPE).communicate()
error = error[1].decode("utf-8")
if error != "" :
messagebox.showerror(title = "Xrandr error", message = error)
开发者ID:charlesbos,项目名称:my-scripts,代码行数:27,代码来源:display-conf-tool.py
示例9: connect
def connect(self, event=None):
"""
Attempts to connect to a Bluetooth device. If there is a Bluetooth Error,
we set 'self.error_message' to equal the error in question so we can then
flag our GUI that there was an issue.
If we have succesfully connected, we set 'self.sock' to equal to the connected
socket, this is then passed into the GUI within the calling function.
Parameters
----------
event : tkinter event
We just need this to enable keybinding <Return> to function properly.
"""
try:
port = int(self.port.get())
address = self.address.get()
except ValueError:
messagebox.showerror("Error","Port must be an integer")
else:
try:
sock = bt.BluetoothSocket(bt.RFCOMM)
sock.connect((address, port))
self.sock = sock
self.address = address
self.port = port
except bt.btcommon.BluetoothError as e:
self.sock = None
self.error_message = e
self.cancel()
开发者ID:harshssd,项目名称:pyToof-Chat,代码行数:30,代码来源:connect_modal.py
示例10: reset
def reset() :
rmFilesFailed = False
question = "The following files will be deleted:\n\n ~/.gtkrc-2.0\n ~/.config/gtk-3.0/settings.ini\n ~/.icons/default/index.theme\n\nDo you want to continue?"
choice = messagebox.askyesno(title = "Reset", message = question)
if choice :
homeDir = os.path.expanduser('~')
try : os.remove(homeDir + "/.gtkrc-2.0")
except FileNotFoundError : pass
except IOError : rmFilesFailed = True
try : os.remove(homeDir + "/.config/gtk-3.0/settings.ini")
except FileNotFoundError : pass
except IOError : rmFilesFailed = True
try : os.remove(homeDir + "/.icons/default/index.theme")
except FileNotFoundError : pass
except IOError : rmFilesFailed = True
if rmFilesFailed : messagebox.showerror(title = "Error", message = "Errors occured whilst removing the settings files.")
ui.varOpG2.set(getResource("gtk2", "gtk-theme-name"))
ui.varOpG3.set(getResource("gtk3", "gtk-theme-name"))
ui.varOpFont.delete(0, len(ui.varOpFont.get()))
ui.varOpFont.insert(0, getResource("gtk2", "gtk-font-name"))
ui.varOpIcons.set(getResource("gtk2", "gtk-icon-theme-name"))
ui.varOpCursors.set(getResource("xdg_cursor", "Inherits"))
ui.varOpButtonImages.set(getResource("gtk2", "gtk-button-images"))
ui.varOpMenuImages.set(getResource("gtk2", "gtk-menu-images"))
ui.varOpDarkTheme.set(getResource("gtk3", "gtk-application-prefer-dark-theme"))
开发者ID:charlesbos,项目名称:my-scripts,代码行数:25,代码来源:setgtktheme.py
示例11: saveAs
def saveAs():
f = asksaveasfile(mode='w',defaultextension='.txt')
t = text.get(0.0,END)
try:
f.write(t.rstrip())
except:
showerror(title="Error",message="File save fail...")
开发者ID:damanjitsingh,项目名称:pythonPrograms,代码行数:7,代码来源:readNWriteTextFiles.py
示例12: start_youtube_dl
def start_youtube_dl(self):
# Start downloading the specified url
if self._output_path.get():
output_path = self._output_path.get()
else:
try:
output_path = os.path.dirname(os.path.abspath(__file__))
except NameError:
import sys
output_path = os.path.dirname(os.path.abspath(sys.argv[0]))
output_tmpl = output_path + '/%(title)s-%(id)s.%(ext)s'
options = {
'format': 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/bestvideo+bestaudio/best',
'merge_output_format': 'mp4',
'socket_timeout': '15',
'progress_hooks': [self._logger.log],
'ignoreerrors': True,
'outtmpl': output_tmpl,
}
if self._extract_audio.get():
options['format'] = 'bestaudio/best',
options['postprocessors'] = [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '3',
}]
dl = YoutubeDL(options)
status = dl.download([self._video_url.get()])
if status != 0:
mbox.showerror("youtube-dl error", "An error happened whilst processing your video(s)")
else:
mbox.showinfo("youtube-dl finished", "Your video(s) have been successfully processed")
开发者ID:pielambr,项目名称:ydlui,代码行数:32,代码来源:main.py
示例13: download_export
def download_export():
if not report_name.get() or not scheme_round.get() \
or not api_key.get():
messagebox.showerror(
title="Error",
message="All fields are required.")
return
file_path = get_file_path()
if not file_path:
return
# Run the given report!
try:
REPORTS_DICT[report_name.get()](
scheme_round.get(),
api_key.get(),
file_path)
messagebox.showinfo(
title="Done!",
message="Download complete! File saved to\n%s" % file_path)
except Exception:
exc_type, exc_value, exc_traceback = sys.exc_info()
message = ''.join(traceback.format_exception(exc_type,
exc_value,
exc_traceback))
messagebox.showerror(
title="Error",
message="We experienced an error:\n " + message)
开发者ID:jcu-eresearch,项目名称:arc-research-office-downloader,代码行数:29,代码来源:arc_reports.py
示例14: install_graphics
def install_graphics(self, listbox):
"""
Installs a graphics pack.
Params:
listbox
Listbox containing the list of graphics packs.
"""
if len(listbox.curselection()) != 0:
gfx_dir = listbox.get(listbox.curselection()[0])
if messagebox.askokcancel(
message='Your graphics, settings and raws will be changed.',
title='Are you sure?'):
result = self.lnp.install_graphics(gfx_dir)
if result is False:
messagebox.showerror(
title='Error occurred', message='Something went wrong: '
'the graphics folder may be missing important files. '
'Graphics may not be installed correctly.\n'
'See the output log for error details.')
elif result:
if messagebox.askyesno(
'Update Savegames?',
'Graphics and settings installed!\n'
'Would you like to update your savegames to '
'properly use the new graphics?'):
self.update_savegames()
else:
messagebox.showerror(
title='Error occurred',
message='Nothing was installed.\n'
'Folder does not exist or does not have required files '
'or folders:\n'+str(gfx_dir))
binding.update()
开发者ID:Estevo-Aleixo,项目名称:pylnp,代码行数:34,代码来源:graphics.py
示例15: execute_operation
def execute_operation(self, operation):
"""Executa operacoes com apenas um automato."""
if self.tabbed_frame.index('end') == 0:
messagebox.showerror('Erro', 'Não há nenhum autômato aberto.')
else:
selected_tab_index = self.tabbed_frame.index('current')
selected_tab = self.opened_tabs[selected_tab_index]
automaton = selected_tab.get_automaton()
aut_op = AutomatonOperation(automaton)
automaton_name = operation + '_' + selected_tab.get_file_name()
result_automaton = None
if operation == 'accessibility':
result_automaton = aut_op.accessibility()
elif operation == 'trim':
result_automaton = aut_op.trim()
elif operation == 'co_accessibility':
result_automaton = aut_op.co_accessibility()
elif operation == 'minimization':
result_automaton = aut_op.minimization()
elif operation == 'convertion':
result_automaton = aut_op.convertion()
else:
print('Operacao invalida.')
tab = Tab(result_automaton, automaton_name, self.tabbed_frame)
self.add_tab(tab)
开发者ID:luisgteixeira,项目名称:StatesMachine,代码行数:27,代码来源:application.py
示例16: fileDialog
def fileDialog(self, fileOptions=None, mode='r', openMode=True):
defaultFileOptions = {}
defaultFileOptions['defaultextension'] = ''
defaultFileOptions['filetypes'] = []
defaultFileOptions['initialdir'] = ''
defaultFileOptions['initialfile'] = ''
defaultFileOptions['parent'] = self.root
defaultFileOptions['title'] = ''
if fileOptions is not None:
for key in fileOptions:
defaultFileOptions[key] = fileOptions[key]
if openMode is True:
file = askopenfilename(**defaultFileOptions)
if file is not None and file is not '':
try :
self.compressionCore.openImage(file)
self.compressionCore.imageSquaring(self.NValue.get())
except Exception:
messagebox.showerror(
_("Error"),
"It's impossible open the image.")
return
self.updateGUI(original=True)
else:
file = asksaveasfilename(**defaultFileOptions)
if file is not None and file is not '':
try:
self.compressionCore.compressedImage.save(fp=file, format="bmp")
except Exception:
messagebox.showwarning(
_("Error"),
"Fail to save compressed image. Please try again.")
开发者ID:SilvioMessi,项目名称:CustomJPEGCompression,代码行数:32,代码来源:guiUtils.py
示例17: execute_composition
def execute_composition(self, composition):
""""""
"""Executa operacoes com apenas um automato."""
selected_tabs_indexes = self.get_selected_checkbuttons()
if len(selected_tabs_indexes) < 2:
messagebox.showerror('Erro', 'Você deve selecionar ao menos dois automatos.')
else:
selected_automatons = []
for selected_tab_index in selected_tabs_indexes:
tab = self.opened_tabs[selected_tab_index]
automaton = tab.get_automaton()
selected_automatons.append(automaton)
aut_op = AutomatonOperation(selected_automatons[0])
automaton_name = composition #+ '_' + selected_tab.get_file_name()
result_automaton = None
if composition == 'product':
result_automaton = selected_automatons[0]
for i in range(1, len(selected_automatons)):
result_automaton = aut_op.product_composition(result_automaton, selected_automatons[i])
elif composition == 'parallel_composition':
result_automaton = selected_automatons[0]
for i in range(1, len(selected_automatons)):
result_automaton = aut_op.parallel_composition(result_automaton, selected_automatons[i])
else:
print('Operacao invalida.')
tab = Tab(result_automaton, automaton_name, self.tabbed_frame)
self.add_tab(tab)
开发者ID:luisgteixeira,项目名称:StatesMachine,代码行数:30,代码来源:application.py
示例18: login
def login(self):
if self.sLoginUser.get() == "" or self.sLoginPass.get() == "":
error = messagebox.showerror("Blank", "Fill in All Blanks")
else:
parameters = (self.sLoginUser.get(), self.sLoginPass.get())
num = self.connect("SELECT * FROM User WHERE Username = \'%s\' AND Password = \'%s\'" % parameters, "Return Execution Number")
if num == 0:
error = messagebox.showerror("Invalid Credentials", "Please Register")
else:
sql = "SELECT * FROM User WHERE UserType = 'student' AND Username = \'%s\'" % self.sLoginUser.get()
isAdmin = self.connect(sql, "Return Execution Number")
self.user = self.sLoginUser.get()
message = messagebox.showinfo("Congratulations", "Login Successfully")
if isAdmin != 0:
username = self.sLoginUser.get()
sMajor = self.connect("SELECT Major FROM User WHERE Username = \'%s\'" % username, "Return Single Item")
self.dMajor = StringVar()
self.dMajor.set(sMajor[0])
self.operation()
self.dYear = StringVar()
self.dYear.set(self.connect("SELECT Year FROM User WHERE Username = \'%s\'" % username, "Return Single Item")[0])
else:
self.chooseFunctionality()
开发者ID:RyanZHe,项目名称:CS4400,代码行数:26,代码来源:version_final.py
示例19: adding_bloggers
def adding_bloggers(info=info):
for entry in connections.keys():
entrydata = []
print(entry.get())
if len(entry.get()) <= 1:
name = 'nothing'
else:
name = entry.get()
entrydata.append(name)
for connected in connections[entry]:
if connected.get() == '':
entrydata.append('nothing')
else:
entrydata.append(connected.get())
if entrydata != ['nothing', 'nothing', 'nothing', 'nothing', 'nothing', 'nothing']:
to_write.append(str(','.join([name for name in entrydata]) + '\n'))
screennames = sum(map(lambda x: 0 if x.split(',')[0] == 'nothing' else 1, to_write))
print(to_write)
print(screennames)
if to_write and screennames == len(to_write):
file = open('%s/Desktop/natappy/bloggers.txt' % home, 'a')
file.writelines(to_write)
file.close()
print(to_write)
counter = 0
for el in to_write:
print(counter, el)
add_blogger_to_excel(el)
counter += 1
second_window(root=root, info=info)
elif to_write and screennames != len(to_write):
messagebox.showerror('Give me screen name', 'Screen name is required!')
开发者ID:glebanatalia,项目名称:natappy,代码行数:33,代码来源:natappy_gui.py
示例20: checkRegistration
def checkRegistration(self):
username = self.sRegisterUser.get()
password = self.sRegisterPass.get()
confirmedPassword = self.sRegisterConPass.get()
email = self.sRegisterEmail.get()
emailFormat = re.compile("\w*@gatech.edu")
if password != confirmedPassword or emailFormat.match(email) == None:
if password != confirmedPassword:
self.sRegisterPass.set("")
self.sRegisterConPass.set("")
error = messagebox.showerror("Passwords Doesn't Match", "Re-enter Password")
elif emailFormat.match(email) == None:
self.sRegisterEmail.set("")
error = messagebox.showerror("Email Format Error", "Enter a Valid GT Email")
else:
num1 = self.connect("SELECT * FROM User WHERE Username = \'%s\'" % username, "Return Execution Number")
num2 = self.connect("SELECT * FROM User WHERE Email = \'%s\'" % email, "Return Execution Number")
if num1 != 0 or num2 != 0:
error = messagebox.showerror("Existed Username or Email", "Pick Another Username or Email")
else:
parameter = (username, email, password, 2016, "NULL", "student")
sql = "INSERT INTO User(Username, Email, Password, Year, Major, UserType) VALUES (\'%s\' ,\'%s\', \'%s\', \'%s\', \'%s\', \'%s\')" % parameter
self.connect(sql, "Insertion")
message = messagebox.showinfo("Congratulations", "Registered Successfully")
self.registrationWin.withdraw()
self.loginWin.deiconify()
开发者ID:RyanZHe,项目名称:CS4400,代码行数:26,代码来源:version_final.py
注:本文中的tkinter.messagebox.showerror函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论