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


Python Treeview.selection_set方法代码示例

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


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

示例1: selection_set

# 需要导入模块: from ttk import Treeview [as 别名]
# 或者: from ttk.Treeview import selection_set [as 别名]
    def selection_set(self, node):
        """Node names on the breakpoint tree are the filename.

        On Windows, this requires escaping, because backslashes
        in filenames cause problems with Tk.
        """
        Treeview.selection_set(self, self._nodify(node))
开发者ID:adamchainz,项目名称:bugjar,代码行数:9,代码来源:widgets.py

示例2: Multicolumn_Listbox

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

#.........这里部分代码省略.........
        try:
            item_ID = list_of_items[index]
        except IndexError:
            raise ValueError("Row index out of range: %d"%index)

        self.interior.selection_toggle(item_ID)     

    def select_row(self, index):
        list_of_items = self.interior.get_children()
        
        try:
            item_ID = list_of_items[index]
        except IndexError:
            raise ValueError("Row index out of range: %d"%index)

        self.interior.selection_add(item_ID)

    def deselect_row(self, index):
        list_of_items = self.interior.get_children()
        
        try:
            item_ID = list_of_items[index]
        except IndexError:
            raise ValueError("Row index out of range: %d"%index)

        self.interior.selection_remove(item_ID)
        
    def deselect_all(self):
        self.interior.selection_remove(self.interior.selection())

    def set_selection(self, indices):
        list_of_items = self.interior.get_children()

        self.interior.selection_set(" ".join(list_of_items[row_index] for row_index in indices))

    @property
    def selected_rows(self):
        data = []
        for item_ID in self.interior.selection():
            data_row = self.item_ID_to_row_data(item_ID)
            data.append(data_row)
        
        return data

    @property
    def indices_of_selected_rows(self):
        list_of_indices = []
        for index, item_ID in enumerate(self.interior.get_children()):
            if item_ID in self.interior.selection():
                list_of_indices.append(index)

        return list_of_indices
        
    def delete_all_selected_rows(self):
        selected_items = self.interior.selection()
        for item_ID in selected_items:
            self.interior.delete(item_ID)
        
        number_of_deleted_rows = len(selected_items)
        self._number_of_rows -= number_of_deleted_rows

        return number_of_deleted_rows

    def _on_select(self, event):
        for item_ID in event.widget.selection():
            data_row = self.item_ID_to_row_data(item_ID)
开发者ID:jacob-carrier,项目名称:code,代码行数:70,代码来源:recipe-580746.py

示例3: __init__

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

#.........这里部分代码省略.........
		l = Label(ef, text="File:", justify=LEFT)
		l.pack(side=LEFT)

		self.entry = Entry(ef, width=12)
		self.entry.pack(side=LEFT)
		fn = 'untitled.g'
		if self.app.GCodeFile:
			fn = os.path.basename(self.app.GCodeFile)
			if len(fn) > 8:
				fn = fn[0:8]
			fn += ".g"
		self.entry.delete(0, END)
		self.entry.insert(0, fn)
		ef.pack()
		
		self.bUpload = Button(blf, text="Upload", command=self.doUpload, width=6)
		self.bUpload.pack()

		blf.pack(fill='x')
		
		if self.app.printing or self.app.sdprinting:
			self.bPrint.config(state=DISABLED)
			self.bUpload.config(state=DISABLED)
			
		if not self.app.GCodeFile:
			self.bUpload.config(state=DISABLED)
			
		blf = Frame(bf)
		self.bExit = Button(blf, text='Exit', command=self.doExit, width=6) 
		self.bExit.pack()
		blf.pack()

		if self.startFile:
			self.tree.selection_set(self.startFile)
			
		self.top.geometry("360x300+100+100")

	def delTop(self):
		self.top.destroy()
		self.top = None
	
	def treeSelect(self, *arg):
		s = self.tree.selection()[0]
		
		try:
			d = s.split(':')[0]
		except:
			d = ""
			
		if len(d) == 0:
			d = '(root)'
			
		self.upDir.config(text="Dir: " + d)
		
		if self.app.printing or self.app.sdprinting or not self.app.GCodeFile:
			self.bUpload.config(state=DISABLED)
		else:
			self.bUpload.config(state=NORMAL)
			
		if ':' in s: # a file is chosen
			if self.app.printing or self.app.sdprinting:
				self.bPrint.config(state=DISABLED)
			else:
				self.bPrint.config(state=NORMAL)
			self.bDelete.config(state=NORMAL)
			
开发者ID:jbernardis,项目名称:repraphost,代码行数:69,代码来源:sdcard.py


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