473,378 Members | 1,462 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,378 software developers and data experts.

wxPython: wxGrid vs. wxListCtrl

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
widget for the "grid view" component. wxGrid allows to edit the
content of the table (which will be the attribute values) but I
havenīt found a way to link a specific cell to a certain xml node.
This is important, because when the cell content changes I would like
to be able to directly communicate this change to the underlying xml
tree (in the tree component of the editor, this is already achieved).
wxListCtrl would be the second choice. THis where I first focused on
an wrote the following code:
class ListCtrlWindow(wxFrame):
def __init__(self, parent, node):
wxFrame.__init__(self, parent, -1,"Attribute list")
attributeListCtrl = wxListCtrl(self,-1,style =
wxLC_REPORT|wxLC_VRULES|wxLC_HRULES|wxLC_EDIT_LABE LS )

numberOfAttributes = 0
attributeNameList = []
attributeListCtrl.InsertColumn(0,"Number",format=w xLIST_FORMAT_LEFT,
width=-1)
for attribute in node.attributes.keys():
attr = node.attributes.get(attribute)
print attr.nodeName + "\n"
attributeListCtrl.InsertColumn(numberOfAttributes+ 2,attr.nodeName,format=wxLIST_FORMAT_LEFT,
width=-1)
+numberOfAttributes
attributeNameList.append(attr.nodeName)
for entry in attributeNameList:
print entry + " " + str(attributeNameList.index(entry)) +
"\n"
numberOfSiblings = 0
if node.parentNode != None:
childs = node.parentNode.childNodes
numRows = 0
for numberOfSiblings in range(len(childs)):
print childs.item(numberOfSiblings).nodeType
if childs.item(numberOfSiblings).nodeType == 1:
attributeListCtrl.InsertStringItem(numRows,str(num Rows))
if childs.item(numberOfSiblings).attributes !=
None:
for attribute in
childs.item(numberOfSiblings).attributes.keys():
attr =
childs.item(numberOfSiblings).attributes.get(attri bute)
if attributeNameList.count(attr.nodeName)
== 0:

attributeNameList.append(attr.nodeName)

attributeListCtrl.SetStringItem(numRows,attributeN ameList.index(attr.nodeName)+1,attr.nodeValue)
numRows = numRows + 1

attributeListCtrl.EnsureVisible(True)
attributeListCtrl.SetColumnWidth(-1,-1)
But there I have two problems/questions: First, a very general one: I
would like to edit the contents of the table, but when I double click
on the respective line, only the first element is editable.
Second, I have not yet completely understood the "data structure"
behind a list item. Does each line of a listctrl represent a single
item? Is it possible to address the entries in the line in the same
was as "cells" of a "table row"? Can items which are located in
different lines but are positioned in the same "column" be selected
like grid cells which belong to one column?
To me it looks a little as if listctrl was mainly for displaying data
and not for editing. So do I have to use a wxGrid for the attribute
list and define my own mechanism to connect a cell to a data object?
Any hints are appreciated.
Regards
Peter
Jul 18 '05 #1
4 5345
Piet wrote on 29 Jun 2004 12:16:11 -0700:

<snip>
Building the tree view was not a problem, but I havenīt found a good
widget for the "grid view" component. wxGrid allows to edit the
content of the table (which will be the attribute values) but I
havenīt found a way to link a specific cell to a certain xml node.
Have you looked at the Huge grid table example in the demo, the one with
the 100 million cells? It demonstrates how to use a table for the grid.
I've made an app inspired by that example which loads stuff on demand from
a bsddb and stores changed items immediatly back to the db - seems quite
similar to what you intend to do.
This is important, because when the cell content changes I would like
to be able to directly communicate this change to the underlying xml
tree (in the tree component of the editor, this is already achieved).


The Grid table is basically sitting in between the grid that the user sees
and whatever storage backend you have. The grid asks the table for data to
be inserted in cell at some coordinates, the table does whatever it deems
necessary and answers. Even better, the grid asks the table about what
attributes each displayed cell should have (color, read-only, custom
editor, the whole lot).

--
Yours,

Andrei

