![]() |
wxPython TextCtrl size?
I've been searching through the wxPython in Action book and through the wxpython.org site but I can't figure out how to make my text area resize to the size of the main frame.
in most examples they use wx.TextCtrl like this: :
self.control = wx.TextCtrl(self, 1, style=wx.TE_MULTILINE)and this is how I'm using it: :
class Frame(wx.Frame):can anyone tell me where I went wrong? Any and all help is appreciated, thank you :) |
Every control in wxWidgets inherits the base attributes of the wxFrame class. As you can see, you set the size of the frame in the third line with size=(200, 100). You can do the same for the wx.TextCtrl. Just add the size attribute to its list of paramaters.
Also, I think it's recommended to use size = wx.Size(200, 100), over size = (200, 100). |
The creation of the text control really has nothing to do with how the wxTextCtrl is sized inside of your panel. You need to add a sizer to the panel that expands to fill it completely. You then need to add the wxTextCtrl to that sizer, and set it to expand to fully fill that text control.
You can hard code the size settings as Sane suggested, but then are you missing out on one of the best features of wxWidgets, sizers. Manually specifying all sizes makes wxWidgets more like VB. Take a look at the sizer overview on the wxWidgets site. I am sure they also have sections on sizers in your book. From a quick look at the wxWidgets docs, it looks perfectly fine to use tuples where you would see wxSize and wxPoint classes in C++. They have even added extra methods like "GetSizeTuple" to wxWindow in wxPython. |
| All times are GMT -5. The time now is 12:21 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC