How to update window title?

I have the following sample:

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
import time

page_number = 0

window = Gtk.Window()
window.set_title("Page "+ str(page_number+1))
window.show_all()
Gtk.main()

In my project, the value of page_number will increase.

Sorry for the very basic question, but how can I make that the window title gets the updated value?

Many thanks for your help.

Sorry, but coding is almost all Greek to me.

I found a dirty hack:

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
import time

page_number = 0

window = Gtk.Window()
window.set_title("Page "+ str(page_number+1))
window.show_all()

window.fullscreen()
page_number = 1000

window.unfullscreen()
window.set_title("Page "+ str(page_number+1))

Gtk.main()

It seems that repeating set_title() does the job.

Even as a newbie coder, the workaround looks crappy to me.

Is there no more elegant way of resetting the window title?

Many thanks for your help.

Why? Setting the title when you want/need to set the title seems fine to me? :slight_smile:

Of course eventually you may use properties/signals, but ultimately it’s always going to be setting :title

1 Like

Many thanks for your reply, Zander.

Probably I should read what properties and signals are and how could be handled.

But that would be for the next project :stuck_out_tongue_closed_eyes:.

Many thanks for your help.

1 Like

After you read the main documentation, you could take a look here. There are two playlists dedicated to Signals and properties.

Many thanks for your reply, @MichiB.

I won’t be able to read C code (I hardly read Python and Lua), but your videos are great for me to grasp the basic meaning of the concepts at stake.

Many thanks for your help.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.