Re : Problem with wxListbox and wxFileDialog

Hello world!!!
Ok, I've undestand how to fill a wxListBox with selected files.
But, why I can't fill my ListBox with this code?
Is there an another way to do this?

Why not create a hidden panel first and show it after the list is
filled with data.

*** NOT TESTED ***

import wx

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.panel = wx.Panel(self, -1)
        self.list_box = wx.ListBox(self.panel, -1, choices=)

        self.__set_properties()
        self.__do_layout()
        # end wxGlade
        barre_de_menu = wxMenuBar()
        file_menu01 = wxMenu()
  ID_OPEN = wx.NewId()
        file_menu01.Append(ID_OPEN,
        "Open...\\tCtrl+O", "Cliquez sur Open pour ouvrir un fichier")
        barre_de_menu.Append(file_menu01, "&File")
        self.SetMenuBar(barre_de_menu)
  EVT_MENU(self, ID_OPEN, self.OnOpen)

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

  # hide panel
  self.panel.Hide() # or use self.panel.Show(False)

    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, wx.EXPAND, 0)
        self.panel.SetAutoLayout(1)
        self.panel.SetSizer(sizer_2)
        sizer_2.Fit(self.panel)
        sizer_2.SetSizeHints(self.panel)
        sizer_1.Add(self.panel, 1, wx.EXPAND, 0)
        self.SetAutoLayout(1)
        self.SetSizer(sizer_1)
        sizer_1.Fit(self)
        sizer_1.SetSizeHints(self)
        self.Layout()
        # end wxGlade

    def OnOpen(self, event):
""" Open a file"""
dirname = 'c:\\media'
dlg = wxFileDialog(self, "Choose a file :", dirname, "",
                           "*.*", wxOPEN|wxMULTIPLE)
if dlg.ShowModal() == wxID_OK:
self.filename=dlg.GetFilename()
self.dirname=dlg.GetDirectory()
for path in dlg.GetPaths():
            self.list_box.Append(path)

        # show the panel
        self.panel.Show(True)

Regards,
Remy

···

On Tuesday 27 April 2004 10:24, tictactouc@altern.org wrote:

class MainWindow(wxFrame):
    def __init__(self,parent,id,title):
        wxFrame.__init__(self,parent,-4, title, size = ( 500,600),
        style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)

        barre_de_menu = wxMenuBar()
        file_menu01 = wxMenu()
        file_menu01.Append(ID_OPEN, "Open...\\tCtrl+O", "Cliquez
sur Open pour ouvrir un fichier") barre_de_menu.Append(file_menu01,
"&File")
        self.SetMenuBar(barre_de_menu)

        EVT_MENU(self, ID_OPEN, self.OnOpen)

    def OnOpen(self, event):
        """ Open a file"""
        dirname = 'c:\\media'
        dlg = wxFileDialog(self, "Choose a file :", dirname, "",
"*.*", wxOPEN|wxMULTIPLE) # if dlg.ShowModal() == wxID_OK:
            self.filename=dlg.GetFilename()
            self.dirname=dlg.GetDirectory()
        event = Form1(frame, -1)
        for path in dlg.GetPaths():
            event.lb1.Append(path)

class Form1(wxPanel):
    def __init__(self, parent, id):
        self.panel = wxPanel.__init__(self, parent, id)

        List_Song =
        self.lb1 = wxListBox(self, 60, wxPoint(300, 150),
wxSize(80, 120), List_Song, wxLB_SINGLE)

Thanks for all!!!

-------------------------------------------------------------------
-- To unsubscribe, e-mail:
wxPython-users-unsubscribe@lists.wxwidgets.org For additional
commands, e-mail: wxPython-users-help@lists.wxwidgets.org