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


Python Listbox.itemconfig方法代码示例

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


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

示例1: ListboxVidget

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

#.........这里部分代码省略.........
        # If the index is valid or is -1.

        # If the listbox is not enabled
        if not self.is_enabled():
            # Raise error
            raise ListboxVidget.DisabledError()

        # If the listbox is enabled.

        # If the listbox is changing
        if self._is_changing:
            # Raise error
            raise ListboxVidget.CircularCallError()

        # If the listbox is not changing.

        # Set changing flag on
        self._is_changing = True

        # Get old active index
        old_indexcur = self._indexcur

        # Set resetting flag on if new and old indexes are equal
        self._is_resetting = (index == old_indexcur)

        # If notify events
        if notify:
            # Notify pre-change event
            self.handler_notify(self.ITEMCUR_CHANGE_SOON, notify_arg)

        # If old active index is valid
        if self.index_is_valid(old_indexcur):
            # Set old active item's background color to normal color
            self._listbox.itemconfig(old_indexcur, background=self._normal_bg)

            # Set old active item's foreground color to normal color
            self._listbox.itemconfig(old_indexcur, foreground=self._normal_fg)

        # Cache new active index
        self._indexcur = index

        # Clear listbox widget's selection
        self._listbox.selection_clear(0, END)

        # Set listbox widget's selection
        self._listbox.selection_set(index)

        # Set listbox widget's activated index
        self._listbox.activate(index)

        # If new active index is valid
        if index != -1:
            # Set new active item's background color to active color
            self._listbox.itemconfig(index, background=self._active_bg)

            # Set new active item's foreground color to active color
            self._listbox.itemconfig(index, foreground=self._active_fg)

        # If set focus
        if focus:
            # Set focus on the listbox widget
            self._listbox.focus_set()

        # If new active index is valid
        if index != -1:
            # Make the active item visible
开发者ID:AoiKuiyuyou,项目名称:AoikRegistryEditor,代码行数:70,代码来源:listbox.py

示例2: Example

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

#.........这里部分代码省略.........
        # config-scrollbar
        self.scrollbar.config(command=self.yview)
        self.scrollbar2["command"] = self.listboxLogs.yview

        # bindeos de acciones
        self.listbox.bind("<<ListboxSelect>>", self.onSelect)
        self.listbox.bind("<MouseWheel>", self.onTest)
        self.listbox2.bind("<<ListboxSelect>>", self.onSelect)
        self.listbox2.bind("<MouseWheel>", self.onTest)
        self.listbox3.bind("<<ListboxSelect>>", self.onSelect)
        self.listbox3.bind("<MouseWheel>", self.onTest)
        self.listbox4.bind("<<ListboxSelect>>", self.onSelect)
        self.listbox4.bind("<MouseWheel>", self.onTest)
        self.listbox5.bind("<<ListboxSelect>>", self.onSelect)
        self.listbox5.bind("<MouseWheel>", self.onTest)
        self.listboxLogs.bind("<<ListboxSelect>>", self.onSelectPlayer)

    # mostrar la barra de scroll
    def yview(self, *args):
        self.listbox.yview(*args)
        self.listbox2.yview(*args)
        self.listbox3.yview(*args)
        self.listbox4.yview(*args)
        self.listbox5.yview(*args)

    # accion de la rueda del raton
    def onTest(self, val):
        return "break"

    # seleccionar un elementos de una listbox
    def onSelect(self, val):
        try:
            if self.ant != None:
                self.listbox.itemconfig(self.ant, background="#FFFFFF")
                self.listbox2.itemconfig(self.ant, background="#FFFFFF")
                self.listbox3.itemconfig(self.ant, background="#FFFFFF")
                self.listbox4.itemconfig(self.ant, background="#FFFFFF")
                self.listbox5.itemconfig(self.ant, background="#FFFFFF")
            self.listbox.itemconfig(val.widget.curselection(), background="#C0C0C0")
            self.listbox2.itemconfig(val.widget.curselection(), background="#C0C0C0")
            self.listbox3.itemconfig(val.widget.curselection(), background="#C0C0C0")
            self.listbox4.itemconfig(val.widget.curselection(), background="#C0C0C0")
            self.listbox5.itemconfig(val.widget.curselection(), background="#C0C0C0")

            self.ant = val.widget.curselection()
        except:
            None
            # print('No hay valores')

    # dependiendo de que nombre se elija en el menu cargamos en lastLine la linea de ese nombre del diccionario
    def onSelectPlayer(self, val):
        try:
            self.name = val.widget.get(val.widget.curselection())
            self.lastLine = optionsDictionary[self.name]
            # print(self.name, ' ', self.lastLine)
        except:
            None
            # print('No hay valores')

    # recorremos el fichero log al clickar sobre el boton 'Refresh!'
    def onRefresh(self):
        if self.name != "":
            yes = False
            count = 0
            dictionary = {}
            dictionaryAuxiliar = {}
开发者ID:Ealdor,项目名称:EQGuildViewer,代码行数:70,代码来源:GuildViewer.py


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