# Failure to create a new monitor in the Monitor Center on a French computer

#1

OS (e.g. Win10):
PsychoPy version (e.g. 1.85.0):
Standard Standalone? (yes)
**What are you trying to achieve?: Create a new monitor from monitor center

**What did you try to make it work?: I opened the monitor center, created a new monitor called Mat, changed Screen Distance to 60 and saved it. Note that I have a French computer (looks like it is the problem).

What specifically went wrong when you tried that?:
I got the following error message:

Traceback (most recent call last):
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\monitors\MonitorCenter.py”, line 566, in onChangeMonSelection
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\monitors\MonitorCenter.py”, line 490, in loadMonitor
self.updateCalibList()
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\monitors\MonitorCenter.py”, line 524, in updateCalibList
self.onChangeCalibSelection(event=-1)
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\monitors\MonitorCenter.py”, line 587, in onChangeCalibSelection
self.ctrlScrPixHoriz.SetValue(locale.str(_sizePix[0]))
File “C:\Program Files (x86)\PsychoPy2\lib\locale.py”, line 303, in str
return format("%.12g", val)
File “C:\Program Files (x86)\PsychoPy2\lib\locale.py”, line 196, in format
return _format(percent, value, grouping, monetary, *additional)
File “C:\Program Files (x86)\PsychoPy2\lib\locale.py”, line 202, in _format
formatted = percent % value
TypeError: float argument required, not NoneType

**UPDATE

I then restarted Psychopy and tried to open the Monitor Center again. It failed to open, I got this error message:

v1.85.0
Traceback (most recent call last):
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\app_psychopyApp.py”, line 518, in openMonitorCenter
None, ‘PsychoPy2 Monitor Center’)
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\monitors\MonitorCenter.py”, line 210, in init
self.updateMonList()
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\monitors\MonitorCenter.py”, line 503, in updateMonList
self.onChangeMonSelection(event=-1)
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\monitors\MonitorCenter.py”, line 566, in onChangeMonSelection
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\monitors\MonitorCenter.py”, line 490, in loadMonitor
self.updateCalibList()
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\monitors\MonitorCenter.py”, line 524, in updateCalibList
self.onChangeCalibSelection(event=-1)
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\monitors\MonitorCenter.py”, line 587, in onChangeCalibSelection
self.ctrlScrPixHoriz.SetValue(locale.str(_sizePix[0]))
File “C:\Program Files (x86)\PsychoPy2\lib\locale.py”, line 303, in str
return format("%.12g", val)
File “C:\Program Files (x86)\PsychoPy2\lib\locale.py”, line 196, in format
return _format(percent, value, grouping, monetary, *additional)
File “C:\Program Files (x86)\PsychoPy2\lib\locale.py”, line 202, in _format
formatted = percent % value
TypeError: float argument required, not NoneType

#2

I found a workaround by creating a monitor in command line:

my_monitor = monitors.Monitor(name='mat_scaled')
my_monitor.setSizePix((1536,864))
my_monitor.setWidth(30)
my_monitor.setDistance(60)
my_monitor.saveMon()


I can now open the monitor center and see my newly created monitor with proper settings. However, Psychopy outputs the following error:

Traceback (most recent call last):
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\monitors\MonitorCenter.py”, line 745, in onChangeScrPixHoriz
self.currentMon.currentCalib[‘sizePix’][0] = newVal
TypeError: ‘tuple’ object does not support item assignment
Traceback (most recent call last):
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\monitors\MonitorCenter.py”, line 752, in onChangeScrPixVert
self.currentMon.currentCalib[‘sizePix’][1] = newVal
TypeError: ‘tuple’ object does not support item assignment

@jon Looks like there’s a bug in MonitorCenter.py. Happy to hear your thoughts!

#3

What happens if you provide a mutable list rather than an immutable tuple:

my_monitor.setSizePix([1536, 864])

#4

I provided a mutable list and that solved the issue. Nevertheless, I still don’t understand why I can’t create a monitor from the Monitor Center. One thing I have noticed is that setting

my_monitor.setWidth(34.7)

generates 34,7 in the monitor center. I suspect the bug is due to a ‘.’ versus ‘,’ decimal problem. When I change my locale into English US, I don’t have any issue with the Monitor Center.

Any idea how to definitively solve this problem without using the above workarounds?
Thank you so much for your help. Very much appreciated.

#5

Ah! That second piece of info, that this is only am issue in some locales, is interesting. I guess this is caused by the loading of the JSON file (which is text) by the Monitor class. We used to use binary pickle files. These jsons are nicer for being more human readable but, like csv files, I guess they can be misinterpreted in the wrong locale

#6

@jon what’s the lastest Psychopy release that used binary pickle files? My students are struggling with Psychopy at the moment because of this bug (I suspect it’s on every french computer given the locale thing)…

#7

Sorry it took me a while to get to this one. The first problem looks like an issue with trying to format something into French numbering when it doesn’t yet have a number (None can’t be a French float).

The second issue turns wasn’t a locale problem but a genuine bug that we’ve apparently had for a while but I haven’t typed a number into that box for some time! It turns out that we now have these sizes in “tuples” instead of “lists” and they behave very slightly different (they aren’t mutable). So rather than
this[‘sizePix’][1] = newVal
we’ll need to do
this['sizePix'] = (this['sizePix'][0], newVal)

A bit annoying but I believe I’ll be able to get a bug-fix release out with these soon.

#9

@jon Great catch ! Let me know if you want me to test the bug fix on my (french) computer.

#10

Hi to both of you,

I have been experiencing similar problems with the Monitor Center and I am using a French computer too.
My concern is that I cannot seem to be able to save a screen no matter how, even if I create a monitor in command line.
Since I am kinda new to PsychoPy, I am not yet able to understand every detail of your discussion regarding “tuples” and “lists”.
I did change the local on my computer in order to solve the “,” versus “.” issue but I don’t know if there is anything I can do right now besides waiting for the new bug-fix release?
I need to calibrate my computer screen but I am a bit stuck if I cannot save any monitor to beggin with.

When I type the following code:

my_monitor = monitors.Monitor(name=‘DellM783p’)
my_monitor.setSizePix((1200,1600))
my_monitor.setWidth(32.5)
my_monitor.setDistance(57)
my_monitor.saveMon()

I get this error message:

wx._core.wxAssertionError: C++ assertion “m_count > 0” failed at …\src\common\object.cpp(352) in wxRefCounter::DecRef(): invalid ref data count
The above exception was the direct cause of the following exception:
SystemError: <class ‘wx._core.IdleEvent’> returned a result with an error set

I really don’t know what to do…

#11

I wonder if (either of) you could test the new 3.0.0b12 release? It will install alongside your older (PsychoPy2) versions. https://github.com/psychopy/psychopy/releases/tag/3.0.0b12

I’m fairly certain I’ve fixed the 2nd problem you were having, and the first one I can’t reproduce (maybe already fixed in previous version?)

thanks,
Jon

#12

@jon Ok so I’ve just tested the new release. Unfortunately, the first problem is not solved.
I first opened the monitor center and created a new monitor called Test_Jon and got the following error message:

And then ran this simple script :

from future import division
from psychopy import core, data, event, visual, gui
import numpy as np
import os
from psychopy import logging

win = visual.Window([800,600], fullscr=False,
monitor=‘Test_Jon’, color=[128,128,128], colorSpace=‘rgb255’, units=‘deg’)

Test = visual.TextStim(win=win, ori=0,
text=u’Test monitor center’,
pos=[0, 0],
color=[0,0,0], colorSpace=u’rgb255’, height = 1.)

Test.draw()
win.flip()
core.wait(1.)

#Shutting down:
win.close()
core.quit()

and got the following error message :

I then opened the monitor center again and discovered that my monitor info has not been saved (see screen capture).

I then tried to replicate the bug on another french computer running windows 10. I opened the monitor center, created a new monitor and saved it. Same error message, and this time I couldn’t open the monitor center anymore (I had to delete the .json and .calib files).

If you want I can give you access to a french computer via TeamViewer or VPN. I have tried to solve the issue myself but I can’t find the bug.

#13

Hi,

Sorry for the delay!

I’ve just tested the 3.0.0b12 release on my Dell computer and I have been able to properly add and save new monitors direcly from the monitor center. It seems to be working fine for me. I don’t get any error message regarding the monitor center. It also saves the “.” decimal format correctly, even when I no longer switch my locale to the english format. Thank you very much @jon.

I don’t know why it still isn’t working for you @Servant_Mathieu.
Just let me know if I can help but I don’t know what might differ between our computers.

