本文整理汇总了Python中wx.EVT_KILL_FOCUS属性的典型用法代码示例。如果您正苦于以下问题:Python wx.EVT_KILL_FOCUS属性的具体用法?Python wx.EVT_KILL_FOCUS怎么用?Python wx.EVT_KILL_FOCUS使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类wx
的用法示例。
在下文中一共展示了wx.EVT_KILL_FOCUS属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_KILL_FOCUS [as 别名]
def __init__(self, parent, default_text, visit_url_func):
wx.TextCtrl.__init__(self, parent, size=(150,-1), style=wx.TE_PROCESS_ENTER|wx.TE_RICH)
self.default_text = default_text
self.visit_url_func = visit_url_func
self.reset_text(force=True)
self._task = TaskSingleton()
event = wx.SizeEvent((150, -1), self.GetId())
wx.PostEvent(self, event)
self.old = self.GetValue()
self.Bind(wx.EVT_TEXT, self.begin_edit)
self.Bind(wx.EVT_SET_FOCUS, self.begin_edit)
def focus_lost(event):
gui_wrap(self.reset_text)
self.Bind(wx.EVT_KILL_FOCUS, focus_lost)
self.Bind(wx.EVT_TEXT_ENTER, self.search)
示例2: create_text_ctrl
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_KILL_FOCUS [as 别名]
def create_text_ctrl(self, panel, value):
style = 0
if self.readonly: style = wx.TE_READONLY
if self.multiline: style |= wx.TE_MULTILINE
else: style |= wx.TE_PROCESS_ENTER
if not self._HORIZONTAL_LAYOUT: style |= wx.HSCROLL
if self.multiline=="grow":
text = ExpandoTextCtrl( panel, -1, value or "", style=style )
#text.Bind(EVT_ETC_LAYOUT_NEEDED, self.on_layout_needed)
text.SetWindowStyle(wx.TE_MULTILINE | wx.TE_RICH2)
text.SetMaxHeight(200)
else:
text = wx.TextCtrl( panel, -1, value or "", style=style )
# bind KILL_FOCUS and Enter for non-multilines
text.Bind(wx.EVT_KILL_FOCUS, self.on_kill_focus)
text.Bind(wx.EVT_SET_FOCUS, self.on_focus)
# XXX
text.Bind(wx.EVT_CHAR, self.on_char)
text.Bind(wx.EVT_TEXT, self._on_text)
return text
示例3: _on_text_click
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_KILL_FOCUS [as 别名]
def _on_text_click(self, event):
if self.deactivated and not self.auto_activated and self.text:
text_rect = self.text.GetClientRect()
text_rect.Offset(self.text.Position)
if text_rect.Contains(event.Position):
self.toggle_active(active=True)
return
event.Skip()
#class ListBoxProperty(ComboBoxProperty):
#def __init__(self, value="", choices=[], default_value=_DefaultArgument, name=None):
#self.choices = choices
#TextProperty.__init__(self, value, False, default_value, name)
#def create_text_ctrl(self, panel, value):
#style = wx.LB_SINGLE
#combo = wx.ListBox( panel, -1, self.value, choices=self.choices, style=style )
#combo.Bind(wx.EVT_LISTBOX, self.on_combobox)
##combo.Bind(wx.EVT_KILL_FOCUS, self.on_kill_focus)
##combo.Bind(wx.EVT_CHAR, self.on_char)
#return combo
示例4: AddSizerParams
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_KILL_FOCUS [as 别名]
def AddSizerParams(self, parent, sizer, params):
for idx, (name, label) in enumerate(params):
border = 0
if idx == 0:
border |= wx.TOP
elif idx == len(params) - 1:
border |= wx.BOTTOM
st = wx.StaticText(parent, label=label)
sizer.AddWindow(st, border=10,
flag=wx.ALIGN_CENTER_VERTICAL | border | wx.LEFT)
tc = wx.TextCtrl(parent, style=wx.TE_PROCESS_ENTER)
setattr(self, name, tc)
callback = self.GetTextCtrlChangedFunction(tc, name)
self.Bind(wx.EVT_TEXT_ENTER, callback, tc)
tc.Bind(wx.EVT_KILL_FOCUS, callback)
sizer.AddWindow(tc, border=10,
flag=wx.GROW | border | wx.RIGHT)
示例5: addSpin
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_KILL_FOCUS [as 别名]
def addSpin(self, name, descr, parent, sizer, cfgName):
sizer.Add(wx.StaticText(parent, -1, descr), 0,
wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 10)
entry = wx.SpinCtrl(parent, -1)
entry.SetRange(*self.cfg.cvars.getMinMax(cfgName))
wx.EVT_SPINCTRL(self, entry.GetId(), self.OnMisc)
wx.EVT_KILL_FOCUS(entry, self.OnKillFocus)
sizer.Add(entry, 0)
setattr(self, name + "Entry", entry)
示例6: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_KILL_FOCUS [as 别名]
def __init__(self, parent, frame, *args, **kwargs):
self.frame = frame
wx.TextCtrl.__init__(self, parent, *args, **kwargs)
self.SetEditable(False)
self.Bind(wx.EVT_MOUSE_EVENTS, self.__OnMouseEvent)
self.Bind(wx.EVT_SET_FOCUS, self.__OnSetFocus)
self.Bind(wx.EVT_KILL_FOCUS, self.__OnKillFocus)
self.Bind(wx.EVT_LEFT_UP, self.__OnLeftUp)
示例7: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_KILL_FOCUS [as 别名]
def __init__(self, parent, id=wx.ID_ANY, label="", pos=wx.DefaultPosition,
size=wx.DefaultSize, style=wx.NO_BORDER, validator=wx.DefaultValidator,
name="roundbutton"):
"""
Default class constructor.
:param `parent`: the L{RoundButton} parent;
:param `id`: window identifier. A value of -1 indicates a default value;
:param `label`: the button text label;
:param `pos`: the control position. A value of (-1, -1) indicates a default position,
chosen by either the windowing system or wxPython, depending on platform;
:param `size`: the control size. A value of (-1, -1) indicates a default size,
chosen by either the windowing system or wxPython, depending on platform;
:param `style`: the button style (unused);
:param `validator`: the validator associated to the button;
:param `name`: the button name.
"""
wx.PyControl.__init__(self, parent, id, pos, size, style, validator, name)
self.Bind(wx.EVT_PAINT, self.OnPaint)
self.Bind(wx.EVT_ERASE_BACKGROUND, lambda event: None)
self.Bind(wx.EVT_SIZE, self.OnSize)
self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
self.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseLeave)
self.Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter)
self.Bind(wx.EVT_SET_FOCUS, self.OnGainFocus)
self.Bind(wx.EVT_KILL_FOCUS, self.OnLoseFocus)
self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
self.Bind(wx.EVT_KEY_UP, self.OnKeyUp)
self.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDown)
self._mouseAction = None
self._hasFocus = False
self._buttonRadius = 0
self.SetLabel(label)
self.InheritAttributes()
self.SetInitialSize(size)
示例8: OnLoseFocus
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_KILL_FOCUS [as 别名]
def OnLoseFocus(self, event):
"""
Handles the ``wx.EVT_KILL_FOCUS`` event for L{RoundButton}.
:param `event`: a `wx.FocusEvent` event to be processed.
"""
self._hasFocus = False
self.Refresh()
self.Update()
示例9: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_KILL_FOCUS [as 别名]
def __init__(self, parent, *args, **kwargs):
wx.StaticText.__init__(
self, parent, *args, style=wx.BORDER_NONE|wx.TE_CENTRE,
size=(-1, 20), **kwargs)
self._StatusPos = 0
self.Bind(wx.EVT_KILL_FOCUS, self._OnUnfocus)
示例10: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_KILL_FOCUS [as 别名]
def __init__(self, parent, option_name, config, setfunc):
wx.TextCtrl.__init__(self, parent)
self.option_name = option_name
self.config = config
self.setfunc = setfunc
self.SetValue(str(config[option_name]))
self.SetBestFittingSize((self.width,-1))
self.Bind(wx.EVT_CHAR, self.text_inserted)
self.Bind(wx.EVT_KILL_FOCUS, self.focus_out)
示例11: create_editor
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_KILL_FOCUS [as 别名]
def create_editor(self, panel, sizer):
if self.val_range is None:
self.val_range = (0, 1000)
hsizer = wx.BoxSizer(wx.HORIZONTAL)
# label
label_text = self._find_label()
label = self.label_ctrl = self._get_label(label_text, panel)
hsizer.Add(label, 0, wx.ALL | wx.ALIGN_CENTER, 3)
# checkbox, if applicable
self.enabler = None
if self.deactivated is not None:
self.enabler = wx.CheckBox(panel, -1, '')
if config.preferences.use_checkboxes_workaround:
size = self.enabler.GetSize()
self.enabler.SetLabel("Enable %s"%label_text)
self.enabler.SetMaxSize(size)
self.enabler.SetValue(not self.deactivated)
self.enabler.Bind( wx.EVT_CHECKBOX, lambda event: self.toggle_active(event.IsChecked()) )
hsizer.Add(self.enabler, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT, 3)
self.spin = self.create_spin_ctrl(panel)
if self.deactivated is not None:
self.spin.Enable(not self.deactivated)
elif self.blocked or self.readonly:
self.spin.Enable(False)
# layout of the controls / sizers
hsizer.Add(self.spin, 5, wx.ALL | wx.ALIGN_CENTER, 3)
sizer.Add(hsizer, 0, wx.EXPAND)
self._set_tooltip(label, self.spin, self.enabler)
self.spin.Bind(wx.EVT_KILL_FOCUS, self.on_kill_focus) # by default, the value is only set when the focus is lost
self.spin.Bind(wx.EVT_SET_FOCUS, self.on_focus)
if wx.Platform == '__WXMAC__' or self.immediate:
self.spin.Bind(wx.EVT_SPINCTRL, self.on_spin)
self.spin.Bind(wx.EVT_TEXT_ENTER, self.on_spin) # we want the enter key (see style above)
self.editing = True
示例12: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_KILL_FOCUS [as 别名]
def __init__(self, parent, document, size=wx.DefaultSize):
self.document = document
self.root = None
self.editLabelId = None
self.insertionMark = None
self.editControl = EditControlProxy(self)
style = (
wx.TR_HAS_BUTTONS |
wx.TR_EDIT_LABELS |
wx.TR_ROW_LINES |
wx.CLIP_CHILDREN
)
wx.TreeCtrl.__init__(self, parent, size=size, style=style)
self.SetImageList(eg.Icons.gImageList)
self.hwnd = self.GetHandle()
self.normalfont = self.GetFont()
self.italicfont = self.GetFont()
self.italicfont.SetStyle(wx.FONTSTYLE_ITALIC)
self.Bind(wx.EVT_SET_FOCUS, self.OnGetFocusEvent)
self.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocusEvent)
self.Bind(wx.EVT_TREE_ITEM_EXPANDING, self.OnItemExpandingEvent)
self.Bind(wx.EVT_TREE_ITEM_COLLAPSING, self.OnItemCollapsingEvent)
self.Bind(wx.EVT_TREE_BEGIN_LABEL_EDIT, self.OnBeginLabelEditEvent)
self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.OnEndLabelEditEvent)
self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnItemActivateEvent)
self.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDoubleClickEvent)
self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.OnRightClickEvent)
self.Bind(wx.EVT_TREE_ITEM_MENU, self.OnItemMenuEvent)
self.Bind(wx.EVT_TREE_BEGIN_DRAG, self.OnBeginDragEvent)
self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelectionChangedEvent)
self.visibleNodes = {}
self.expandedNodes = document.expandedNodes
self.dropTarget = DropTarget(self)
self.SetDropTarget(self.dropTarget)
eg.Bind("NodeAdded", self.OnNodeAdded)
eg.Bind("NodeDeleted", self.OnNodeDeleted)
eg.Bind("NodeChanged", self.OnNodeChanged)
eg.Bind("NodeSelected", self.OnNodeSelected)
eg.Bind("DocumentNewRoot", self.OnNewRoot)
if document.root:
self.OnNewRoot(document.root)
示例13: OnKillFocusEvent
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_KILL_FOCUS [as 别名]
def OnKillFocusEvent(self, event):
"""
Handles wx.EVT_KILL_FOCUS
"""
if self.editLabelId is None:
eg.Notify("FocusChange", None)
event.Skip(True)
示例14: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_KILL_FOCUS [as 别名]
def __init__(self, parent, choices=None, dropDownClick=True,
element_path=None, **therest):
"""
Constructor works just like wx.TextCtrl except you can pass in a
list of choices. You can also change the choice list at any time
by calling setChoices.
"""
therest['style'] = wx.TE_PROCESS_ENTER | therest.get('style', 0)
wx.TextCtrl.__init__(self, parent, **therest)
# Some variables
self._dropDownClick = dropDownClick
self._lastinsertionpoint = None
self._hasfocus = False
self._screenheight = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_Y)
self.element_path = element_path
self.listbox = None
self.SetChoices(choices)
# gp = self
# while ( gp != None ) :
# gp.Bind ( wx.EVT_MOVE , self.onControlChanged, gp )
# gp.Bind ( wx.EVT_SIZE , self.onControlChanged, gp )
# gp = gp.GetParent()
self.Bind(wx.EVT_KILL_FOCUS, self.OnControlChanged)
self.Bind(wx.EVT_TEXT_ENTER, self.OnControlChanged)
self.Bind(wx.EVT_TEXT, self.OnEnteredText)
self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
# If need drop down on left click
if dropDownClick:
self.Bind(wx.EVT_LEFT_DOWN, self.OnClickToggleDown)
self.Bind(wx.EVT_LEFT_UP, self.OnClickToggleUp)
示例15: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_KILL_FOCUS [as 别名]
def __init__(self, *args, **kwargs):
wx.lib.intctrl.IntCtrl.__init__(self, *args, **kwargs)
self.Bind(wx.EVT_KILL_FOCUS, self.UpdateValue)
self.SetLongAllowed(True)
self.SetLimited(False)