Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gtk.ToolButton expects a Gtk.Image for the icon, not a GdkPixbuf.Pixbuf #2152

Closed
rmartin16 opened this issue Oct 10, 2023 · 1 comment · Fixed by #2075
Closed

Gtk.ToolButton expects a Gtk.Image for the icon, not a GdkPixbuf.Pixbuf #2152

rmartin16 opened this issue Oct 10, 2023 · 1 comment · Fixed by #2075
Labels
bug A crash or error in behavior. linux The issue relates Linux support.

Comments

@rmartin16
Copy link
Member

rmartin16 commented Oct 10, 2023

Describe the bug

The icon for a command on a toolbar throws this error:

[gtktest] Starting in dev mode...
===========================================================================
Traceback (most recent call last):
  File "/home/russell/github/beeware/briefcase/venv-3.10-briefcase/lib/python3.10/site-packages/toga_gtk/app.py", line 98, in gtk_startup
    self.interface._startup()
  File "/home/russell/github/beeware/briefcase/venv-3.10-briefcase/lib/python3.10/site-packages/toga/app.py", line 556, in _startup
    self.startup()
  File "/home/russell/tmp/beeware/gtktest/src/gtktest/app.py", line 35, in startup
    self.main_window.toolbar.add(cmd1)
  File "/home/russell/github/beeware/briefcase/venv-3.10-briefcase/lib/python3.10/site-packages/toga/command.py", line 393, in add
    self.on_change()
  File "/home/russell/github/beeware/briefcase/venv-3.10-briefcase/lib/python3.10/site-packages/toga_gtk/window.py", line 82, in create_toolbar
    item_impl.set_icon_widget(cmd.icon._impl.native_32)
TypeError: argument icon_widget: Expected Gtk.Widget, but got gi.overrides.GdkPixbuf.Pixbuf

Steps to reproduce

Sample app named gtktest

import toga
from toga.style import Pack
from toga.style.pack import COLUMN, ROW


class gtktest(toga.App):

    def startup(self):
        stuff_group = toga.Group('Stuff', order=40)
        cmd1 = toga.Command(
            lambda: print(self),
            text='Example command',
            tooltip='Tells you when it has been activated',
            shortcut='k',
            icon='resources/gtktest.png',
            group=stuff_group,
            section=0
        )

        self.main_window = toga.MainWindow(title=self.formal_name)

        self.commands.add(cmd1)
        self.main_window.toolbar.add(cmd1)

        main_box = toga.Box()
        self.main_window.content = main_box
        self.main_window.show()


def main():
    return gtktest()

Expected behavior

Icon renders without an error.

Screenshots

No response

Environment

  • Operating System: pop os 22.04
  • Python version: 3.10.12
  • Software versions:
    • Briefcase: 0.3.16.dev278+gf732c612.d20231010
    • Toga: 0.3.2.dev1256+gedb92eb5

Logs

briefcase.2023_10_10-16_19_32.dev.log

Additional context

Initial report: https://discord.com/channels/836455665257021440/836455665257021443/1161383265698070700

@rmartin16 rmartin16 added bug A crash or error in behavior. linux The issue relates Linux support. labels Oct 10, 2023
@freakboy3742
Copy link
Member

I can confirm this in the morning, but I think this has been addressed by #2075.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A crash or error in behavior. linux The issue relates Linux support.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants