zoukankan      html  css  js  c++  java
  • 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)
  • 相关阅读:
    HDU 1285
    HDU 1251
    HDU 1166
    UVA 10003
    HDU 5968
    CodeForces 371C
    POJ 2456
    POJ 2250
    oracle的start with connect by prior
    Hibernate session中的createCriteria方法
  • 原文地址:https://www.cnblogs.com/fply/p/8412935.html
Copyright © 2011-2022 走看看