Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > wx.checklistbox

Reply
Thread Tools

wx.checklistbox

 
 
luca72
Guest
Posts: n/a
 
      03-31-2006
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

 
Reply With Quote
 
 
 
 
Philippe Martin
Guest
Posts: n/a
 
      03-31-2006
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


 
Reply With Quote
 
 
 
 
luca72
Guest
Posts: n/a
 
      03-31-2006
Sorry Philippe
is a Wx.checklistbox

 
Reply With Quote
 
luca72
Guest
Posts: n/a
 
      03-31-2006
I have solved with appen.items()
Regards

Luca

 
Reply With Quote
 
luca72
Guest
Posts: n/a
 
      03-31-2006
sorry
appenditems

 
Reply With Quote
 
luca72
Guest
Posts: n/a
 
      04-01-2006
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

 
Reply With Quote
 
Philippe Martin
Guest
Posts: n/a
 
      04-01-2006
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


 
Reply With Quote
 
Fredrik Lundh
Guest
Posts: n/a
 
      04-01-2006
"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>



 
Reply With Quote
 
luca72
Guest
Posts: n/a
 
      04-01-2006
Thank Fredrik

I try and then i will inform you

Luca

 
Reply With Quote
 
luca72
Guest
Posts: n/a
 
      04-03-2006
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?

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments