wx.checklistbox

L

luca72

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
 
P

Philippe Martin

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
 
L

luca72

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
 
P

Philippe Martin

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
 
F

Fredrik Lundh

luca72 said:
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>
 
L

luca72

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?
 
L

luca72

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

beutifulsoup 5
stupid question about html page 4
qpushbutton 1
csv module 1
file resume 2
read from bin file 2
Simulate `bash` behaviour using Python and named pipes. 15
Python problem accessing lotus notes 0

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top