473,406 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

wxPython Grid Cell change question

Hello All,
I created a grid, where I register events every time the user changes
an existing value inside the grid control. Right now, I am using the
event: EVT_GRID_CELL_CHANGE. However, I realized that I need to
register that same kind of event even if the user doesnt change the
value, but just selects and then deselects.

I tried creating my own custom event, where i check to see if the
editor is activated and then deactivated, and if so, then set the sell
value. However, this doesnt work because the value that it needs to be
set to is the same previous value that was in the grid. Therefore, I
can never get a new value in the grid. Here is the code for the events:

in init():
self.Bind(wx.grid.EVT_GRID_EDITOR_SHOWN, self.EditorShown)
self.Bind(wx.grid.EVT_GRID_EDITOR_HIDDEN, self.EditorHidden)
def EditorShown(self, event):
self.editorShown = True
event.Skip()

def EditorHidden(self, event):
self.editorHidden = True
row = event.GetRow()
col = event.GetCol()
print "VAL = " + str(self.grid.GetCellValue(row, col))
+str(self.OnTestCellValue(row, col))
event.Skip()

def OnTestCellValue(self, row, col):
if self.editorShown and self.editorHidden:
self.editorShown = False
self.editorHidden = False
self.SetCellValue(row, col)

def SetCellValue(self, row, col):
print "EVENT PROCESSIGN STARTED"
print "RAW VAL = " + str(self.grid.GetCellValue(row, col))
value = int(self.grid.GetCellValue(row, col), 16)
print "VAL = " + str(value)
# if we need to add a row
if row == (len(self.data)-1):
self.expandGrid()
self.data.append([])
# if we need to delete a row
if row != 0 and value == '':
self.data[row][3] = 'Delete'
else:
self.addToData(row, col, value, True)
# whether the user intended a read or write
if self.data[row][3] != 'Delete':
if col == 1:
self.data[row][3] = 'Read'
elif col == 2:
self.data[row][3] = 'Write'

q = copy.deepcopy(self.data) # cloning object
self.requestQueue.put(q) # putting object onto queue
print "EVENT PROCESSIGN ENDED"

Thanks a lot for your help, and please mind the spacing.

I should note that before, my bind was:
self.Bind(wx.grid.EVT_GTID_CELL_CHANGE, self.SetCellValue)
thanks,
Kiran

Jul 13 '06 #1
1 4127
Never mind, I used 2 different binds for the 2 different situations and
it worked.

thanks for looking anyhow.

-- Kiran
Kiran wrote:
Hello All,
I created a grid, where I register events every time the user changes
an existing value inside the grid control. Right now, I am using the
event: EVT_GRID_CELL_CHANGE. However, I realized that I need to
register that same kind of event even if the user doesnt change the
value, but just selects and then deselects.

I tried creating my own custom event, where i check to see if the
editor is activated and then deactivated, and if so, then set the sell
value. However, this doesnt work because the value that it needs to be
set to is the same previous value that was in the grid. Therefore, I
can never get a new value in the grid. Here is the code for the events:

in init():
self.Bind(wx.grid.EVT_GRID_EDITOR_SHOWN, self.EditorShown)
self.Bind(wx.grid.EVT_GRID_EDITOR_HIDDEN, self.EditorHidden)
def EditorShown(self, event):
self.editorShown = True
event.Skip()

def EditorHidden(self, event):
self.editorHidden = True
row = event.GetRow()
col = event.GetCol()
print "VAL = " + str(self.grid.GetCellValue(row, col))
+str(self.OnTestCellValue(row, col))
event.Skip()

def OnTestCellValue(self, row, col):
if self.editorShown and self.editorHidden:
self.editorShown = False
self.editorHidden = False
self.SetCellValue(row, col)

def SetCellValue(self, row, col):
print "EVENT PROCESSIGN STARTED"
print "RAW VAL = " + str(self.grid.GetCellValue(row, col))
value = int(self.grid.GetCellValue(row, col), 16)
print "VAL = " + str(value)
# if we need to add a row
if row == (len(self.data)-1):
self.expandGrid()
self.data.append([])
# if we need to delete a row
if row != 0 and value == '':
self.data[row][3] = 'Delete'
else:
self.addToData(row, col, value, True)
# whether the user intended a read or write
if self.data[row][3] != 'Delete':
if col == 1:
self.data[row][3] = 'Read'
elif col == 2:
self.data[row][3] = 'Write'

q = copy.deepcopy(self.data) # cloning object
self.requestQueue.put(q) # putting object onto queue
print "EVENT PROCESSIGN ENDED"

Thanks a lot for your help, and please mind the spacing.

I should note that before, my bind was:
self.Bind(wx.grid.EVT_GTID_CELL_CHANGE, self.SetCellValue)
thanks,
Kiran
Jul 14 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Piet | last post by:
I am developping a small Python/wxPython app to track expenses. A bunch of information is collected in a wxGUI consisting of text controls, comboboxes and a small grid. Some values are not put in...
1
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...
4
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...
1
by: Mad Scientist Jr | last post by:
can someone explain how to simply populate a grid in .net ? the way i understand it, there is no more msflexgrid, and instead is this new control that has to be tied to a dataset, and it is a real...
117
by: phil-news-nospam | last post by:
Is there really any advantage to using DIV elements with float style properies, vs. the old method of TABLE and TR and TD? I'm finding that by using DIV, it still involves the same number of...
6
by: rbann11 | last post by:
Hi, I am looking for example code that consists of just a frame and a grid(10x2). The grid must fill the its parent even if the frame is resized. Thanks in advance, Roger
2
by: Kiran | last post by:
Hello All, I am writing an app in wxPython using a grid. I need to be able to recognize what cell in the grid the user is hovering over with the mouse. How to do this? I tried XYToCell(x, y),...
4
by: tomKeating | last post by:
First I am new to both python and wxPython. I have developed a couple of applications for myself with Paradox, but it is time to move on. I am having difficulty creating a solid background for a...
9
by: Tyler | last post by:
Hello All: I am currently working on a project to create an FEM model for school. I was thinking about using wxPython to gather the 12 input variables from the user, then, after pressing the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.