jwdj / EasyABC

EasyABC
GNU General Public License v2.0
87 stars 36 forks source link

image file .../img/v.png not found when current directory is different from the location of easy_abc.py #43

Closed bomm closed 2 years ago

bomm commented 3 years ago

When I run python3 path/to/easy_abc.py on Ubuntu 20.04.2 LTS, I get an error message window Failed to load image from file "/current/working/directory/img/v.png". and

Traceback (most recent call last):
  File "jwdj/EasyABC/easy_abc.py", line 8402, in OnInit
    self.frame = self.NewMainFrame()
  File "jwdj/EasyABC/easy_abc.py", line 8361, in NewMainFrame
    frame = MainFrame(None, 0, self.app_dir, self.settings)
  File "jwdj/EasyABC/easy_abc.py", line 3684, in __init__
    self.setup_menus()
  File "jwdj/EasyABC/easy_abc.py", line 5711, in setup_menus
    self.popup_ornaments = self.create_symbols_popup_menu(ornaments)
  File "jwdj/EasyABC/easy_abc.py", line 5649, in create_symbols_popup_menu
    append_menu_item(menu, ' ', description, self.OnInsertSymbol, bitmap=image.ConvertToBitmap())
  File "/usr/lib/python3/dist-packages/wx/core.py", line 752, in _Image_ConvertToBitmap
    bmp = wx.Bitmap(self, depth)
wx._core.wxAssertionError: C++ assertion "image.IsOk()" failed at ../src/gtk/bitmap.cpp(581) in wxBitmap(): invalid image
OnInit returned false, exiting...

Apparently, EasyABC contains relative paths to the image files like "img/v.png" which are interpreted relative to the current directory instead of relative to the location of the program.

The problem occurs both with the master version from https://github.com/jwdj/EasyABC and the fix_layout_issues branch in https://github.com/mmehl/EasyABC.

I think it is a problem with the value of variable cwd. I will try to prepare a fix. (And there seems to be a confusion between "current working directory" and "program directory" which is not necessarily the same, depending on how the program is started.)

Background information: I started EasyABC this way because I cloned both repositories mentioned above and wanted to check if a different problem occurs in both version.

jwdj commented 3 years ago

Hello Bodo,

It has been a while, but I think I have fixed this issue in the latest version of EasyABC (both on GitHub and on SourceForge.net)

Best regards, Jan Wybren

On 20-6-2021 20:03, Bodo wrote:

When I run |python3 path/to/easy_abc.py| on Ubuntu 20.04.2 LTS, I get an error message window |Failed to load image from file "/current/working/directory/img/v.png"|. and

|Traceback (most recent call last): File "jwdj/EasyABC/easy_abc.py", line 8402, in OnInit self.frame = self.NewMainFrame() File "jwdj/EasyABC/easy_abc.py", line 8361, in NewMainFrame frame = MainFrame(None, 0, self.app_dir, self.settings) File "jwdj/EasyABC/easy_abc.py", line 3684, in init self.setup_menus() File "jwdj/EasyABC/easy_abc.py", line 5711, in setup_menus self.popup_ornaments = self.create_symbols_popup_menu(ornaments) File "jwdj/EasyABC/easy_abc.py", line 5649, in create_symbols_popup_menu append_menu_item(menu, ' ', description, self.OnInsertSymbol, bitmap=image.ConvertToBitmap()) File "/usr/lib/python3/dist-packages/wx/core.py", line 752, in _Image_ConvertToBitmap bmp = wx.Bitmap(self, depth) wx._core.wxAssertionError: C++ assertion "image.IsOk()" failed at ../src/gtk/bitmap.cpp(581) in wxBitmap(): invalid image OnInit returned false, exiting... |

Apparently, EasyABC contains relative paths to the image files like "img/v.png" which are interpreted relative to the current directory instead of relative to the location of the program.

The problem occurs both with the |master| version from |https://github.com/jwdj/EasyABC| and the |fix_layout_issues| branch in |https://github.com/mmehl/EasyABC|.

I think it is a problem with the value of variable |cwd|. I will try to prepare a fix. (And there seems to be a confusion between "current working directory" and "program directory" which is not necessarily the same, depending on how the program is started.)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jwdj/EasyABC/issues/43, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC22EZBCAK2ATUSHGB5R56TTTYUPXANCNFSM47AJBHHA.