Howdy, Stranger!

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

Supported by

Input Validation

Hello,

I am trying to present a questionnare to participants. It includes different questions and rating scales. I want participants to fill each rating scale, and not to go next page until that.

I used form validation function but somehow it does not work. Could you help me please. I am sharing my script below. For clarity I used validation function only for question1 here.

def my_form_validator(): 

return var.question1 != u'no'


question1 = Label(text=u'Tiksinme', center=False)

question2 = Label(text=u'Korku', center=False)

question3 = Label(text=u'Öfke', center=False)

question4 = Label(text=u'Mutluluk', center=False)

question5 = Label(text=u'Şaşkınlık', center=False)

question6 = Label(text=u'Üzüntü', center=False)

question7 = Label(text=u'Nötr', center=False)

question8 = Label(text=u'arousal', center=False)

question9 = Label(text=u'valence', center=False)


ratingScale1 = RatingScale(nodes=[u'1', u'2',u'3',u'4',u'5',u'6',u'7'],var=u'question1')

ratingScale2 = RatingScale(nodes=[u'',u'',u'',u'',u'',u'',u''], var=u'question2')

ratingScale3 = RatingScale(nodes=[u'',u'',u'',u'',u'',u'',u''], var=u'question3')

ratingScale4 = RatingScale(nodes=[u'',u'',u'',u'',u'',u'',u''], var=u'question4')

ratingScale5 = RatingScale(nodes=[u'',u'',u'',u'',u'',u'',u''], var=u'question5')

ratingScale6 = RatingScale(nodes=[u'',u'',u'',u'',u'',u'',u''], var=u'question6')

ratingScale7 = RatingScale(nodes=[u'',u'',u'',u'',u'',u'',u''], var=u'question7')

ratingScale8 = RatingScale(nodes=[u'1', u'2',u'3',u'4',u'5',u'6',u'7'],var=u'question8')

ratingScale9 = RatingScale(nodes=[u'1', u'2',u'3',u'4',u'5',u'6',u'7'], var=u'question9')

image = ImageWidget(path=pool[u'3.jpg'], adjust=True, frame=False)

image1 = ImageWidget(path=pool[u'sam.jpg'], adjust=False, frame=False)

image2 = ImageWidget(path=pool[u'sam.jpg'], adjust=False, frame=False)

nextButton = Button(text=u'Next')

my_form = Form(validator=my_form_validator, rows=[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1], cols=[1,1,1], margins=(5,20,10,20), spacing=15)

my_form.set_widget(image, (0, 0), colspan=2, rowspan=3)

my_form.set_widget(question1, (0, 3))

my_form.set_widget(question2, (0, 4))

my_form.set_widget(question3, (0, 5))

my_form.set_widget(question4, (0, 6))

my_form.set_widget(question5, (0, 7))

my_form.set_widget(question6, (0, 8))

my_form.set_widget(question7, (0, 9))

my_form.set_widget(question8, (0, 13))

my_form.set_widget(question9, (0, 16))

my_form.set_widget(ratingScale1, (1, 3), colspan=2)

my_form.set_widget(ratingScale2, (1, 4), colspan=2)

my_form.set_widget(ratingScale3, (1, 5), colspan=2)

my_form.set_widget(ratingScale4, (1, 6), colspan=2)

my_form.set_widget(ratingScale5, (1, 7), colspan=2)

my_form.set_widget(ratingScale6, (1, 8), colspan=2)

my_form.set_widget(ratingScale7, (1, 9), colspan=2)


my_form.set_widget(image1, (1, 11), colspan=3)

my_form.set_widget(ratingScale8, (1, 13), colspan=3)

my_form.set_widget(image2, (1, 14), colspan=2)

my_form.set_widget(ratingScale9, (1, 16), colspan=3)

my_form.set_widget(nextButton, (2, 17), rowspan=2)

my_form._exec()

