[pygtk] Resuing tabs?
Alessandro Pellizzari
shuriken at neko.it
Sat Jul 24 16:26:11 WST 2004
On Fri, 23 Jul 2004 10:13:57 +1200, "John C Barstow"
<jbowtie at amathaine.com> wrote:
> I have a project where, having done GLADE layout for a notebook, I
> need multiple instances of a certain tab. They will all be children of
> the same notebook.
I use something like this:
Create a notebook named "nb_main" in glade and add a single tab to it
with all the widgets you need. Call the container within
the tab "tab_contents" In every callback pass "tab_contents" as
widget.
The structure shoul be something like
window
+- notebook
| +- tab_contents
| | +- widget1
| | +- widget2
...
In prg.glade you should have something like
<child>
<widget class="GtkEntry" id="widget1">
...
<signal name="changed" handler="on_widget1_changed"
object="tab_contents" last_modification_time="Sat, 24 Apr 2004 09:12:57
GMT"/>
</widget>
When you need a new tab:
tablabel = gtk.Label("New tab")
tablist[maxtab+1]=libglade.XML(gladefile,"tab_contents")
newtab = tablist[maxtab+1].get_widget("tab_contents")
gui.get_widget("nb_main").insert_page(tablabel, newtab)
As all the widgets will have the same name and handler of other tabs,
you must use "tab_contents" to know in which tab the signal was born:
for tab in tablist:
if tab==passed_widget:
we are working on this tab
I simplified a lot and used meta-code, but I hope the concept is clear.
:)
Bye.
More information about the pygtk
mailing list