=====
Real contact info (decode with rot13):
ce******@jnanqbb.ay. Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V ernq
gur yvfg, fb gurer'f ab arrq gb PP.
Jul 18 '05 #2
In article <1v****************************@40tude.net>, project5
@redrival.net says...
Piet wrote on 29 Jun 2004 12:16:11 -0700:
The Grid table is basically sitting in between the grid that the user sees
and whatever storage backend you have. The grid asks the table for data to
be inserted in cell at some coordinates, the table does whatever it deems
necessary and answers. Even better, the grid asks the table about what
attributes each displayed cell should have (color, read-only, custom
editor, the whole lot).


I've built a grid in this way and it was slow as I was changing the
data in the table continuously. Is there any way to tell the grid
that just a few cells have changed? My program was redrawing the
whole grid (the visible portion of the grid) each time I changed
any cell.

Cheers,
Rich
Jul 18 '05 #3
RichH wrote:
I've built a grid in this way and it was slow as I was changing the
data in the table continuously. Is there any way to tell the grid
that just a few cells have changed? My program was redrawing the
whole grid (the visible portion of the grid) each time I changed
any cell.


When you send the wxGRIDTABLE_REQUEST_VIEW_GET_VALUES message the
grid will end up requesting all visible values. I couldn't
see any way of doing just a subset of the values.

There are some ways of mitigating this. The simplest would
be to add an idle handler and have it check if the message
should be sent. That way you can continuously update the
table values, but send far fewer messages about the updates.

I would also recommend you post your query on the wxPython-users
mailing list as Robin and many other people respond there
way quicker and in more detail than this group.

I would also recommend you have a sample program illustrating
what you are trying to do and how you have coded it. Robin
usually requests one, and it helps other people to see what
you are seeing.

Roger
Jul 18 '05 #4
In article <f4************@home.rogerbinns.com>, ro****@rogerbinns.com
says...
RichH wrote:
I've built a grid in this way and it was slow as I was changing the
data in the table continuously. Is there any way to tell the grid
that just a few cells have changed? My program was redrawing the
whole grid (the visible portion of the grid) each time I changed
any cell.


When you send the wxGRIDTABLE_REQUEST_VIEW_GET_VALUES message the
grid will end up requesting all visible values. I couldn't
see any way of doing just a subset of the values.

There are some ways of mitigating this. The simplest would
be to add an idle handler and have it check if the message
should be sent. That way you can continuously update the
table values, but send far fewer messages about the updates.

I would also recommend you post your query on the wxPython-users
mailing list as Robin and many other people respond there
way quicker and in more detail than this group.

I would also recommend you have a sample program illustrating
what you are trying to do and how you have coded it. Robin
usually requests one, and it helps other people to see what
you are seeing.

Roger


Thanks for your response... I read the source and asked a
question last year on wxPython-users. Got a similar answer.

Cheers,
Rich
Jul 18 '05 #5

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

Similar topics

1
by: bmoore | last post by:
Hello. I am working on an application using wxPython that includes a panel with a wxListCtrl populated with data received from a LAN attached database. I want the wxListCtrl panel to be...
1
by: chauhan | last post by:
Hi, I am new to pogramming. I have written a small program which retrieves emails from server, unless all the messages are loaded only then it displays on screen properlely. Whole thing works...
1
by: Mark Carter | last post by:
I would like a wxListCtrl with 3 columns in it. The number of rows in it will vary during run-time. In the first column of each row should be a wxCheckBox, which the user can check or uncheck. ...
5
by: Andrew | last post by:
Hi I just started learning wxPython I wanted to know how I could do this in wxPython self.listbox.delete(0, END) for item in self.results: self.listbox.insert(END, item)
3
by: Piet | last post by:
Hi there. I am trying to display tabular data in a wxListCtrl. What I get from the script below are only the headers, not the items themselves. The documentation didnīt help me much; instead I was...
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...
0
by: Piet | last post by:
Hello, I am working on a graphical MySQL Frontend written in python/wxPython. The results from a table query are displayed either in a wxGrid or in a wxListCtrl. I would prefer the latter because...
1
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
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
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.