473,574 Members | 2,581 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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")
attributeListCt rl = wxListCtrl(self ,-1,style =
wxLC_REPORT|wxL C_VRULES|wxLC_H RULES|wxLC_EDIT _LABELS )

numberOfAttribu tes = 0
attributeNameLi st = []
attributeListCt rl.InsertColumn (0,"Number",for mat=wxLIST_FORM AT_LEFT,
width=-1)
for attribute in node.attributes .keys():
attr = node.attributes .get(attribute)
print attr.nodeName + "\n"
attributeListCt rl.InsertColumn (numberOfAttrib utes+2,attr.nod eName,format=wx LIST_FORMAT_LEF T,
width=-1)
+numberOfAttrib utes
attributeNameLi st.append(attr. nodeName)
for entry in attributeNameLi st:
print entry + " " + str(attributeNa meList.index(en try)) +
"\n"
numberOfSibling s = 0
if node.parentNode != None:
childs = node.parentNode .childNodes
numRows = 0
for numberOfSibling s in range(len(child s)):
print childs.item(num berOfSiblings). nodeType
if childs.item(num berOfSiblings). nodeType == 1:
attributeListCt rl.InsertString Item(numRows,st r(numRows))
if childs.item(num berOfSiblings). attributes !=
None:
for attribute in
childs.item(num berOfSiblings). attributes.keys ():
attr =
childs.item(num berOfSiblings). attributes.get( attribute)
if attributeNameLi st.count(attr.n odeName)
== 0:

attributeNameLi st.append(attr. nodeName)

attributeListCt rl.SetStringIte m(numRows,attri buteNameList.in dex(attr.nodeNa me)+1,attr.node Value)
numRows = numRows + 1

attributeListCt rl.EnsureVisibl e(True)
attributeListCt rl.SetColumnWid th(-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 5359
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******@jnanqb b.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_REQ UEST_VIEW_GET_V ALUES 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.rogerbinn s.com>, ro****@rogerbin ns.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_REQ UEST_VIEW_GET_V ALUES 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
2120
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 loaded with a small amount of data initially. When the user moves the vertical scrollbar or press PageUp or PageDown, I want to load the list view with...
1
4419
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 fine if I use events to activate logMail() after start but I don't know how to activate an event at the start (witout pressing mouse or menu key)...
1
4118
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. Is such an arrangement possible? Any example source code? wxCheckListBox comes close - but not close enough. Unfortunately, it does not derive...
5
10600
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
4990
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 lost in ListItemId´s and different possibilities of inserting items and strings. I am sure the solution is only one step away, but I need somebody...
1
7075
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)
0
1597
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 it underlines the read-only character of the data, but I am not happy with the way the results are displayed. The wxGrid with the results is laid...
1
4935
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
2749
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
7807
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, 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...
0
8058
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. ...
1
7820
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...
0
6456
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...
0
5301
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...
0
3753
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2249
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
1
1344
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1061
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...

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.