Hi,
How can I capture the EVT_SET_FOCUS on a wxGrid?
Tank's in advance
Luca 10 4654
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.gr id.EVT_SET_FOCU S, self.onGridFocu s)
If you want to catch when a cell in the grid gets the focus, use:
grid.Bind(wx.gr id.EVT_GRID_SEL ECT_CELL, self.onCellSele cted)
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.gr id.EVT_SET_FOCU S, self.onGridFocu s)
Oops, my bad:
grid.Bind(wx.EV T_SET_FOCUS, self.onGridFocu s)
If you want to catch when a cell in the grid gets the focus, use: >>> grid.Bind(wx.gr id.EVT_GRID_SEL ECT_CELL, self.onCellSele cted)
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 "onGridFocu s"
evt.Skip()
def onCellSelected( evt):
print "onCellSelected "
evt.Skip()
g.Bind(wx.grid. EVT_GRID_SELECT _CELL, onCellSelected)
g.Bind(wx.EVT_S ET_FOCUS, onGridFocus)
p.SetSizer(s)
f.Show()
app.MainLoop()
############### ###
lux wrote: Can you try this code?
Sure, thanks for posting it!
If you press only the TAB key the focus go from the TextCtrl to the Grid (I suppose) but onGridFocus in not called.
Confirmed, at least on Gtk.
any idea?
Yep, the grid is actually a collection of subwindows, and I made the guess that
the first window to get the focus is actually that little corner window at the
intersection of the column labels and the row labels. Try this instead: g.GetGridCorner LabelWindow().B ind(wx.EVT_SET_ FOCUS, onGridFocus)
--
Paul McNett http://paulmcnett.com http://dabodev.com
TANKS!!!
Now it work!!!
Luca
lux wrote: TANKS!!! Now it work!!!
Not so fast. I've found out that I had to do the following ugly workaround to
ensure it works in all cases:
def _initEvents(sel f):
...
if self.BaseClass. __name__ == "dGrid":
## Ugly workaround for grids not firing focus events from the keyboard
## correctly.
self._lastGridF ocusTimestamp = 0.0
self.GetGridCor nerLabelWindow( ).Bind(wx.EVT_S ET_FOCUS, self.__onWxGotF ocus)
self.GetGridCol LabelWindow().B ind(wx.EVT_SET_ FOCUS, self.__onWxGotF ocus)
self.GetGridRow LabelWindow().B ind(wx.EVT_SET_ FOCUS, self.__onWxGotF ocus)
self.GetGridWin dow().Bind(wx.E VT_SET_FOCUS, self.__onWxGotF ocus)
self.Bind(wx.EV T_SET_FOCUS, self.__onWxGotF ocus)
...
def __onWxGotFocus( self, evt):
if self.BaseClass. __name__ == "dGrid":
## Continuation of ugly workaround for grid focus event. Only raise the
## Dabo event if we are reasonably sure it isn't a repeat.
prev = self._lastGridF ocusTimestamp
now = self._lastGridF ocusTimestamp = time.time()
if now-prev < .05:
return
self.raiseEvent (dEvents.GotFoc us, evt)
--
Paul McNett http://paulmcnett.com http://dabodev.com
So Paul, are you saying there's a bug with the wxGrid control and if so,
do you know if there's been a bug-report submitted to the wxWidgets
and/or wxPython folks?
Or is this just the way the wxGrid control works?
Thanks!
Paul McNett wrote: Not so fast. I've found out that I had to do the following ugly workaround to ensure it works in all cases:
Bugs wrote: So Paul, are you saying there's a bug with the wxGrid control and if so,
Yes, I think it is a bug.
do you know if there's been a bug-report submitted to the wxWidgets and/or wxPython folks?
I don't know, but I've been meaning to check.
Or is this just the way the wxGrid control works? Thanks!
wxPython/wxWidgets, like any GUI toolkit, is pretty complex. For the most part
all the commonly-needed things work just fine - it is when you venture into the
less-used things that you get into trouble.
If I filed a proper bug report for everything wrong with wxPython/wxWidgets, I'd
probably not get anything else done. But on the other hand you couldn't force me
to stop using wxPython if you tried!
--
Paul McNett http://paulmcnett.com http://dabodev.com
Paul McNett wrote: If I filed a proper bug report for everything wrong with wxPython/wxWidgets, I'd probably not get anything else done. But on the other hand you couldn't force me to stop using wxPython if you tried!
Like any open-source software, the community is what makes it better.
I agree, it's still a great toolkit even with the bugs.
But think how much better a toolkit it would be with fewer bugs! =)
Thanks Paul This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Tom Lee |
last post by:
#
# Python 2.2.3, wxWindows/wxPython 2.4.1
#
# The code:
#
from wxPython.wx import *
class TestFrame( wxFrame ):
def __init__( self ):
|
by: Kepes Krisztian |
last post by:
Hi !
My problem is that:
1.)
I want to create a frame with some buttons, and client area.
If the user clicked on a button, the procedure create components on
client area, and show results.
|
by: matthiasjanes |
last post by:
dear all,
I just need a little help.
could anyone give real code example (simple) how to read the value of
a grid cell.
i could not figure it out and really would like to do a simple
spreadsheet application in wxpython (my first try with wxpython gui)
|
by: Piet |
last post by:
Hello.
I am working on an XML editor that will not display the xml file as
plain text, but will rather work with a combination of a tree view for
the main element nodes and some kind of tabular view to view
attributes. By this way, the user (i.e. me) will only have the
opportunity to change textual contents and attribute values, but
neither element nor attribute names.
Building the tree view was not a problem, but I haven´t found a good...
|
by: James |
last post by:
wxpython 2.5.3
hi,
anyone know how to make a multiline cell editor for wxgrid?
thank you :)
best regards,
James
| |
by: Peter Wright |
last post by:
Hi all.
Hopefully this should demonstrate the problem I'm having:
http://flooble.net/~pete/focus-problem-demo/
(I'm testing it in Mozilla only, but I'm not sure if it's actually a
Mozilla-only problem)
I'm capturing the focus and blur events for the document, updating a
|
by: Neil Ginsberg |
last post by:
OK, this is a stupid thing, but I can't seem to get this to work. I have a
form with a subform (in continuous form view). A combo box on the main form
has code in the AfterUpdate event which adds a record to the subform (based
on the value of the combo box) and requeries the subform control. I want the
focus to return to the combo box on the main form when it's done, but I
can't get it to do so if the user enters a value and presses Enter...
|
by: clickon |
last post by:
For testing purposes i have got a 2 step WizardControl. Eqach step contains
a text box, TextBox1 and TextBox2 respectively. If i put the following code
in the respective activate event handlers for the two steps,
TextBox1.Text ="foo";
and
TextBox2.Text = "bar";
|
by: Subsciber123 |
last post by:
Hi,
I'm using Python 2.6, and I'm trying to write a gui program that uses wxGrid. I have made it so that the columns can be dragged around to different locations, but I need to bind to an event that tells me when they are moved, and which one moved where. Can anybody help me with this? I don't see any events that jump out at me as being relevant.
Thanks.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |