本文整理汇总了Python中tkMessageBox.showerror方法的典型用法代码示例。如果您正苦于以下问题:Python tkMessageBox.showerror方法的具体用法?Python tkMessageBox.showerror怎么用?Python tkMessageBox.showerror使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkMessageBox
的用法示例。
在下文中一共展示了tkMessageBox.showerror方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loadData
# 需要导入模块: import tkMessageBox [as 别名]
# 或者: from tkMessageBox import showerror [as 别名]
def loadData(self):
try:
# load the setup data, reload to refresh the data
import setup_data
reload(setup_data)
except:
if self.__is_verbose:
print "ERROR: Problem loading data from ./setup_data.py"
tkMessageBox.showerror(
title = "Error!",
message = "Problem loading data from setup_data.py"
)
self.__is_saved = True
return setup_data.boxes
# --------------------------------------------------------------------------
# Check Data
# --------------------------------------------------------------------------
示例2: clickLoad
# 需要导入模块: import tkMessageBox [as 别名]
# 或者: from tkMessageBox import showerror [as 别名]
def clickLoad(self):
if self.__is_verbose: print "ACTION: Clicked 'Load'"
# turn off toggle buttons
self.spaces_button.setOff()
self.cps_button.setOff()
if not self.loadImage(self.SETUP_IMAGE, self.display,
s.PICTURE_RESOLUTION[0]/2, s.PICTURE_RESOLUTION[1]/2):
tkMessageBox.showerror(title = "Error!",
message = "Error loading setup image."
+ " Please ensure setup image exists as ./image/setup_image.jpeg.")
return
# clear all previous data, and activate buttons
self.clear_button.invoke()
self.cps_button.config(state = tk.ACTIVE)
self.spaces_button.config(state = tk.ACTIVE)
示例3: center_on_node
# 需要导入模块: import tkMessageBox [as 别名]
# 或者: from tkMessageBox import showerror [as 别名]
def center_on_node(self, data_node):
"""Center canvas on given **DATA** node"""
try:
disp_node = self._find_disp_node(data_node)
except ValueError as e:
tkm.showerror("Unable to find node", str(e))
return
x,y = self.coords(self.dispG.node[disp_node]['token_id'])
# Find center of canvas
w = self.winfo_width()/2
h = self.winfo_height()/2
if w == 0:
# We haven't been drawn yet
w = int(self['width'])/2
h = int(self['height'])/2
# Calc delta to move to center
delta_x = w - x
delta_y = h - y
self.move(tk.ALL, delta_x, delta_y)
示例4: goto_path
# 需要导入模块: import tkMessageBox [as 别名]
# 或者: from tkMessageBox import showerror [as 别名]
def goto_path(self, event):
frm = self.node_entry.get()
to = self.node_entry2.get()
self.node_entry.delete(0, tk.END)
self.node_entry2.delete(0, tk.END)
if frm == '':
tkm.showerror("No From Node", "Please enter a node in both "
"boxes to plot a path. Enter a node in only the first box "
"to bring up nodes immediately adjacent.")
return
if frm.isdigit() and int(frm) in self.canvas.dataG.nodes():
frm = int(frm)
if to.isdigit() and int(to) in self.canvas.dataG.nodes():
to = int(to)
self.canvas.plot_path(frm, to, levels=self.level)
示例5: print_selection
# 需要导入模块: import tkMessageBox [as 别名]
# 或者: from tkMessageBox import showerror [as 别名]
def print_selection(self, *e):
if self._root is None: return
if self._selection is None:
tkMessageBox.showerror('Print Error', 'No tree selected')
else:
c = self._cframe.canvas()
for widget in self._treewidgets:
if widget is not self._selection:
self._cframe.destroy_widget(widget)
c.delete(self._selectbox)
(x1,y1,x2,y2) = self._selection.bbox()
self._selection.move(10-x1,10-y1)
c['scrollregion'] = '0 0 %s %s' % (x2-x1+20, y2-y1+20)
self._cframe.print_to_file()
# Restore our state.
self._treewidgets = [self._selection]
self.clear()
self.update()
示例6: load_chart
# 需要导入模块: import tkMessageBox [as 别名]
# 或者: from tkMessageBox import showerror [as 别名]
def load_chart(self, *args):
"Load a chart from a pickle file"
filename = askopenfilename(filetypes=self.CHART_FILE_TYPES,
defaultextension='.pickle')
if not filename: return
try:
chart = pickle.load(open(filename, 'r'))
self._chart = chart
self._cv.update(chart)
if self._matrix: self._matrix.set_chart(chart)
if self._matrix: self._matrix.deselect_cell()
if self._results: self._results.set_chart(chart)
self._cp.set_chart(chart)
except Exception, e:
raise
tkMessageBox.showerror('Error Loading Chart',
'Unable to open file: %r' % filename)
示例7: save_grammar
# 需要导入模块: import tkMessageBox [as 别名]
# 或者: from tkMessageBox import showerror [as 别名]
def save_grammar(self, *args):
filename = asksaveasfilename(filetypes=self.GRAMMAR_FILE_TYPES,
defaultextension='.cfg')
if not filename: return
try:
if filename.endswith('.pickle'):
pickle.dump((self._chart, self._tokens), open(filename, 'w'))
else:
file = open(filename, 'w')
prods = self._grammar.productions()
start = [p for p in prods if p.lhs() == self._grammar.start()]
rest = [p for p in prods if p.lhs() != self._grammar.start()]
for prod in start: file.write('%s\n' % prod)
for prod in rest: file.write('%s\n' % prod)
file.close()
except Exception, e:
tkMessageBox.showerror('Error Saving Grammar',
'Unable to open file: %r' % filename)
示例8: _auto_align_timer
# 需要导入模块: import tkMessageBox [as 别名]
# 或者: from tkMessageBox import showerror [as 别名]
def _auto_align_timer(self, *args):
# Check thread status.
if self.work_done:
# Update status message, with popup on error.
if self.work_status is not None:
self._set_status(self.work_status)
if self.work_error is not None:
self._set_status('Auto-alignment failed.')
tkMessageBox.showerror('Auto-alignment error', self.work_error)
# Clear the 'done' flag for future runs.
self.work_done = False
else:
# Update status message and keep hourglass.
if self.work_status is not None:
self._set_status(self.work_status, 'wait')
# Reset timer to be called again.
self.parent.after(200, self._auto_align_timer)
# Create panorama object using current settings.
示例9: pcap_analyse
# 需要导入模块: import tkMessageBox [as 别名]
# 或者: from tkMessageBox import showerror [as 别名]
def pcap_analyse(self):
if os.path.exists(self.pcap_file.get()):
self.progressbar.start()
result = Queue.Queue()
packet_read = threading.Thread(target=pcapReader.pcapReader,args=(self.pcap_file.get(),result))
packet_read.start()
while packet_read.is_alive():
self.progressbar.update()
packet_read.join()
self.progressbar.stop()
#packet_read.join()
self.capture_read = result.get()
reportThreadpcap = threading.Thread(target=reportGen.reportGen().packetDetails,args=(self.capture_read,))
reportThreadpcap.start()
#self.option.set("Tor")
self.option.trace("w",self.map_select)
#self.option.set("Tor")
self.name_servers = ""
else:
tkMessageBox.showerror("Error","File Not Found !")
示例10: browse_directory
# 需要导入模块: import tkMessageBox [as 别名]
# 或者: from tkMessageBox import showerror [as 别名]
def browse_directory(self, option):
if option == "pcap":
# Reference: http://effbot.org/tkinterbook/tkinter-dialog-windows.htm
self.pcap_file.set(fd.askopenfilename(initialdir = sys.path[0],title = "Select Packet Capture File!",filetypes = (("All","*.pcap *.pcapng"),("pcap files","*.pcap"),("pcapng files","*.pcapng"))))
self.filename = self.pcap_file.get().replace(".pcap","")
if "/" in self.filename:
self.filename = self.filename.split("/")[-1]
#,("all files","*.*")
#self.filename_field.delete(0, END)
#self.filename_field.insert(0, self.pcap_file)
print(self.filename)
print(self.pcap_file)
else:
self.destination_report.set(fd.askdirectory())
if self.destination_report.get():
if not os.access(self.destination_report.get(), os.W_OK):
mb.showerror("Error","Permission denied to create report! Run with higher privilege.")
else:
mb.showerror("Error", "Enter a output directory!")
示例11: open_module
# 需要导入模块: import tkMessageBox [as 别名]
# 或者: from tkMessageBox import showerror [as 别名]
def open_module(self, event=None):
# XXX Shouldn't this be in IOBinding or in FileList?
try:
name = self.text.get("sel.first", "sel.last")
except TclError:
name = ""
else:
name = name.strip()
name = tkSimpleDialog.askstring("Module",
"Enter the name of a Python module\n"
"to search on sys.path and open:",
parent=self.text, initialvalue=name)
if name:
name = name.strip()
if not name:
return
# XXX Ought to insert current file's directory in front of path
try:
(f, file, (suffix, mode, type)) = _find_module(name)
except (NameError, ImportError), msg:
tkMessageBox.showerror("Import error", str(msg), parent=self.text)
return
示例12: NameOk
# 需要导入模块: import tkMessageBox [as 别名]
# 或者: from tkMessageBox import showerror [as 别名]
def NameOk(self):
#simple validity check for a sensible
#ConfigParser file section name
nameOk=1
name=self.name.get()
name.strip()
if not name: #no name specified
tkMessageBox.showerror(title='Name Error',
message='No name specified.', parent=self)
nameOk=0
elif len(name)>30: #name too long
tkMessageBox.showerror(title='Name Error',
message='Name too long. It should be no more than '+
'30 characters.', parent=self)
nameOk=0
elif name in self.usedNames:
tkMessageBox.showerror(title='Name Error',
message='This name is already in use.', parent=self)
nameOk=0
return nameOk
示例13: open
# 需要导入模块: import tkMessageBox [as 别名]
# 或者: from tkMessageBox import showerror [as 别名]
def open(self, filename, action=None):
assert filename
filename = self.canonize(filename)
if os.path.isdir(filename):
# This can happen when bad filename is passed on command line:
tkMessageBox.showerror(
"File Error",
"%r is a directory." % (filename,),
master=self.root)
return None
key = os.path.normcase(filename)
if key in self.dict:
edit = self.dict[key]
edit.top.wakeup()
return edit
if action:
# Don't create window, perform 'action', e.g. open in same window
return action(filename)
else:
return self.EditorWindow(self, filename, key)
示例14: MenuOk
# 需要导入模块: import tkMessageBox [as 别名]
# 或者: from tkMessageBox import showerror [as 别名]
def MenuOk(self):
"Simple validity check for a sensible menu item name"
menuOk = True
menu = self.menu.get()
menu.strip()
if not menu:
tkMessageBox.showerror(title='Menu Item Error',
message='No menu item specified',
parent=self)
self.entryMenu.focus_set()
menuOk = False
elif len(menu) > 30:
tkMessageBox.showerror(title='Menu Item Error',
message='Menu item too long:'
'\nLimit 30 characters.',
parent=self)
self.entryMenu.focus_set()
menuOk = False
return menuOk
示例15: PathOk
# 需要导入模块: import tkMessageBox [as 别名]
# 或者: from tkMessageBox import showerror [as 别名]
def PathOk(self):
"Simple validity check for menu file path"
pathOk = True
path = self.path.get()
path.strip()
if not path: #no path specified
tkMessageBox.showerror(title='File Path Error',
message='No help file path specified.',
parent=self)
self.entryPath.focus_set()
pathOk = False
elif path.startswith(('www.', 'http')):
pass
else:
if path[:5] == 'file:':
path = path[5:]
if not os.path.exists(path):
tkMessageBox.showerror(title='File Path Error',
message='Help file path does not exist.',
parent=self)
self.entryPath.focus_set()
pathOk = False
return pathOk