wx.checklistbox

Discussion in 'Python' started by luca72, Mar 31, 2006.

  1. luca72

    luca72 Guest

    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
    luca72, Mar 31, 2006
    #1
    1. Advertising

  2. 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
    Philippe Martin, Mar 31, 2006
    #2
    1. Advertising

  3. luca72

    luca72 Guest

    Sorry Philippe
    is a Wx.checklistbox
    luca72, Mar 31, 2006
    #3
  4. luca72

    luca72 Guest

    I have solved with appen.items()
    Regards

    Luca
    luca72, Mar 31, 2006
    #4
  5. luca72

    luca72 Guest

    sorry
    appenditems
    luca72, Mar 31, 2006
    #5
  6. luca72

    luca72 Guest

    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
    luca72, Apr 1, 2006
    #6
  7. 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
    Philippe Martin, Apr 1, 2006
    #7
  8. "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>
    Fredrik Lundh, Apr 1, 2006
    #8
  9. luca72

    luca72 Guest

    Thank Fredrik

    I try and then i will inform you

    Luca
    luca72, Apr 1, 2006
    #9
  10. luca72

    luca72 Guest

    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?
    luca72, Apr 3, 2006
    #10
  11. luca72

    luca72 Guest

    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
    luca72, Apr 3, 2006
    #11
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. D. Shane Fowlkes
    Replies:
    0
    Views:
    559
    D. Shane Fowlkes
    Apr 7, 2004
  2. brian

    CheckListBox

    brian, Apr 27, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    519
    brian
    Apr 27, 2004
  3. Mau

    Problem with CheckListBox

    Mau, Sep 27, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    2,424
    Martin Dechev
    Sep 27, 2004
  4. Vikram

    Height of checklistbox

    Vikram, Mar 1, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    2,865
    Steve C. Orr [MVP, MCSD]
    Mar 1, 2005
  5. =?Utf-8?B?VmlkZHM=?=

    CheckListBox MouseOver

    =?Utf-8?B?VmlkZHM=?=, Jan 12, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    1,674
    cbDevelopment
    Mar 13, 2006
Loading...

Share This Page