handler()缺少1个必需的位置参数:“事件”

时间:2019-05-18 12:07:42

标签: python

我正在尝试打印并输入用户输入的关键字给Arduino信号,但该功能无法正常工作

def handler(event):

    move = ""
    if event.char == "w":
        move = "Forward"
        current_time=time.strftime("%H:%m:%S")
    elif event.char == "s":
        move = "Backward"
        current_time=time.strftime("%H:%m:%S")
    elif event.char == "d":
        move = "Right"
        current_time=time.strftime("%H:%m:%S")
    elif event.char == "q":
        move = "left_forward"
        current_time=time.strftime("%H:%m:%S")
    elif event.char == "e":
        move = "right_forward"
        current_time=time.strftime("%H:%m:%S")
    elif event.char == "a":
        move = "Left"
        current_time=time.strftime("%H:%m:%S")
    elif event.char == "x":
        move = "Stop"
        current_time=time.strftime("%H:%m:%S")
    elif event.char == "j":
        move = "Speed set to high"
    elif event.char == "k":
        move = "Speed set to medium"
    elif event.char == "l":
        move = "Speed set to low"
    else:
        # print "Invalid Input"
        pass
        #return

    print current_time + " " + move
    global ser
    ser.write(str.encode(event.char))
handler(event)

我希望按用户和时间打印出给定的字符

1 个答案:

答案 0 :(得分:-1)

这是我要删除tkinter部分的完整代码

<th *ngFor="let col of columns" [ngSwitch]="col.filter">

<input *ngSwitchDefault pInputText type="text" input)="dt.filter($event.target.value, col.field, 'contains')" [value]="dt.filters[col.field]?.value" style="width:100%">

<p-multiSelect *ngSwitchCase="'select'" [options]="arrayValues" defaultLabel="Filter" (onChange)="dt.filter($event.value, col.field, 'in')" [style]="{'width':'100%'}"></p-multiSelect>
</th>