I have also tested the v1.90.1 version on my personnal Mac computer instead of my professional Dell one (I did not have the chance to do it sooner) and it actually works fine.

The only thing with the 3.0.0b12 version that I have noticed so far by running my pretty basic scripts, is that there is a problem with some specific characters such as the right single quotation mark " ’ " or apostrophe, and letters with accent marks which are massively used in French.

Do you know how I could easily solve this problem?

Here is the exact error message:

Traceback (most recent call last):
consigne = visual.TextStim(w, height=30, font=“Arial”, color=“White”, text=“Vous allez participer à une tâche durant laquelle vous allez voir 4 carrés.\n\nDurant chaque essai, un des 4 quatre carré va brièvement changer de luminosité.\n\nNous vous demandons d’appuyer sur le clavier numérique (touches 1, 2, 4, 5) pour indiquer quel carré parmi les 4 a effectivement changé. \n\nAppuyez sur la barre d’espace pour commencer.”)
File “C:\Program Files (x86)\PsychoPy3_PY2\lib\site-packages\psychopy\visual\text.py”, line 209, in init
self.setText(text, log=False)
File “C:\Program Files (x86)\PsychoPy3_PY2\lib\site-packages\psychopy\visual\text.py”, line 354, in setText
setAttribute(self, ‘text’, text, log)
File “C:\Program Files (x86)\PsychoPy3_PY2\lib\site-packages\psychopy\tools\attributetools.py”, line 141, in setAttribute
setattr(self, attrib, value)
File “C:\Program Files (x86)\PsychoPy3_PY2\lib\site-packages\psychopy\tools\attributetools.py”, line 32, in set
newValue = self.func(obj, value)
File “C:\Program Files (x86)\PsychoPy3_PY2\lib\site-packages\psychopy\visual\text.py”, line 327, in text
text = str(text) # make sure we have unicode object to render
File “C:\Program Files (x86)\PsychoPy3_PY2\lib\site-packages\future\types\newstr.py”, line 102, in new
return super(newstr, cls).new(cls, value)
UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xc3 in position 22: ordinal not in range(128)

Thanks!

#14

@CoralieCreupelandt Could detail the steps you followed to save new monitors directly from the monitor center? Did you try to call the newly created monitor from a script (this is actually where the bug happens most of the time). Did you use the PY2 or PY3 version?
I have tested the new Psychopy (PY2) version on 3 computers (with a french locale and windows 10), and also asked my french colleagues to conduct this test on their computers. None of us could use the monitor center (there was either a bug when saving the monitor from the monitor center, or a bug when calling the newly created monitor in a script).
Regarding your character problem, try adding u right before a string object (exemple: u"problème")

#15

@jon Coralie tested the new release with an english locale. The monitor center cannot be used with a french locale (see bugs that I reported previously).

#16

OK, Mathieu, I managed to recreate this by switching to French on a windows box on Py2. (Mac in French was fine and I think Py3 on win10 was also fine - were you using PsychoPy3 on Python2 version?).

Looks like something broken in an upstream function to do the conversion (something in wx.locale) but I’ve inserted some extra checks to correct when the bug occurs. Anyway, I think that should fix it in next release.

You could test by replacing your calibTools.py file with this one:
https://raw.githubusercontent.com/peircej/psychopy/b623e1e95a285f8f36686dcbe0f313934964d2bf/psychopy/monitors/calibTools.py

The full commit, with some other tweaks is at:
https://github.com/peircej/psychopy/commit/b623e1e95a285f8f36686dcbe0f313934964d2bf

#17

Hi Jon, thanks for the help. I tried to replace calibTools in PsychoPy 1.85.6 and PsychoPy3 PY2 (you are right, I was using the PY2 version), but that didn’t solve the issue.

For example, when I started PsychoPy3 PY2, I got this error message:

I then created a monitor named Jon and saved it:

When I opened again the monitor center, the newly created monitor is there but specifications have disappeared:

#18

Don’t worry about those deprecation warnings for tooltipstring - they’re not a problem right now. The error has obviously disappeared, so that’s a good thing, but I’ll look again at what else could be wrong

#19

OK, I tracked that further bug down and I’m confident this is now fixed.

https://github.com/psychopy/psychopy/pull/2174/commits/0100d22f082abeef7d6003e0fb131c0c70e51c9f

#20

Champagne, the bug is fixed! Thank you so much Jon!