本文整理汇总了Python中wx.EVT_SET_FOCUS属性的典型用法代码示例。如果您正苦于以下问题:Python wx.EVT_SET_FOCUS属性的具体用法?Python wx.EVT_SET_FOCUS怎么用?Python wx.EVT_SET_FOCUS使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类wx
的用法示例。
在下文中一共展示了wx.EVT_SET_FOCUS属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_SET_FOCUS [as 别名]
def __init__(self, parent, content='', *args, **kwargs):
GUI.ChildWindow.__init__(self, parent, *args, **kwargs)
tc = wx.TextCtrl(self, style=wx.TE_MULTILINE | wx.TE_READONLY)
def tc_OnChar(e):
keyInput = e.GetKeyCode()
if keyInput == 1: # Ctrl+A
tc.SelectAll()
else:
e.Skip()
tc.Bind(wx.EVT_CHAR, tc_OnChar)
def tc_OnFocus(e):
tc.ShowNativeCaret(False)
e.Skip()
tc.Bind(wx.EVT_SET_FOCUS, tc_OnFocus)
tc.SetValue(content)
#self.Center()
self.CenterOnScreen()
self.Show()
示例2: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_SET_FOCUS [as 别名]
def __init__(self, parent, id):
wx.Panel.__init__(
self, parent, id,
# wxMSW/Windows does not seem to support
# wx.NO_BORDER, which sucks
style = wx.WANTS_CHARS | wx.NO_BORDER)
hsizer = wx.BoxSizer(wx.HORIZONTAL)
self.scrollBar = wx.ScrollBar(self, -1, style = wx.SB_VERTICAL)
self.ctrl = MyCtrl(self, -1)
hsizer.Add(self.ctrl, 1, wx.EXPAND)
hsizer.Add(self.scrollBar, 0, wx.EXPAND)
wx.EVT_COMMAND_SCROLL(self, self.scrollBar.GetId(),
self.ctrl.OnScroll)
wx.EVT_SET_FOCUS(self.scrollBar, self.OnScrollbarFocus)
self.SetSizer(hsizer)
# we never want the scrollbar to get the keyboard focus, pass it on to
# the main widget
示例3: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_SET_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)
示例4: create_text_ctrl
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_SET_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
示例5: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_SET_FOCUS [as 别名]
def __init__(self, parent, label, title, mesg, treeLink=None):
if treeLink is None:
treeLink = eg.TreeLink(eg.Utils.GetTopLevelWindow(parent).treeItem)
self.treeLink = treeLink
self.macro = treeLink.target
if self.macro is None:
macroName = ""
else:
macroName = self.macro.name
self.title = title
self.mesg = mesg
wx.Window.__init__(self, parent, -1)
self.textBox = eg.StaticTextBox(self, -1, macroName, size=(200, -1))
self.button = wx.Button(self, -1, label)
self.Bind(wx.EVT_BUTTON, self.OnButton)
sizer = wx.BoxSizer(wx.HORIZONTAL)
sizer.Add(self.textBox, 1, wx.EXPAND | wx.ALIGN_CENTER_VERTICAL)
sizer.Add(self.button, 0, wx.LEFT, 5)
self.SetSizer(sizer)
self.Bind(wx.EVT_SIZE, self.OnSize)
self.Bind(wx.EVT_SET_FOCUS, self.OnSetFocus)
self.Layout()
示例6: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_SET_FOCUS [as 别名]
def __init__(self, parent, label, title="", mesg="", imageString=None):
self.title = title
self.mesg = mesg
self.imageString = imageString
wx.Window.__init__(self, parent, -1)
self.button = wx.Button(self, -1, label)
self.imageBox = wx.StaticBitmap(
self, -1, size=(10, 10), style=wx.SUNKEN_BORDER
)
self.SetValue(imageString)
sizer = wx.BoxSizer(wx.HORIZONTAL)
sizer.Add(self.button, 0, wx.RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
sizer.Add(self.imageBox, 1, wx.EXPAND | wx.ALIGN_CENTER_VERTICAL)
self.SetSizer(sizer)
self.Bind(wx.EVT_BUTTON, self.OnButton)
self.Bind(wx.EVT_SIZE, self.OnSize)
self.Bind(wx.EVT_SET_FOCUS, self.OnSetFocus)
self.Layout()
示例7: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_SET_FOCUS [as 别名]
def __init__(self, parent, id, evtList, ix, plugin):
width = 205
wx.ListCtrl.__init__(self, parent, id, style=wx.LC_REPORT |
wx.LC_NO_HEADER | wx.LC_SINGLE_SEL, size = (width, -1))
self.parent = parent
self.id = id
self.evtList = evtList
self.ix = ix
self.plugin = plugin
self.sel = -1
self.il = wx.ImageList(16, 16)
self.il.Add(wx.BitmapFromImage(wx.Image(join(eg.imagesDir, "event.png"), wx.BITMAP_TYPE_PNG)))
self.SetImageList(self.il, wx.IMAGE_LIST_SMALL)
self.InsertColumn(0, '')
self.SetColumnWidth(0, width - 5 - SYS_VSCROLL_X)
self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnSelect)
self.Bind(wx.EVT_SET_FOCUS, self.OnChange)
self.Bind(wx.EVT_LIST_INSERT_ITEM, self.OnChange)
self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.OnChange)
self.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.OnRightClick)
self.SetToolTipString(self.plugin.text.toolTip)
示例8: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_SET_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)
示例9: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_SET_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)
示例10: OnGainFocus
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_SET_FOCUS [as 别名]
def OnGainFocus(self, event):
"""
Handles the ``wx.EVT_SET_FOCUS`` event for L{RoundButton}.
:param `event`: a `wx.FocusEvent` event to be processed.
"""
self._hasFocus = True
self.Refresh()
self.Update()
示例11: create_editor
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_SET_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: finish_widget_creation
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_SET_FOCUS [as 别名]
def finish_widget_creation(self, level, sel_marker_parent=None):
ManagedBase.finish_widget_creation(self, sel_marker_parent)
#self.widget.Bind(wx.EVT_SET_FOCUS, self.on_set_focus)
self.widget.Bind(wx.EVT_CHILD_FOCUS, self.on_set_focus)
#self.widget.Bind(wx.EVT_TEXT, self.on_set_focus)
示例13: finish_widget_creation
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_SET_FOCUS [as 别名]
def finish_widget_creation(self, level, sel_marker_parent=None):
ManagedBase.finish_widget_creation(self, level, sel_marker_parent)
self.widget.Bind(wx.EVT_CHILD_FOCUS, self._on_set_focus)
self.widget.Bind(wx.EVT_SET_FOCUS, self._on_set_focus)
self.widget.Bind(wx.EVT_SPIN, self.on_set_focus)
示例14: create_widget
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_SET_FOCUS [as 别名]
def create_widget(self):
choices = [c[0] for c in self.choices]
selection = self.selection
self.widget = wx.ComboBox(self.parent_window.widget, self.id, choices=choices)
self.widget.Bind(wx.EVT_SET_FOCUS, self.on_set_focus)
self.widget.SetSelection(selection)
示例15: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_SET_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)