Help with wxPython BoxSizers

Miki Tebeka tebeka at cs.bgu.ac.il
Tue Mar 4 10:53:29 EST 2003


Hello All,

Can someone tell me what I'm doing wrong in the following code?
I'd like to get the [...] button next to the text control and not below it.

10x.

--- client.py ---
from wxPython.wx import *

ID_READ_DATA = NewId()
ID_QUIT = NewId()
ID_DEFECT = NewId()
ID_BROWSE = NewId()

FILE_FILTER = 'Defect Files|*.001;*.002;*.003;*.cmp;*.kla'
RECIPE_NAME = ''

class Client(wxFrame):
    def __init__(self, parent, id):
        wxFrame.__init__(self, parent, id, 'Compass Client')
        topsizer = wxBoxSizer(wxVERTICAL)
        # Top Read Data button
        b = wxButton(self, ID_READ_DATA, 'Read Data')
        EVT_BUTTON(self, ID_READ_DATA, self.on_read_data)
        topsizer.Add(b)
        # Defect file
        #FIXME: Why doesn't layout work?       
        topsizer.Add(wxStaticText(self, -1, 'Defect file:'))
        hsizer = wxBoxSizer(wxHORIZONTAL)
        self.defect = \
            wxTextCtrl(self, ID_DEFECT, '', size=(200, -1))
        hsizer.Add(self.defect)
        b = wxButton(self, ID_BROWSE, '...', size=(20, -1))
        hsizer.Add(b)
        topsizer.Add(hsizer)
        EVT_BUTTON(self, ID_BROWSE, self.on_select_defect)
        topsizer.Add(b)
        
        q = wxButton(self, ID_QUIT, 'Quit', wxPoint(0, 70))
        EVT_BUTTON(self, ID_QUIT, lambda e: self.Close(1))
        topsizer.Add(q)
        self.SetSizer(topsizer)
        self.SetAutoLayout(1)
        topsizer.Fit(self)

    def on_read_data(self, event):
        print event
    
    def on_select_defect(self, event):
        dlg = wxFileDialog(self, 'Select a Defect File', '', '', FILE_FILTER, \
                           wxOPEN)
        if dlg.ShowModal() != wxID_OK:
            return
        self.defect.SetValue(dlg.GetPath())
        

if __name__ == '__main__':
    app = wxPySimpleApp()
    frame = Client(None, -1)
    frame.Show(1)
    app.MainLoop()
    
--- client.py ---




More information about the Python-list mailing list