Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Text/Font position

edited November 2017 in OpenSesame

Hi,

In my experiment, I draw single letters/symbols in the center of the screen and alternate between them and a fixation dot. I noticed that while the fixation dot is nicely centered, the symbols/letters are not (always). For instance, a capital O or a + sign are, but a small x and a - are not. They appear slightly below the center of the screen. Keyword center is always on default (True) and x and y coordinates are the same between all stimuli (0,0). Is this because text/fonts are drawn as a picture with a dedicated area large enough to fit capitalized as well as small letters?
Either way, is there a way to make sure they are always properly centered without messing around with the x,y coordinates?

Thanks,
Michel

Comments

  • Hi Michel,

    Is this because text/fonts are drawn as a picture with a dedicated area large enough to fit capitalized as well as small letters?

    Not exactly, I think, but it must have something to do with the bounding box that is determined by the font renderer (which works in mysterious ways).

    This would be a good moment to try the prerelease of 3.2, which uses an entirely different way to render text, and which should not suffer from this issue. If you try this, could you let me know how this works out?

    Cheers!
    Sebastiaan

  • edited November 2017

    Hey Sebastiaan,

    I just tested it with the latest release I could find (opensesame_3.2.0a10-py2.7-win32-1) but could not get it to work. I am getting a bunch of other errors that do not seem to have anything to do with the issue at hand.

    For example, this:
    exception type: AttributeError
    exception message: 'str' object has no attribute 'copy'

    With:
    var.dispSearch.copy(var.dispBlank)


    And this:

    File "C:\OSPrerelease\opensesame_3.2.0a10-py2.7-win32-1\lib\site-packages\libopensesame\inline_script.py", line 81, in prepare
        self.experiment.python_workspace._exec(self.cprepare)
      File "C:\OSPrerelease\opensesame_3.2.0a10-py2.7-win32-1\lib\site-packages\libopensesame\python_workspace.py", line 173, in _exec
        exec(bytecode, self._globals)
      Inline script, line 102, in <module>
      File "C:\OSPrerelease\opensesame_3.2.0a10-py2.7-win32-1\lib\site-packages\openexp\_canvas\canvas.py", line 1080, in text
        **style_args)
      File "C:\OSPrerelease\opensesame_3.2.0a10-py2.7-win32-1\lib\site-packages\openexp\_canvas\canvas.py", line 409, in __iadd__
        self['stim%d' % self._stimnr] = element
      File "C:\OSPrerelease\opensesame_3.2.0a10-py2.7-win32-1\lib\site-packages\openexp\_canvas\canvas.py", line 347, in __setitem__
        value = value.construct(self)
      File "C:\OSPrerelease\opensesame_3.2.0a10-py2.7-win32-1\lib\site-packages\openexp\canvas_elements.py", line 37, in construct
        return cls(canvas, *self._args, **self._kwargs)
      File "C:\OSPrerelease\opensesame_3.2.0a10-py2.7-win32-1\lib\site-packages\openexp\_canvas\_richtext\richtext.py", line 59, in __init__
        Element.__init__(self, canvas, **properties)
      File "C:\OSPrerelease\opensesame_3.2.0a10-py2.7-win32-1\lib\site-packages\openexp\_canvas\_element\element.py", line 62, in __init__
        self.prepare()
      File "C:\OSPrerelease\opensesame_3.2.0a10-py2.7-win32-1\lib\site-packages\openexp\_canvas\_richtext\psycho.py", line 30, in prepare
        im = self._to_pil()
      File "C:\OSPrerelease\opensesame_3.2.0a10-py2.7-win32-1\lib\site-packages\openexp\_canvas\_richtext\richtext.py", line 157, in _to_pil
        im = Image.fromqimage(self._to_qimage())
      File "C:\OSPrerelease\opensesame_3.2.0a10-py2.7-win32-1\lib\site-packages\openexp\_canvas\_richtext\richtext.py", line 144, in _to_qimage
        t = self._to_qgraphicstextitem()
      File "C:\OSPrerelease\opensesame_3.2.0a10-py2.7-win32-1\lib\site-packages\openexp\_canvas\_richtext\richtext.py", line 118, in _to_qgraphicstextitem
        t.setDefaultTextColor(QColor(self.color.colorspec))
    TypeError: arguments did not match any overloaded call:
      QColor(Qt.GlobalColor): argument 1 has unexpected type 'tuple'
      QColor(int): too many arguments
      QColor(QRgba64): argument 1 has unexpected type 'tuple'
      QColor(Any): argument 1 has unexpected type 'tuple'
      QColor(): argument 1 has unexpected type 'tuple'
    

    After this line:
    path_template = var.get_file('stimuli_out/'+var.cond_category+'//'+str(var.exemplarTemplate)+'.bmp')

    So, at least with this build, I cannot test it out yet :(

    Michel

  • edited November 2017

    As a side note: I am having issues with presenting images loaded in like above but only with the expyriment and legacy backend, not with psychopy. However, OS does not throw an error, it just does not present the images, while it does so when using the psychopy backend. I am gonna test whether that has anything to do with the specific images or format. If not, I'll create another thread for this issue.

    Edit: Not sure whether that is a general issue or somehow related to the pictures I use but everything works fine when converting my .bmp pictures into .jpgs.

  • I can confirm that expyriment and legacy refuse to display .bmps when using the canvas functions, whereas psychopy works. (And .jpgs work as well with all backends)

    Buy Me A Coffee

  • Thanks for testing, guys! Once I'm back in Groningen, I'll fix these issue and build a new prerelease. (Assuming that they're easy to fix, but I assume so.)

  • Just for clarification: the issue with the images was not specific to the latest prerelease version but already an issue on the latest stable version. I assume that it is really specific to the pictures. Eduard and I observed that other .bmps seem to work.
    The errors posted in my second post however are specific to the prereleases.

  • Hi Michel,

    Regarding the first error, resulting from:

    var.dispSearch.copy(var.dispBlank)
    

    Without more context, this strikes me as a problem with your script: var.dispSearch is a str object, whereas you seem to be assuming that it's a canvas. Or is there something more?

    Regarding the second error:

    TypeError: arguments did not match any overloaded call:
    

    This seems to come from a call to canvas.text(). Is that possible? What exactly triggers the error?

    Cheers!
    Sebastiaan

  • edited November 2017

    Hey Sebastiaan,

    Regarding the first error:
    I don't think it is a string variable. When checking their types they both show up as classes. Also, as mentioned, the same code works fine with the latest stable version.
    I just noticed though that it might indeed become clearer if I send you the full error message. The second-last line suggests, as far as I understand it, that something fails in copying the to-be-copied canvas on the designated canvas.

    File "C:\OSPrerelease\opensesame_3.2.0a10-py2.7-win32-1\lib\site-packages\libopensesame\inline_script.py", line 81, in prepare
        self.experiment.python_workspace._exec(self.cprepare)
      File "C:\OSPrerelease\opensesame_3.2.0a10-py2.7-win32-1\lib\site-packages\libopensesame\python_workspace.py", line 173, in _exec
        exec(bytecode, self._globals)
      Inline script, line 16, in <module>
      File "C:\OSPrerelease\opensesame_3.2.0a10-py2.7-win32-1\lib\site-packages\openexp\_canvas\canvas.py", line 672, in copy
        self._elements = [e.copy(self) for e in canvas._elements]
    AttributeError: 'str' object has no attribute 'copy'
    

    Regarding the second error:
    I just checked and you're right. After removing all canvas.text calls from the script (and the copy call from error #1), it works fine. Do I take from this that you will also change the name/keywords of the text-drawing function or is this still a bug?
    By the way, I just noticed that the error message now indicates exactly the line where the error occurs rather than the previous line as it did in the past (that's also the reason why I copied the wrong line in my previous post), is that new or did I miss something?

    Cheers,
    Michel

    PS: If you want to take a look at the script, see my email to you from last week. It should still be on my google drive.

  • Hi Michel,

    As of 3.2.0a11, these issues should be resolved. Thanks for testing this.

    By the way, I just noticed that the error message now indicates exactly the line where the error occurs rather than the previous line as it did in the past (that's also the reason why I copied the wrong line in my previous post), is that new or did I miss something?

    That's new. The old behavior was of course unintended, and resulted from counting an invisible line that specifies the character encoding.

    Cheers!
    Sebastiaan

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games