I have a Frame called ChangeDirPanel and an other one called MyFrame, the last one is the top-lvl window and has a function called file_show_dir which updates a listbox in that same window.

(both frames have their own class, is it better to have the same class?)

I want to run the function from an other frame (the changedirpanel)
but somehow the listbox isn't updated =(

I really don't see why

ChangeDirPanel class

class ChangeDirPanel(wx.Frame):
    #left init away

    def changedir(self, event): # wxGlade: ChangeDirPanel.<event_handler>
	myframe = MyFrame(None, -1, "")
	myrame.SetStatusText("Hello")
                myframe.filedir = self.text_ctrl_16.GetValue()
	myframe.file_show_dir()

    def cancel(self, event): # wxGlade: ChangeDirPanel.<event_handler>
        self.Close()

# end of class ChangeDirPanel

Recommended Answers

All 15 Replies

Some goofy indentations in there.

You are mixing tabs and spaces, a recipe for disaster!
I recommend to stick with spaces!

Some goofy indentations in there.

Is that the reason for this?
All my other functions etc.. work great

not sure what you want but here are tricks I use
Use GetParent function to get parent and store that parent in variable. Then use that variable to call any parent method. For dialog, its parent will be a Frame and by that trick you can call any frame methods from Dialog.

Using Multi class is better for learning and big projects. For small projects keep with one class

Okay also here I cleaned the indentations but no luck, it still does not change the listbox...

def changedir(self, event): # wxGlade: ChangeDirPanel.<event_handler>
        myframe = MyFrame(None, -1, "")
        myframe.SetStatusText("Hello")
        myframe.filedir = self.text_ctrl_16.GetValue()
        myframe.file_show_dir()

You got to let us know what class MyFrame looks like and how you instantiate class ChangeDirPanel so that widget self.text_ctrl_16 can be passed through.

You got to let us know what class MyFrame looks like and how you instantiate class ChangeDirPanel so that widget self.text_ctrl_16 can be passed through.

the problem is probably with the last, because I'm not sure it is completely right...I initiate it like this (in MyFrame):

def change_dir(self, event): # wxGlade: MyFrame.<event_handler>
        self.chgedirframe = ChangeDirPanel(MyFrame(self), -1, "")
        self.chgedirframe.Show()

Yeah i agree with vegaseat, we need to see the code for MyFrame, thats where the problem most likely is.

Also just to make sure, are you actually getting any errors? Or is it just not updating?

Well the class MyFrame is over 1000 lines of code but I will give you the initialization from wx itself:

