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


Python Treeview.tag_configure方法代码示例

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


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

示例1: show

# 需要导入模块: from ttk import Treeview [as 别名]
# 或者: from ttk.Treeview import tag_configure [as 别名]
    def show(frame, iterator):
        """Выводит на экран выборку, заданную в iterator"""

        scrollbar = Scrollbar(frame)
        tree = Treeview(frame, selectmode='none', padding=3,
                                style='Custom.Treeview', height=REPORT_HEIGHT,
                                yscrollcommand=scrollbar.set)
        tree.pack(side=LEFT, fill=BOTH, expand=YES)
        scrollbar.config(command=tree.yview)
        scrollbar.pack(side=LEFT, fill=Y)

        tree.tag_configure('1', font=('Verdana', FONT_SIZE_REPORT))
        tree.tag_configure('2', font=('Verdana', FONT_SIZE_REPORT),
                                                           background='#f5f5ff')

        Style().configure('Custom.Treeview', rowheight=FONT_SIZE_REPORT*2)

        columns = ['#' + str(x + 1) for x in range(8)]
        tree.configure(columns=columns)

        for q in range(len(header)):
            tree.heading('#%d' % (q + 1), text=header[q], anchor='w')
            tree.column('#%d' % (q + 1), width=REPORT_SCALE * col_width[q + 1],
                                                                     anchor='w')
        tree.heading('#0', text='', anchor='w')
        tree.column('#0', width=0, anchor='w', minwidth=0)

        flag = True
        summ = 0
        for item in iterator:

            value = item.quantity * item.price * (100 - item.discount) / 100
            summ += value

            col = []
            col.append(add_s(item.check.id))
            col.append(add_s(item.goods.cathegory.name))
            col.append(add_s(item.goods.name))
            col.append(add_s(item.quantity))
            col.append(add_s(item.discount) +'%' if item.discount else ' -- ')
            col.append(add_s(u'%6.2f грн.' % value))
            col.append(add_s(item.check.date_time.strftime('%d.%m.%Y')))
            col.append(add_s(item.check.date_time.time())[:8])

            flag = not flag
            if flag:
                tree.insert('', 'end', text='', values=col, tag='2')
            else:
                tree.insert('', 'end', text='', values=col, tag='1')

        return summ
开发者ID:sychov,项目名称:conditer,代码行数:53,代码来源:report_make.py

示例2: Multicolumn_Listbox

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

#.........这里部分代码省略.........

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

        return self.item_ID_to_row_data(item_ID)

    def update_row(self, index, data):
        try:
            item_ID = self.interior.get_children()[index]
        except IndexError:
            raise ValueError("Row index out of range: %d"%index)
            
        if len(data) == len(self._columns):
            self.interior.item(item_ID, values=data)
        else:
            raise ValueError("The multicolumn listbox has only %d columns"%self._number_of_columns)

    def delete_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.delete(item_ID)
        self._number_of_rows -= 1
        
        if self._stripped_rows:
            for i in range(index, self._number_of_rows):
                self.interior.tag_configure(list_of_items[i+1], background=self._stripped_rows[i%2])
            
    def insert_row(self, data, index=None):
        if len(data) != self._number_of_columns:
            raise ValueError("The multicolumn listbox has only %d columns"%self._number_of_columns)
        
        if index is None:
            index = self._number_of_rows-1

        item_ID = self.interior.insert('', index, values=data)        
        self.interior.item(item_ID, tags=item_ID)

        self._number_of_rows += 1        

        if self._stripped_rows:            
            list_of_items = self.interior.get_children()

            self.interior.tag_configure(item_ID, background=self._stripped_rows[index%2])

            for i in range(index+1, self._number_of_rows):
                self.interior.tag_configure(list_of_items[i], background=self._stripped_rows[i%2])

    def column_data(self, index):
        return [self.interior.set(child_ID, index) for child_ID in self.interior.get_children('')]

    def update_column(self, index, data):
        for i, item_ID in enumerate(self.interior.get_children()): 
            data_row = self.item_ID_to_row_data(item_ID)
            data_row[index] = data[i]

            self.interior.item(item_ID, values=data_row)

        return data
开发者ID:jacob-carrier,项目名称:code,代码行数:70,代码来源:recipe-580746.py

示例3: __init__

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

#.........这里部分代码省略.........
    def add_menu(self, menuName, commandList):
        self.menus[menuName] = Menu(self.menubar,tearoff=0)
        for c in commandList:
            if 'separator' in c: self.menus[menuName].add_separator()
            else: self.menus[menuName].add_command(label=c['name'], command=c['command'], accelerator=c['accelerator'] if 'accelerator' in c else '')
        self.menubar.add_cascade(label=menuName, menu=self.menus[menuName])
        self.main_window.config(menu=self.menubar)

    # Labels
    def create_file_path_labels(self):
        self.leftFileLabel = Label(self.main_window, anchor='center', width=1000, background=self.lightGrayColor)
        self.leftFileLabel.grid(row=self.filePathLabelsRow, column=self.leftFilePathLabelsCol, columnspan=2)
        self.rightFileLabel = Label(self.main_window, anchor='center', width=1000, background=self.lightGrayColor)
        self.rightFileLabel.grid(row=self.filePathLabelsRow, column=self.rightFilePathLabelsCol, columnspan=2)

    # Search text entnry
    def create_search_text_entry(self, searchButtonCallback):
        self.searchTextDialog = SearchTextDialog(self.main_window, [self.leftFileTextArea, self.rightFileTextArea], searchButtonCallback)
        self.searchTextDialog.grid(row=self.searchTextRow, column=self.leftFilePathLabelsCol, columnspan=5, sticky=EW)

        self.searchTextDialog.grid_remove()

    # File treeview
    def create_file_treeview(self):
        self.fileTreeView = Treeview(self.main_window)
        self.fileTreeYScrollbar = Scrollbar(self.main_window, orient='vertical', command=self.fileTreeView.yview)
        self.fileTreeXScrollbar = Scrollbar(self.main_window, orient='horizontal', command=self.fileTreeView.xview)
        self.fileTreeView.configure(yscroll=self.fileTreeYScrollbar.set, xscroll=self.fileTreeXScrollbar.set)

        self.fileTreeView.grid(row=self.fileTreeRow, column=self.fileTreeCol, sticky=NS, rowspan=3)
        self.fileTreeYScrollbar.grid(row=self.fileTreeRow, column=self.fileTreeScrollbarCol, sticky=NS, rowspan=3)
        self.fileTreeXScrollbar.grid(row=self.horizontalScrollbarRow, column=self.fileTreeCol, sticky=EW)

        self.fileTreeView.tag_configure('red', background=self.redColor)
        self.fileTreeView.tag_configure('green', background=self.greenColor)
        self.fileTreeView.tag_configure('yellow', background=self.yellowColor)

        # hide it until needed
        self.fileTreeView.grid_remove()
        self.fileTreeYScrollbar.grid_remove()
        self.fileTreeXScrollbar.grid_remove()

    # Text areas
    def create_text_areas(self):
        self.leftFileTextArea = Text(self.main_window, padx=5, pady=5, width=1, height=1, bg=self.grayColor)
        self.leftFileTextArea.grid(row=self.textAreasRow, column=self.leftTextAreaCol, sticky=NSEW)
        self.leftFileTextArea.config(font=self.text_area_font)
        self.leftFileTextArea.config(wrap='none')

        self.rightFileTextArea = Text(self.main_window, padx=5, pady=5, width=1, height=1, bg=self.grayColor)
        self.rightFileTextArea.grid(row=self.textAreasRow, column=self.rightTextAreaCol, sticky=NSEW)
        self.rightFileTextArea.config(font=self.text_area_font)
        self.rightFileTextArea.config(wrap='none')

        # configuring highlight tags
        self.leftFileTextArea.tag_configure('red', background=self.redColor)
        self.leftFileTextArea.tag_configure('darkred', background=self.darkredColor)
        self.leftFileTextArea.tag_configure('gray', background=self.grayColor)
        self.leftFileTextArea.tag_configure('search', background=self.darkYellowColor)
        self.rightFileTextArea.tag_configure('green', background=self.greenColor)
        self.rightFileTextArea.tag_configure('darkgreen', background=self.darkgreenColor)
        self.rightFileTextArea.tag_configure('gray', background=self.grayColor)
        self.rightFileTextArea.tag_configure('search', background=self.darkYellowColor)

        # disable the text areas
        self.leftFileTextArea.config(state=DISABLED)
开发者ID:yebrahim,项目名称:pydiff,代码行数:70,代码来源:mainwindow_ui.py

示例4: GUIMainMenu

# 需要导入模块: from ttk import Treeview [as 别名]
# 或者: from ttk.Treeview import tag_configure [as 别名]
class GUIMainMenu(Frame):
    """Main menu for test of Genesi i.MX53 systems"""

    def __init__(self,master=None):
        """Initialize the base class"""
        Frame.__init__(self,master)

        """Set window title"""
        self.master.title("Select System Test")

        """System Tests"""
        self.createTestEntries()

        """Constants"""
        self.TEST_COL=0
        self.STATUS_COL=1
        self.TEXT_ROW=0
        self.TREEVIEW_ROW=1
        self.BUTTON_ROW=2

        """Display main window with padding"""
        self.grid()
        self.createWidgets()

    def createTestEntries(self):
        #TODO must be a better way. Pickle?
        self.tests = [TestInfo("Audio", AudioGUI), TestInfo("Clock", Dummy1),
                      TestInfo("Display", Dummy1), TestInfo("Keyboard", Dummy1),
                      TestInfo("Network", Dummy1), TestInfo("SSD", Dummy2),
                      TestInfo("Video", VideoGUI)]
        self.testsLookup = {}
        for te in self.tests:
            self.testsLookup.update({te.name : te})

    def createWidgets(self):
        """Create all the initial widgets for this menu"""
        """Labels"""
        lbl = Label(self, text="Select test below", justify=LEFT)
        lbl.grid(row=self.TEXT_ROW, column=self.TEST_COL)
        
        """Tests"""
        self.trv = Treeview(self, columns=("Status"), displaycolumns='#all')

        for test in self.tests:
            treeviewInsertTest(self.trv, test)

        self.trv.column('#0', width=100)
        self.trv.heading('#0', text="Test")
        self.trv.heading('Status', text='Status')

        self.trv.grid(column=self.TEST_COL, row=self.TREEVIEW_ROW,
                      columnspan=2)

        """Buttons"""
        self.btnOK = Button(self, text="OK", command=self.launchTest)
        self.btnOK.grid(row=self.BUTTON_ROW, column=0)
        self.btnQuit = Button(self, text="Quit", command=self.quit)
        self.btnQuit.grid(row=self.BUTTON_ROW, column=1)

    def launchTest(self):
        # get the item in focus
        testItem = self.trv.item(self.trv.focus())

        if not testItem['text'] == '':
            testInfo = self.testsLookup[testItem['text']]
            testInfo.launchTest(self)

    def processResults(self, testInfo):
        self.trv.item(testInfo.name, values=(testInfo.status),
                      tags=(testInfo.status))
        # update color notifications
        self.trv.tag_configure('Success', foreground='green')
        self.trv.tag_configure('Failure', foreground='red')

        self.deiconify()

    def withdraw(self):
        """Helpful function to hide window"""
        self.master.withdraw()

    def deiconify(self):
        """Helpful function to restore window"""
        self.master.deiconify()
开发者ID:cjenkin2,项目名称:iMX53-GUI-Hardware-Test,代码行数:85,代码来源:mainMenu.py


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