aaaaaaaaaaaa
代码改变世界

python我的tkinter学习,玩玩

2018-02-02 16:11  二进制乐谱  阅读(304)  评论(0编辑  收藏  举报

1.开始

#!/usr/bin/env python
#coding:utf-8


import Tkinter

########################################################################
class dex:
    """"""

    #--解析dex
    def __init__(self,filename):
        """Constructor"""
        fd = open(filename,"wb")
        self.m_content = fd.read()
        fd.close()


    #----------------------------------------------------------------------
    def getStrings(self):
        """"""


        print "!11"




if __name__ == '__main__':

    tp = Tkinter.Tk()
    tp.mainloop()

控件位置管理:

pack()包装;

grid()网格;

place()位置;

 

先上树型控件

if __name__ == '__main__':

    tp = Tkinter.Tk()

    tv = ttk.Treeview(tp)
    tv.pack()
    rtnode=tv.insert("",0,"中国",text="中国China",values=("1"))

    node1=tv.insert(rtnode,1,"cq",text="cq",values=("2"))
    node2=tv.insert(rtnode,1,"sc",text="sc",values=("2"))

    tp.mainloop()

 

带滚动条的TreeView

if __name__ == '__main__':
    
    _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")
    rtnode=tv.insert("",0,"dex",text="dex",values=("1"))
    
    for i in xrange(0,len(_strs)):
        tv.insert(rtnode,1,i,text=_strs[i],values=("2"))

    tp.mainloop()

 

 

aaaaaaaaaaaaa