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 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
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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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
|
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
|
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)
|
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,
|
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...
| |
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)
|
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;
|
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.
|
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 -->
<!--
/*...
|
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...
|
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...
| |
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...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |