Skip to content

Commit

Permalink
Find correct default image for AboutDialog (#1142)
Browse files Browse the repository at this point in the history
* Add a test that fails because image is not loaded correctly.

* Move AboutDialog trait definitions to mixin class.

This ensures that the Image trait can find the about.png file in pyface/images

* Fix flake8 issues.
  • Loading branch information
corranwebster committed Jul 8, 2022
1 parent 4065ef1 commit 9608848
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 24 deletions.
14 changes: 13 additions & 1 deletion pyface/i_about_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

from traits.api import HasTraits, List, Str


from pyface.i_dialog import IDialog
from pyface.ui_traits import Image

Expand All @@ -37,3 +36,16 @@ class MAboutDialog(HasTraits):
""" The mixin class that contains common code for toolkit specific
implementations of the IAboutDialog interface.
"""

#: Additional strings to be added to the dialog.
additions = List(Str)

#: Additional copyright strings to be added above the standard ones.
copyrights = List(Str)

#: The image displayed in the dialog.
image = Image()

def _image_default(self):
from .image_resource import ImageResource
return ImageResource('about')
15 changes: 14 additions & 1 deletion pyface/tests/test_about_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#
# Thanks for using Enthought open source!


import os
import unittest

from ..about_dialog import AboutDialog
Expand Down Expand Up @@ -104,3 +104,16 @@ def test__create_html(self):
self.assertIn(
"Copyright &copy; copyright<br />Copyright &copy; copyleft", html
)

def test_image_default(self):
# test that the default image is found
import pyface
expected_path = os.path.join(
os.path.dirname(pyface.__file__),
"images",
"about.png",
)
self.assertEqual(
self.dialog.image.absolute_path,
expected_path,
)
12 changes: 1 addition & 11 deletions pyface/ui/qt4/about_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@

import platform

from traits.api import Any, Callable, List, provides, Str, Tuple
from traits.api import Any, Callable, List, provides, Tuple

from pyface.qt import QtCore, QtGui
from pyface.i_about_dialog import IAboutDialog, MAboutDialog
from pyface.ui_traits import Image
from .dialog import Dialog
from .image_resource import ImageResource


# The HTML displayed in the QLabel.
Expand Down Expand Up @@ -60,14 +58,6 @@ class AboutDialog(MAboutDialog, Dialog):
IAboutDialog interface for the API documentation.
"""

# 'IAboutDialog' interface ---------------------------------------------

additions = List(Str)

copyrights = List(Str)

image = Image(ImageResource("about"))

# Private interface ---------------------------------------------------#

#: A list of connected Qt signals to be removed before destruction.
Expand Down
12 changes: 1 addition & 11 deletions pyface/ui/wx/about_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@
import wx.html
import wx.lib.wxpTag

from traits.api import List, provides, Str
from traits.api import provides

from pyface.i_about_dialog import IAboutDialog, MAboutDialog
from pyface.ui_traits import Image
from .dialog import Dialog
from .image_resource import ImageResource


_DIALOG_TEXT = """
Expand Down Expand Up @@ -70,14 +68,6 @@ class AboutDialog(MAboutDialog, Dialog):
IAboutDialog interface for the API documentation.
"""

# 'IAboutDialog' interface ---------------------------------------------

additions = List(Str)

copyrights = List(Str)

image = Image(ImageResource("about"))

# ------------------------------------------------------------------------
# Protected 'IDialog' interface.
# ------------------------------------------------------------------------
Expand Down

0 comments on commit 9608848

Please sign in to comment.