本文整理汇总了Python中tkinter.ttk.Treeview.tag_configure方法的典型用法代码示例。如果您正苦于以下问题:Python Treeview.tag_configure方法的具体用法?Python Treeview.tag_configure怎么用?Python Treeview.tag_configure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.ttk.Treeview
的用法示例。
在下文中一共展示了Treeview.tag_configure方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: per
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import tag_configure [as 别名]
class per():
def __init__(self,data,y,v='план'):
w=Toplevel()
w.wm_title('Доп')
w.columnconfigure(0,weight=1)
w.rowconfigure(0,weight=1)
years=sorted(data.keys())
cols=data['2013']['degurs'] # ЗАГЛУШКА : список дежурных
self.t=Treeview(w,columns=cols)
for c in cols:
self.t.heading(c,text=c)
self.t.column(c,width=65,anchor='center')
self.t.tag_configure('табель',background='green')
self.t.tag_configure('ош',background='red')
#self.t.tag_configure('табель',background='green')
self.scrX=Scrollbar(w,orient='horizontal',command=self.t.xview)
self.scrY=Scrollbar(w,orient='vertical',command=self.t.yview)
self.t['xscrollcommand']=self.scrX.set
self.t['yscrollcommand']=self.scrY.set
self.t.grid(row=0,column=0,sticky=N+S+E+W)
self.scrX.grid(row=1,column=0,sticky=E+W)
self.scrY.grid(row=0,column=1,sticky=N+S)
for y in years:
x=self.t.insert('','end',text=y)
eeY=[]
for m in ['01','02','03','04','05','06','07','08','09','10','11','12']:
d0=data[y]
if m not in d0: continue
d=d0[m]
rez=dict()
tag=''
if v=='авто':
if 'табель' in d['degur']:
vv='табель'
tag=vv
else:
vv='план'
elif v=='табель':
if 'табель' not in d['degur']:
vv='план'
tag='ош'
else:
vv=v
tag=vv
else:
vv=v
for j,s in d['degur'][vv].items():
rez[j]=analyse2(s,d)
NUL=(0,0,0,0,0,0,0)
ee=[rez.get(j,NUL)[0]-rez.get(j,NUL)[3]+rez.get(j,NUL)[4] for j in cols]
eeY.append(ee)
self.t.insert(x,'end',text=m,values=[x or '-' for x in ee],tag=tag)
eeY=[sum(x) for x in zip(*eeY)]
self.t.insert(x,'end',text='итого',values=eeY,tag='Y')
示例2: tabel
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import tag_configure [as 别名]
class tabel():
def __init__(self,data,y,m):
w=Toplevel()
w.geometry('{0}x{1}+0+0'.format(120+25*21,w.winfo_screenheight()-80))
w.columnconfigure(0,weight=1)
w.rowconfigure(0,weight=1)
d=data[y][m]
v='план'
if 'табель' in d['degur']:
v='табель'
w.wm_title('{0} {1} {2}'.format(v,y,m))
#deg=data['2013']['11']['degurs'] # ЗАГЛУШКА : список дежурных
deg=d['degurs'] # ЗАГЛУШКА : список дежурных
cc=list(range(1,17))
cols=[str(c) for c in cc]+['s','сум','ноч','пра','доп']
self.t=Treeview(w,columns=cols)
self.t.column('#0',width=100)
for c in cols:
self.t.heading(c,text=c)
self.t.column(c,width=25,anchor='center')
self.t.tag_configure('title',background='gray')
self.scrX=Scrollbar(w,orient='horizontal',command=self.t.xview)
self.scrY=Scrollbar(w,orient='vertical',command=self.t.yview)
self.t['xscrollcommand']=self.scrX.set
self.t['yscrollcommand']=self.scrY.set
self.t.grid(row=0,column=0,sticky=N+S+E+W)
self.scrX.grid(row=1,column=0,sticky=E+W)
self.scrY.grid(row=0,column=1,sticky=N+S)
rez=dict()
for j,s in d['degur'][v].items():
rez[j]=analyse2(s,d)
for j in deg:
ww1=[]
ww2=[]
a=0
nn1=[]
for x in d['degur'][v].get(j,''):
if a:
if x=='Д':
ww1.append('!!')
nn1+=[0,0]
y=a+12
a=0
elif x in [str(xx) for xx in range(1,10)]:
ww1.append('Я')
nn1+=[0,0]
y=a+int(x)
a=0
elif x=='Н':
ww1.append('!')
nn1+=[2,6]
y=a+4
a=8
elif x=='-':
ww1.append('Н')
nn1+=[0,0]
y=a+0
a=0
else:
ww1.append('!')
nn1+=[0,0]
y=a+0
a=0
else:
if x=='Д':
ww1.append('Я')
nn1+=[0,0]
y=12
a=0
elif x in [str(xx) for xx in range(1,10)]:
ww1.append('Я')
nn1+=[0,0]
y=int(x)
a=0
elif x=='Н':
ww1.append(x)
nn1+=[2,6]
y=4
a=8
elif x=='-':
ww1.append('В')
nn1+=[0,0]
y=0
a=0
else:
ww1.append(x)
nn1+=[0,0]
y=0
a=0
ww2.append(y)
ww=rez.get(j,(0,0,0,0))[0]
ee=rez.get(j,(0,0,0,0))[0] -rez.get(j,(0,0,0,0))[3]
#ee=rez.get(j,(0,0,0,0))[3]
nn=rez.get(j,(0,0,0,0))[1]
hh=rez.get(j,(0,0,0,0))[2]
s1=sum([x and 1 for x in ww2[1:16]])
#.........这里部分代码省略.........
示例3: statistic_q
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import tag_configure [as 别名]
class statistic_q():
def __init__(self,data,y,v='план'):
w=Toplevel()
w.wm_title('Поквартальная статистика за {0} год ({1})'.format(y,v))
w.columnconfigure(0,weight=1)
w.rowconfigure(0,weight=1)
cols=data[y]['degurs'] # ЗАГЛУШКА : список дежурных
self.t=Treeview(w,columns=cols)
self.t.column('#0',width=120)
for c in cols:
self.t.heading(c,text=c)
self.t.column(c,width=65,anchor='center')
self.t.tag_configure('табель',background='green')
self.t.tag_configure('ош',background='red')
self.scrX=Scrollbar(w,orient='horizontal',command=self.t.xview)
self.scrY=Scrollbar(w,orient='vertical',command=self.t.yview)
self.t['xscrollcommand']=self.scrX.set
self.t['yscrollcommand']=self.scrY.set
self.t.grid(row=0,column=0,sticky=N+S+E+W)
self.scrX.grid(row=1,column=0,sticky=E+W)
self.scrY.grid(row=0,column=1,sticky=N+S)
r=self.t.insert('','end',text='рабочих')
w=self.t.insert('','end',text='отработано')
e=self.t.insert('','end',text='дополнительные')
n=self.t.insert('','end',text='ночные')
h=self.t.insert('','end',text='праздничные')
x=self.t.insert('','end',text='xxx')
rz_root=self.t.insert('','end',text='резерв')
rez=dict()
wwY=[]
rrY=[]
eeY=[]
xxY=[]
nnY=[]
hhY=[]
rzY=[]
for mm in [1,2,3,4]:
mmm=[str((mm-1)*3+x).zfill(2) for x in [1,2,3]]
mmm=[x for x in mmm if x in data[y]]
tag=''
k=['табель' in data[y][m]['degur'] for m in mmm]
#print(k)
if v=='авто':
if k==[True, True, True]:
vv='табель'
tag=vv
else:
vv='план'
elif v=='табель':
if k!=[True, True, True]:
vv='план'
tag='ош'
else:
vv=v
tag=vv
else:
vv=v
ww=[]
rr=[]
ee=[]
xx=[]
nn=[]
hh=[]
rz=[]
for m in mmm:
d=data[y][m]
for j in cols:
s=d['degur'][vv].get(j,'*ООООООООООООООООООООООООООООООО*')
rez[j]=analyse2(s,d)
NUL=(0,0,0,0,0,0,0)
ww.append([rez.get(j,NUL)[0] for j in cols])
ee.append([rez.get(j,NUL)[0]-rez.get(j,NUL)[3] + \
rez.get(j,NUL)[4] for j in cols])
xx.append([rez.get(j,NUL)[0]-rez.get(j,NUL)[3] for j in cols])
rr.append([rez.get(j,NUL)[3]-rez.get(j,NUL)[4] for j in cols])
nn.append([rez.get(j,NUL)[1] for j in cols])
hh.append([rez.get(j,NUL)[2] for j in cols])
rz.append([rez.get(j,NUL)[5] for j in cols])
ww=[sum(x) for x in zip(*ww)]
rr=[sum(x) for x in zip(*rr)]
ee=[sum(x) for x in zip(*ee)]
xx=[sum(x) for x in zip(*xx)]
nn=[sum(x) for x in zip(*nn)]
hh=[sum(x) for x in zip(*hh)]
rz=[sum(x) for x in zip(*rz)]
wwY.append(ww)
rrY.append(rr)
eeY.append(ee)
xxY.append(xx)
nnY.append(nn)
hhY.append(hh)
rzY.append(rz)
self.t.insert(w,'end',text=mm,values=ww,tag=tag)
self.t.insert(r,'end',text=mm,values=rr,tag=tag)
#.........这里部分代码省略.........
示例4: statistic_xx
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import tag_configure [as 别名]
class statistic_xx():
def __init__(self,data,y,v='план'):
w=Toplevel()
w.wm_title('Итоги по месяцам за {0} год ({1}) '.format(y,v))
w.columnconfigure(0,weight=1)
w.rowconfigure(0,weight=1)
cols=data[y]['degurs'] # ЗАГЛУШКА : список дежурных
self.t=Treeview(w,columns=cols)
self.t.column('#0',width=120)
for c in cols:
self.t.heading(c,text=c)
self.t.column(c,width=65,anchor='center')
self.t.tag_configure('табель',background='green')
self.t.tag_configure('ош',background='red')
self.scrX=Scrollbar(w,orient='horizontal',command=self.t.xview)
self.scrY=Scrollbar(w,orient='vertical',command=self.t.yview)
self.t['xscrollcommand']=self.scrX.set
self.t['yscrollcommand']=self.scrY.set
self.t.grid(row=0,column=0,sticky=N+S+E+W)
self.scrX.grid(row=1,column=0,sticky=E+W)
self.scrY.grid(row=0,column=1,sticky=N+S)
roots=dict()
for m in ['01','02','03','04','05','06','07','08','09','10','11','12']:
d0=data[y]
if m not in d0: continue
roots[m]=self.t.insert('','end',text=m+' ('+data[y][m]['month']+')')
#r=self.t.insert('','end',text='рабочих')
#x=self.t.insert('','end',text='xxx')
#w=self.t.insert('','end',text='отработано')
#e=self.t.insert('','end',text='дополнительные')
#n=self.t.insert('','end',text='ночные')
#h=self.t.insert('','end',text='праздничные')
#rz_root=self.t.insert('','end',text='резерв')
for m in ['01','02','03','04','05','06','07','08','09','10','11','12']:
d0=data[y]
if m not in d0: continue
d=d0[m]
rez=dict()
tag=''
if v=='авто':
if 'табель' in d['degur']:
vv='табель'
tag=vv
else:
vv='план'
elif v=='табель':
if 'табель' not in d['degur']:
vv='план'
tag='ош'
else:
vv=v
tag=vv
else:
vv=v
for j,s in d['degur'][vv].items():
rez[j]=analyse2(s,d)
NUL=(0,0,0,0,0,0,0)
ww=[rez.get(j,NUL)[0] for j in cols]
ee=[rez.get(j,NUL)[0]-rez.get(j,NUL)[3]+rez.get(j,NUL)[4] for j in cols]
xx=[rez.get(j,NUL)[0]-rez.get(j,NUL)[3] for j in cols]
nn=[rez.get(j,NUL)[1] for j in cols]
hh=[rez.get(j,NUL)[2] for j in cols]
rr=[rez.get(j,NUL)[3]-rez.get(j,NUL)[4] for j in cols]
rz=[rez.get(j,NUL)[5] for j in cols]
self.t.insert(roots[m],'end',text='отработано',values=ww,tag=tag)
self.t.insert(roots[m],'end',text='рабочие',values=rr,tag=tag)
self.t.insert(roots[m],'end',text='дополнительные',values=ee,tag=tag)
self.t.insert(roots[m],'end',text='ночные',values=nn,tag=tag)
self.t.insert(roots[m],'end',text='праздничные',values=hh,tag=tag)
示例5: Gr
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import tag_configure [as 别名]
class Gr():
def __init__(self,root,data,SCRY=None):
self.data=data
self.columns=[x for x in range(1,8)]+['day']
root.rowconfigure(1,weight=1)
root.columnconfigure(0,weight=1)
root.columnconfigure(1,weight=1)
root.columnconfigure(2,weight=1)
f=Frame(root)
f.columnconfigure(0,weight=1)
f.rowconfigure(1,weight=1)
self.v=Combobox(root)
self.v.grid(row=0,column=0)
self.v.bind('<<ComboboxSelected>>',self.select_ver)
f.grid(row=1,column=0,columnspan=3,sticky=N+S)
self.tree=Treeview(f,
columns=self.columns,
displaycolumns=['day']+self.columns[:-1],
show='headings')
#self.tree.tag_configure('odd',background='white')
#self.tree.tag_configure('even',background='gray')
self.tree.tag_configure('dif',foreground='brown')
self.tree.tag_configure('work',background='white')
self.tree.tag_configure('short',background='#F5EFE0')
self.tree.tag_configure('rest',background='#E0B0B0')
self.tree.tag_configure('holyday',background='#E7B7A4')
for c in self.columns:
self.tree.heading(c,text=c)
self.tree.column(c,width=65,anchor='center')
self.tree.column('day',width=30)
scrX=Scrollbar(f,orient='horizontal',command=self.tree.xview)
self.tree['xscrollcommand']=scrX.set
if not SCRY:
self.scrY=Scrollbar(f,orient='vertical',command=self.yview)
self.tree['yscrollcommand']=self.scrY.set
else:
self.tree['yscrollcommand']=SCRY.set
self.tree.grid(row=1,column=0,sticky=N+S)
if not SCRY:
self.scrY.grid(row=1,column=1,sticky=N+S)
scrX.grid(row=2,column=0,sticky=E+W)
def set(self,y,m):
self.y=y
self.m=m
self.show()
def yview(self,*args):
self.tree.yview(*args)
self.yview2(*args)
def yview2(self,*args):
pass
def show(self):
d=self.data[self.y][self.m]
V=list(d['degur'].keys())
self.v['values']=V
self.v.set(V[0])
self.select_ver()
def select_ver(self,*e):
self.tree.delete(*self.tree.get_children())
d=self.data[self.y][self.m]
offset=d['offset']
v=self.v.get()
col=[]
for i,deg in enumerate(d['degurs']):
self.tree.heading(i+1,text=deg)
col.append(i+1)
self.tree.configure(displaycolumns=['day']+col)
items=dict()
if 'табель' in d['degur']:
a=[''.join(x) for x in zip(*[[x for x in d['degur']['план'][j]] \
for j in d['degurs']])]
b=[''.join(x) for x in zip(*[[x for x in d['degur']['табель'][j]] \
for j in d['degurs']])]
c=[x!=y for x,y in zip(a,b)]
else:
c=[False]*32
for i in range(1,d['days']+1):
tag = (i+offset) % 7 in [0,6] and 'rest' or 'work'
if i in d['holydays'] : tag='holyday'
elif i in d['restdays'] : tag='rest'
elif i in d['shortdays'] : tag='short'
elif i in d['workdays'] : tag='work'
if c[i]: tag=[tag,'dif']
ii=self.tree.insert('','end',values=['-','-','-','-','-'],tag=tag)
self.tree.set(ii,column='day',value=i)
items[i]=ii
for j,s in d['degur'][v].items(): # j-degur
if not s: continue
for i,val in enumerate(s[1:-1]):
if val=='J':
val='до'
elif val=='j':
val='од'
elif val=='a':
val='10'
self.tree.set(items[i+1],column=d['degurs'].index(j)+1,value=val)
if s[0]=='Н':
#.........这里部分代码省略.........
示例6: fillTree
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import tag_configure [as 别名]
class Window:
def fillTree(self,path, parent, list):
for file in os.listdir(path):
abspath = os.path.join(path,file)
color = ""
treelist = None
for mini in list:
if abspath in mini:
color = 'red'
treelist = mini
else:
for lk in mini:
if abspath in lk:
color = 'purple'
child = None
if color == 'red':
child = self.tree.insert(parent,'end',text=file,open=False,tags=(abspath,'red',str(treelist)),)
elif color == 'purple':
child = self.tree.insert(parent,'end',text=file,open=False,tags=(abspath,'purple'))
else:
child = self.tree.insert(parent,'end',text=file,open=False,tags=(abspath,'white'))
if(os.path.isdir(abspath)):
self.tree.insert(child,'end',text='',open=False)
def __init__(self,list,dirlist):
self.root = Tk()
self.root.wm_title("Duplicate_Files")
self.min = None
self.list = list
self.root.geometry('600x600+0+0')
self.tree = Treeview(self.root ,height=15)
self.tree.pack(expand='yes',fill='both')
self.tree.heading('#0',text="files")
self.tree.tag_configure('red',foreground='red')
self.tree.tag_configure('purple',foreground='#cc00ff')
self.tree.bind("<Double-1>",self.onDoubleClick)
self.tree.bind("<<TreeviewOpen>>",self.onOpen)
self.tree.bind("<<TreeviewClose>>",self.onClose)
for path in dirlist:
branch = self.tree.insert('','end',text=path,open=True,tags=(path,'white'))
self.fillTree(path,branch,list)
self.root.mainloop()
def onDoubleClick(self,event):
item = self.tree.selection()[0]
print ("clicked" + str(self.tree.item(item,'tags')[0]))
if str(self.tree.item(item,'tags')[1]) == "red":
list_of_files = ast.literal_eval(str(self.tree.item(item,'tags')[2]))
if self.min != None:
if self.min.mini.winfo_exists():
self.min.mini.destroy()
self.min = MiniWindow(self.root,list_of_files)
def onOpen(self,event):
item = self.tree.selection()[0]
if self.tree.parent(item) != '':
if len(self.tree.get_children(item))>0:
self.tree.delete(self.tree.get_children(item))
abspath = str(self.tree.item(item,'tags')[0])
if(os.path.isdir(abspath)):
self.fillTree(abspath, item,self.list)
def onClose(self,event):
item = self.tree.selection()[0]
if self.tree.parent(item) != '':
if len(self.tree.get_children(item))>0:
self.tree.delete(self.tree.get_children(item))