def CheckProjectPathPerm(self, dosave=True):
if CheckPathPerm(self.ProjectPath):
return True
if self.AppFrame is not None:
dialog = wx.MessageDialog(
self.AppFrame,
_('You must have permission to work on the project\nWork on a project copy ?'),
_('Error'),
wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)
answer = dialog.ShowModal()
dialog.Destroy()
if answer == wx.ID_YES:
if self.SaveProjectAs():
self.AppFrame.RefreshTitle()
self.AppFrame.RefreshFileMenu()
self.AppFrame.RefreshPageTitles()
return True
return False
python类NO_DEFAULT的实例源码
def OnClose(self,event):
if self.CHANGES_TO_BE_SAVED:
dlg=wx.MessageDialog(self, "There are Unsaved Changes..Don't You Want to Save them?",'', wx.YES_NO|wx.YES_DEFAULT | wx.ICON_QUESTION)
#dlg = wx.MessageDialog(None, )
#dlg = wx.MessageDialog(None, "Don't You Want to Save Changes?", wx.NO_DEFAULT | wx.ICON_QUESTION)
if dlg.ShowModal() == wx.ID_YES:
self.Save_Clicked(None)
self.Parent.IsGridChild=0
self.Parent.Show()
self.P=None
self.DB=None
event.Skip()
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 OnChkCopyFile(self, event):
if not event.IsChecked():
dial = wx.MessageDialog(None,
'Are you sure? Disabling copy means that files are removed from their source location.', 'Disable copy?',
wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)
retCode = dial.ShowModal()
if (retCode != wx.ID_YES):
self.chkCopyFiles.SetValue(True)
dial.Destroy()
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 onOk(self, evt):
# #39: Prompt if switching from stable to development channel.
currentUpdateChannel = config.conf["wintenApps"]["updateChannel"]
newUpdateChannel = ("dev", "stable")[self.channels.GetSelection()]
if currentUpdateChannel == "stable" and newUpdateChannel == "dev":
if gui.messageBox(
# Translators: The confirmation prompt displayed when changing to development channel (with risks involved).
_("You are about to switch to development updates channel. Although updates from this channel brings exciting features, it also comes with updates that might be unstable at times and should be used for testing and sending feedback to the add-on developer. If you prefer to use stable releases, please answer no and switch to stable update channel. Are you sure you wish to switch to the development update channel?"),
# Translators: The title of the channel switch confirmation dialog.
_("Switching to unstable channel"),
wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION, self
) == wx.NO:
return
global updateChecker
if updateChecker and updateChecker.IsRunning(): updateChecker.Stop()
config.conf["wintenApps"]["autoUpdateCheck"] = self.autoUpdateCheckbox.Value
config.conf["wintenApps"]["updateCheckTimeInterval"] = self.updateInterval.Value
if not self.updateInterval.Value:
config.conf["wintenApps"]["updateCheckTime"] = 0
updateChecker = None
else:
updateChecker = wx.PyTimer(autoUpdateCheck)
currentTime = time.time()
whenToCheck = currentTime+(self.updateInterval.Value * addonUpdateCheckInterval)
updateChecker.Start(whenToCheck-currentTime, True)
config.conf["wintenApps"]["updateChannel"] = ("dev", "stable")[self.channels.GetSelection()]
self.Destroy()
def PreExit(self):
msg = 'GriPy Application is preparing to terminate....'
log.info(msg)
print '\n', msg
OM = ObjectManager(self)
if OM.get_changed_flag():
dial = wx.MessageDialog(self.GetTopWindow(),
'Do you want to save your project?',
'GriPy',
wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION
)
if dial.ShowModal() == wx.ID_YES:
self.on_save()
#
self.reset_ObjectManager()
#
app_UI_filename = self._gripy_app_state.get('app_UI_file')
Interface.save_UI_application_data(app_UI_filename)
user_UI_filename = self._gripy_app_state.get('user_UI_file')
Interface.save_UI_user_data(user_UI_filename)
# This time I choose not use the line below because there was a little
# freeze on exiting (1-2 seconds). Then I opted delegate it do compiler.
#UIM = UIManager()
#UIM.close()
UIM = UIManager()
UIM.PreExit()
# As indicated by https://forums.wxwidgets.org/viewtopic.php?t=32138
aui_manager = wx.aui.AuiManager.GetManager(self.GetTopWindow())
aui_manager.UnInit()