Creating a Text widget in a Dialog (Tkinter)
Aki Niimura
akineko at pacbell.net
Sun Sep 8 16:27:49 EDT 2002
Hi,
I'm trying to create a simple dialog which has a Text with
scrollbars(H and V)
in a dialog. (I'm inherting Tkinter Dialog class)
I'm using a grid to attach two scrollbars to the Text widget.
I don't know why but the text widget is disappeared (not mapped) while
two
scrollbars are displayed correctly.
If I use pack instead of grid then all of them appear (but Horizontal
scrollbar are not placed correctly). I used the same code in the main
window
and it worked fine.
Is there anything I'm overlooking?
Any insights are highly appreciated.
Thanks,
Aki-
###
### Class HelpDlg
###
class HelpDlg(Dialog):
def __init__(self, parent, excerpt, title = None):
self.lines = excerpt
Dialog.__init__(self, parent, title)
def body(self, master):
self.usage = Text(master, height=26, width=80)
self.grid = Frame(master)
self.yscroll = Scrollbar(master, command=self.usage.yview)
self.xscroll = Scrollbar(master, orient=HORIZONTAL,
command=self.usage.xview)
self.usage.configure(xscrollcommand=self.xscroll.set,
yscrollcommand=self.yscroll.set)
for line in self.lines:
self.usage.insert(END, line+'\n')
self.grid.pack(expand=YES, fill=BOTH)
self.usage.grid(in_=self.grid, row=0, column=0)
self.yscroll.grid(in_=self.grid, row=0, column=1,
sticky='news')
self.xscroll.grid(in_=self.grid, row=1, column=0,
sticky='news')
More information about the Python-list
mailing list