Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 27th, 2006, 2:53 AM   #1
Yarvin
Programmer
 
Join Date: Sep 2005
Location: Anchorage, Alaska
Posts: 37
Rep Power: 0 Yarvin is on a distinguished road
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 the text area is automatically resized to fit the main frame.

and this is how I'm using it:
class Frame(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, wx.ID_ANY, title, size = ( 200,100),
                                                style=wx.DEFAULT_FRAME_STYLE|
                                                wx.NO_FULL_REPAINT_ON_RESIZE)
            self.makemenubar()
            self.splitwin = wx.SplitterWindow(self)
            self.pan1 = wx.Panel(self.splitwin, style=wx.SUNKEN_BORDER)
            self.pan2 = wx.Panel(self.splitwin, style=wx.SUNKEN_BORDER)

            self.pan2.Hide()
            self.splitwin.Initialize(self.pan1)
            self.splitwin.SetMinimumPaneSize(10)   
            self.splitwin.SplitVertically(self.pan1, self.pan2, 0)
            #self.SetSizer(self.splitwin)
            self.SetPosition((100, 100))


            self.text = wx.TextCtrl(self.pan1, 1, "text\n\ttext\n\t\tand more text",
								style = wx.TE_MULTILINE)
            self.text2 = wx.TextCtrl(self.pan2, 1, style = wx.TE_MULTILINE)

            self.CreateStatusBar() # A StatusBar in the bottom of the window

            horizon = wx.BoxSizer(wx.HORIZONTAL)
            vert = wx.BoxSizer(wx.VERTICAL)
            vert.Add(self.text, 1, wx.EXPAND | wx.TOP | wx.RIGHT | wx.LEFT)

can anyone tell me where I went wrong?

Any and all help is appreciated, thank you
__________________
[ADM]art
Yarvin is offline   Reply With Quote
Old Jul 27th, 2006, 8:30 AM   #2
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,827
Rep Power: 5 Sane will become famous soon enough
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).
Sane is offline   Reply With Quote
Old Jul 27th, 2006, 9:01 AM   #3
Game_Ender
Professional Programmer
 
Game_Ender's Avatar
 
Join Date: May 2006
Location: Maryland, USA
Posts: 306
Rep Power: 3 Game_Ender is on a distinguished road
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.
Game_Ender is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
wxPython syntax error help. Yarvin Python 5 Jul 26th, 2006 9:31 PM
Glade and wxPython? titaniumdecoy Python 7 Jul 2nd, 2006 9:54 PM
drawString size? Writlaus Java 19 Dec 22nd, 2005 9:11 AM
Minimize the Window size to certain pixel parthiban JavaScript and Client-Side Browser Scripting 13 Oct 21st, 2005 7:37 PM
How to say the size of an array using printf ? colt C 2 May 19th, 2005 3:25 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:26 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC