473,573 Members | 2,922 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 4988
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
2237
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
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)
0
1674
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
3170
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...
0
1381
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
9946
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
2382
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...
1
1833
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...
0
7694
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7787
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
8065
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...
0
6419
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...
1
5593
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...
0
3732
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3733
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2213
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
1303
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.