python-3.xgtk3graphical-logo

Can I put Logo directly on Gtk header bar? (without widget)


I am trying to put logo on Gtk.Headerbar directly in place of title. Logo is created in microsoft word. below is my portion of code

class MainWindow(Gtk.Window): """Main window containing notebook""" def init(self): Gtk.Window.init(self, title="") # since the title is blank, the default header bar with Python icon self.set_border_width(10) screen = self.get_screen() screen_width = screen.get_width() screen_height = screen.height()

    if screen_width > 1366 or screen_height > 768:
        self.set_size_request(1300, 800)

    else:
        self.set_size_request(screen_width, screen_height)

    self.set_resizable(True)

    self.set_resizable(True)

    # self.maximize()
    # Creating headerbar & adding it to our window
    title = "Pareto"
    subtitle = "Shape your world"
    header_bar = Gtk.HeaderBar(title=title, subtitle=subtitle)
    header_bar.set_show_close_button(True)


    samco_logo = Gtk.Image.new_from_file(r"C:\Users\njoshi\Desktop\pareto\icons\pareto_logo1.png")
    # this line convert the created icon to an image

    header_bar.pack_start(samco_logo)
    time_label = TimeLabel()             # show time on header bar
    header_bar.pack_end(time_label)
    self.set_titlebar(header_bar)

    # creating a notebook
    notebook = Gtk.Notebook()

Right now I am using Gtk.Image widget for Logo. Can I design logo directly in my code using html?


Solution

  • I got it!There is no way we can put logo directly on any of the widgets in GTK 3. Only way is add image widget on top of header bar.

       self.header_bar = Gtk.HeaderBar()
        self.header_bar.props.title = "Pareto"
    
        self.header_bar.set_show_close_button(True)
        pareto_logo =  Gtk.Image.new_from_file(r"loc\image.png")
        self.header_bar.pack_start(pareto_logo)