本文整理汇总了Python中Settings.Settings.preserve方法的典型用法代码示例。如果您正苦于以下问题:Python Settings.preserve方法的具体用法?Python Settings.preserve怎么用?Python Settings.preserve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Settings.Settings
的用法示例。
在下文中一共展示了Settings.preserve方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SetupGUI
# 需要导入模块: from Settings import Settings [as 别名]
# 或者: from Settings.Settings import preserve [as 别名]
#.........这里部分代码省略.........
self.Bind(wx.EVT_BUTTON, self.OnAddWager, self.addbtn)
elif index is not -1:
self.addbtn.SetLabel("Edit")
self.Unbind(wx.EVT_BUTTON, self.addbtn)
# need to subtract one from the index to account for the "New" item
self.addbtn.Bind(wx.EVT_BUTTON, lambda event : self.OnEditWager(event, index-1))
def OnDeleteWager(self, event):
index = -1
for wager in self.wagerrows:
if wager.GetItem(2).GetWindow() is event.GetEventObject():
break
self.RemoveWager(wager)
def OnEditWager(self, event, index):
wagertext = self.wagerrows[index].GetItem(1).GetWindow()
wagertext.SetLabel(self.amountentry.GetValue() + " " + self.currencytype.GetStringSelection())
self.update_wagers()
def RemoveWager(self, wager):
index = self.wagerrows.index(wager)
self.wagertable.Hide(self.wagerrows[index])
self.wagerrows[index].DeleteWindows()
del self.wagerrows[index]
self.wagernum.Delete(index+1)
# fix the wager numbering
i = 1
for wager in self.wagerrows:
number = wager.GetItem(0).GetWindow()
number.SetLabel("Wager " + str(i) + ":")
self.wagernum.SetString(i, str(i))
i += 1
self.update_wagers()
def OnSave(self, event):
saveDia = wx.FileDialog(self, 'Save your settings', 'settings', self.settings.name, "*.set", wx.FD_SAVE)
outcome = saveDia.ShowModal()
if outcome == wx.ID_OK:
name = saveDia.GetPath()
#HACKY TIME
count = name.count(".set")
if count > 1:
name = name.replace(".set", "", count - 1)
self.settings.name = name
self.settings.preserve()
def OnLoad(self, event):
openDia = wx.FileDialog(self, 'Choose your settings', 'settings', self.settings.name, "*.set", wx.FD_OPEN)
outcome = openDia.ShowModal()
if outcome == wx.ID_OK:
f = open(openDia.GetPath())
settings = pickle.load(f)
f.close()
self.settings = settings
self.UpdateFromSettings()
#*******************************************
# Info Callbacks
#*******************************************
def OnGetProbEstimate(self, event):
self.enable_sizer_items(self.probrow, event.IsChecked())
#*******************************************
# Common Callbacks
#*******************************************
def OnOkay(self, event):
message = wx.MessageDialog(self, "Do you want to accept these settings?", caption="",
style=wx.YES_NO|wx.ICON_QUESTION)
ans = message.ShowModal()
if ans == wx.ID_YES:
self.Hide()
if self.collectname.IsChecked() or self.collectage.IsChecked() or self.collectsex.IsChecked() or self.collecthandedness.IsChecked():
infodialog = subjectinfo.SubjectInfoDialog(self, "Subject Info")
infodialog.enable_control("Name", self.collectname.IsChecked())
infodialog.enable_control("Age", self.collectage.IsChecked())
infodialog.enable_control("Sex", self.collectsex.IsChecked())
infodialog.enable_control("Handedness", self.collecthandedness.IsChecked())
ans2 = infodialog.ShowModal()
if ans2 == wx.ID_SAVE:
#infodialog.save_info()
infodialog.save_info()
infodialog.cogsub.expname = self.settings.saveAs
infodialog.cogsub.session = self.settings.session
game = gameplay.GamePlayGUI(None, self.settings, infodialog.cogsub)
else:
self.Show()
return
else:
game = gameplay.GamePlayGUI(None, self.settings, None)
game.Show()
self.Destroy()