Python wx.EVT_KILL_FOCUS Examples
The following are 21
code examples of wx.EVT_KILL_FOCUS().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
wx
, or try the search function
.
Example #1
Source File: new_properties.py From wxGlade with MIT License | 7 votes |
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
Example #2
Source File: ProjectPropertiesPanel.py From OpenPLC_Editor with GNU General Public License v3.0 | 6 votes |
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)
Example #3
Source File: DownloadManager.py From BitTorrent with GNU General Public License v3.0 | 6 votes |
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)
Example #4
Source File: new_properties.py From wxGlade with MIT License | 6 votes |
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
Example #5
Source File: new_properties.py From wxGlade with MIT License | 5 votes |
def create_editor(self, panel, sizer): if not _is_gridbag(self.owner.parent): return max_rows, max_cols = self.owner.parent.check_span_range(self.owner.index, *self.value) hsizer = wx.BoxSizer(wx.HORIZONTAL) # label self.label_ctrl = label = self._get_label(self._find_label(), panel) hsizer.Add(label, 0, wx.ALL | wx.ALIGN_CENTER, 3) # checkbox, if applicable self.enabler = None style = wx.TE_PROCESS_ENTER | wx.SP_ARROW_KEYS self.rowspin = wx.SpinCtrl( panel, -1, style=style, min=1, max=max_rows) # don't set size here as the self.colspin = wx.SpinCtrl( panel, -1, style=style, min=1, max=max_cols) # combination withe SetSelection fails val = self.value self.rowspin.SetValue(val and val[0] or 1) self.colspin.SetValue(val and val[1] or 1) self.rowspin.Enable(max_rows!=1) self.colspin.Enable(max_cols!=1) self.rowspin.SetSelection(-1, -1) self.colspin.SetSelection(-1, -1) # layout of the controls / sizers; when adding the spins, set min size as well hsizer.Add(wx.StaticText(panel, -1, _("Rows:")), 1, wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 3) si = hsizer.Add(self.rowspin, 5, wx.ALL | wx.ALIGN_CENTER, 3).SetMinSize( (30,-1) ) hsizer.Add(wx.StaticText(panel, -1, _("Cols:")), 1, wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 3) hsizer.Add(self.colspin, 5, wx.ALL | wx.ALIGN_CENTER, 3).SetMinSize( (30,-1) ) sizer.Add(hsizer, 0, wx.EXPAND) self._set_tooltip(label, self.rowspin, self.colspin) self.rowspin.Bind(wx.EVT_KILL_FOCUS, self.on_kill_focus) # by default, the value is only set when the focus is lost self.colspin.Bind(wx.EVT_KILL_FOCUS, self.on_kill_focus) self.rowspin.Bind(wx.EVT_SET_FOCUS, self.on_focus) self.colspin.Bind(wx.EVT_SET_FOCUS, self.on_focus) if self.immediate: self.rowspin.Bind(wx.EVT_SPINCTRL, self.on_spin) self.rowspin.Bind(wx.EVT_TEXT_ENTER, self.on_spin) # we want the enter key (see style above) self.colspin.Bind(wx.EVT_SPINCTRL, self.on_spin) self.colspin.Bind(wx.EVT_TEXT_ENTER, self.on_spin) self.editing = True
Example #6
Source File: spotfinder_frame.py From dials with BSD 3-Clause "New" or "Revised" License | 5 votes |
def OnDestroy(self, event): "Handle any cleanup when the windows is being destroyed. Manually Called." # If we don't remove this here, then we can get called after destroy self.brightness_txt_ctrl.Unbind(wx.EVT_KILL_FOCUS) # CONTROLS 2: Fetch values from widgets
Example #7
Source File: ObjectListView.py From bookhub with MIT License | 5 votes |
def _ConfigureCellEditor(self, editor, bounds, rowIndex, subItemIndex): """ Perform the normal configuration on the cell editor. """ editor.SetDimensions(*bounds) colour = self.GetItemBackgroundColour(rowIndex) if colour.IsOk(): editor.SetBackgroundColour(colour) else: editor.SetBackgroundColour(self.GetBackgroundColour()) colour = self.GetItemTextColour(rowIndex) if colour.IsOk(): editor.SetForegroundColour(colour) else: editor.SetForegroundColour(self.GetTextColour()) font = self.GetItemFont(rowIndex) if font.IsOk(): editor.SetFont(font) else: editor.SetFont(self.GetFont()) if hasattr(self.cellEditor, "SelectAll"): self.cellEditor.SelectAll() editor.Bind(wx.EVT_CHAR, self._Editor_OnChar) editor.Bind(wx.EVT_COMMAND_ENTER, self._Editor_OnChar) editor.Bind(wx.EVT_KILL_FOCUS, self._Editor_KillFocus)
Example #8
Source File: CustomIntCtrl.py From OpenPLC_Editor with GNU General Public License v3.0 | 5 votes |
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)
Example #9
Source File: TextCtrlAutoComplete.py From OpenPLC_Editor with GNU General Public License v3.0 | 5 votes |
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)
Example #10
Source File: TreeCtrl.py From EventGhost with GNU General Public License v2.0 | 5 votes |
def OnKillFocusEvent(self, event): """ Handles wx.EVT_KILL_FOCUS """ if self.editLabelId is None: eg.Notify("FocusChange", None) event.Skip(True)
Example #11
Source File: TreeCtrl.py From EventGhost with GNU General Public License v2.0 | 5 votes |
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)
Example #12
Source File: new_properties.py From wxGlade with MIT License | 5 votes |
def create_text_ctrl(self, panel, value): combo = wx.ComboBox( panel, -1, self.value, choices=self.choices, style=self._CB_STYLE ) combo.SetStringSelection(self.value) combo.Bind(wx.EVT_COMBOBOX, self.on_combobox) combo.Bind(wx.EVT_KILL_FOCUS, self.on_kill_focus) combo.Bind(wx.EVT_SET_FOCUS, self.on_focus) combo.Bind(wx.EVT_CHAR, self.on_char) return combo
Example #13
Source File: new_properties.py From wxGlade with MIT License | 5 votes |
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
Example #14
Source File: __init__.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
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)
Example #15
Source File: benchmarks.py From nuxhash with GNU General Public License v3.0 | 5 votes |
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)
Example #16
Source File: recipe-577951.py From code with MIT License | 5 votes |
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()
Example #17
Source File: recipe-577951.py From code with MIT License | 5 votes |
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)
Example #18
Source File: yamled.py From report-ng with GNU General Public License v2.0 | 5 votes |
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)
Example #19
Source File: cfgdlg.py From trelby with GNU General Public License v2.0 | 5 votes |
def addSpin(self, name, descr, parent, sizer, cfgName): hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add(wx.StaticText(parent, -1, descr), 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 10) tmp = wx.SpinCtrl(parent, -1) tmp.SetRange(*self.cfg.cvars.getMinMax(cfgName)) wx.EVT_SPINCTRL(self, tmp.GetId(), self.OnMisc) wx.EVT_KILL_FOCUS(tmp, self.OnKillFocus) hsizer.Add(tmp) sizer.Add(hsizer, 0, wx.BOTTOM, 10) setattr(self, name + "Entry", tmp)
Example #20
Source File: cfgdlg.py From trelby with GNU General Public License v2.0 | 5 votes |
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)
Example #21
Source File: cfgdlg.py From trelby with GNU General Public License v2.0 | 4 votes |
def __init__(self, parent, id, cfg): wx.Panel.__init__(self, parent, id) self.cfg = cfg vsizer = wx.BoxSizer(wx.VERTICAL) vsizer.Add(wx.StaticText(self, -1, "Screen fonts:")) self.fontsLb = wx.ListBox(self, -1, size = (300, 100)) for it in ["fontNormal", "fontBold", "fontItalic", "fontBoldItalic"]: self.fontsLb.Append("", it) vsizer.Add(self.fontsLb, 0, wx.BOTTOM, 10) hsizer = wx.BoxSizer(wx.HORIZONTAL) btn = wx.Button(self, -1, "Change") wx.EVT_LISTBOX_DCLICK(self, self.fontsLb.GetId(), self.OnChangeFont) wx.EVT_BUTTON(self, btn.GetId(), self.OnChangeFont) self.errText = wx.StaticText(self, -1, "") self.origColor = self.errText.GetForegroundColour() hsizer.Add(btn) hsizer.Add((20, -1)) hsizer.Add(self.errText, 0, wx.ALIGN_CENTER_VERTICAL) vsizer.Add(hsizer, 0, wx.BOTTOM, 20) vsizer.Add(wx.StaticText(self, -1, "The settings below apply only" " to 'Draft' view mode."), 0, wx.BOTTOM, 15) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add(wx.StaticText(self, -1, "Row spacing:"), 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 10) self.spacingEntry = wx.SpinCtrl(self, -1) self.spacingEntry.SetRange(*self.cfg.cvars.getMinMax("fontYdelta")) wx.EVT_SPINCTRL(self, self.spacingEntry.GetId(), self.OnMisc) wx.EVT_KILL_FOCUS(self.spacingEntry, self.OnKillFocus) hsizer.Add(self.spacingEntry, 0) hsizer.Add(wx.StaticText(self, -1, "pixels"), 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 10) vsizer.Add(hsizer, 0, wx.EXPAND | wx.BOTTOM, 15) self.pbRb = wx.RadioBox(self, -1, "Page break lines to show", style = wx.RA_SPECIFY_COLS, majorDimension = 1, choices = [ "None", "Normal", "Normal + unadjusted " ]) vsizer.Add(self.pbRb) self.fontsLb.SetSelection(0) self.updateFontLb() self.cfg2gui() util.finishWindow(self, vsizer, center = False) wx.EVT_RADIOBOX(self, self.pbRb.GetId(), self.OnMisc)