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


Python Listbox.itemconfigure方法代码示例

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


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

示例1: second_window

# 需要导入模块: from tkinter import Listbox [as 别名]
# 或者: from tkinter.Listbox import itemconfigure [as 别名]
def second_window(root, info):
    def next_step():
        idxs = lbox.curselection()
        for blogger in idxs:
            name = bloggers()[blogger]
            if name not in info['bloggers']:
                info['bloggers'].append(name)
        if 'Blogs' in info['platforms']:
            blog_posts(root, info)
        else:
            third_window(root, info)

    def cantfind(info=info):
        idxs = lbox.curselection()
        for blogger in idxs:
            name = bloggers()[blogger]
            if name not in info['bloggers']:
                info['bloggers'].append(name)
        add_blogger(info=info)

    def active_next(*args):
        send.state(['!disabled', 'active'])

    def back():
        idxs = lbox.curselection()
        for blogger in idxs:
            name = bloggers()[blogger]
            if name not in info['bloggers']:
                info['bloggers'].append(name)
        first_window(root, info=info)

    c = ttk.Frame(root, padding=(5, 0, 0, 0))
    c.grid(column=0, row=0, sticky=(N, W, E, S))

    background_image = tkinter.PhotoImage(file='%s/Desktop/natappy/images/moon.gif' % home)
    background_label = tkinter.Label(c, image=background_image)
    background_label.image = background_image
    background_label.place(x=0, y=0, relwidth=1, relheight=1)

    root.grid_columnconfigure(0, weight=3)
    root.grid_rowconfigure(0, weight=3)

    lbox = Listbox(c, selectmode=MULTIPLE)
    lbox.grid(column=0, row=1, rowspan=11, columnspan=7, sticky=(
        N, W, S), padx=(10, 10), pady=(1, 1), ipadx=75)

    yscroll = ttk.Scrollbar(command=lbox.yview, orient=VERTICAL)
    yscroll.grid(row=0, column=0, padx=(0, 10), sticky=(N, W, S))

    lbox.configure(yscrollcommand=yscroll.set)

    for blogger in bloggers():
        lbox.insert(END, blogger)
        lbox.bind("<<ListboxSelect>>")

    lbox.yview_scroll(40, 'units')

    cantfind = ttk.Button(c, text='Add new bloggers', command=cantfind)
    cantfind.grid(column=4, row=1, padx=(10, 0), sticky=(N, S, E, W), pady=(20, 10))

    send = ttk.Button(c, text='Next', command=next_step, default='active', state='disabled')
    send.grid(column=6, row=11, sticky=E, pady=20, padx=(2, 20))

    close = ttk.Button(c, text='Back', command=back, default='active')
    close.grid(column=5, row=11, sticky=S + E, pady=20, padx=2)

    lbox.bind('<<ListboxSelect>>', active_next)

    if info['bloggers']:
        for blogger in info['bloggers']:
            i = bloggers().index(blogger)
            lbox.selection_set(i)
        active_next()

    for i in range(len(bloggers()), 2):
        lbox.itemconfigure(i, background='#f0f0ff')

    c.grid_columnconfigure(0, weight=1)
    c.grid_rowconfigure(5, weight=1)

    root.title('2/5 Select bloggers')
    root.geometry('680x550+300+40')
开发者ID:glebanatalia,项目名称:natappy,代码行数:84,代码来源:natappy_gui.py

示例2: __init__

# 需要导入模块: from tkinter import Listbox [as 别名]
# 或者: from tkinter.Listbox import itemconfigure [as 别名]

#.........这里部分代码省略.........
        ext.grid(column=2, row=1, columnspan=2, sticky=W)

        # dictionary for check boxes and associated error term
        self.msg_type_dict = {
            "I": lambda: self.information_box.get() == 1,
            "C": lambda: self.convention_box.get() == 1,
            "R": lambda: self.refactor_box.get() == 1,
            "E": lambda: self.error_box.get() == 1,
            "W": lambda: self.warning_box.get() == 1,
            "F": lambda: self.fatal_box.get() == 1,
        }
        self.txtModule.focus_set()

    def select_recent_file(self, event):
        """adds the selected file in the history listbox to the Module box"""
        if not self.showhistory.size():
            return

        selected = self.showhistory.curselection()
        item = self.showhistory.get(selected)
        # update module
        self.txtModule.delete(0, END)
        self.txtModule.insert(0, item)

    def refresh_msg_window(self):
        """refresh the message window with current output"""
        # clear the window
        self.lbMessages.delete(0, END)
        for msg in self.msgs:
            if self.msg_type_dict.get(msg[0])():
                msg_str = self.convert_to_string(msg)
                self.lbMessages.insert(END, msg_str)
                fg_color = COLORS.get(msg_str[:3], "black")
                self.lbMessages.itemconfigure(END, fg=fg_color)

    def refresh_results_window(self):
        """refresh the results window with current output"""
        # clear the window
        self.results.delete(0, END)
        try:
            for res in self.tabs[self.box.get()]:
                self.results.insert(END, res)
        except:
            pass

    def convert_to_string(self, msg):
        """make a string representation of a message"""
        if msg[2] != "":
            return "(" + msg[0] + ") " + msg[1] + "." + msg[2] + " [" + msg[3] + "]: " + msg[4]
        else:
            return "(" + msg[0] + ") " + msg[1] + " [" + msg[3] + "]: " + msg[4]

    def process_incoming(self):
        """process the incoming messages from running pylint"""
        while self.msg_queue.qsize():
            try:
                msg = self.msg_queue.get(0)
                if msg == "DONE":
                    self.report_stream.output_contents()
                    return False

                # adding message to list of msgs
                self.msgs.append(msg)

                # displaying msg if message type is selected in check box
                if self.msg_type_dict.get(msg[0])():
开发者ID:OFFIS-Automation,项目名称:Framework,代码行数:70,代码来源:gui.py


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