Hi,

On Sun, 24 Jan 2016 12:58:05 +0100
ingo <ingoo...@gmail.com> wrote:

> Extended the code with a ttk.notebook and a button. Seems to work. Text 
> is added only at the last opened tab, by the button, I think I 
> understand why but will look into that later.

when I run your code here, it seems to work as expected, there is a text
widget being added to every new tab. However, you should be careful: in
your add_edtab () method you override the value of self.ed each time a
new tab is created, so if you need to access the text widgets later
programatically you will only be able to get your hands on the one that
was created last. You could use a list or a dictionary instead to keep
references to the text widgets in the Nnotebook class.

> 
> When I add a tab through the button, no event is generated. When adding 
> through a double-click or ctrl-n it does. Where does this difference 
> come from?

This is because the event is not generated by the tab-adding procedure,
but by clicking the button or pressing the keys ;-)
Of course there is a <Button> event triggered when you click the "Add tab"
button, but this one is handled inside the tcl event handler (somewhere in
button.tcl) and so none of its properties can be accessed from Python
(afaik at least).
If for some reason you really need to access the event
object's properties in your callback, you would probably have to remove
the default widget bindings for the events in question and write your own
event handlers for these and apply the bindings again (though I am not
sure if there is a good reason why one would want to do so).

Best regards

Michael

.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

Romulan women are not like Vulcan females.  We are not dedicated to
pure logic and the sterility of non-emotion.
                -- Romulan Commander, "The Enterprise Incident",
                   stardate 5027.3
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to