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()
python类CANCEL的实例源码
def __init__(self, parent):
# Translators: The title of a dialog to configure advanced WinTenApps add-on options such as update checking.
super(WinTenAppsConfigDialog, self).__init__(parent, title=_("Windows 10 App Essentials settings"))
mainSizer = wx.BoxSizer(wx.VERTICAL)
w10Helper = gui.guiHelper.BoxSizerHelper(self, orientation=wx.VERTICAL)
# Translators: A checkbox to toggle automatic add-on updates.
self.autoUpdateCheckbox=w10Helper.addItem(wx.CheckBox(self,label=_("Automatically check for add-on &updates")))
self.autoUpdateCheckbox.SetValue(config.conf["wintenApps"]["autoUpdateCheck"])
# Translators: The label for a setting in WinTenApps add-on settings to select automatic update interval in days.
self.updateInterval=w10Helper.addLabeledControl(_("Update &interval in days"), gui.nvdaControls.SelectOnFocusSpinCtrl, min=0, max=30, initial=config.conf["wintenApps"]["updateCheckTimeInterval"])
# Translators: The label for a combo box to select update channel.
labelText = _("&Add-on update channel:")
self.channels=w10Helper.addLabeledControl(labelText, wx.Choice, choices=["development", "stable"])
self.updateChannels = ("dev", "stable")
self.channels.SetSelection(self.updateChannels.index(config.conf["wintenApps"]["updateChannel"]))
if canUpdate:
# Translators: The label of a button to check for add-on updates.
updateCheckButton = w10Helper.addItem(wx.Button(self, label=_("Check for add-on &update")))
updateCheckButton.Bind(wx.EVT_BUTTON, self.onUpdateCheck)
w10Helper.addDialogDismissButtons(self.CreateButtonSizer(wx.OK | wx.CANCEL))
self.Bind(wx.EVT_BUTTON, self.onOk, id=wx.ID_OK)
self.Bind(wx.EVT_BUTTON, self.onCancel, id=wx.ID_CANCEL)
mainSizer.Add(w10Helper.sizer, border=gui.guiHelper.BORDER_FOR_DIALOGS, flag=wx.ALL)
mainSizer.Fit(self)
self.Sizer = mainSizer
self.autoUpdateCheckbox.SetFocus()
self.Center(wx.BOTH | (wx.CENTER_ON_SCREEN if hasattr(wx, "CENTER_ON_SCREEN") else 2))
def __init__(self, parent, name, library, default=None):
wx.Dialog.__init__(self,
name='BrowseValueDialog', parent=parent,
style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER,
title=_('Browse %s values library') % name)
self.staticText1 = wx.StaticText(
label=_('Choose a value for %s:') % name, name='staticText1', parent=self,
pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
self.ValuesLibrary = wx.TreeCtrl(
name='ValuesLibrary', parent=self, pos=wx.Point(0, 0),
size=wx.Size(400, 200), style=wx.TR_HAS_BUTTONS | wx.TR_SINGLE | wx.SUNKEN_BORDER | wx.TR_HIDE_ROOT | wx.TR_LINES_AT_ROOT)
self.ButtonSizer = self.CreateButtonSizer(wx.OK | wx.CANCEL | wx.CENTRE)
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=10)
self.flexGridSizer1.AddWindow(self.staticText1, 0, border=20, flag=wx.GROW | wx.TOP | wx.LEFT | wx.RIGHT)
self.flexGridSizer1.AddWindow(self.ValuesLibrary, 0, border=20, flag=wx.GROW | wx.LEFT | wx.RIGHT)
self.flexGridSizer1.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT | wx.BOTTOM | wx.LEFT | wx.RIGHT)
self.flexGridSizer1.AddGrowableCol(0)
self.flexGridSizer1.AddGrowableRow(1)
self.SetSizer(self.flexGridSizer1)
self.Fit()
root = self.ValuesLibrary.AddRoot("")
self.GenerateValuesLibraryBranch(root, library, default)
def __init__(self, parent, message, caption="Please enter text", defaultValue="",
style=wx.OK | wx.CANCEL | wx.CENTRE, pos=wx.DefaultPosition):
wx.TextEntryDialog.__init__(self, parent, message, caption, defaultValue, style, pos)
self.PouNames = []
self.Bind(wx.EVT_BUTTON, self.OnOK,
self.GetSizer().GetItem(2).GetSizer().GetItem(1).GetSizer().GetAffirmativeButton())
def __init__(self, parent, iec_type, defaultValue=""):
wx.TextEntryDialog.__init__(
self, parent,
message=_("Forcing Variable Value"),
caption=_("Please enter value for a \"%s\" variable:") % iec_type,
defaultValue=defaultValue,
style=wx.OK | wx.CANCEL | wx.CENTRE, pos=wx.DefaultPosition)
self.IEC_Type = iec_type
self.Bind(wx.EVT_BUTTON, self.OnOK,
self.GetSizer().GetItem(2).GetSizer().GetItem(1).
GetSizer().GetAffirmativeButton())
self.ValueTextCtrl = self.GetSizer().GetItem(1).GetWindow()
if self.IEC_Type == "BOOL":
self.ToggleButton = wx.ToggleButton(self, label=_("Toggle value"))
value = GetTypeValue[self.IEC_Type](defaultValue)
if value is not None:
self.ToggleButton.SetValue(value)
border = self.GetSizer().GetItem(1).GetBorder()
self.GetSizer().Insert(before=2, item=self.ToggleButton,
border=border,
flag=wx.LEFT | wx.RIGHT | wx.EXPAND)
self.Bind(wx.EVT_TOGGLEBUTTON, self.ToggleBoolValue, self.ToggleButton)
self.Fit()
def __init__(self, parent):
wx.Dialog.__init__(self, parent, title=_('Create a new transition'))
main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
main_sizer.AddGrowableCol(0)
main_sizer.AddGrowableRow(0)
infos_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=3, vgap=10)
infos_sizer.AddGrowableCol(1)
main_sizer.AddSizer(infos_sizer, border=20,
flag=wx.GROW | wx.TOP | wx.LEFT | wx.RIGHT)
transitionname_label = wx.StaticText(self, label=_('Transition Name:'))
infos_sizer.AddWindow(transitionname_label, border=4,
flag=wx.ALIGN_CENTER_VERTICAL | wx.TOP)
self.TransitionName = wx.TextCtrl(self, size=wx.Size(180, -1))
infos_sizer.AddWindow(self.TransitionName, flag=wx.GROW)
language_label = wx.StaticText(self, label=_('Language:'))
infos_sizer.AddWindow(language_label, border=4,
flag=wx.ALIGN_CENTER_VERTICAL | wx.TOP)
self.Language = wx.ComboBox(self, style=wx.CB_READONLY)
infos_sizer.AddWindow(self.Language, flag=wx.GROW)
button_sizer = self.CreateButtonSizer(wx.OK | wx.CANCEL | wx.CENTRE)
self.Bind(wx.EVT_BUTTON, self.OnOK, button_sizer.GetAffirmativeButton())
main_sizer.AddSizer(button_sizer, border=20, flag=wx.ALIGN_RIGHT | wx.BOTTOM)
self.SetSizer(main_sizer)
for language in GetTransitionLanguages():
self.Language.Append(_(language))
self.Fit()
self.PouNames = []
self.PouElementNames = []
def __init__(self, parent):
wx.Dialog.__init__(self, parent, title=_('Edit Duration'))
main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
main_sizer.AddGrowableCol(0)
main_sizer.AddGrowableRow(0)
controls_sizer = wx.FlexGridSizer(cols=len(CONTROLS), hgap=10, rows=2, vgap=10)
main_sizer.AddSizer(controls_sizer, border=20,
flag=wx.TOP | wx.LEFT | wx.RIGHT | wx.GROW)
controls = []
for i, (name, label) in enumerate(CONTROLS):
controls_sizer.AddGrowableCol(i)
st = wx.StaticText(self, label=label)
txtctrl = wx.TextCtrl(self, value='0', style=wx.TE_PROCESS_ENTER)
self.Bind(wx.EVT_TEXT_ENTER,
self.GetControlValueTestFunction(txtctrl),
txtctrl)
setattr(self, name, txtctrl)
controls.append((st, txtctrl))
for st, txtctrl in controls:
controls_sizer.AddWindow(st, flag=wx.GROW)
for st, txtctrl in controls:
controls_sizer.AddWindow(txtctrl, flag=wx.GROW)
button_sizer = self.CreateButtonSizer(wx.OK | wx.CANCEL | wx.CENTRE)
self.Bind(wx.EVT_BUTTON, self.OnOK, button_sizer.GetAffirmativeButton())
main_sizer.AddSizer(button_sizer, border=20,
flag=wx.ALIGN_RIGHT | wx.BOTTOM | wx.LEFT | wx.RIGHT)
self.SetSizer(main_sizer)
self.Fit()
self.Days.SetFocus()
def __init__(self, parent, message, caption="Please enter text", defaultValue="",
style=wx.OK | wx.CANCEL | wx.CENTRE, pos=wx.DefaultPosition):
wx.TextEntryDialog.__init__(self, parent, message, caption, defaultValue, style, pos)
self.PouNames = []
self.Variables = []
self.StepNames = []
self.Bind(wx.EVT_BUTTON, self.OnOK,
self.GetSizer().GetItem(2).GetSizer().GetItem(1).GetSizer().GetAffirmativeButton())
def OnBrowseButtonClick(self, event):
# pop up the location browser dialog
dialog = BrowseLocationsDialog(self, self.VarType, self.Controller)
if dialog.ShowModal() == wx.ID_OK:
infos = dialog.GetValues()
else:
infos = None
dialog.Destroy()
if infos is not None:
location = infos["location"]
# set the location
if not infos["location"].startswith("%"):
dialog = wx.SingleChoiceDialog(
self,
_("Select a variable class:"),
_("Variable class"),
[_("Input"), _("Output"), _("Memory")],
wx.DEFAULT_DIALOG_STYLE | wx.OK | wx.CANCEL)
if dialog.ShowModal() == wx.ID_OK:
selected = dialog.GetSelection()
else:
selected = None
dialog.Destroy()
if selected is None:
self.Location.SetFocus()
return
if selected == 0:
location = "%I" + location
elif selected == 1:
location = "%Q" + location
else:
location = "%M" + location
self.Location.SetValue(location)
self.VarType = infos["IEC_type"]
self.Location.SetFocus()
def AddJump(self):
if isinstance(self.SelectedElement, SFC_Step) and not self.SelectedElement.Output:
choices = []
for block in self.Blocks:
if isinstance(block, SFC_Step):
choices.append(block.GetName())
dialog = wx.SingleChoiceDialog(self.ParentWindow,
_("Add a new jump"),
_("Please choose a target"),
choices,
wx.DEFAULT_DIALOG_STYLE | wx.OK | wx.CANCEL)
if dialog.ShowModal() == wx.ID_OK:
value = dialog.GetStringSelection()
self.SelectedElement.AddOutput()
self.RefreshStepModel(self.SelectedElement)
step_connectors = self.SelectedElement.GetConnectors()
transition = self.CreateTransition(step_connectors["output"])
transition_connectors = transition.GetConnectors()
id = self.GetNewId()
jump = SFC_Jump(self, value, id)
pos = transition_connectors["output"].GetPosition(False)
jump.SetPosition(pos.x, pos.y + SFC_WIRE_MIN_SIZE)
self.AddBlock(jump)
self.Controler.AddEditedElementJump(self.TagName, id)
jump_connector = jump.GetConnector()
wire = self.ConnectConnectors(jump_connector, transition_connectors["output"])
transition.RefreshOutputPosition()
wire.SetPoints([wx.Point(pos.x, pos.y + SFC_WIRE_MIN_SIZE), wx.Point(pos.x, pos.y)])
self.RefreshJumpModel(jump)
self.RefreshBuffer()
self.RefreshScrollBars()
self.Refresh(False)
dialog.Destroy()
def EditJumpContent(self, jump):
choices = []
for block in self.Blocks.itervalues():
if isinstance(block, SFC_Step):
choices.append(block.GetName())
dialog = wx.SingleChoiceDialog(self.ParentWindow,
_("Edit jump target"),
_("Please choose a target"),
choices,
wx.DEFAULT_DIALOG_STYLE | wx.OK | wx.CANCEL)
try:
indx = choices.index(jump.GetTarget())
dialog.SetSelection(indx)
except ValueError:
pass
if dialog.ShowModal() == wx.ID_OK:
value = dialog.GetStringSelection()
rect = jump.GetRedrawRect(1, 1)
jump.SetTarget(value)
rect = rect.Union(jump.GetRedrawRect())
self.RefreshJumpModel(jump)
self.RefreshBuffer()
self.RefreshScrollBars()
self.RefreshVisibleElements()
jump.Refresh(rect)
dialog.Destroy()
def __init__(self, parent, message, caption=_("Please enter text"), defaultValue="",
style=wx.OK | wx.CANCEL | wx.CENTRE, pos=wx.DefaultPosition):
wx.TextEntryDialog.__init__(self, parent, message, caption, defaultValue, style, pos)
self.Tests = []
if wx.VERSION >= (2, 8, 0):
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetAffirmativeId())
elif wx.VERSION >= (2, 6, 0):
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetAffirmativeButton().GetId())
else:
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId())
def yes_no(info, title="ImagePy Yes-No ?!"):
dlg = wx.MessageDialog(curapp, info, title, wx.YES_NO | wx.CANCEL)
rst = dlg.ShowModal()
dlg.Destroy()
dic = {wx.ID_YES:'yes', wx.ID_NO:'no', wx.ID_CANCEL:'cancel'}
return dic[rst]
def MsgDlg(window, string, caption='OFAImage', style=wx.YES_NO | wx.CANCEL):
"""Common MessageDialog."""
dlg = wx.MessageDialog(window, string, caption, style)
result = dlg.ShowModal()
dlg.Destroy()
return result
def __init__(self, *args, **kwargs):
if 'size' not in kwargs:
kwargs['size'] = (360, 240)
super(NewPartitionDialog, self).__init__(*args, **kwargs)
# ico = wx.Icon(r'./icons/plus32x32.ico', wx.BITMAP_TYPE_ICO)
# self.SetIcon(ico)
fgs = wx.BoxSizer(wx.HORIZONTAL)
main_label = wx.StaticText(self, label="Fill up the cell below to create a new partition.")
name_label = wx.StaticText(self, label="Name Partition: ")
# unit_label = wx.StaticText(self, label="Unidade: ")
self.name_ctrl = wx.TextCtrl(self)
# self.unit_ctrl = wx.TextCtrl(self)
fgs.Add(name_label, 0, wx.EXPAND)
fgs.Add(self.name_ctrl, 1, wx.EXPAND)
# fgs.AddGrowableRow(0)
sizer = wx.BoxSizer(wx.VERTICAL)
button_sizer = self.CreateButtonSizer(wx.OK | wx.CANCEL)
#if _iswxphoenix:
sizer.Add(main_label, 1, wx.GROW | wx.EXPAND)
sizer.Add(fgs, 0, wx.EXPAND)
sizer.Add(button_sizer, 0, wx.EXPAND)
#else:
# sizer.AddSizer(fgs, proportion=1, flag=wx.EXPAND)
# sizer.AddSizer(button_sizer, proportion=0, flag=wx.EXPAND)
# self.
self.SetSizer(sizer)
self.name_ctrl.SetFocus()
def __init__(self, welluid, *args, **kwargs):
super(Dialog, self).__init__(*args, **kwargs)
self.welluid = welluid
self.partitionuid = None
self._OM = ObjectManager(self)
self.partitionmap = [pttn.uid for pttn in self._OM.list('partition', self.welluid)]
partitionchoiceitems = [pttn.name for pttn in self._OM.list('partition', self.welluid)]
self.partmap = []
self.partitionchoice = wx.Choice(self)
self.partitionchoice.AppendItems(partitionchoiceitems)
self.partitionchoice.Bind(wx.EVT_CHOICE, self.on_partition_choice)
self.partslistbox = wx.CheckListBox(self)
button_sizer = self.CreateButtonSizer(wx.OK | wx.CANCEL)
main_sizer = wx.BoxSizer(wx.VERTICAL)
main_sizer.Add(self.partitionchoice, proportion=0, flag=wx.EXPAND)
main_sizer.Add(self.partslistbox, proportion=1, flag=wx.EXPAND)
main_sizer.AddSizer(button_sizer, proportion=0, flag=wx.ALIGN_RIGHT)
self.SetSizer(main_sizer)
if len(self.partitionmap) == 1:
self.set_partitionuid(self.partitionmap[0])
def __init__(self, *args, **kwargs):
if 'on_ok_callback' in kwargs:
self.on_ok_callback = kwargs.pop('on_ok_callback')
else:
self.on_ok_callback = None
if 'on_cancel_callback' in kwargs:
self.on_cancel_callback = kwargs.pop('on_cancel_callback')
else:
self.on_cancel_callback = None
super(Dialog, self).__init__(*args, **kwargs)
self._OM = ObjectManager(self)
self._OM.subscribe(self.on_wells_changed, 'add')
self._OM.subscribe(self.on_wells_changed, 'post_remove')
#self._OM.addcallback("add", self.on_wells_change)
#self._OM.addcallback("post-remove", self.on_wells_change)
self._mapui = []
self.choice = wx.Choice(self)
self.choice.Bind(wx.EVT_CHOICE, self.on_select)
self.ls_panel = Panel(self)
button_sizer = self.CreateButtonSizer(wx.OK | wx.CANCEL)
self.Bind(wx.EVT_BUTTON, self.on_button)
vbox = wx.BoxSizer(wx.VERTICAL)
vbox.Add(self.choice, flag=wx.ALIGN_CENTER)
vbox.Add(self.ls_panel, 1, wx.ALL | wx.EXPAND)
vbox.Add(button_sizer, flag=wx.ALIGN_RIGHT)
self.SetSizer(vbox)
self.SetSize((400, 600))
self.SetTitle(u"Seletor de Perfis para Plotagem")
self.on_wells_change(None)
def __init__(self, parent, names, units, curvetypes, datatypes, *args, **kwargs):
if 'on_ok_callback' in kwargs:
self.on_ok_callback = kwargs.pop('on_ok_callback')
else:
self.on_ok_callback = None
if 'on_cancel_callback' in kwargs:
self.on_cancel_callback = kwargs.pop('on_cancel_callback')
else:
self.on_cancel_callback = None
super(Dialog, self).__init__(parent, *args, **kwargs)
self.names = names
self.units = units
self.curvetypes = curvetypes
self.datatypes = datatypes
self.nrows = len(self.names)
style = wx.LC_REPORT | wx.LC_VRULES | wx.LC_HRULES | wx.LC_SINGLE_SEL | ULC.ULC_HAS_VARIABLE_ROW_HEIGHT
self.list = ULC.UltimateListCtrl(self, wx.ID_ANY, agwStyle=style)
self._fill_list()
button_sizer = self.CreateButtonSizer(wx.OK | wx.CANCEL)
self.Bind(wx.EVT_BUTTON, self.on_button)
vbox = wx.BoxSizer(wx.VERTICAL)
vbox.Add(self.list, proportion=1, flag=wx.EXPAND)
vbox.Add(button_sizer, flag=wx.ALIGN_RIGHT)
self.SetSizerAndFit(vbox)
self.SetSize((400, 600))
self.SetTitle(u"Importar como:")
def __init__(self, *args, **kwargs):
if 'on_ok_callback' in kwargs:
self.on_ok_callback = kwargs.pop('on_ok_callback')
else:
self.on_ok_callback = None
if 'on_cancel_callback' in kwargs:
self.on_cancel_callback = kwargs.pop('on_cancel_callback')
else:
self.on_cancel_callback = None
super(Dialog, self).__init__(*args, **kwargs)
self.wells = None
self.choice = wx.Choice(self)
button_sizer = self.CreateButtonSizer(wx.OK | wx.CANCEL)
self.Bind(wx.EVT_BUTTON, self.on_button)
vbox = wx.BoxSizer(wx.VERTICAL)
vbox.Add(self.choice, flag=wx.ALIGN_CENTER)
vbox.Add(button_sizer, flag=wx.ALIGN_RIGHT)
self.SetSizer(vbox)
self.SetSize((300, 200))
self.SetTitle(u"Seletcione o poço")
def __init__(self, uiparent, inputdesc, *args, **kwargs):
if 'on_ok_callback' in kwargs:
self.on_ok_callback = kwargs.pop('on_ok_callback')
else:
self.on_ok_callback = None
if 'on_cancel_callback' in kwargs:
self.on_cancel_callback = kwargs.pop('on_cancel_callback')
else:
self.on_cancel_callback = None
super(AutoGenDialog, self).__init__(uiparent, *args, **kwargs)
self._OM = ObjectManager(self)
well_label = wx.StaticText(self, label=u"Poço:")
self.well_choice = self._create_well_choice()
hbox = wx.BoxSizer(wx.HORIZONTAL)
hbox.Add(well_label, proportion=0, flag=wx.ALL, border=5)
hbox.Add(self.well_choice, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)
self.autogenpanel = AutoGenPanel(self, inputdesc)
button_sizer = self.CreateButtonSizer(wx.OK | wx.CANCEL)
self.Bind(wx.EVT_BUTTON, self.on_button)
vbox = wx.BoxSizer(wx.VERTICAL)
vbox.Add(hbox, proportion=0, flag=wx.EXPAND | wx.ALL, border=5)
vbox.Add(self.autogenpanel, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)
vbox.Add(button_sizer, flag=wx.ALIGN_RIGHT | wx.ALL, border=5)
self.SetSizerAndFit(vbox)
# self.SetSize((400, 800))