Howdy, Stranger!

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

Supported by

[solved] Change backgrounds colors and fonts in widgets

edited July 2013 in OpenSesame

First of all thanks a lot guys for this amazing tool. I was a matlab user and at the moment I am trying to switch to Python. Looking for some package similar to Psychtoolbox I found OpenSesame and I am really amazed how simple and flexible is it. Thanks Again to the developers!

Now my question. As a newbie probably i am asking easy to solve question but so far I cant find a solution:
I need to set up some variables at the beginning of my experiment (screen size, distance to screen and so on) I am using the widgets tool for this in a inline script, like in the following example:

from libopensesame import widgets

form = widgets.form(self.experiment, cols=[1,1,1], rows=[1,1,1,1,1,1,1],
    margins=(200,200,50,100), spacing=50)

question_text = "Before starting this experiment please fill some variables:"
question_label = widgets.label(form, text=question_text)
input1 = widgets.text_input(form, return_accepts=True, var='Length_cm')
input2 = widgets.text_input(form, return_accepts=True, var='Length_px')
input3 = widgets.text_input(form, return_accepts=True, var='Width_px')
input4 = widgets.text_input(form, return_accepts=True, var='Distance_cm')
input5 = widgets.text_input(form, return_accepts=True, var='Size_dg')

question1 = widgets.label(form, text='Length Screen (in cm)', center=False)
question2 = widgets.label(form, text='Length Screen (in Pixels)', center=False)
question3 = widgets.label(form, text='Width Screen (in Pixels)', center=False)
question4 = widgets.label(form, text='Distance to Screen (in cm)', center=False)
question5 = widgets.label(form, text='Size of Stimulus (in deg)', center=False)

form.set_widget(question_label, (0,0), colspan=3)
form.set_widget(input1, (0,1))
form.set_widget(input2, (0,2))
form.set_widget(input3, (0,3))
form.set_widget(input4, (0,4))
form.set_widget(input5, (0,5))
form.set_widget(question1, (1,1))
form.set_widget(question2, (1,2))
form.set_widget(question3, (1,3))
form.set_widget(question4, (1,4))
form.set_widget(question5, (1,5))

Is there any way to change the fonts, size and colors of the sentences and the boxes colors in the code?
If it is possible: How could I do it?
Thanks a lot in advance!

And thanks again for this amazing tool!

Cheers,

Felipe

Comments

  • edited 4:23AM

    First of all thanks a lot guys for this amazing tool. I was a matlab user and at the moment I am trying to switch to Python. Looking for some package similar to Psychtoolbox I found OpenSesame and I am really amazed how simple and flexible is it. Thanks Again to the developers!

    Thank you!

    Is there any way to change the fonts, size and colors of the sentences and the boxes colors in the code? If it is possible: How could I do it? Thanks a lot in advance!

    The easiest way is to simply change the font and color settings of your experiment, in the General tab. These settings will be used by the form as well. If you want to customize your text in more detail, you can use (a subset of) HTML tags:

    By default, the frames/ boxes will remain gray, regardless of the experiment colors. That's a property of the default theme, which is called gray. The plain theme will follow your colors more closely:

    Good luck!

    Sebastiaan

  • edited July 2013

    Hi Sebastian, Thanks a lot for your quick answer.

    Nevertheless I still have 2 questions:

    1- Like in me previous example:

    form = widgets.form(self.experiment, cols=[1,1,1], rows=[1,1,1,1,1,1,1],
        margins=(200,200,50,100), spacing=50)
    
    question_text = "Before starting this experiment please fill some variables:"
    question_label = widgets.label(form, text=question_text)
    

    How should I use the HTML? (I am totally naive with it)
    Should I add the html tags inside the sentence ? (I never worked with HTML before), like:

     question_text = "<span color="red">Before starting this experiment please fill some variables:</span>"  .... because this way seems that doesnt work, at least on my script
    

    2- I am having problems to use my variables, like in the previous example i put:

    input1 = widgets.text_input(form, return_accepts=True, var='Length_cm')
    question1 = widgets.label(form, text='Length Screen (in cm)', center=False)
    form.set_widget(input1, (0,1))
    form.set_widget(question1, (1,1))
    input1.on_mouse_click((0,0))
    Length_cm = [self.get('Length_cm')]
    

    The if I fill the widget with 123 for example, when I try to use Length_cm as variable it tells me that is stored as list.
    So if for example I want to divide it by 3 : Length_cm / 3
    it doesn't allow me.

    Is it that self.get stored the variable as [1,2,3] ?
    How is the 'var' stored in the text_input widget ?
    How Can I get the value I introduced as answer as a number?

    Thanks again for the excellent work and support.

    Felipe

  • edited July 2013

    How should I use the HTML? (I am totally naive with it) Should I add the html tags inside the sentence ? (I never worked with HTML before), like:

    question_text = "<span color="red">Before starting this experiment please fill some variables:</span>"
    

    Right, the reason that this doesn't work is that it's not valid Python syntax. The quotes are used to indicate that this is a string. If you want to use quotes as part of the string as well, you therefore need to either escape them, or use single quotes. To give some examples, the following is all valid Python:

    # Escape the quotes in the string
    question_text = "<span color=\"red\">Before starting this experiment please fill some variables:</span>"
    # Or use single quotes in the string
    question_text = "<span color='red'>Before starting this experiment please fill some variables:</span>"
    # Or use double quotes to indicate the string
    question_text ='<span color="red">Before starting this experiment please fill some variables:</span>'
    

    I am having problems to use my variables, like in the previous example i put:

    Length_cm = [self.get('Length_cm')]
    

    The if I fill the widget with 123 for example, when I try to use Length_cm as variable it tells me that is stored as list.

    The command self.get('Length_cm') will retrieve the variable as a string, integer, or float, depending on what you entered (see smart variable typing). By wrapping square brackets around this value, you tell Python that you want to create a list with that value as the only item. In OpenSesame script and in the user interface, the square-brackets indicates that something should be interpreted as a variable. But this is not Python syntax: In Python, you use self.get() instead of the square brackets.

    In general, I would recommend walking through one of the basic Python tutorials. That will help you get a grip on the syntax. You don't need to know any Python wizardry, so don't worry, but you'll need to know the basics in order to use Python inline scripting in OpenSesame

    Code academy also has some very good interactive tutorials:

    Good luck!
    Sebastiaan

  • edited 4:23AM

    Hi Sebastian,

    Got everything much more clear now.
    Thanks a lot for your time and patience.
    Experiment is working well now.

    Best

    Felipe

  • Hi Sebastian,

    can you repost the link below to an existing side?

    http://osdoc.cogsci.nl/forms/custom-forms/#themes

    I wanna change the color of "widget.button" if clicked :)

    Best Regards,
    Lars

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