470,849 Members | 1,196 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,849 developers. It's quick & easy.

wx.checklistbox

Hello
I write one file using:.......(i think that is ok for write all the
lines of my list)
luca = open('/tmp/luca', 'w')
luca.writelines(list)

when i open the application again i use:

leggi = open('/tmp/luca', 'r')
leggi.readlines()

How can i store this line in to a wx.checkbox.....

Thanks Luca

Mar 31 '06 #1
10 3188
Not sure I understand: a wx.CheckBox has up to three states (on, off ...
does not apply/greyed)

Is that what you read from your file ?

Philippe

luca72 wrote:
Hello
I write one file using:.......(i think that is ok for write all the
lines of my list)
luca = open('/tmp/luca', 'w')
luca.writelines(list)

when i open the application again i use:

leggi = open('/tmp/luca', 'r')
leggi.readlines()

How can i store this line in to a wx.checkbox.....

Thanks Luca


Mar 31 '06 #2
Sorry Philippe
is a Wx.checklistbox

Mar 31 '06 #3
I have solved with appen.items()
Regards

Luca

Mar 31 '06 #4
sorry
appenditems

Mar 31 '06 #5
i have again one simple problem:
the script is this:

def output(self):
global lista2
lista2 = open('/lista2', 'w')
iteminlista2 = self.checkListBox2.GetStrings()
lista2.writelines(iteminlista2)

def input1(self):
lista2leggi = open('/lista2', 'r')
cd = lista2leggi.readlines()
self.checkListBox2.AppendItems(cd)

The write file is like:

item1item2item3

when i read the and i put the item in the checklistbox , i don't find :

item1
item2
item3

but :

item1item2item3

How to do for have it like :

item1
item2
item3

Regards

Luca

Apr 1 '06 #6
Hi,

I do not see where you close the file: I beleve you need to close it to
flush information prior to reading again.

Philippe

luca72 wrote:
i have again one simple problem:
the script is this:

def output(self):
global lista2
lista2 = open('/lista2', 'w')
iteminlista2 = self.checkListBox2.GetStrings()
lista2.writelines(iteminlista2)

def input1(self):
lista2leggi = open('/lista2', 'r')
cd = lista2leggi.readlines()
self.checkListBox2.AppendItems(cd)

The write file is like:

item1item2item3

when i read the and i put the item in the checklistbox , i don't find :

item1
item2
item3

but :

item1item2item3

How to do for have it like :

item1
item2
item3

Regards

Luca


Apr 1 '06 #7
"luca72" wrote:
i have again one simple problem:
the script is this:

def output(self):
global lista2
lista2 = open('/lista2', 'w')
iteminlista2 = self.checkListBox2.GetStrings()
lista2.writelines(iteminlista2)

def input1(self):
lista2leggi = open('/lista2', 'r')
cd = lista2leggi.readlines()
self.checkListBox2.AppendItems(cd)

The write file is like:

item1item2item3


writelines doesn't add newlines; you have to do that yourself. try
using a plain loop instead:

for item in iteminlista2:
lista2.write(item + "\n")

</F>

Apr 1 '06 #8
Thank Fredrik

I try and then i will inform you

Luca

Apr 1 '06 #9
Hello Frefrik
It works but sometimes it insert a blank row so the file is like:

item1

item2
item3
item4
etc..

I don't inderstand why.

But supposing that we can't solve this, is it possible to delete blanlk
items in the checkListBox?

Apr 3 '06 #10
I have solve in this way i'm sure it's not the best, but it works:

lista1leggi = open('/lista1.txt', 'r')
mt = lista1leggi.readlines()
lunghezzamt = len(mt)
lucianino = 0
while lucianino < (lunghezzamt - 1):
if mt[lucianino] == '\n':
del mt[lucianino]
lucianino = lucianino - 1
lunghezzamt = lunghezzamt - 1
else: lucianino = lucianino + 1

pippo = self.checkListBox1.AppendItems(mt)

Ragards Luca

Apr 3 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by ncookson | last post: by
5 posts views Thread by Bernie Yaeger | last post: by
3 posts views Thread by MikeY | last post: by
reply views Thread by Ville Mattila | last post: by
3 posts views Thread by obrienkev | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.