基于使用python显示更新值的输入循环递增

时间:2014-07-10 02:33:46

标签: python gpio

所以我遇到的麻烦是,当我点击按钮时信息互相重叠,所以我尝试将写入文本添加到if块中,但它仍然重叠,如何清除它或只是增加一个静态数字我还需要24小时计时器,每24小时更新一次siteDay和companyDay

while True:
    try:
        if(GPIO.input(17)== 1): #alstom increment
            companyDay +=1
            company +=difference1
            turtle.pencolor("orange")
            writeTexts (companyDay, -350,50)
            turtle.pencolor("black")
            writeTexts (company ,-150,-215)
        if(GPIO.input(18)== 1): #alstom decrement
            companyDay -=1
            company -=difference1
             turtle.pencolor("orange")
            writeTexts (companyDay, -350,50)
            turtle.pencolor("black")
            writeTexts (company ,-150,-215)
        if(GPIO.input(27)== 1): #alstom reset
           companyDate == 0
           company ==0
           turtle.pencolor("orange")
            writeTexts(companyDate ,-350,50)
            writeTexts(company ,-150,-215)     
    turtle.pencolor("black")
    writeTexts (site ,500,-215)
    writeTexts (company ,-150,-215)
    writeTexts (today ,500,-310)
    turtle.pencolor("orange")

1 个答案:

答案 0 :(得分:0)

而不是所有三个if语句仅在语句尝试elif

if(condition):
    ...
elif(condition):
   ...
elif(condition):
   ...
else:
   ...

告诉我它是否有效!