python - 表单检查不起作用

时间:2015-08-13 17:35:40

标签: python tkinter

我有问题。我想在python中创建一个表单。如果出现问题,我需要一个警报窗口(showwarning())。否则它应该在命令行中写入“TRUE”。 问题是我每次都会收到警报窗口。如果表单填写正确或错误,则无关紧。 有人可以帮我解决这个问题吗?

代码:

""" Variables """

    inputError_1 = bool(0)
    inputError_2 = bool(0)
    inputError_3 = bool(0)
    valueCheck = bool(0)

""" Check-Button """
def Check():
    if len(nameOne.get()) == 0:
        inputError_1 == TRUE
    elif len(nameTwo.get()) == 0:
        inputError_2 == TRUE
    elif len(comment.get(INSERT)) == 0:
        inputError_3 == TRUE
    else:
        valueCheck = bool(1)

    if inputError_1 == FALSE or inputError_2 == FALSE or inputError_3 == FALSE:
        showwarning()
    else:
        print'TRUE'

1 个答案:

答案 0 :(得分:1)

我认为你可以用更简单的方式做到这一点:

     product_tags.click(function() {

        $.sidr('toggle', 'shop_bar');               

        $.post("display_products_2.php", {'product_title_selected': product_title_selected}, function(display_shop) {

        var shop_array = $.parseJSON(display_shop);


        for ( c = 0; c <shop_array.length; c++)

                  {
                    var one_color =  "<div style='background-color:" + shop_array[c][3] + "'" + "class='one_color'></div>" 

                    var product_colors = product_colors + one_color;

                   }; 


        var one_color = "";

        var SHOPcontent =

                "<div id='shop_bar'>" +

                "<div style='background-color:" + shop_array[0][3] + "'" + "id='shop_translucent_banner'></div>" +

                "<div id='shop_title'>" +

                "<span id='shop_brand'>" +

                 shop_array[0][2] +

                "</span>" +

                shop_array[0][4] +

                "</div>" +

                "<div id='shop_price'>" +

                shop_array[0][6] +

                "</div>" +

                "<div id='shop_picture'>" + 

                "<img src='" + "product_pictures/" + shop_array[0][9] + "'>" +

                "</div>" +

                "<div id='shop_description'>" +

                shop_array[0][5] +

                "</div>" +

                "<div id='more_product_information'>MORE INFORMATION</div>" +

                "<div id='shop_colors'>" +

                product_colors +

                "</div>" +

                "<div id='buy'>Buy</div>"  +

                "</div>"  ;

         });


   $('#shop_bar').sidr( {

                displace: false,
                name: 'shop_bar',
                source: function() {

                $('.sidr').html(SHOPcontent)

                } 

          });