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

ControlImage not working for >=4.0 #82

Open
radikalliberal opened this issue Sep 28, 2018 · 2 comments
Open

ControlImage not working for >=4.0 #82

radikalliberal opened this issue Sep 28, 2018 · 2 comments

Comments

@radikalliberal
Copy link

Hi,
I made a project some time ago and used the 3.0 Version.
This snipped worked for me back then:

self._image = ControlImage('Image', visible=True)
self._image.value = image # image -> np.ndarray

When i use a later version the same snipped gives me a plain black image. I also tried giving a path to value, still just plain black.

@boulund
Copy link

boulund commented Oct 6, 2018

I also have an issue related to ControlImage:

In the pyforms 3.0-version of my code I had the following two lines.

    self._toplogo = ControlImage()
    self._toplogo.value = cv2.imread("img/logo.jpg")

This now fails with:

Traceback (most recent call last):
  File "C:\Users\fredr\Documents\Code\list_scanner\list_scanner\list_scanner.py", line 262, in <module>
    main()
  File "C:\Users\fredr\Documents\Code\list_scanner\list_scanner\list_scanner.py", line 258, in main
    pyforms.start_app(ListScanner)
  File "C:\Users\fredr\AppData\Local\conda\conda\envs\pyforms\lib\site-packages\pyforms_gui\appmanager.py", line 177, in start_app
    mainwindow = StandAloneContainer(ClassObject)
  File "C:\Users\fredr\AppData\Local\conda\conda\envs\pyforms\lib\site-packages\pyforms_gui\appmanager.py", line 17, in __init__
    w = ClassObject()
  File "C:\Users\fredr\Documents\Code\list_scanner\list_scanner\list_scanner.py", line 45, in __init__
    self._toplogo.value = cv2.imread("img/logo.jpg")
  File "C:\Users\fredr\AppData\Local\conda\conda\envs\pyforms\lib\site-packages\pyforms_gui\controls\control_base.py", line 214, in value
    if oldvalue != value:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Looks like there is an oldvalue vs value comparison that didn't anticipate the value potentially being an array (https://github.com/UmSenhorQualquer/pyforms-gui/blob/ddcb6ad5c215ae289e65eb6818332fe298ae39f7/pyforms_gui/controls/control_base.py#L214).

@radikalliberal
Copy link
Author

radikalliberal commented Oct 8, 2018

I also have an issue related to ControlImage:

In the pyforms 3.0-version of my code I had the following two lines.

    self._toplogo = ControlImage()
    self._toplogo.value = cv2.imread("img/logo.jpg")

This now fails with:

Traceback (most recent call last):
  File "C:\Users\fredr\Documents\Code\list_scanner\list_scanner\list_scanner.py", line 262, in <module>
    main()
  File "C:\Users\fredr\Documents\Code\list_scanner\list_scanner\list_scanner.py", line 258, in main
    pyforms.start_app(ListScanner)
  File "C:\Users\fredr\AppData\Local\conda\conda\envs\pyforms\lib\site-packages\pyforms_gui\appmanager.py", line 177, in start_app
    mainwindow = StandAloneContainer(ClassObject)
  File "C:\Users\fredr\AppData\Local\conda\conda\envs\pyforms\lib\site-packages\pyforms_gui\appmanager.py", line 17, in __init__
    w = ClassObject()
  File "C:\Users\fredr\Documents\Code\list_scanner\list_scanner\list_scanner.py", line 45, in __init__
    self._toplogo.value = cv2.imread("img/CTMR_logo_white_background.jpg")
  File "C:\Users\fredr\AppData\Local\conda\conda\envs\pyforms\lib\site-packages\pyforms_gui\controls\control_base.py", line 214, in value
    if oldvalue != value:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Looks like there is an oldvalue vs value comparison that didn't anticipate the value potentially being an array (https://github.com/UmSenhorQualquer/pyforms-gui/blob/ddcb6ad5c215ae289e65eb6818332fe298ae39f7/pyforms_gui/controls/control_base.py#L214).

The issue goes deeper, I did comment out the if statement and it didn't work afterward either. But this issue could be fixed by distinguishing between a value: str and value :np.ndarray and using

if type(oldvalue) is not type(value) or not np.array_equal(oldvalue, value): ...

instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants