Problem with custom font dialog

Hi,

I'd like to create a custom font dialog where you can select font and font size.
Here is some example code:

#!/usr/bin/python

import wx

class FontDialog(wx.Dialog):

    def __init__(self,*args,**kwargs):
        super(FontDialog,self).__init__(*args,**kwargs)

        self.InitUI()

    def InitUI(self):
        self.panel = wx.Panel(self)
        self.mainSizer = wx.BoxSizer(wx.VERTICAL)

        self.SetSize((400,400))

        self.subSizer1=wx.BoxSizer(wx.HORIZONTAL)
        self.fontList=wx.ListBox(self.panel,size=(100,200))
        self.sizeList=wx.ListBox(self.panel,size=(100,200))
        self.subSizer1.Add(self.fontList)
        self.subSizer1.Add(self.sizeList)
        self.mainSizer.Add(self.subSizer1,wx.EXPAND)

        self.subSizer2=wx.BoxSizer(wx.HORIZONTAL)
        self.okButton=wx.Button(self,wx.ID_OK)
        self.cancelButton=wx.Button(self,wx.ID_CANCEL)
        self.subSizer2.Add(self.okButton)
        self.subSizer2.Add(self.cancelButton)
        self.mainSizer.Add(self.subSizer2,wx.BOTTOM)

        self.panel.SetSizer(self.mainSizer)
        self.Center()
        self.Show()

def main():
    app = wx.App(False)
    FontDialog(None)
    app.MainLoop()

if __name__ == "__main__":
    main()

Now the problem with that code is, that instead of having the two ListBox next to each other, I only see a small rectangle in the top left of the screen. Whatever I tried, I didn't manage to get it looking right.

Any ideas?
Thank you!

Hi,

I'd like to create a custom font dialog where you can select font and font size.
Here is some example code:

...

Now the problem with that code is, that instead of having the two ListBox next to each other, I only see a small rectangle in the top left of the screen. Whatever I tried, I didn't manage to get it looking right.

Use the WIT - http://wiki.wxpython.org/Widget%20Inspection%20Tool to debug layout issues, it should not be too difficult to find why your version does not work by using the "sizers" and the "hightlight" buttons in the WIT on the different widgets on your dialog.

I couldn't resist to push the sized_controls, see attached. with the sc's you get platform conform spacing out of the box and free of charge.

Werner

cdialog.py (1023 Bytes)

···

On 13/02/2013 00:48, pythonfan@Safe-mail.net wrote: