当前位置: 首页>>代码示例>>Python>>正文


Python Treeview.configure方法代码示例

本文整理汇总了Python中tkinter.ttk.Treeview.configure方法的典型用法代码示例。如果您正苦于以下问题:Python Treeview.configure方法的具体用法?Python Treeview.configure怎么用?Python Treeview.configure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tkinter.ttk.Treeview的用法示例。


在下文中一共展示了Treeview.configure方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Mk_Book_display

# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import configure [as 别名]
def Mk_Book_display(book, name):
    w = book.page(name)
    disp = Frame(w)

    tree_columns = ('book_no', 'book_name', 'book_author', 'book_publisher', 'in_out_status')
    Entries=Treeview(   disp,
                        columns=tree_columns,
                        show="headings"
                    )


    global_bucket['book_shelf'] = Entries

    vsb = Scrollbar (   disp,
                        orient="vertical",
                        command=Entries.yview)
    Entries.configure(yscrollcommand=vsb.set)
    for col,width in zip(tree_columns,(4,20,10,5,6)):
        Entries.heading(col, text=col.title(), anchor='w')
        Entries.column(col, width=1)

    vsb.pack(side=RIGHT,fill=Y)
    Entries.pack(fill=BOTH, expand=1)
    disp.pack(fill=BOTH, expand=1)

    update()
开发者ID:peruraj,项目名称:Intelligent_library,代码行数:28,代码来源:frontend.py

示例2: DeviceToFrame

# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import configure [as 别名]
class DeviceToFrame(CopilotInnerFrame):
    def __init__(self, master, config, state):
        super(DeviceToFrame, self).__init__(master, config)

        self._state = state

        if self._state.action == 'copy':
            self._frame_lbl['text'] = 'Copy To Directory'
        elif self._state.action == 'delete':
            self._frame_lbl['text'] = 'Delete From Directory'

        self._next_btn['command'] = self._next_cmd

        self._tree = Treeview(self._master, columns=('size'))
        self._tree.heading('size', text='Size')
        self._tree.grid(row=1, column=0, columnspan=3, sticky='nsew')
        self._tree.configure(yscrollcommand=self._sb.set)
        self._sb['command'] = self._tree.yview

        self._item_paths = {}
        self._populate_tree(self._state.to_device.part().mount())

    def _next_cmd(self):
        cur_item = self._tree.focus()
        cur_path = self._item_paths.get(cur_item, '')
        if cur_path != '':
            self._state.device_to_path = cur_path
            self._new_state_window(CopyFileFrame, self._state)

    def _populate_tree(self, tree_root):
        self._item_paths = {}
        def insert_path(tree, path, parent_id):
            dirs = [e for e in scandir(path) if e.is_dir()]
            dirs.sort(key=lambda e: e.name)

            for d in dirs:
                dir_name = d.name
                dir_id = '{}-{}'.format(parent_id, dir_name)
                dir_path = os.path.join(path, dir_name)
                tree.insert(parent_id, 'end', dir_id, text=dir_name, tags=('dir'))
                self._item_paths[dir_id] = dir_path
                try:
                    insert_path(tree, dir_path, dir_id)
                except:
                    pass

        insert_path(self._tree, tree_root, '')

        tree = self._tree
        tree.tag_configure('dir', font=self._config.item_font)
        tree.tag_configure('file', font=self._config.item_font)
        tree.tag_configure('file_odd', background='light grey')
开发者ID:aphistic,项目名称:copilot,代码行数:54,代码来源:device_to.py

示例3: Mk_Status_display

# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import configure [as 别名]
def Mk_Status_display(book, name):
    w = book.page(name)
    disp = Frame(w)

    tree_columns = ('book_no', 'book_name', 'date', 'staff_id', 'staff_name', 'note')
    Entries=Treeview(   disp,
                        columns=tree_columns,
                        show="headings",
                    )

    global_bucket['status_register'] = Entries

    vsb = Scrollbar (   disp,
                        orient="vertical",
                        command=Entries.yview)
    Entries.configure(yscrollcommand=vsb.set)
    for col in tree_columns:
        Entries.heading(col, text=col.title(), anchor='w')
        Entries.column(col, width=0)
    vsb.pack(side=RIGHT,fill=Y)
    Entries.pack(fill=BOTH, expand=1)
    disp.pack(fill=BOTH, expand=1)

    update()
开发者ID:peruraj,项目名称:Intelligent_library,代码行数:26,代码来源:frontend.py

示例4: CopyFileFrame

# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import configure [as 别名]
class CopyFileFrame(CopilotInnerFrame):
    def __init__(self, master, config, state):
        super(CopyFileFrame, self).__init__(master, config)

        self._state = state

        self._item_paths = {}

        self._tree = Treeview(self._master, columns=('size'))
        self._tree.heading('size', text='Size')
        self._tree.grid(row=1, column=0, columnspan=3, sticky='nsew')
        self._tree.configure(yscrollcommand=self._sb.set)
        self._sb['command'] = self._tree.yview

        if self._state.action == 'copy':
            self._next_btn['text'] = 'Copy'
            self._frame_lbl['text'] = 'Copy File'
            self._populate_tree(self._config.file_root)
        elif self._state.action == 'delete':
            self._next_btn['text'] = 'Delete'
            self._frame_lbl['text'] = 'Delete File'
            self._populate_tree(self._state.to_device.part().mount())

        self._next_btn['command'] = self._next_cmd

    def _next_cmd(self):
        if self._state.action == 'copy':
            self._copy_file()
        elif self._state.action == 'delete':
            self._delete_file()

    def _copy_file(self):
        cur_item = self._tree.focus()
        cur_path = self._item_paths.get(cur_item, '')
        if cur_path != '':
            new_path = os.path.join(self._state.device_to_path, os.path.basename(cur_path))
            try:
                if os.path.exists(new_path):
                    if ConfirmFrame.show(
                        self._master, self._config,
                        'The file already exists in the destination.\n'
                        'Would you like to overwrite it?',
                        'Yes', 'No'
                    ):
                        shutil.copyfile(cur_path, new_path)
                else:
                    shutil.copyfile(cur_path, new_path)
            except PermissionError:
                OkFrame.show(
                    self._master, self._config,
                    'Error copying file:\n\nInvalid permissions'
                )
            except Exception as e:
                OkFrame.show(
                    self._master, self._config,
                    'An error occurred while copying the file:\n\n{}'.format(e)
                )

    def _delete_file(self):
        cur_item = self._tree.focus()
        cur_path = self._item_paths.get(cur_item, '')
        if cur_path != '':
            disp_path = cur_path[len(self._state.to_device.part().mount()):]
            try:
                if ConfirmFrame.show(
                    self._master, self._config,
                    'Are you sure you\'d like to delete this file?\n{}'.format(disp_path),
                    'Yes', 'No'
                ):
                    os.remove(cur_path)
                    self._tree.delete(self._tree.focus())
            except PermissionError:
                OkFrame.show(
                    self._master, self._config,
                    'Error deleting file:\n\nInvalid permissions'
                )
            except Exception as e:
                OkFrame.show(
                    self._master, self._config,
                    'An error occurred while deleting the file:\n\n{}'.format(e)
                )

    def _populate_tree(self, tree_root):
        self._item_paths = {}

        def insert_path(tree, path, parent_id):
            dirs = [e for e in scandir(path) if e.is_dir()]
            dirs.sort(key=lambda e: e.name)

            for d in dirs:
                dir_name = d.name
                dir_id = '{}-{}'.format(parent_id, dir_name)
                dir_path = os.path.join(path, dir_name)
                tree.insert(parent_id, 'end', dir_id, text=dir_name, tags=('dir'))
                try:
                    insert_path(tree, dir_path, dir_id)
                except:
                    pass

            files = [e for e in scandir(path) if e.is_file()]
#.........这里部分代码省略.........
开发者ID:aphistic,项目名称:copilot,代码行数:103,代码来源:copy_file.py

示例5: calender

# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import configure [as 别名]
def calender(w):
    global year, mon
    date_bg = "white"
    date_fg = "black"
    date_fgb = "blue"
    date_bgt = "white"
    date_fgt = "red"
    day_bg = "orange"
    day_fg = "white"
    mon_bg = "violet"
    mon_fg = "white"
    Magic_Sequence = "2345012356013456123460124560"
    month = {
        "jan": 0,
        "feb": 8,
        "mar": 25,
        "apr": 5,
        "may": 1,
        "jun": 9,
        "jul": 5,
        "aug": 13,
        "sep": 21,
        "oct": 17,
        "nov": 25,
        "dec": 21,
    }
    months = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"]
    day = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"]
    # ~ current year and month
    now = ctime().split()
    year = int(now[4])
    mon = now[1].lower()
    date = int(now[2])

    def Cal_config(modify=False):
        global year, mon
        mon_limit = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
        now = ctime().split()
        cyear = int(now[4])
        cmon = now[1].lower()
        cdate = int(now[2])
        if modify == "go":
            year, mon = int(y.entry.get()), m.entry.get()
        elif modify:
            if months.index(mon) + modify > 11:
                year, mon = year + 1, "jan"
            elif months.index(mon) + modify < 0:
                year, mon = year - 1, "dec"
            else:
                mon = months[months.index(mon) + modify]
        monl.config(text="%s - %d" % (mon.title(), year))
        if not year % 4:
            mon_limit[1] = 29  # Leap year Check
        year_id = (year + 3) % 28
        Required_Sequence = Magic_Sequence[month[mon] :] + Magic_Sequence[: month[mon]]
        addition_factor = int(Required_Sequence[year_id])
        notes = CalLookUp(mon)
        d = 1
        for i in range(37):
            if i < addition_factor or d > mon_limit[months.index(mon)]:  # blank positions
                datebuttons[i].config(text="", bg=date_bg, activebackground=date_bg)
            else:  # positions with date
                bc, fc = date_bg, date_fg
                bracket = 0
                if year == cyear and mon == cmon and d == cdate:
                    bc, fc, bracket = date_bgt, date_fgt, 1
                if "%0.2d" % (d) in notes:
                    fc = date_fgb
                datebuttons[i].config(
                    text="%s%0.2d%s" % ("(" * bracket, d, ")" * bracket),
                    bg=bc,
                    fg=fc,
                    activebackground="yellow",
                    activeforeground="black",
                )
                d += 1
        for each_item in Entries.get_children():
            Entries.delete(each_item)
        ordered = []
        for memo in notes:
            ordered.append(memo)
        ordered.sort()
        for memo in ordered:
            for note in notes[memo]:
                Entries.insert("", "end", values=(memo, note[0], note[1]))
        print("Cal configured to", mon, year)
        # ~ main calender frame

    pane = tkinter.tix.PanedWindow(w, orientation="vertical")
    pane.pack(side=tkinter.tix.TOP, fill=BOTH)
    f1 = pane.add("top", size=190, expand="0", allowresize=0)
    f2 = pane.add("info", expand="0", allowresize=0)

    f1pane = tkinter.tix.PanedWindow(f1, orientation="horizontal")
    f1pane.pack(side=tkinter.tix.TOP, fill=BOTH)
    f1f1 = f1pane.add("calender", size=200, allowresize=0)
    f1f2 = f1pane.add("options", allowresize=0)

    # ~ month heading
    calhead = Frame(f1f1, bg=date_bg)
#.........这里部分代码省略.........
开发者ID:rajivm1991,项目名称:Power-Toy,代码行数:103,代码来源:CalenderSet.py

示例6: Gr

# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import 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]=='Н':
#.........这里部分代码省略.........
开发者ID:da-sher,项目名称:degur,代码行数:103,代码来源:degur.py

示例7: digiclock

# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import configure [as 别名]

#.........这里部分代码省略.........
			if (ct[3].split(':')[0] == '00' ):	
				ct[3]='12' + ct[3][2:]
				ConfigEvents()
			#~ if (not int(ct[3].split(':')[2])%10):	ts.config( bg=colour[ int( int( ct[3].split(':')[2] )/10) ] )
			mhs=ct[3].split(':')
			mode=	{
					'time&date'	:'%s-%s-%s\n%s\n%0.2d:%0.2d:%0.2d %s'%(ct[1],ct[2],ct[4],day[ct[0]],int(mhs[0]),int(mhs[1]),int(mhs[2]),m),
					'time'		:'%0.2d:%0.2d:%0.2d %s'%(int(mhs[0]),int(mhs[1]),int(mhs[2]),m)
					}
			text	=mode['time&date']
			#~ print(ct)
			ts.config(text=text)
			#~ print(al_time,mode['time'],al_time==mode['time'])
			if(al_time==mode['time']):
				set.config( text='Stop' )
				cal.config( text='Expired @ ' + al_time[:-2] )
				thread.start_new_thread(lambda snd='ringout', repeat=ON :play( snd, repeat ) ,() )
			sleep(1)
	def sett():
		global al_status,sound_continueous,al_time
		if(al_status):
			al_status = OFF
			sound_continueous = OFF
			al_time = ''
			cal.config( text='No Alarm' )
			set.config( text='Set' )
		else:
			al_status = ON
			al_time = at.entry.get()+' '+ampm.entry.get()
			cal.config( text='Set @ ' + al_time )
			set.config( text='Remove' )
	bg='orange'
	#~ time frame
	tf=Frame( f1, bg='black' )
	ts=Label(		tf
				,text="rajiv.m1991\[email protected]\ngmail.com"
				,font='times 40'
				,bg='violet'
				,width=11
				,fg='white')
	tf.pack(fill=BOTH)
	ts.pack(fill=X)
	#~ alarm frame
	af=Frame(f2f1,bg=bg)
	al=Label(	af
			,text="$ Alarm $"
			,font='times'
			,fg='white'
			,bg='black')
	at=LabelEntry( af, label='HH:MM:SS', bg=bg )
	at.label.config( fg='white', bg=bg )
	at.entry.config( width=13, borderwidth=0 )
	at.entry.insert( 0, '00:00:00' )
	ampm=LabelEntry( af, label='AM / PM ', bg=bg )
	ampm.entry.config( borderwidth=0 )
	ampm.label.config( fg='white', bg=bg)
	if( int( ctime().split(' ')[3].split(':')[0]) > 11 ):		ampm.entry.insert( 0,'PM' )
	else:	ampm.entry.insert( 0, 'AM' )
	set=Button(af
			,text='Set'
			,command=sett
			,fg='brown')
	ast=Label(	af
			,text='Alarm status:'
			,fg='white'
			,bg=bg
			,anchor='sw')
	cal=Label(	af
			,text='No Alarm'
			,fg='white'
			,bg='black'
			,anchor='sw')
	af.pack(fill=BOTH)
	al.pack(fill=X)
	at.pack(fill=X,padx=5,pady=5)
	ampm.pack(fill=X,padx=5,pady=5)
	set.pack()
	ast.pack(fill=X)
	cal.pack(fill=X)
	#~ options
	L=Label(f2f2,text="Upcoming Events")
	L.pack(fill=X)
	tree_columns = ("Dt", "Note", "Category")
	Entries=Treeview(	f2f2,
					columns=tree_columns,
					show="headings",
					height=5)
	vsb = Scrollbar(f2f2,orient="vertical", command=Entries.yview)
	Entries.configure(yscrollcommand=vsb.set)
	for col in tree_columns:
		Entries.heading(col, text=col.title())
	Entries.column(tree_columns[0],width=20)
	Entries.column(tree_columns[1],width=75)
	Entries.column(tree_columns[2],width=75)
	vsb.pack(side=RIGHT,fill=Y)
	Entries.pack(fill=BOTH)
	#~ start clock
	ConfigEvents()
	thread.start_new_thread(lambda st=ts_status ,ts=ts : displayTime(st,ts),())
	print('Digital Clock Successfully built')
开发者ID:rajivm1991,项目名称:Power-Toy,代码行数:104,代码来源:DigiClock.py


注:本文中的tkinter.ttk.Treeview.configure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。