[prev in list] [next in list] [prev in thread] [next in thread] 

List:       abiword-dev
Subject:    Re: close an abiwidget
From:       "Martin Sevior" <msevior () gmail ! com>
Date:       2009-01-05 22:43:26
Message-ID: 6d78b3860901051443q33fdffccn687a38f0cd731914 () mail ! gmail ! com
[Download RAW message or body]


Hi Daniel,
              You appear to have discovered an important bug! I don't
we've ever tested abiwidget in a multi-instance environment.
I'm not sure if the bug is in abiwidget or the python bindings. I'll
see if I can find out what is happening.

Thanks very much for the clear bug bug report!

Cheers

Martin


On Tue, Jan 6, 2009 at 2:17 AM, Daniel Carvalho <idnael@gmail.com> wrote:
> hi!
> I also tried with the destroy method.
>
> The three examples included in pyabiword-0.6.1/examples only have one
> canvas. The olpc example that Tomeu mentioned here in this list also
> only uses one canvas in the program. Is there more example
> applications available that use pyabiword?
>
>
> The following is a small demonstration of an application with multiple
> abiwidgets. The open button creates a new temporary txt file and opens
> it. The close button closes the current pane.
>
> If you do open, close, and open again, the application will crash. If
> you comment the destroy() line it will not crash at this point but
> will, later, if you open and close more files.
>
>
> #!/usr/bin/env python
> # -*- coding: utf-8 -*-
>
> import pygtk
> pygtk.require('2.0')
> import gtk
>
> import abiword
>
> import os.path
> import tempfile
> import shutil
>
> import tempfile
>
>
> class Tabes(gtk.Notebook):
>
>    def __init__(self):
>
>        gtk.Notebook.__init__(self)
>        self.popup_enable()
>
>        self.set_scrollable(True)
>        self.set_show_border(False)
>
>    def __map_editor_cb(self,widget,event,editor):
>        pass
>        #editor.invoke_cmd("com.abisource.abiword.loadbindings.fromURI","keybindings.xml",0,0)
>
>
>    n=0
>    def teste_open_cb(self,widget, data=None):
>
>        path=tempfile.mkstemp(".txt","_teste"+str(self.n))[1]
>        f=open(path,"w")
>        f.write("ola "+str(self.n)+"\n"+path)
>        f.close()
>
>        print "Open "+path
>
>        nome=os.path.basename(path)
>
>        editor=abiword.Canvas()
>        # nota: path tem que ser absoluto...
>        editor.load_file("file:"+path,path)
>
>
>        editor.set_show_margin(False) # sem efeito...
>
>        editor.connect_after("map-event",self.__map_editor_cb,editor)
>
>        editor.show()
>
>        lab=gtk.Label(nome)
>
>        index=self.append_page(editor,lab)
>        self.set_current_page(index)
>
>        self.n = (self.n+1 ) % 30
>
>    def teste_close_cb(self,widget, data=None):
>        if self.get_n_pages()==0:
>            return
>
>        print "Close..."
>        pnum=self.get_current_page()
>        editor=self.get_nth_page(pnum)
>
>        self.remove_page(pnum)
>        #editor.destroy()
>
>
>
> if __name__ == "__main__":
>
>    window=gtk.Window(gtk.WINDOW_TOPLEVEL)
>    window.set_default_size(640, 480)
>
>    box=gtk.VBox(False,5)
>    box.show()
>    window.add(box)
>
>    tabes=Tabes()
>    box.add(tabes)
>    tabes.show()
>
>    # buttons:
>
>    b=gtk.Button("open")
>    b.show()
>    b.connect("clicked",tabes.teste_open_cb, None)
>    box.pack_end(b,False,False)
>
>    b=gtk.Button("close")
>    b.show()
>    b.connect("clicked",tabes.teste_close_cb, None)
>    box.pack_end(b,False,False)
>
>    window.show()
>
>    gtk.main()
>
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic