def OnQuit(self,event,dbfile):
if _plat.startswith('linux'):
dlg = wx.MessageDialog(self, 'Really quit?','', wx.OK | wx.CANCEL | wx.ICON_ERROR)
val = dlg.ShowModal()
dlg.Show()
if val == wx.ID_CANCEL:
dlg.Destroy()
elif val == wx.ID_OK:
OKQuit = self.DBQuit(dbfile)
if OKQuit == 42:
self.Close()
elif _plat.startswith('darwin'):
pass
elif _plat.startswith('win'):
OKQuit = self.DBQuit(dbfile)
if OKQuit == 42:
self.Close()
sys.exit()#windows
self.Refresh()
python类MessageDialog()的实例源码
def do_input(Class, parent, title, fields, data):
dlg = Class(parent, -1, title, size=(350, 200),
style=wx.DEFAULT_DIALOG_STYLE, # & ~wx.CLOSE_BOX,
fields=fields, data=data
)
dlg.CenterOnScreen()
while 1:
val = dlg.ShowModal()
if val == wx.ID_OK:
values = {}
for field in fields:
try:
values[field] = eval(dlg.textctrls[field].GetValue())
except Exception, e:
msg = wx.MessageDialog(parent, unicode(e),
"Error in field %s" % field,
wx.OK | wx.ICON_INFORMATION
)
msg.ShowModal()
msg.Destroy()
break
else:
return dict([(field, values[field]) for field in fields])
else:
return None
def DoLog(self, level, msg, time):
if level == wx.LOG_Warning:
caption = 'Warning'
elif level == wx.LOG_Error:
caption = 'Error'
else:
caption = 'Message'
fullMessage = caption + ': ' + msg + '\n'
if level == wx.LOG_Error:
sys.stderr.write(fullMessage)
sys.stderr.flush()
for tctrl in self.textCtrls:
tctrl.AppendText(fullMessage)
if level <= wx.LOG_Warning:
dialog = wx.MessageDialog(None, message=msg, caption=caption,
style=wx.ICON_ERROR | wx.OK)
dialog.ShowModal()
dialog.Destroy()
def onsoftreboot(self, event):
fila = self.listadoVM
for i in range(len(fila)):
if logger != None: logger.info(fila[i])
# El 9 elemento es el UUID
if logger != None: logger.info (fila[8])
#Pedimos confirmacion del reset de la mv con ventana dialogo
dlg_reset = wx.MessageDialog(self,
"Estas a punto de reiniciar \n " + fila[1] + " ",
"Confirm Exit", wx.OK | wx.CANCEL | wx.ICON_QUESTION)
result = dlg_reset.ShowModal()
dlg_reset.Destroy()
if result == wx.ID_OK:
vm = conexion.searchIndex.FindByUuid(None,fila[8], True)
if vm is not None:
if logger != None: logger.info ("The current powerState is: {0}".format(vm.runtime.powerState))
TASK = vm.RebootGuest()
#Este da error tasks.wait_for_tasks(conexion, [TASK])
if logger != None: logger.info("Soft reboot its done.")
def onsoftPowerOff(self, event):
fila = self.listadoVM
for i in range(len(fila)):
if logger != None: logger.info(fila[i])
# El 9 elemento es el UUID
if logger != None: logger.info (fila[8])
#Pedimos confirmacion del reset de la mv con ventana dialogo
dlg_reset = wx.MessageDialog(self,
"Estas a punto de Soft Apagar \n " + fila[1] + " ",
"Confirm Exit", wx.OK | wx.CANCEL | wx.ICON_QUESTION)
result = dlg_reset.ShowModal()
dlg_reset.Destroy()
if result == wx.ID_OK:
vm = conexion.searchIndex.FindByUuid(None,fila[8], True)
if vm is not None:
if logger != None: logger.info ("The current powerState is: {0}".format(vm.runtime.powerState))
TASK = vm.ShutdownGuest()
#Este da error tasks.wait_for_tasks(conexion, [TASK])
if logger != None: logger.info("Soft poweroff its done.")
# Reiniciamos el ordenador seleccionado en el menu contextual
def onreboot(self, event):
fila = self.listadoVM
for i in range(len(fila)):
if logger != None: logger.info(fila[i])
# El 9 elemento es el UUID
if logger != None: logger.info (fila[8])
#Pedimos confirmacion del reset de la mv con ventana dialogo
dlg_reset = wx.MessageDialog(self,
"Estas a punto de reiniciar \n " + fila[1] + " ",
"Confirm Exit", wx.OK | wx.CANCEL | wx.ICON_QUESTION)
result = dlg_reset.ShowModal()
dlg_reset.Destroy()
if result == wx.ID_OK:
vm = conexion.searchIndex.FindByUuid(None,fila[8], True)
if vm is not None:
if logger != None: logger.info ("The current powerState is: {0}".format(vm.runtime.powerState))
TASK = vm.ResetVM_Task()
tasks.wait_for_tasks(conexion, [TASK])
if logger != None: logger.info("reboot its done.")
def onpower_on(self, event):
fila = self.listadoVM
for i in range(len(fila)):
if logger != None: logger.info(fila[i])
# El 9 elemento es el UUID
if logger != None: logger.info (fila[8])
#Pedimos confirmacion del poweron de la mv con ventana dialogo
dlg_reset = wx.MessageDialog(self,
"Estas a punto de iniciar \n " + fila[1] + "\nAhora esta: " + fila[3],
"Confirm Exit", wx.OK | wx.CANCEL | wx.ICON_QUESTION)
result = dlg_reset.ShowModal()
dlg_reset.Destroy()
if result == wx.ID_OK:
vm = conexion.searchIndex.FindByUuid(None,fila[8], True)
if vm is not None and not vm.runtime.powerState == 'poweredOn':
if logger != None: logger.info ("The current powerState is: {0}".format(vm.runtime.powerState))
TASK = vm.PowerOn()
tasks.wait_for_tasks(conexion, [TASK])
if logger != None: logger.info("Power ON its done.")
def onpowerOff(self, event):
fila = self.listadoVM
for i in range(len(fila)):
if logger != None: logger.info(fila[i])
# El 9 elemento es el UUID
if logger != None: logger.info (fila[8])
#Pedimos confirmacion del reset de la mv con ventana dialogo
dlg_reset = wx.MessageDialog(self,
"Estas a punto de Apagar \n " + fila[1] + " ",
"Confirm Exit", wx.OK | wx.CANCEL | wx.ICON_QUESTION)
result = dlg_reset.ShowModal()
dlg_reset.Destroy()
if result == wx.ID_OK:
vm = conexion.searchIndex.FindByUuid(None,fila[8], True)
if vm is not None and not vm.runtime.powerState == 'poweredOff':
if logger != None: logger.info ("The current powerState is: {0}".format(vm.runtime.powerState))
TASK = vm.PowerOff()
tasks.wait_for_tasks(conexion, [TASK])
if logger != None: logger.info("Power OFF its done.")
def PrintPreview(self):
"""Print-preview current plot."""
printout = PlotPrintout(self)
printout2 = PlotPrintout(self)
self.preview = wx.PrintPreview(printout, printout2, self.print_data)
if not self.preview.IsOk():
wx.MessageDialog(self, "Print Preview failed.\n"
"Check that default printer is configured\n",
"Print error", wx.OK | wx.CENTRE).ShowModal()
self.preview.SetZoom(40)
# search up tree to find frame instance
frameInst = self
while not isinstance(frameInst, wx.Frame):
frameInst = frameInst.GetParent()
frame = wx.PreviewFrame(self.preview, frameInst, "Preview")
frame.Initialize()
frame.SetPosition(self.GetPosition())
frame.SetSize((600, 550))
frame.Centre(wx.BOTH)
frame.Show(True)
def OnHelp(self,e):
dlg = wx.MessageDialog(self, "Bonsu will attempt to open the"+os.linesep+"documentation with your default"+os.linesep+"browser. Continue?","Confirm Open", wx.OK|wx.CANCEL|wx.ICON_QUESTION)
result = dlg.ShowModal()
dlg.Destroy()
if result == wx.ID_OK:
path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'docs', 'bonsu.html')
if sys.platform.startswith('win'):
os.startfile(path)
elif sys.platform.startswith('darwin'):
from subprocess import Popen
Popen(['open', path])
else:
try:
from subprocess import Popen
Popen(['xdg-open', path])
except:
pass
def OnConnect(self,event):
Username = self.username.GetValue()
Password = self.pwd.GetValue()
mac = get.get_mac_address()
self.MAC=mac
ip = get.Get_local_ip()
self.IP=ip
upnet_net = packet.generate_upnet(mac, ip, Username, Password)
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
hosts = '210.45.194.10'
status,message= connect.upnet(sock, upnet_net, hosts,self.getsession)
if status == 0:
msgbox = wx.MessageDialog(None, "",message,wx.OK)
msgbox.ShowModal()
frame=MainFrame()
frame.Show()
else:
self.connect.Disable()
self.disconnect.Enable()
self.username.SetEditable(False)
self.pwd.SetEditable(False)
wx.MessageBox(u'??????',message)
self.SetStatusText(u"????")
self.OnStartThread()
def tellToDoSwipeOrInput(self, evt):
operationString = self.OpeartionBox.GetStringSelection()
inputC = self.inputContent.GetValue()
sX = self.swipeStartX.GetValue()
sY = self.swipeStartY.GetValue()
eX = self.swipeEndX.GetValue()
eY = self.swipeEndY.GetValue()
if operationString=="??":
if inputC=="":
dlg = wx.MessageDialog(self, u"???????", u"????????", wx.OK | wx.ICON_ERROR)
if dlg.ShowModal() == wx.ID_OK:
dlg.Destroy()
else:
keyb = self.keyboardType.GetValue()
wx.CallAfter(pub.sendMessage, "DoSwipeOrInput", msg =inputC+"\n"+keyb)
else:
if sX=="" or sY=="" or eX=="" or eY=="":
dlg = wx.MessageDialog(self, u"?????????", u"??????????????????", wx.OK | wx.ICON_ERROR)
if dlg.ShowModal() == wx.ID_OK:
dlg.Destroy()
else:
wx.CallAfter(pub.sendMessage, "DoSwipeOrInput", msg ="??\n%d\n%d\n%d\n%d" % (sX,sY,eX,eY))
def on_transform_button_click(self, event):
slice_startswith = self.slice_text.GetValue()
template_path = self.get_template_path()
response_body = self.GetParent().get_response_content()
try:
handler = Request2Doc()
handler.set_slice_startswith(slice_startswith)
handler.set_response_body(response_body)
if not handler.get_response_data():
return wx.MessageDialog(None, u'Response body is not legal format', u"Information", wx.OK | wx.ICON_INFORMATION).ShowModal()
self.GetParent().set_document_content(handler.render_string(template_path))
except Exception, e:
return wx.MessageDialog(None, traceback.format_exc(), u"Exception", wx.OK | wx.ICON_ERROR).ShowModal()
def update_check(parent):
"""Check for updates using the GitHub API
Args:
parent (wx.Window): The parent window (for the message dialog)
Returns:
None
"""
r = requests.get('https://api.github.com/repos/10se1ucgo/pyjam/releases/latest')
if not r.ok:
return
new = r.json()['tag_name']
try:
if StrictVersion(__version__) < StrictVersion(new.lstrip('v')):
info = wx.MessageDialog(parent, message="pyjam {v} is now available!\nGo to download page?".format(v=new),
caption="pyjam Update", style=wx.OK | wx.CANCEL | wx.ICON_INFORMATION)
if info.ShowModal() == wx.ID_OK:
webbrowser.open_new_tab(r.json()['html_url'])
info.Destroy()
except ValueError:
pass
def on_ok(self, event):
songs = yt_extract(self.audio_links.GetValue().split(','))
if not songs:
error = wx.MessageDialog(parent=self,
message="Invalid/Unsupported URL!",
caption="Error!", style=wx.OK | wx.ICON_WARNING)
error.ShowModal()
error.Destroy()
return
self.num_songs = len(songs)
self.progress_dialog = wx.ProgressDialog(title="Download", message="Downloading songs...",
maximum=self.num_songs * 100, parent=self, style=PD_STYLE)
self.downloader = DownloaderThread(self, songs, self.out_dir.GetPath())
self.downloader.start()
def download_complete(self, errors):
if self.progress_dialog:
logger.info("Beginning download")
self.downloader.join()
if errors:
done_string = "Songs downloaded with {errors} error(s)".format(errors=len(errors))
else:
done_string = "All songs were downloaded succesfully!"
logger.info(done_string)
done_message = wx.MessageDialog(parent=self, message=done_string, caption="pyjam")
done_message.ShowModal()
done_message.Destroy()
if errors:
errors = '\n'.join(errors)
logger.critical("Error downloading these these URLs:\n{errors}".format(errors=errors))
error_dialog = wx.MessageDialog(parent=self, message="The following URLs caused errors\n" + errors,
caption="Download Error!", style=wx.ICON_ERROR)
error_dialog.ShowModal()
error_dialog.Destroy()
self.progress_dialog.Destroy()
self.Destroy()
wx.CallAfter(self.parent.convert, event=None, in_dir=self.out_dir.GetPath())
def on_ok(self, event):
if not os.path.exists(self.out_dir.GetPath()):
os.makedirs(self.out_dir.GetPath())
self.num_songs = len(self.in_files)
if self.num_songs <= 0:
alert = wx.MessageDialog(self, "No songs selected!", "pyjam", wx.ICON_EXCLAMATION)
alert.ShowModal()
alert.Destroy()
return
self.progress_dialog = wx.ProgressDialog(title="Conversion", message="Converting songs...",
maximum=self.num_songs * 2, parent=self, style=PD_STYLE)
self.converter = FFmpegConvertThread(parent=self, dest=self.out_dir.GetPath(), rate=self.game_rate.GetValue(),
vol=self.volume.GetValue(), songs=self.in_files)
self.converter.start()
def convert_update(self, message):
progress = "{songs} out of {total}".format(songs=message // 2, total=self.num_songs)
if self.progress_dialog and self.converter.isAlive():
if message >= self.num_songs * 2:
message = self.num_songs * 2 - 1
if not self.progress_dialog.Update(value=message, newmsg="Converted: {prog}".format(prog=progress))[0]:
self.converter.abort()
self.converter.join()
self.progress_dialog.Destroy()
alert_string = "Aborted! Only {progress} songs were converted".format(progress=progress)
alert = wx.MessageDialog(parent=self, message=alert_string, caption="pyjam", style=wx.ICON_EXCLAMATION)
alert.ToggleWindowStyle(wx.STAY_ON_TOP)
alert.ShowModal()
alert.Destroy()
logger.info("Audio conversion canceled canceled.")
logger.info(progress)
# wx.CallAfter(self.progress_dialog.Destroy)
def OnStartButton(self, e):
if wpkg_running():
dlg_msg = _(u"WPKG is currently running,\n"
u"please wait a few seconds and try again.")
dlg = wx.MessageDialog(self, dlg_msg, app_name, wx.OK | wx.ICON_EXCLAMATION)
dlg.ShowModal()
dlg.Destroy()
return
dlg_title = _(u"2. Warning")
dlg_msg = _(u"Close all open programs!\n\nThe System could restart without further confirmation!\n\n" \
u"Continue?")
dlg = wx.MessageDialog(self, dlg_msg, dlg_title, wx.YES_NO|wx.YES_DEFAULT|wx.ICON_EXCLAMATION)
if dlg.ShowModal() == wx.ID_YES:
dlg.Destroy()
# Disable/enable buttons and disable Close Window option!
self.startButton.Disable()
self.abortButton.Enable()
self.EnableCloseButton(enable=False)
# Set Start Time
self.wpkg_start_time = datetime.datetime.now()
# Reset Log
self.log = None
startWorker(self.LongTaskDone, self.LongTask)
def OnAbortButton(self, e):
if not self.running:
self.Close()
return
dlg_title = _(u"Cancel")
dlg_msg = _(u"System update in progress!\n\n Canceling this Progress could result in installation issues.\n"
u"Cancel?")
dlg = wx.MessageDialog(self, dlg_msg, dlg_title, wx.YES_NO|wx.YES_DEFAULT|wx.ICON_EXCLAMATION)
if dlg.ShowModal() == wx.ID_YES:
dlg.Destroy()
if not self.running:
# WPKG Process by this client has finished, no cancel possible
return
print 'Aborting WPKG Process' #TODO: MOVE TO DEBUG LOGGER
self.shouldAbort = True
msg = 'Cancel'
try:
pipeHandle = CreateFile("\\\\.\\pipe\\WPKG", GENERIC_READ | GENERIC_WRITE, 0, None, OPEN_EXISTING, 0, None)
except pywintypes.error, (n, f, e):
print "Error when generating pipe handle: %s" % e #TODO: MOVE TO DEBUG LOGGER
return 1
SetNamedPipeHandleState(pipeHandle, PIPE_READMODE_MESSAGE, None, None)
WriteFile(pipeHandle, msg)
def OnStartButton(self, e):
if wpkg_running():
dlg_msg = _(u"WPKG is currently running,\n"
u"please wait a few seconds and try again.")
dlg = wx.MessageDialog(self, dlg_msg, app_name, wx.OK | wx.ICON_EXCLAMATION)
dlg.ShowModal()
dlg.Destroy()
return
dlg_title = _(u"2. Warning")
dlg_msg = _(u"Close all open programs!\n\nThe System could restart without further confirmation!\n\n" \
u"Continue?")
dlg = wx.MessageDialog(self, dlg_msg, dlg_title, wx.YES_NO|wx.YES_DEFAULT|wx.ICON_EXCLAMATION)
if dlg.ShowModal() == wx.ID_YES:
dlg.Destroy()
# Disable/enable buttons and disable Close Window option!
self.startButton.Disable()
self.abortButton.Enable()
self.EnableCloseButton(enable=False)
# Set Start Time
self.wpkg_start_time = datetime.datetime.now()
# Reset Log
self.log = None
startWorker(self.LongTaskDone, self.LongTask)
def OnAbortButton(self, e):
if not self.running:
self.Close()
return
dlg_title = _(u"Cancel")
dlg_msg = _(u"System update in progress!\n\n Canceling this Progress could result in installation issues.\n"
u"Cancel?")
dlg = wx.MessageDialog(self, dlg_msg, dlg_title, wx.YES_NO|wx.YES_DEFAULT|wx.ICON_EXCLAMATION)
if dlg.ShowModal() == wx.ID_YES:
dlg.Destroy()
if not self.running:
# WPKG Process by this client has finished, no cancel possible
return
print 'Aborting WPKG Process' #TODO: MOVE TO DEBUG LOGGER
self.shouldAbort = True
msg = 'Cancel'
try:
pipeHandle = CreateFile("\\\\.\\pipe\\WPKG", GENERIC_READ | GENERIC_WRITE, 0, None, OPEN_EXISTING, 0, None)
except pywintypes.error, (n, f, e):
print "Error when generating pipe handle: %s" % e #TODO: MOVE TO DEBUG LOGGER
return 1
SetNamedPipeHandleState(pipeHandle, PIPE_READMODE_MESSAGE, None, None)
WriteFile(pipeHandle, msg)
def OnGenerateProgramMenu(self, event):
dialog = wx.FileDialog(self, _("Choose a file"), os.getcwd(), self.Controler.GetProgramFilePath(), _("ST files (*.st)|*.st|All files|*.*"), wx.SAVE | wx.CHANGE_DIR)
if dialog.ShowModal() == wx.ID_OK:
filepath = dialog.GetPath()
message_text = ""
header, icon = _("Done"), wx.ICON_INFORMATION
if os.path.isdir(os.path.dirname(filepath)):
program, errors, warnings = self.Controler.GenerateProgram(filepath)
message_text += "".join([_("warning: %s\n") % warning for warning in warnings])
if len(errors) > 0:
message_text += "".join([_("error: %s\n") % error for error in errors])
message_text += _("Can't generate program to file %s!") % filepath
header, icon = _("Error"), wx.ICON_ERROR
else:
message_text += _("Program was successfully generated!")
else:
message_text += _("\"%s\" is not a valid folder!") % os.path.dirname(filepath)
header, icon = _("Error"), wx.ICON_ERROR
message = wx.MessageDialog(self, message_text, header, wx.OK | icon)
message.ShowModal()
message.Destroy()
dialog.Destroy()
def GetDimensions(self):
message = None
dimensions_list = []
dimension_strings = self.Dimensions.GetStrings()
if len(dimension_strings) == 0:
message = _("Empty dimension isn't allowed.")
for dimensions in dimension_strings:
result = DIMENSION_MODEL.match(dimensions)
if result is None:
message = _("\"%s\" value isn't a valid array dimension!") % dimensions
break
bounds = result.groups()
if int(bounds[0]) >= int(bounds[1]):
message = _("\"%s\" value isn't a valid array dimension!\nRight value must be greater than left value.") % dimensions
break
dimensions_list.append(bounds)
if message is not None:
dlg = wx.MessageDialog(self, message, _("Error"), wx.OK | wx.ICON_ERROR)
dlg.ShowModal()
dlg.Destroy()
return None
return dimensions_list
def OnOK(self, event):
message = None
step_name = self.GetSizer().GetItem(1).GetWindow().GetValue()
if step_name == "":
message = _("You must type a name!")
elif not TestIdentifier(step_name):
message = _("\"%s\" is not a valid identifier!") % step_name
elif step_name.upper() in IEC_KEYWORDS:
message = _("\"%s\" is a keyword. It can't be used!") % step_name
elif step_name.upper() in self.PouNames:
message = _("A POU named \"%s\" already exists!") % step_name
if message is not None:
dialog = wx.MessageDialog(self, message, _("Error"), wx.OK | wx.ICON_ERROR)
dialog.ShowModal()
dialog.Destroy()
else:
self.EndModal(wx.ID_OK)
event.Skip()
def OnOK(self, event):
message = None
step_name = self.GetSizer().GetItem(1).GetWindow().GetValue()
if step_name == "":
message = _("You must type a name!")
elif not TestIdentifier(step_name):
message = _("\"%s\" is not a valid identifier!") % step_name
elif step_name.upper() in IEC_KEYWORDS:
message = _("\"%s\" is a keyword. It can't be used!") % step_name
elif step_name.upper() in self.PouNames:
message = _("A POU named \"%s\" already exists!") % step_name
elif step_name.upper() in self.Variables:
message = _("A variable with \"%s\" as name already exists in this pou!") % step_name
elif step_name.upper() in self.StepNames:
message = _("\"%s\" step already exists!") % step_name
if message is not None:
dialog = wx.MessageDialog(self, message, _("Error"), wx.OK | wx.ICON_ERROR)
dialog.ShowModal()
dialog.Destroy()
else:
self.EndModal(wx.ID_OK)
event.Skip()
def CheckSaveBeforeClosing(self, title=_("Close Project")):
"""Function displaying an question dialog if project is not saved"
:returns: False if closing cancelled.
"""
if not self.Controler.ProjectIsSaved():
dialog = wx.MessageDialog(self, _("There are changes, do you want to save?"), title, wx.YES_NO | wx.CANCEL | wx.ICON_QUESTION)
answer = dialog.ShowModal()
dialog.Destroy()
if answer == wx.ID_YES:
self.SaveProject()
elif answer == wx.ID_CANCEL:
return False
for idx in xrange(self.TabsOpened.GetPageCount()):
window = self.TabsOpened.GetPage(idx)
if not window.CheckSaveBeforeClosing():
return False
return True
# -------------------------------------------------------------------------------
# File Menu Functions
# -------------------------------------------------------------------------------
def OnTreeEndLabelEdit(self, event):
new_name = event.GetLabel()
if new_name != "":
old_filepath = self.GetPath(event.GetItem())
new_filepath = os.path.join(os.path.split(old_filepath)[0], new_name)
if new_filepath != old_filepath:
if not os.path.exists(new_filepath):
os.rename(old_filepath, new_filepath)
event.Skip()
else:
message = wx.MessageDialog(self,
_("File '%s' already exists!") % new_name,
_("Error"), wx.OK | wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
event.Veto()
else:
event.Skip()
def ShowMessage(self, message):
"""
Show error message in Error Dialog
@param message: Error message to display
"""
dialog = wx.MessageDialog(self.ParentWindow,
message,
_("Error"),
wx.OK | wx.ICON_ERROR)
dialog.ShowModal()
dialog.Destroy()
# -------------------------------------------------------------------------------
# Debug Variable Graphic Viewer Class
# -------------------------------------------------------------------------------
def OnEnumeratedValueEndEdit(self, event):
text = event.GetText()
values = self.EnumeratedValues.GetStrings()
index = event.GetIndex()
if index >= len(values) or values[index].upper() != text.upper():
if text.upper() in [value.upper() for value in values]:
message = wx.MessageDialog(self, _("\"%s\" value already defined!") % text, _("Error"), wx.OK | wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
event.Veto()
elif text.upper() in IEC_KEYWORDS:
message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!") % text, _("Error"), wx.OK | wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
else:
initial_selected = None
if index < len(values) and self.EnumeratedInitialValue.GetStringSelection() == values[index]:
initial_selected = text
wx.CallAfter(self.RefreshEnumeratedValues, initial_selected)
wx.CallAfter(self.RefreshTypeInfos)
event.Skip()
else:
event.Skip()