473,788 Members | 2,896 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Grid issues

Greetings,
I am new to Python...and I am having some difficulty updating a grid
(wx.grid.PyGrid TableBase). Everything works just fine (adding
/deleting/ resizing rows, cols) except updating individual cells.

I am using the grids to display data from a database (which is working
fine), I am trying to use the SetValue (as well as self.data[r][c] =
string and others ) method but it does not seem to work. I am at a
lost.

Here is the call to the UpdateRowData function:

self.frame.grid _4.GetTable().U pdateRowData(nd ata, ndata[0][0],
len(ndata[0]))

frame id wxFrame
ndata is a list
ndata[0][0] is the row number to update
len(ndata[0]) is the number of columns for the table

Here is the class for your review.

Any help would be most appreciated.
Scott


#-----------------------------------------------------------------
class DataTable(wx.gr id.PyGridTableB ase):

def __init__(self, headers=(['h','h','h']),
data=(['a','a','a'],['b','b','b'])):
wx.grid.PyGridT ableBase.__init __(self)
self.headers = headers
self.data = data
def GetNumberRows(s elf): # Called from
__init__
return len(self.data)
def GetNumberCols(s elf): # Called from
__init__
return len(self.header s)
def GetColLabelValu e(self, col): # Called from
__init__
return self.headers[col]
def GetValue(self, row, col): # Called from
__init__
# Get Value is for updating the Table on screen
try:
return self.data[row][col]
except KeyError:
pass

def IsEmptyCell(sel f, row, col): # Called from
__init__
#print "empty Cell", row, col
try:
if self.data[row][col] != "":
return True
else:
return False
except:
return False

#--------- END __INIT__ Calls
#def RemoveData(self ,rowNum):
# self.data.pop()
# msg = wx.grid.GridTab leMessage(self,
wx.grid.GRIDTAB LE_NOTIFY_ROWS_ DELETED, len(self.data), 1)
# self.GetView(). ProcessTableMes sage(msg)

def AddData(self, ndata):
#print "Add Data"
for i in ndata:
self.data.appen d(i)

msg1 = wx.grid.GridTab leMessage(
self,wx.grid.GR IDTABLE_NOTIFY_ ROWS_APPENDED, len(ndata) )
msg2 = wx.grid.GridTab leMessage(
self,wx.grid.GR IDTABLE_REQUEST _VIEW_GET_VALUE S )

for msg in [ msg1, msg2]:
self.GetView(). ProcessTableMes sage(msg)
def UpdateRowData(s elf, ndata, row, col):
num = self.GetNumberR ows()

if row <= num:
for i in range(col):
#print ndata[i]
sr = ndata[0][i]
print i, sr
self.SetValue(r ow, i, str(sr))
#self.SetCellVa lue(row, i, str(sr)) ?????
else:
for i in ndata:
self.data.appen d(i)

msg1 = wx.grid.GridTab leMessage(
self,wx.grid.GR IDTABLE_NOTIFY_ ROWS_APPENDED, len(ndata) )
self.GetView(). ProcessTableMes sage(msg1)

msg = wx.grid.GridTab leMessage(
self,wx.grid.GR IDTABLE_REQUEST _VIEW_GET_VALUE S )
self.GetView(). ProcessTableMes sage(msg)
def SetValue(self, row, col, value):
try:
self.data[row][col] = value

msg = wx.grid.GridTab leMessage(
self,wx.grid.GR IDTABLE_REQUEST _VIEW_GET_VALUE S )
self.GetView(). ProcessTableMes sage(msg)
except IndexError:
print "FAIL"
#------------------------------ End DataTable Class

Jul 18 '05 #1
0 1950

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

Similar topics

5
21574
by: Faiz | last post by:
Dear Experts, We are currently using True DB Grid 7.0 with VB6 on Windows 2000 platform. Our objective is to display Excel like formatted data (in rows and columns), allow users to perform cut/copy and paste operations on the selected range of cells and, lastly to get data entered by the users in different cells for further processing. Now the users report that this grid control is difficult to use and the behaviour(in terms of user...
1
2070
by: kk | last post by:
I have 2 issues, please help ! 1st issue : -------------------------------------------------------- Loading Grid ------------ 1) creating new rows in a datatable and adding data a array list to datatable.
5
2517
by: pmud | last post by:
Hi, I need to display columns in a data grid based on 7 different queries. Now I have 32 questions: 1. Is it possble to have 1 single data adapter with 7 queries & 1 data set or do I need to have a separate data adapter & a separate data set for each select query? If thats possible then how?
5
2377
by: sdbranum | last post by:
I have been using Visual C#.NET to code a large project having many data adapters, data sets, datagrids, multiple forms with tab pages, each containing various controls (mostly label, text boxes, check boxes, date pickers, combo boxes and datagrids). I have been coding alone on this project for about a year, and I have experienced many problems which have not been addressed by various SP's, including the recent SP1 to Framework.NET 1.1,...
3
1382
by: thomson | last post by:
Hi All, We all know the flexibility given by the datagrid, in asp.net. But i want to know one thing Is there any performance issues using the datagrid, In Asp. we used tables to manipulate a grid like structure, and it was bit tedious, Datagrid programming was extremely easy when compared to the tables. That is an advantage, But is there any performance issues, when
117
18578
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 elements in the HTML to get everything just right. When you consider the class attribute on the DIV elements, there's not much size savings anymore for using DIV. There are other disadvantages to not using TABLE/TR/TD, such as the lack of ability...
1
2585
by: Ed | last post by:
hi everyone, maybe someone can give me a hand here. I am working with vb 2005 and i have a gridview that i am loading data from a recordset. I have the recordset returned from the query and i am loading the data, but the problem is... this recordset is going to hold about 25,000+ records and the grid view and form "goes to sleep" and i can click on anything. I would like the user to be able to scroll the grid view and maybe min and max the...
2
4715
by: moondaddy | last post by:
I'm trying to do something real simple. Add a thumb to a grid at the end of a line using c#. the code executes but I dont see the thumb. Can anyone explain what and what I need to do to properly show the thumb? Here's the xaml for the window and the c# below. <Window x:Class="DragLineSample.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
7
69135
by: moondaddy | last post by:
I have WPF window and a grid. The grid has several columns and rows. How do I add an object to a specific row and column of the gird using c#? If I use: myGrid.Children.Add(dg); then dg will be added to
0
10364
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10172
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
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,...
0
9967
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
agi2029
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...
1
7517
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 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...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4069
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
3
2894
bsmnconsultancy
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...

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.