Comments

  • Hi sinem,

    I am no expert, but I can tell you what I learned about the form validator.

    First, you need to have as many conditions as variables: that is, in this line "return var.question1 != u'no'" you actually need to add all variables in this form.

    This would look like this:

    return var.question1 != u'no' and var.question2 != u'no' etc. (add as many variables as you want to check for)

    Second, the condition to check if a ratingscale is "empty" or not, is this:

    return var.question1 != u'None' (notice the 'None' instead of 'no')

    because the default value of a ratingscale is "none".

    Hope this helps!

    Cheers,

    Paula

  • Hi Paula,

    Thank you very much for your help. I revised the script and it works now. I want to share in case someone may benefit from it.

    def kontrol(): 

    return var.ratingscale1 != None and var.ratingscale2 != None and var.ratingscale3 != None and var.ratingscale4 != None and var.ratingscale5 != None and var.ratingscale6 != None and var.ratingscale7 != None and var.ratingscale8 != None and var.ratingscale9 != None

    question1 = Label(text='Tiksinme', center=False)

    question2 = Label(text='Korku', center=False)

    question3 = Label(text='Öfke', center=False)

    question4 = Label(text='Mutluluk', center=False)

    question5 = Label(text='Şaşkınlık', center=False)

    question6 = Label(text='Üzüntü', center=False)

    question7 = Label(text='Nötr', center=False)

    question8 = Label(text='Arousal', center=False)

    question9 = Label(text='Valence', center=False)


    ratingScale1 = RatingScale(nodes=['1','2','3','4','5','6','7'],var="ratingscale1")

    ratingScale2 = RatingScale(nodes=['','','','','','',''], var="ratingscale2")

    ratingScale3 = RatingScale(nodes=['','','','','','',''], var="ratingscale3")

    ratingScale4 = RatingScale(nodes=['','','','','','',''], var="ratingscale4")

    ratingScale5 = RatingScale(nodes=['','','','','','',''], var="ratingscale5")

    ratingScale6 = RatingScale(nodes=['','','','','','',''], var="ratingscale6")

    ratingScale7 = RatingScale(nodes=['','','','','','',''], var="ratingscale7")

    ratingScale8 = RatingScale(nodes=['1','2','3','4','5','6','7'],var="ratingscale8")

    ratingScale9 = RatingScale(nodes=['1','2','3','4','5','6','7'], var="ratingscale9")

    image = ImageWidget(path=pool['3.jpg'], adjust=True, frame=False)

    image1 = ImageWidget(path=pool['sam.jpg'], adjust=False, frame=False)

    image2 = ImageWidget(path=pool['sam.jpg'], adjust=False, frame=False)

    nextButton = Button(text=u'Next')


    my_form = Form(validator=kontrol, rows=19, cols=3, margins=(5,20,10,20), spacing=15)


    my_form.set_widget(image, (0, 0), colspan=2, rowspan=3)

    my_form.set_widget(question1, (0, 3))

    my_form.set_widget(question2, (0, 4))

    my_form.set_widget(question3, (0, 5))

    my_form.set_widget(question4, (0, 6))

    my_form.set_widget(question5, (0, 7))

    my_form.set_widget(question6, (0, 8))

    my_form.set_widget(question7, (0, 9))

    my_form.set_widget(question8, (0, 13))

    my_form.set_widget(question9, (0, 16))

    my_form.set_widget(ratingScale1, (1, 3), colspan=2)

    my_form.set_widget(ratingScale2, (1, 4), colspan=2)

    my_form.set_widget(ratingScale3, (1, 5), colspan=2)

    my_form.set_widget(ratingScale4, (1, 6), colspan=2)

    my_form.set_widget(ratingScale5, (1, 7), colspan=2)

    my_form.set_widget(ratingScale6, (1, 8), colspan=2)

    my_form.set_widget(ratingScale7, (1, 9), colspan=2)


    my_form.set_widget(image1, (1, 11), colspan=3)

    my_form.set_widget(ratingScale8, (1, 13), colspan=3)

    my_form.set_widget(image2, (1, 14), colspan=2)

    my_form.set_widget(ratingScale9, (1, 16), colspan=3)

    my_form.set_widget(nextButton, (2, 17), rowspan=2)

    my_form._exec()

  • So glad it works! Thanks for sharing!

  • I want to share the working script, i deleted the first one while trying to edit :)

    def kontrol(): 

    return var.ratingscale1 != None and var.ratingscale2 != None and var.ratingscale3 != None and var.ratingscale4 != None and var.ratingscale5 != None and var.ratingscale6 != None and var.ratingscale7 != None and var.ratingscale8 != None and var.ratingscale9 != None

    question1 = Label(text='Tiksinme', center=False)

    question2 = Label(text='Korku', center=False)

    question3 = Label(text='Öfke', center=False)

    question4 = Label(text='Mutluluk', center=False)

    question5 = Label(text='Şaşkınlık', center=False)

    question6 = Label(text='Üzüntü', center=False)

    question7 = Label(text='Nötr', center=False)

    question8 = Label(text='Arousal', center=False)

    question9 = Label(text='Valence', center=False)


    ratingScale1 = RatingScale(nodes=['1','2','3','4','5','6','7'],var="ratingscale1")

    ratingScale2 = RatingScale(nodes=['','','','','','',''], var="ratingscale2")

    ratingScale3 = RatingScale(nodes=['','','','','','',''], var="ratingscale3")

    ratingScale4 = RatingScale(nodes=['','','','','','',''], var="ratingscale4")

    ratingScale5 = RatingScale(nodes=['','','','','','',''], var="ratingscale5")

    ratingScale6 = RatingScale(nodes=['','','','','','',''], var="ratingscale6")

    ratingScale7 = RatingScale(nodes=['','','','','','',''], var="ratingscale7")

    ratingScale8 = RatingScale(nodes=['1','2','3','4','5','6','7'],var="ratingscale8")

    ratingScale9 = RatingScale(nodes=['1','2','3','4','5','6','7'], var="ratingscale9")

    image = ImageWidget(path=pool['3.jpg'], adjust=True, frame=False)

    image1 = ImageWidget(path=pool['sam.jpg'], adjust=False, frame=False)

    image2 = ImageWidget(path=pool['sam.jpg'], adjust=False, frame=False)

    nextButton = Button(text=u'Next')


    my_form = Form(validator=kontrol, rows=19, cols=3, margins=(5,20,10,20), spacing=15)


    my_form.set_widget(image, (0, 0), colspan=2, rowspan=3)

    my_form.set_widget(question1, (0, 3))

    my_form.set_widget(question2, (0, 4))

    my_form.set_widget(question3, (0, 5))

    my_form.set_widget(question4, (0, 6))

    my_form.set_widget(question5, (0, 7))

    my_form.set_widget(question6, (0, 8))

    my_form.set_widget(question7, (0, 9))

    my_form.set_widget(question8, (0, 13))

    my_form.set_widget(question9, (0, 16))

    my_form.set_widget(ratingScale1, (1, 3), colspan=2)

    my_form.set_widget(ratingScale2, (1, 4), colspan=2)

    my_form.set_widget(ratingScale3, (1, 5), colspan=2)

    my_form.set_widget(ratingScale4, (1, 6), colspan=2)

    my_form.set_widget(ratingScale5, (1, 7), colspan=2)

    my_form.set_widget(ratingScale6, (1, 8), colspan=2)

    my_form.set_widget(ratingScale7, (1, 9), colspan=2)


    my_form.set_widget(image1, (1, 11), colspan=3)

    my_form.set_widget(ratingScale8, (1, 13), colspan=3)

    my_form.set_widget(image2, (1, 14), colspan=2)

    my_form.set_widget(ratingScale9, (1, 16), colspan=3)

    my_form.set_widget(nextButton, (2, 17), rowspan=2)


    my_form._exec()

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