how use wx.findfoucs

hi i want open one file from a list when select the item but the class
list is in other file and i got the event of select item and i want to
read the findfoucs.OpenFile in the main frame class file the class
list that is in other file is included in the main frame class where i
got the focus to find when i compiling give this

error openfile is not defined

this is the code in the list class def OnItemActivated(self, event,
item=None):
        if event:
            item = event.GetItem()
            self.activeitem = item
            if item != self.root:

                #self.editor = wx.Window.FindFocus()#stxt(nb, -1)
                #self.editor.LoadFile(self.GetItemText(item))
                win = wx.Window.FindFocus()
                win.OpenFile(item) # i want to find this in the frame
class
                #win.AddPage(self.editor, "File")

and this in the frame class where i import the file of the list

        def OpenFile(self, item):

        self.editor = stxt(self.notebook, -1)
        self.editor.LoadFile(self.GetItemText(item))

        self.notebook.AddPage(self.editor, "Untitled")

what i want is read the file and open it in a new tab of the notebook
but i dont kwnow how do it in separatly classes

···

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Hi,

hi i want open one file from a list when select the item but the class
list is in other file and i got the event of select item and i want to
read the findfoucs.OpenFile in the main frame class file the class
list that is in other file is included in the main frame class where i
got the focus to find when i compiling give this

error openfile is not defined

this is the code in the list class def OnItemActivated(self, event,
item=None):
if event:
item = event.GetItem()
self.activeitem = item
if item != self.root:

           \#self\.editor = wx\.Window\.FindFocus\(\)\#stxt\(nb, \-1\)
           \#self\.editor\.LoadFile\(self\.GetItemText\(item\)\)
           win = wx\.Window\.FindFocus\(\)
           win\.OpenFile\(item\) \# i want to find this in the frame

class
#win.AddPage(self.editor, "File")

and this in the frame class where i import the file of the list

   def OpenFile\(self, item\):

   self\.editor = stxt\(self\.notebook, \-1\)
   self\.editor\.LoadFile\(self\.GetItemText\(item\)\)

   self\.notebook\.AddPage\(self\.editor, "Untitled"\)

what i want is read the file and open it in a new tab of the notebook
but i dont kwnow how do it in separatly classes

--

Check out pubsub - http://wiki.wxpython.org/PubSub
Basically, one class registers as a listener to a topic of interest,
and other classes publish a message to say the topic occurred, and
then any listeners perform any registered methods.

In this case, your list will send a message saying "file loaded" and
your class containing the notebook can subscribe to that message and
then add the file

···

On 4 May 2010 16:11, iozk_Live <iozk117@gmail.com> wrote:

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

What is the class of the object returned from FindFocus? My guess is that it is not the frame you are interested in but rather some widget within it. In that case you can do something like this:

  frame = win.GetTopLevelParent()
  frame.OpenFile(item)

Although using pubsub to decouple UI elements and the dependencies on their structure is a good idea too.

···

On 5/4/10 8:11 AM, iozk_Live wrote:

hi i want open one file from a list when select the item but the class
list is in other file and i got the event of select item and i want to
read the findfoucs.OpenFile in the main frame class file the class
list that is in other file is included in the main frame class where i
got the focus to find when i compiling give this

error openfile is not defined

this is the code in the list class def OnItemActivated(self, event,
item=None):
         if event:
             item = event.GetItem()
             self.activeitem = item
             if item != self.root:

                 #self.editor = wx.Window.FindFocus()#stxt(nb, -1)
                 #self.editor.LoadFile(self.GetItemText(item))
                 win = wx.Window.FindFocus()
                 win.OpenFile(item) # i want to find this in the frame
class
                 #win.AddPage(self.editor, "File")

--
Robin Dunn
Software Craftsman

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

ok i try to fin more about the pubsub

···

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en