• python tkinter Treeview 事件绑定


    def trefun(event):
        sels= event.widget.selection()#event.widget获取Treeview对象,调用selection获取选择对象名称
        for idx in sels:
            print tv.item(idx)["text"]
        print "111"
    
    
    
    if __name__ == '__main__':
        global tv   
        _dex = dex("classes.dex")
        _strs = _dex.getStrings()
    
        tp = Tk()
        tv = ttk.Treeview(tp)
        tv.grid(row = 0, column = 0)
        scb= ttk.Scrollbar(tp, command = tv.yview)
        tv.config(yscroll = scb.set)
        scb.grid(row = 0, column = 1, sticky = "ns")
        txt= Text(tp)
        txt.grid(row = 0, column = 2)
        tv.bind("<<TreeviewSelect>>", trefun)
        
        rtnode=tv.insert("",0,"dex",text="dex",values=("1"))
        apknode=tv.insert(rtnode,1,"apk信息",text="apk信息",values=("1"))
        strsnode=tv.insert(apknode, 2,"strings",text="strings",values=("1"))
        
        dexclsnode=tv.insert(rtnode,1,"dexclasses",text="dexclasses",values=("1"))
        
        strslen =  len(_strs)
        for i in xrange(0,strslen):
            tv.insert(strsnode, -1,strslen - i,text=_strs[i],values=("2"))
    
        tp.mainloop()

    事件:

    The Treeview widget generates the following virtual events.

    eventdescription
    <<TreeviewSelect>> Generated whenever the selection changes.
    <<TreeviewOpen>> Generated just before settings the focus item to open=True.
    <<TreeviewClose>> Generated just after setting the focus item to open=False.
        tv.bind("<<TreeviewSelect>>", trefun)
  • 相关阅读:
    [转]windows Mobile使用ActiveSync上网
    C++剪切板操作
    jdk1.8源码分析hashMap
    【杂项】VMware 虚拟机安装ubuntu 16.04教程
    【Linux命令】数据流重定向
    【ceph | 运维】crush相关命令
    【Linux命令】更改hostname
    【Linux命令】sed命令
    【Linux命令】vim基本快捷键
    【Linux命令】install
  • 原文地址:https://www.cnblogs.com/fply/p/8412935.html
Copyright © 2020-2023  润新知