Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 移动tkinter listbox游标并移动项目?_Python 2.7_Select_Tkinter_Listbox - Fatal编程技术网

Python 2.7 移动tkinter listbox游标并移动项目?

Python 2.7 移动tkinter listbox游标并移动项目?,python-2.7,select,tkinter,listbox,Python 2.7,Select,Tkinter,Listbox,使用Tkinter运行python 2.7.8。我有一个移动列表框项的函数。这个功能有效。但是,我还想移动列表框选择(即,移动对象的指示器) 我的换档功能基于。 以下是之前的列表: 调用函数后: 我如何将选择“从”到我的班次??Thx def shift_sel_up(seltext): posList = data_list.curselection() if not posList: # exit if nothing selected return

使用Tkinter运行python 2.7.8。我有一个移动列表框项的函数。这个功能有效。但是,我还想移动列表框选择(即,移动对象的指示器)

我的换档功能基于。 以下是之前的列表: 调用函数后:

我如何将选择“从”到我的班次??Thx

def shift_sel_up(seltext):
    posList = data_list.curselection()
    if not posList: # exit if nothing selected
       return

    for pos in posList:
        if pos == 0:
            my_status_update('Item at top of list.')
            continue
        text = data_list.get(pos)
        data_list.delete(pos)
        data_list.insert(pos -1, text)
# new, doesn't work - [from here][4].
#        data_list.selection_clear()
        data_list.selection_set(pos)
    return
使用
activate(index)
就可以了。这会将给定索引处的项设置为活动项(给它加下划线)

您还需要为选择集添加
-1

data_list.selection_set(pos -1)

好极了!非常感谢!!
data_list.selection_set(pos -1)