class MyFrame(wx.Frame):
    def __init__(self, *args, **kwds):
        # begin wxGlade: MyFrame.__init__
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.notebook_1 = wx.Notebook(self, -1, style=0)
        self.notebook_1_pane_4 = wx.Panel(self.notebook_1, -1)
        self.notebook_1_pane_3 = wx.Panel(self.notebook_1, 3)
        self.notebook_1_pane_2 = wx.Panel(self.notebook_1, 2)
        self.notebook_1_pane_1 = wx.Panel(self.notebook_1, 1)
        self.notebook_3 = wx.Notebook(self.notebook_1_pane_1, -1, style=wx.NB_RIGHT)
        self.notebook_3_pane_2 = wx.Panel(self.notebook_3, -1)
        self.notebook_3_pane_1 = wx.Panel(self.notebook_3, -1)
        
        # Menu Bar
        self.menubar = wx.MenuBar()
        wxglade_tmp_menu = wx.Menu()
        wxglade_tmp_menu.Append(5, "Options", "", wx.ITEM_NORMAL)
        wxglade_tmp_menu.Append(12, "Extlib Manager", "", wx.ITEM_NORMAL)
        wxglade_tmp_menu.Append(13, "Update Extlib", "", wx.ITEM_NORMAL)
        wxglade_tmp_menu.Append(11, "Open FIle", "", wx.ITEM_NORMAL)
        wxglade_tmp_menu.AppendSeparator()
        wxglade_tmp_menu.Append(2, "Quit", "", wx.ITEM_NORMAL)
        self.menubar.Append(wxglade_tmp_menu, "DCM")
        wxglade_tmp_menu = wx.Menu()
        wxglade_tmp_menu.Append(1, "Change Dir", "", wx.ITEM_NORMAL)
        self.menubar.Append(wxglade_tmp_menu, "File Manager")
        wxglade_tmp_menu = wx.Menu()
        wxglade_tmp_menu.Append(3, "Start", "", wx.ITEM_NORMAL)
        wxglade_tmp_menu.Append(4, "Stop", "", wx.ITEM_NORMAL)
        self.menubar.Append(wxglade_tmp_menu, "MySql")
        wxglade_tmp_menu = wx.Menu()
        wxglade_tmp_menu.Append(6, "start", "", wx.ITEM_NORMAL)
        wxglade_tmp_menu.Append(7, "stop", "", wx.ITEM_NORMAL)
        self.menubar.Append(wxglade_tmp_menu, "FTP")
        wxglade_tmp_menu = wx.Menu()
        wxglade_tmp_menu.Append(8, "Save", "", wx.ITEM_NORMAL)
        wxglade_tmp_menu.Append(9, "Upload (FTP)", "", wx.ITEM_NORMAL)
        wxglade_tmp_menu.Append(10, "2nd Deditor", "", wx.ITEM_NORMAL)
        self.menubar.Append(wxglade_tmp_menu, "Deditor")
        self.SetMenuBar(self.menubar)
        # Menu Bar end
        self.statusbar = self.CreateStatusBar(0, 0)
        self.list_box_1 = wx.ListBox(self.notebook_1_pane_1, -1, choices=[])
        self.label_1 = wx.StaticText(self.notebook_3_pane_1, -1, "Name:")
        self.label_2 = wx.StaticText(self.notebook_3_pane_1, -1, "")
        self.label_15 = wx.StaticText(self.notebook_3_pane_1, -1, "Size:")
        self.label_16 = wx.StaticText(self.notebook_3_pane_1, -1, "")
        self.button_1 = wx.Button(self.notebook_3_pane_1, -1, "DOPEN")
        self.button_2 = wx.Button(self.notebook_3_pane_1, -1, "Edit")
        self.text_ctrl_1 = wx.TextCtrl(self.notebook_3_pane_2, -1, "")
        self.button_3 = wx.Button(self.notebook_3_pane_2, -1, "Rename")
        self.text_ctrl_12 = wx.TextCtrl(self.notebook_3_pane_2, -1, "")
        self.button_4 = wx.Button(self.notebook_3_pane_2, -1, "Chmod")
        self.radio_box_1 = wx.RadioBox(self.notebook_3_pane_2, -1, "chmod input", choices=["octal", "symbolic"], majorDimension=0, style=wx.RA_SPECIFY_ROWS)
        self.label_17 = wx.StaticText(self.notebook_3_pane_2, -1, "example:\nOctal        (0)755\nSymbolic  rwxr-xr-x")
        self.list_box_3 = wx.ListBox(self.notebook_1_pane_2, -1, choices=[])
        self.text_ctrl_2 = wx.TextCtrl(self.notebook_1_pane_2, -1, "")
        self.button_7 = wx.Button(self.notebook_1_pane_2, -1, "Run!")
        self.text_ctrl_9 = wx.TextCtrl(self.notebook_1_pane_2, -1, "Query Output Will Appear here.", style=wx.TE_MULTILINE|wx.TE_READONLY)
        self.text_ctrl_8 = wx.TextCtrl(self.notebook_1_pane_3, -1, "", style=wx.TE_MULTILINE)
        self.list_box_2 = wx.ListBox(self.notebook_1_pane_4, -1, choices=[])
        self.label_13 = wx.StaticText(self.notebook_1_pane_4, -1, "Name:")
        self.label_14 = wx.StaticText(self.notebook_1_pane_4, -1, "")
        self.button_10 = wx.Button(self.notebook_1_pane_4, -1, "Download and Open with Deditor")

        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_MENU, self.options, id=5)
        self.Bind(wx.EVT_MENU, self.extlibman, id=12)
        self.Bind(wx.EVT_MENU, self.extupdate, id=13)
        self.Bind(wx.EVT_MENU, self.open_file, id=11)
        self.Bind(wx.EVT_MENU, self.quit, id=2)
        self.Bind(wx.EVT_MENU, self.change_dir, id=1)
        self.Bind(wx.EVT_MENU, self.start_mysql, id=3)
        self.Bind(wx.EVT_MENU, self.stop_mysql, id=4)
        self.Bind(wx.EVT_MENU, self.ftp_start, id=6)
        self.Bind(wx.EVT_MENU, self.ftp_stop, id=7)
        self.Bind(wx.EVT_MENU, self.dedsave, id=8)
        self.Bind(wx.EVT_MENU, self.fptup, id=9)
        self.Bind(wx.EVT_MENU, self.secded, id=10)
        self.Bind(wx.EVT_LISTBOX_DCLICK, self.listbox, self.list_box_1)
        self.Bind(wx.EVT_BUTTON, self.dopen, self.button_1)
        self.Bind(wx.EVT_BUTTON, self.edit, self.button_2)
        self.Bind(wx.EVT_BUTTON, self.rename, self.button_3)
        self.Bind(wx.EVT_BUTTON, self.chmod, self.button_4)
        self.Bind(wx.EVT_RADIOBOX, self.init_chmod, self.radio_box_1)
        self.Bind(wx.EVT_BUTTON, self.do_query, self.button_7)
        self.Bind(wx.EVT_LISTBOX_DCLICK, self.ftp_list, self.list_box_2)
        self.Bind(wx.EVT_BUTTON, self.fdown, self.button_10)
        # end wxGlade

        self.initialize()

    def __set_properties(self):
        # begin wxGlade: MyFrame.__set_properties
        self.SetTitle("DCM")
        _icon = wx.EmptyIcon()
        _icon.CopyFromBitmap(wx.Bitmap("/home/darragh/Afbeeldingen/mysql.png", wx.BITMAP_TYPE_ANY))
        self.SetIcon(_icon)
        self.SetSize((1279, 691))
        self.statusbar.SetStatusWidths([])
        # statusbar fields
        statusbar_fields = []
        for i in range(len(statusbar_fields)):
            self.statusbar.SetStatusText(statusbar_fields[i], i)
        self.list_box_1.SetMinSize((350, 605))
        self.label_1.SetBackgroundColour(wx.Colour(216, 216, 191))
        self.label_1.SetForegroundColour(wx.Colour(255, 0, 0))
        self.label_2.SetBackgroundColour(wx.Colour(216, 216, 191))
        self.label_2.SetForegroundColour(wx.Colour(255, 0, 0))
        self.label_15.SetBackgroundColour(wx.Colour(216, 216, 191))
        self.label_15.SetForegroundColour(wx.Colour(255, 0, 0))
        self.label_16.SetBackgroundColour(wx.Colour(216, 216, 191))
        self.label_16.SetForegroundColour(wx.Colour(255, 0, 0))
        self.text_ctrl_1.SetMinSize((400, 27))
        self.text_ctrl_12.SetMinSize((400, 27))
        self.radio_box_1.SetSelection(0)
        self.notebook_1_pane_1.SetBackgroundColour(wx.Colour(216, 216, 191))
        self.list_box_3.SetMinSize((350, 63))
        self.text_ctrl_2.SetMinSize((250, 27))
        self.notebook_1_pane_2.SetBackgroundColour(wx.Colour(216, 216, 191))
        self.text_ctrl_8.SetBackgroundColour(wx.Colour(216, 216, 191))
        self.list_box_2.SetMinSize((350, 328))
        self.label_13.SetBackgroundColour(wx.Colour(216, 216, 191))
        self.label_13.SetForegroundColour(wx.Colour(255, 0, 0))
        self.label_14.SetBackgroundColour(wx.Colour(216, 216, 191))
        self.label_14.SetForegroundColour(wx.Colour(255, 0, 0))
        self.notebook_1_pane_4.SetBackgroundColour(wx.Colour(216, 216, 191))
        self.notebook_1.SetBackgroundColour(wx.Colour(255, 0, 0))
        self.notebook_1.SetForegroundColour(wx.Colour(255, 255, 255))
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: MyFrame.__do_layout
        sizer_1 = wx.BoxSizer(wx.VERTICAL)
        sizer_10 = wx.BoxSizer(wx.HORIZONTAL)
        grid_sizer_4 = wx.GridSizer(2, 2, 0, 0)
        sizer_11 = wx.BoxSizer(wx.HORIZONTAL)
        sizer_4 = wx.BoxSizer(wx.HORIZONTAL)
        grid_sizer_5 = wx.GridSizer(2, 2, 0, 0)
        sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
        sizer_16 = wx.BoxSizer(wx.VERTICAL)
        grid_sizer_6 = wx.GridSizer(3, 2, 0, 0)
        sizer_14 = wx.BoxSizer(wx.VERTICAL)
        grid_sizer_1 = wx.GridSizer(5, 2, 0, 0)
        sizer_2.Add(self.list_box_1, 0, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
        grid_sizer_1.Add(self.label_1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
        grid_sizer_1.Add(self.label_2, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE|wx.FIXED_MINSIZE, 0)
        grid_sizer_1.Add(self.label_15, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE|wx.FIXED_MINSIZE, 0)
        grid_sizer_1.Add(self.label_16, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE|wx.FIXED_MINSIZE, 0)
        grid_sizer_1.Add(self.button_1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
        grid_sizer_1.Add(self.button_2, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
        sizer_14.Add(grid_sizer_1, 0, wx.EXPAND, 0)
        self.notebook_3_pane_1.SetSizer(sizer_14)
        grid_sizer_6.Add(self.text_ctrl_1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
        grid_sizer_6.Add(self.button_3, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
        grid_sizer_6.Add(self.text_ctrl_12, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
        grid_sizer_6.Add(self.button_4, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
        grid_sizer_6.Add(self.radio_box_1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
        grid_sizer_6.Add(self.label_17, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
        sizer_16.Add(grid_sizer_6, 0, wx.EXPAND, 0)
        self.notebook_3_pane_2.SetSizer(sizer_16)
        self.notebook_3.AddPage(self.notebook_3_pane_1, "Basic")
        self.notebook_3.AddPage(self.notebook_3_pane_2, "Advanced")
        sizer_2.Add(self.notebook_3, 1, wx.EXPAND, 0)
        self.notebook_1_pane_1.SetSizer(sizer_2)
        sizer_4.Add(self.list_box_3, 0, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
        grid_sizer_5.Add(self.text_ctrl_2, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
        grid_sizer_5.Add(self.button_7, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
        grid_sizer_5.Add(self.text_ctrl_9, 0, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
        sizer_4.Add(grid_sizer_5, 1, wx.EXPAND, 0)
        self.notebook_1_pane_2.SetSizer(sizer_4)
        sizer_11.Add(self.text_ctrl_8, 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
        self.notebook_1_pane_3.SetSizer(sizer_11)
        sizer_10.Add(self.list_box_2, 0, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
        grid_sizer_4.Add(self.label_13, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
        grid_sizer_4.Add(self.label_14, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
        grid_sizer_4.Add(self.button_10, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
        sizer_10.Add(grid_sizer_4, 1, wx.EXPAND, 0)
        self.notebook_1_pane_4.SetSizer(sizer_10)
        self.notebook_1.AddPage(self.notebook_1_pane_1, "File Manager")
        self.notebook_1.AddPage(self.notebook_1_pane_2, "MySql")
        self.notebook_1.AddPage(self.notebook_1_pane_3, "Deditor")
        self.notebook_1.AddPage(self.notebook_1_pane_4, "Ftp")
        sizer_1.Add(self.notebook_1, 1, wx.EXPAND, 0)
        self.SetSizer(sizer_1)
        self.Layout()
        self.SetSize((1279, 691))
        # end wxGlade

btw it does not trow an error :s and if I print the value of myframe.filedir after that it is changed, it contains the right value. ...

Looks like you had fun with wxGlade, but I still don't know how MyFrame connects to your Panel class. So help is just about impossible.

Can you create a very simple version of what you are trying to do? Let's say a MyPanel class with an text entry box and a MyFrame class with a list box.

Okay I made a frame with a listbox and a button to open the MyFrame2.
the MyFrame2 contains a textbox and a button to output its content in the listbox

but the listbox is not update =(

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# generated by wxGlade 0.6.3 on Sun Feb 14 17:36:36 2010

import wx

# begin wxGlade: extracode
# end wxGlade



class MyFrame(wx.Frame):
    def __init__(self, *args, **kwds):
        # begin wxGlade: MyFrame.__init__
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.list_box_1 = wx.ListBox(self, -1, choices=[])
        self.open_panel = wx.Button(self, -1, "Open panel")

        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_BUTTON, self.openpanel, self.open_panel)
        # end wxGlade

    def __set_properties(self):
        # begin wxGlade: MyFrame.__set_properties
        self.SetTitle("frame_1")
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: MyFrame.__do_layout
        sizer_1 = wx.BoxSizer(wx.VERTICAL)
        sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
        sizer_2.Add(self.list_box_1, 0, wx.ADJUST_MINSIZE, 0)
        sizer_2.Add(self.open_panel, 0, wx.ADJUST_MINSIZE, 0)
        sizer_1.Add(sizer_2, 1, wx.EXPAND, 0)
        self.SetSizer(sizer_1)
        sizer_1.Fit(self)
        self.Layout()
        # end wxGlade

    def openpanel(self, event): # wxGlade: MyFrame.<event_handler>
        self.panel = MyFrame2(MyFrame(self), -1, "")
        self.panel.Show()

# end of class MyFrame


class MyFrame2(wx.Frame):
    def __init__(self, *args, **kwds):
        # begin wxGlade: MyPanel.__init__
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.text_ctrl_1 = wx.TextCtrl(self, -1, "")
        self.button_1 = wx.Button(self, -1, "button_1")

        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_BUTTON, self.list, self.button_1)
        # end wxGlade

    def __set_properties(self):
        # begin wxGlade: MyPanel.__set_properties
        pass
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: MyPanel.__do_layout
        sizer_3 = wx.BoxSizer(wx.VERTICAL)
        sizer_3.Add(self.text_ctrl_1, 0, wx.ADJUST_MINSIZE, 0)
        sizer_3.Add(self.button_1, 0, wx.ADJUST_MINSIZE, 0)
        self.SetSizer(sizer_3)
        sizer_3.Fit(self)
        # end wxGlade

    def list(self, event): # wxGlade: MyPanel.<event_handler>
        myframe = MyFrame(None, -1 , "")
        myframe.list_box_1.Append(self.text_ctrl_1.GetValue())

# end of class MyPanel


if __name__ == "__main__":
    app = wx.PySimpleApp(0)
    wx.InitAllImageHandlers()
    frame_1 = MyFrame(None, -1, "")
    app.SetTopWindow(frame_1)
    frame_1.Show()
    app.MainLoop()

See the remarks ending with '!!!!!!!!!!' in the modified code ...

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# generated by wxGlade 0.6.3 on Sun Feb 14 17:36:36 2010

import wx

# begin wxGlade: extracode
# end wxGlade



class MyFrame(wx.Frame):
    def __init__(self, *args, **kwds):
        # begin wxGlade: MyFrame.__init__
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.list_box_1 = wx.ListBox(self, -1, choices=[])
        self.open_panel = wx.Button(self, -1, "Open panel")

        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_BUTTON, self.openpanel, self.open_panel)
        # end wxGlade

    def __set_properties(self):
        # begin wxGlade: MyFrame.__set_properties
        self.SetTitle("frame_1")
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: MyFrame.__do_layout
        sizer_1 = wx.BoxSizer(wx.VERTICAL)
        sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
        sizer_2.Add(self.list_box_1, 0, wx.ADJUST_MINSIZE, 0)
        sizer_2.Add(self.open_panel, 0, wx.ADJUST_MINSIZE, 0)
        sizer_1.Add(sizer_2, 1, wx.EXPAND, 0)
        self.SetSizer(sizer_1)
        sizer_1.Fit(self)
        self.Layout()
        # end wxGlade

    def openpanel(self, event): # wxGlade: MyFrame.<event_handler>
        self.panel = MyFrame2(MyFrame(self), -1, "")
        self.panel.Show()

# end of class MyFrame


class MyFrame2(wx.Frame):
    def __init__(self, *args, **kwds):
        # begin wxGlade: MyPanel.__init__
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.text_ctrl_1 = wx.TextCtrl(self, -1, "")
        self.button_1 = wx.Button(self, -1, "button_1")

        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_BUTTON, self.list, self.button_1)
        # end wxGlade

    def __set_properties(self):
        # begin wxGlade: MyPanel.__set_properties
        pass
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: MyPanel.__do_layout
        sizer_3 = wx.BoxSizer(wx.VERTICAL)
        sizer_3.Add(self.text_ctrl_1, 0, wx.ADJUST_MINSIZE, 0)
        sizer_3.Add(self.button_1, 0, wx.ADJUST_MINSIZE, 0)
        self.SetSizer(sizer_3)
        sizer_3.Fit(self)
        # end wxGlade

    def list(self, event): # wxGlade: MyPanel.<event_handler>
        # this would create a new instance of MyFrame!!!!!!!!!!!!
        #myframe = MyFrame(None, -1 , "")
        # you want to use the existing frame_1 instance from __main__
        frame_1.list_box_1.Append(self.text_ctrl_1.GetValue())

# end of class MyPanel


if __name__ == "__main__":
    app = wx.PySimpleApp(0)
    wx.InitAllImageHandlers()
    frame_1 = MyFrame(None, -1, "")
    app.SetTopWindow(frame_1)
    frame_1.Show()
    app.MainLoop()

Also, its good practice to not have functions that are using names that are already taken. Such as print, int, str, list bool and so on. So it's probably best if you change your list() function to another name. :)

Also, its good practice to not have functions that are using names that are already taken. Such as print, int, str, list bool and so on. So it's probably best if you change your list() function to another name. :)

I know, but because this was just a quickly built example, I didn't really look at the names; but you're right =)


btw thanks vegaseat

Also, its good practice to not have functions that are using names that are already taken. Such as print, int, str, list bool and so on. So it's probably best if you change your list() function to another name. :)

If you do large project, names get finished. I use sometimes, myList, Listed, .. et al

Thanks to OOP for the rescue ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.