[Tkinter-discuss] Tkinter-discuss Digest, Vol 25, Issue 7

Harlin Seritt harlinseritt at yahoo.com
Tue Mar 21 12:48:12 CET 2006

Hi Mr. M.-
  Change this line:
  self.bible_scroll.pack (side = RIGHT, fill = Y, expand = "yes", anchor = W)
  to this:
  self.bible_scroll.pack (side = RIGHT, fill = Y, anchor = W)
  Remember that not everything needs to expand! Good luck with your project!
  If you get a chance, I'd like to know more offline (away from this list) about your app.
  Harlin Seritt

tkinter-discuss-request at python.org wrote:
  Send Tkinter-discuss mailing list submissions to
tkinter-discuss at python.org

To subscribe or unsubscribe via the World Wide Web, visit
or, via email, send a message with subject or body 'help' to
tkinter-discuss-request at python.org

You can reach the person managing the list at
tkinter-discuss-owner at python.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Tkinter-discuss digest..."

Today's Topics:

1. Need help with a text + scrollbar widget and expansion


Message: 1
Date: Mon, 20 Mar 2006 12:10:41 -0600
From: Mannequin* 
Subject: [Tkinter-discuss] Need help with a text + scrollbar widget
and expansion
To: Tkinter Discuss 
Message-ID: <441EF021.2010101 at invigorated.org>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Hi all,

I'm new to the list, and I have a question about how I can get a text + 
scrollbar widget to expand properly in their frame.

I'll first give you the sample code, then I'll link to images of the 


from Tkinter import *

APP_NAME = "Spurgeon"
APP_VERSION = "0.10"
BIBLE_BOOKS = ["Genesis", "Exodus", "Leviticus", "Numbers"]

class Spurgeon (Frame):
"""Hopefully a class to create the Tkinter interface"""
def __init__ (self, parent = None):
"""Creates main window and widgets"""
self.root = Tk ()
self.root.title (APP_NAME + ' ' + APP_VERSION)
self.root.config (borderwidth = 3)

Frame.__init__ (self, parent)
self.pack (fill = "both", expand = "yes")

self.make_widgets ()

def make_widgets (self):
"""Create the widgets for the main window"""
# Create the main menu
self.mainmenu = Menu (self.root)

# Create the File menu
self.file_menu = Menu (self.mainmenu, tearoff = 0)
self.file_menu.add_command (label = "Open", underline = 0)
self.file_menu.add_separator ()
self.file_menu.add_command (label = "Quit", underline = 0, command = 
self.mainmenu.add_cascade (label = "File", menu = self.file_menu, 
underline = 0)

# Create the Edit menu
self.edit_menu = Menu (self.mainmenu, tearoff = 0)
self.edit_menu.add_command (label = "Cut", underline = 2)
self.edit_menu.add_command (label = "Copy", underline = 0)
self.edit_menu.add_command (label = "Paste", underline = 0)
self.edit_menu.add_command (label = "Delete", underline = 0)
self.mainmenu.add_cascade (label = "Edit", menu = self.edit_menu, 
underline = 0)

# Create the Help menu
self.help_menu = Menu (self.mainmenu, tearoff = 0)
self.help_menu.add_command (label = "About", underline = 0)
self.mainmenu.add_cascade (label = "Help", menu = self.help_menu, 
underline = 0)

# Display the main menu
self.root.config (menu = self.mainmenu)

# Create the left frame
self.tool_frame = Frame (self, borderwidth = 2)
self.tool_frame.pack (side = LEFT, anchor = NW)
Label (self.tool_frame, text = "Left frame").pack ()

# Create the right frame
self.view_frame = Frame (self, borderwidth = 2)
self.view_frame.pack (side = RIGHT, expand = "yes", fill = "both")
# Create the area where the Bible is viewed from
self.bible_scroll = Scrollbar (self.view_frame)
self.bible_view = Text (self.view_frame, relief = SUNKEN)
self.bible_scroll.config (command = self.bible_view.yview)
self.bible_view.config (yscrollcommand = self.bible_scroll.set)
self.bible_view.pack (side = LEFT, fill = "both", expand = "yes")
self.bible_scroll.pack (side = RIGHT, fill = Y, expand = "yes", anchor 
= W)

if (__name__ == "__main__"):
a = Spurgeon ()
a.mainloop ()


Now, if you run this, you'll notice that when you expand the window 
horizontally ( <---> ) that the text + scrollbar widget doesn't expand 
with the window.

Here is a screenshot of the problem to illustrate what I'm talking about:

I hope I've given enough information here to be helpful.

By the way, is there anyway to enhance the look of the Tkinter widgets 
under Linux using what comes standard with Python. I'm trying to stay as 
standard as I possibly can.



Tkinter-discuss mailing list
Tkinter-discuss at python.org

End of Tkinter-discuss Digest, Vol 25, Issue 7

Yahoo! Mail
Bring photos to life! New PhotoMail  makes sharing a breeze. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20060321/b0e5e000/attachment.html 

More information about the Tkinter-discuss mailing list