473,779 Members | 2,023 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Making items visible in wxPython wxListCtrl

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 to point in
the direction. Heres the script:

from wxPython.wx import *
class MainWindow(wxFr ame):
def __init__(self,p arent,id,title) :
wxFrame.__init_ _(self,parent,-1, title,
style=wxDEFAULT _FRAME_STYLE)
self.panel = wxPanel(self,-1)
self.Lctrl = wxListCtrl(self .panel,-1,size=(200,200 ),style =
wxLC_REPORT)
for i in range(2):
self.Lctrl.Inse rtColumn(i,"Col umn"+str(i),for mat=wxLIST_FORM AT_LEFT,width=1 00)
self.Lctrl.SetS tringItem(i,1," Hi")
self.Lctrl.SetS tringItem(i,2," there")
self.Lctrl.SetI temData(i,1)
app = wxPySimpleApp()
frame = MainWindow(None , -1, "List Control Test")
frame.Show(1)
app.MainLoop()

Best regards

Peter
Jul 18 '05 #1
3 5004
Piet wrote:
Hi there.
I am trying to display tabular data in a wxListCtrl. What I get from
...
I hope this clears it up.
from wxPython.wx import *
class MainWindow(wxFr ame):
def __init__(self,p arent,id,title) :
wxFrame.__init_ _(self,parent,-1, title,
style=wxDEFAULT _FRAME_STYLE)
self.panel = wxPanel(self,-1)
self.Lctrl = wxListCtrl(self .panel,-1,
size=(200,200), style =wxLC_REPORT)

# for i in range(2):
# self.Lctrl.Inse rtColumn(i, "Column"+str(i) ,
# format=wxLIST_F ORMAT_LEFT,widt h=100)
# self.Lctrl.SetS tringItem(i,1," Hi")
# self.Lctrl.SetS tringItem(i,2," there")
# self.Lctrl.SetI temData(i,1)

self.Lctrl.Inse rtColumn(0, "Name")
self.Lctrl.Inse rtColumn(1, "ID")
self.Lctrl.Inse rtColumn(2, "Spam Level")

people = [["George", "3t4d3", "5"],
["Beth", "34g245", "3"],
["Zaphod", "424242", "42"]]

# Notice you use InsertStringIte m for the first item
# in the row and then use SetStringItem for the rest
for index, (name, id, spam) in enumerate(peopl e):
self.Lctrl.Inse rtStringItem(in dex, name)
self.Lctrl.SetS tringItem(index , 1, id)
self.Lctrl.SetS tringItem(index , 2, spam)
app = wxPySimpleApp()
frame = MainWindow(None , -1, "List Control Test")
frame.Show(1)
app.MainLoop()
Best regards

Peter


Ditto,
greg

Jul 18 '05 #2
Piet wrote:
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 to point in
the direction. Heres the script:

from wxPython.wx import *
class MainWindow(wxFr ame):
def __init__(self,p arent,id,title) :
wxFrame.__init_ _(self,parent,-1, title,
style=wxDEFAULT _FRAME_STYLE)
self.panel = wxPanel(self,-1)
self.Lctrl = wxListCtrl(self .panel,-1,size=(200,200 ),style =
wxLC_REPORT)
for i in range(2):
self.Lctrl.Inse rtColumn(i,"Col umn"+str(i),for mat=wxLIST_FORM AT_LEFT,width=1 00)
self.Lctrl.SetS tringItem(i,1," Hi")
self.Lctrl.SetS tringItem(i,2," there")
self.Lctrl.SetI temData(i,1)
app = wxPySimpleApp()
frame = MainWindow(None , -1, "List Control Test")
frame.Show(1)
app.MainLoop()

Best regards

Peter

Mixing rows and columns ?

for i in range(2):
self.Lctrl.Inse rtColumn(i,"Col umn"+str(i),for mat=wxLIST_FORM AT_LEFT,width=1 00)
self.Lctrl.SetS tringItem(i,1," Hi")
self.Lctrl.SetS tringItem(i,2," there")
self.Lctrl.SetI temData(i,1)


# Create 2 columns
for i in range(2):
self.Lctrl.Inse rtColumn(i,"Col umn"+str(i),
format=wxLIST_F ORMAT_LEFT,widt h=100)
# Add 6 rows of data
for i in range(6):
self.Lctrl.Inse rtStringItem(i, "Hi") # Col 0
self.Lctrl.SetS tringItem(i,1," there") # Col 1
self.Lctrl.SetI temData(i,1)

http://wiki.wxpython.org/index.cgi/ListControls
Cheers,
// moma
http://www.futuredesktop.org



Jul 18 '05 #3
Shame on me....
Looks like as if wanted to populate a non-existing column with data.
Anyway, now evrything is working properly. Many, many thanks! That helped me a lot.

Piet
Jul 18 '05 #4

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

Similar topics

1
2243
by: Krzysztof Kaczkowski | last post by:
Hello Im having problem, my class inherit in wxTreeItemData. (Python2.3 i wxPython2.4.1.2u) class MyTreeItemData (wxTreeItemData): def __init__(self, name): wxTreeItemData.__init__(self) self.name_key = name def TEST(): pass
1
4142
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 from wxListCtrl, which contains the function InsertColumn() needed for multiple columns
5
10626
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)
0
1686
by: Sven Tissot | last post by:
Hello, I am trying to build an editable ListCtrl_edit via TextEditMixin. It displays o.k. and I can edit the first field with this is the code piece: class VokabelListCtrl(wxListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.TextEditMixin): def __init__(self, parent, ID, pos=wxDefaultPosition,
9
3193
by: tshad | last post by:
I have a datagrid that I want to add a new column to. This column will only be visible under certain conditions. So I want to set the column visible=false. Then when the right condition happens to change it to visible=true. You can't do that with a bound column (no ID), but you can create a templatecolumn with a label. To make these visible, I am going through each datagriditem and making them visible after I have bound the data to...
0
1389
by: David Poundall | last post by:
In the following example the phone number does not apear in the phone column of the llistbox. Can anybody tell me what I am doing wrong here ? from wxPython.wx import * class MyApp (wxApp) : def OnInit (self) : frame = MyFrame(NULL, -1, "Phone List") frame.Show(true)
2
9959
by: sree reddy | last post by:
..cs using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls;
16
2415
by: Andrea Gavana | last post by:
Hi Diez & All, Do you mind explaining "why" you find it *buttugly*? I am asking just out of curiosity, obviously. I am so biased towards wxPython that I won't make any comment on this thread in particular, but I am curious to know why some people find it "ugly" or "bad" or whatever. It has its own bugs and missing features, of course, but it is one of the major GUI player in the arena, together with PyQt and PyGTK.
1
1845
by: HACKhalo2 | last post by:
Hi. I'm helping a friend of mine develop an online game, which is currently outdated. The person making skins for the site came up with a cool looking NavBar (found at http://www.thejackofclubs.net/images/soc_concept4.png ) and I want to change the current navbar (which is right now generated via PHP using tables and outdated expressions). The code is <script language="javascript" type="text/javascript"> <!-- Modified menu code --> <!-- /*...
0
10302
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
10136
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...
0
9925
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
8958
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...
0
6723
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();...
0
5501
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4036
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
2
3631
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2867
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.