def OnDelete(self, ev=None):
"""
Deleting selected items.
"""
tree = self.treeCtrlItems
itemsL = tree.GetSelections()
namesL = []
deleteL = []
for i in itemsL:
# only items (ie. no groups)
if tree.GetPyData(i) == 1:
parent = tree.GetItemParent(i)
parentName = tree.GetItemText(parent)
name = tree.GetItemText(i).split()[0] #only name
namesL.append('%s.%s' % (parentName, name))
deleteL.append(i)
if namesL:
namesS = ',\n '.join(namesL)
ret = show_message_dialog(self,
'Really delete following name(s)?:\n %s' % namesS,
'-- Confirm --', wx.YES|wx.NO|wx.ICON_QUESTION)
if ret == wx.ID_YES:
for name, i in zip(namesL,deleteL):
if self.nsc_delete(name):
tree.Delete(i)
python类YES的实例源码
def OnDeleteGroup(self, ev=None):
"""
Deleting selected groups.
"""
tree = self.treeCtrlItems
itemsL = tree.GetSelections()
namesL = []
deleteL = []
for i in itemsL:
# only groups (ie. no items)
if tree.GetPyData(i) == 0:
name = tree.GetItemText(i)
if name not in PROTECTED_GROUPS and tree.GetChildrenCount(i)==0:
namesL.append(name)
deleteL.append(i)
if namesL:
namesS = ',\n'.join(namesL)
ret = show_message_dialog(self,
'Really delete following group(s)?:\n %s' % namesS,
'-- Confirm --', wx.YES|wx.NO|wx.ICON_QUESTION)
if ret == wx.ID_YES:
for name, i in zip(namesL, deleteL):
if self.nsc_delete_group(name):
tree.Delete(i)
def close(self, event):
if not self._world:
event.Skip()
return
modified = False
for level in self._world.levels:
modified = modified | level.modified
if modified:
result = wx.MessageBox('Do you want to save your changes?', 'Unsaved changes', wx.YES_NO | wx.CANCEL | wx.ICON_EXCLAMATION)
if result == wx.YES:
self._world.save()
elif result == wx.CANCEL:
return
event.Skip()
def onInstallDragonCommands(evt):
#Translators: Warning about having custom commands already.
goAhead = gui.messageBox(_("If you are on a computer with shared commands, and you have multiple users using these commands, this will override them. Please do not proceed unless you are sure you aren't sharing commands over a network. if you are, please read \"Importing Commands Into a Shared System\" in the Dictation Bridge documentation for manual steps.\nDo you want to proceed?"),
#Translators: Warning dialog title.
_("Warning: Potentially Dangerous Opperation Will be Performed"),
wx.YES|wx.NO)
if goAhead==wx.NO:
return
dialog = gui.IndeterminateProgressDialog(gui.mainFrame,
#Translators: Title for a dialog shown when Dragon Commands are being installed!
_("Dragon Command Installation"),
#Translators: Message shown in the progress dialog for dragon command installation.
_("Please wait while Dragon commands are installed."))
try:
gui.ExecAndPump(_onInstallDragonCommands)
except: #Catch all, because if this fails, bad bad bad.
log.error("DictationBridge commands failed to install!", exc_info=True)
finally:
dialog.done()
def Run( self ):
fileName = GetBoard().GetFileName()
if len(fileName)==0:
wx.LogMessage("a board needs to be saved/loaded!")
else:
dirpath = os.path.abspath(os.path.expanduser(fileName))
path, fname = os.path.split(dirpath)
ext = os.path.splitext(os.path.basename(fileName))[1]
name = os.path.splitext(os.path.basename(fileName))[0]
LogMsg="reading from "+ dirpath
out_filename=path+os.sep+name+".dxf"
LogMsg+="writing to "+out_filename
content=[]
txtFile = open(fileName,"r")
content = txtFile.readlines()
content.append(" ")
txtFile.close()
#wx.MessageDialog(None, 'This is a message box. ONLY TEST!', 'Test', wx.OK | wx.ICON_INFORMATION).ShowModal()
#wx.MessageDialog(None, 'This is a message box. ONLY TEST!', content, wx.OK | wx.ICON_INFORMATION).ShowModal()
#found_selected=False
#board = pcbnew.GetBoard()
dlg=wx.MessageBox( 'Only SAVED board file will be exported to DXF file', 'Confirm', wx.OK | wx.CANCEL | wx.ICON_INFORMATION )
if dlg == wx.OK:
if os.path.isfile(out_filename):
dlg=wx.MessageBox( 'Overwrite DXF file?', 'Confirm', wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION )
if dlg == wx.YES:
export_dxf(content, out_filename)
else:
export_dxf(content, out_filename)
def OnButtonSave(self, msg):
if not self.model.status:
wx.MessageBox('No export file has been successfully loaded yet!')
return
ret = wx.MessageBox('Overwrite the original file?', 'Attention!',
wx.YES_NO | wx.ICON_QUESTION)
if ret == wx.YES:
self.model.save(self.fileread.path)
def onInstall():
requiredVer = "Windows 10 Version 1703"
# Translators: Dialog text shown when attempting to install the add-on on an unsupported version of Windows (minSupportedVersion is the minimum version required for this add-on).
if sys.getwindowsversion().build < 15063 and gui.messageBox(_("You are using an older version of Windows. This add-on requires {minSupportedVersion} or later. Are you sure you wish to install this add-on anyway?").format(minSupportedVersion = requiredVer),
# Translators: title of the dialog shown when attempting to install the add-on on an old version of Windows.
_("Old Windows version"), wx.YES | wx.NO | wx.CANCEL | wx.CENTER | wx.ICON_QUESTION) == wx.NO:
raise RuntimeError("Old Windows version detected")
def getUpdateResponse(message, caption, updateURL):
if gui.messageBox(message, caption, wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL | wx.CENTER | wx.ICON_QUESTION) == wx.YES:
W10UpdateDownloader([updateURL]).start()
def doMove(self,move,score):
if move:
self.putTile()
self.drawChange(score)
if self.isGameOver():
if wx.MessageBox(u"????????????",u"??",
wx.YES_NO|wx.ICON_INFORMATION)==wx.YES:
bstScore = self.bstScore
self.initGame()
self.bstScore = bstScore
self.drawAll()
def OnRemoveClick(self, event): # wxGlade: MyFrame.<event_handler>
self.remove_row_index
msg="This student along with all data will be deleted\nAre you sure you want to Delete this row?"
if wx.MessageBox(msg, "Want to Delete?", wx.YES_NO) == wx.YES:
removed_item=self.CURRENT_LIST[0][self.remove_row_index+1]
#print "removing",removed_item
self.DB.RemoveScore(removed_item[4]) #Passing score id
#Checking if the student has any other record in any other div
query='SELECT * FROM T1 WHERE STUDENT_ID=?'
self.DB.cur.execute(query,(removed_item[1],))
if self.DB.cur.fetchone()==None:
self.DB.RemoveStudent(removed_item[1]) #passing student_id
else:
print 'other records exixts'
if self.SUBJECT=="Basic Science":
removed_item2=self.CURRENT_LIST[1][self.remove_row_index]
removed_item3=self.CURRENT_LIST[2][self.remove_row_index]
self.CURRENT_LIST[1].remove(removed_item2)
self.CURRENT_LIST[2].remove(removed_item3)
self.grid_1.DeleteRows(self.remove_row_index,1)
#except:
#print "Error in removing row"
event.Skip()