Hi Emmanuel,
On Tue, 1 Aug 2017 10:36:08 +0100
Emmanuel Adeiza wrote:
> i am currently working on a project(using tkinter) that uses the
> Notebook widget and has an area that serves as an editor but when i
> click on 'new file' it does open it in a new tab but does not show the
> tab, the previous tab that i was on before clicking 'new file' is still
> the one on display... i need it to automatically display the new tab
> instead of me having to click on it before i see the tab
> this is the source code for that:
> def new(self,filename1='Untitled'):
> global content_text
> filename=filename1
> tab_frame=Frame(myNote,height=600, width=1350,
> background='#113147208', borderwidth=1, relief= FLAT)
> line_number_bar = Text(tab_frame, width=2, padx=2,
> takefocus=True,border=0, background='tan', state='disabled',
> wrap='none', cursor = 'dotbox')
> line_number_bar.pack(side='left', fill='y')
> content_text = Text(tab_frame, wrap='word',
> background='AntiqueWhite3')
> content_text.pack(expand='yes', fill='both')
> scroll_bar = Scrollbar(content_text, cursor = 'dotbox')
> content_text.configure(yscrollcommand=scroll_bar.set)
> scroll_bar.config(command=content_text.yview)
> scroll_bar.pack(side='right', fill='y')
you need to explicitely add the newly created Frame as a new "slave" to
the Notebook, then you can tell the Notebook to select the newly created
tab, like this:
myNote.add(tab_frame, text=filename1)
myNote.select(myNote.index('end')-1) # or: myNote.select(
#tab_frame)
Hre you can find a complete reference of the Notebook widget (and other
Tkinter widgets as well :)
http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/ttk-Notebook.html
I hope this helps!
Best regards
Michael
.-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-.
I'm a soldier, not a diplomat. I can only tell the truth.
-- Kirk, "Errand of Mercy", stardate 3198.9
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss