#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2005
    Posts
    62
    Rep Power
    10

    From file2.py append an item to file1.py combobox


    Hi to all:
    How can I append some data from file1.py to a combobox
    on file2.py?
    I know, if you want to append data to a combobox
    inside the same script, I would be like follows:
    Code:
    # file1.py
    import wx
    class Myframe(wx.Frame):
      def __init__(self, *args, **kwds):
        ...
        self.mycombobox = wx.Combobox(...
        ...
        # and then...
    
        self.mycombobox.Append("Item")
    
        # would append to the combobox a new item.
    I'm having some trouble sending the new "item" from file2.py
    Code:
    # file2.py
    # So here are my problems...
    # I got:
    import wx,file1
    class Subframe(wx.Frame):
      def __init__(self, *args, **kwds)
      ...
    
      def Mymethod(self,event):
        file1.Myframe.mycombobox.Append("Item")
    
      # and it doesnt work...
      # file1.Myframe.self.mycombobox.Append("item")
      # does not work either..
    What can I do? thanks in advance
    Daniel.
  2. #2
  3. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    155
    You seem to understand the basic concept of how to do this. Importing the other file. But is that file1.py located in the correct directory? Try moving it to your Lib directory or to another place where Python library (module) files are stored.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2005
    Posts
    62
    Rep Power
    10
    They are both in the same directory...
    So... it should work then? the pseudocode is correct?
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2005
    Posts
    62
    Rep Power
    10
    maybe i should make the combobox global?? I'll try that...
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2005
    Posts
    62
    Rep Power
    10
    Oh, now I get it. I was trying to Append the new item calling the combobox to file2.py, but there was no combobox there!
    I should have done it all the way around, that is, calling the new item variable from file2.py to file1.py and then append it to the existing combobox in there...
    So sintax was right, but I was doing it the wrong way.
  10. #6
  11. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    155
    Glad you figured out the problem.

IMN logo majestic logo threadwatch logo seochat tools logo