wxGrid和焦点事件 [英] wxGrid and Focus Event

查看:87
本文介绍了wxGrid和焦点事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何在wxGrid上捕获EVT_SET_FOCUS?


坦克'提前

Luca

解决方案

lux写道:

如何捕获wxGrid上的EVT_SET_FOCUS?




如果您希望在整个网格获得焦点时捕获,请使用:

< blockquote class =post_quotes> grid.Bind(wx.grid.EVT_SET_FOCUS,self.onGridFocus)



如果要捕获网格中的单元格获取焦点,使用:

grid.Bind(wx.grid.EVT_GRID_SELECT_CELL,self.onCellSelected)



并且,你的问题在
http://wxpython.org/上的wxpython用户列表会更好maillist.php

-

Paul McNett
http://paulmcnett.com
http://dabodev.com


Paul McNett写道:

lux写道:
< blockquote class =post_quotes>如何捕获wxGrid上的EVT_SET_FOCUS?

如果想要在整个网格获得焦点时捕获,请使用:

>>> grid.Bind(wx.grid.EVT_SET_FOCUS,self.onGridFocus)


哎呀,我的坏:

grid.Bind(wx.EVT_SET_FOCUS,self.onGridFocus )



如果要在网格中的单元格获得焦点时捕获,请使用:
>>> grid.Bind(wx.grid.EVT_GRID_SELECT_CELL,self.onCellSelected)



而且,你的问题在wxpython-users列表上会更好
http://wxpython.org/maillist.php

< br $> b $ b -

Paul McNett
http:/ /paulmcnett.com
http://dabodev.com


你能试试这个代码吗?


如果你只按TAB键

焦点从TextCtrl转到网格(我想)

但没有调用onGridFocus。


任何想法?

Luca 。

##################

import wx

import wx.grid


app = wx.PySimpleApp()


f = wx.Frame(无,-1,"")

p = wx.Panel(f,-1)

s = wx.BoxSizer(wx.VERTICAL)


t1 = wx.TextCtrl(p)

s.Add(t1)


g = wx.grid.Grid(p,-1)

g.CreateGrid(2,2)

s.Add (g,1,wx.EXPAND)


def onGridFocus(evt):

print" onGridFocus"

evt。跳过()


def onCellSelected(evt):

print" onCellSelected"

evt.Skip()


g.Bind(wx.grid.EVT_GRID_SELECT_CELL,onCellSelected)

g.Bind(wx.EVT_SET_FOCUS,onGridFocus)


p.SetSizer(s)

f.Show()


app.MainLoop()


# #################


Hi,
How can I capture the EVT_SET_FOCUS on a wxGrid?

Tank''s in advance
Luca

解决方案

lux wrote:

How can I capture the EVT_SET_FOCUS on a wxGrid?



If you want to catch when the grid as a whole gets the focus, use:

grid.Bind(wx.grid.EVT_SET_FOCUS, self.onGridFocus)

If you want to catch when a cell in the grid gets the focus, use:
grid.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.onCellSelected)


And, your questions will be better on the wxpython-users list at
http://wxpython.org/maillist.php
--
Paul McNett
http://paulmcnett.com
http://dabodev.com


Paul McNett wrote:

lux wrote:

How can I capture the EVT_SET_FOCUS on a wxGrid?

If you want to catch when the grid as a whole gets the focus, use:

>>> grid.Bind(wx.grid.EVT_SET_FOCUS, self.onGridFocus)
Oops, my bad:
grid.Bind(wx.EVT_SET_FOCUS, self.onGridFocus)


If you want to catch when a cell in the grid gets the focus, use:
>>> grid.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.onCellSelected)


And, your questions will be better on the wxpython-users list at
http://wxpython.org/maillist.php


--
Paul McNett
http://paulmcnett.com
http://dabodev.com


Can you try this code?

If you press only the TAB key
the focus go from the TextCtrl to the Grid (I suppose)
but onGridFocus in not called.

any idea?
Luca.
##################

import wx
import wx.grid

app = wx.PySimpleApp()

f = wx.Frame(None, -1, "")
p = wx.Panel(f, -1)
s = wx.BoxSizer(wx.VERTICAL)

t1 = wx.TextCtrl(p)
s.Add(t1)

g = wx.grid.Grid(p, -1)
g.CreateGrid(2, 2)
s.Add(g, 1, wx.EXPAND)

def onGridFocus(evt):
print "onGridFocus"
evt.Skip()

def onCellSelected(evt):
print "onCellSelected"
evt.Skip()

g.Bind(wx.grid.EVT_GRID_SELECT_CELL, onCellSelected)
g.Bind(wx.EVT_SET_FOCUS, onGridFocus)

p.SetSizer(s)
f.Show()

app.MainLoop()

##################


这篇关于wxGrid和焦点事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