Search code examples
wxglade

wxGlade: Set the initial size based on number of characters inside wxGlade


I have a wx.Choice control in glade however I am not sure how I would be able to set the default size of the control to be equivalent to x number of characters.

Is there a way to set the initial size of the widget inside wxGlade, to be the length of an expected string (in pixels)?

wx.Choice.SetInitialSize(dc.GetTextExtent("expected string")[0])


Solution

  • In short, there is no such option, there might be added in the future, however currently wxGlade does not provide a convenient way to specify an initial size in terms of number of characters.

    Adding the code of

    wx.Choice.SetInitialSize(dc.GetTextExtent("expected string")[0])
    

    In the code section within wxGlade is one way of doing this, the other is to add it in manually within the Python code.