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


Python Listbox.selection_get方法代码示例

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


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

示例1: __init__

# 需要导入模块: from tkinter import Listbox [as 别名]
# 或者: from tkinter.Listbox import selection_get [as 别名]
class SpeciesListDialog:
    def __init__(self, parent):
        self.parent = parent
        self.gui = Toplevel(parent.guiRoot)
        self.gui.grab_set()
        self.gui.focus()

        self.gui.columnconfigure(0, weight=1)
        self.gui.rowconfigure(1, weight=1)

        Label(self.gui, text="Registered Species:").grid(row=0, column=0, pady=5, padx=5, sticky="w")
        self.listRegisteredSpecies = Listbox(self.gui, width=70)
        self.buttonAdd = Button(self.gui, text=" + ")
        self.buttonDel = Button(self.gui, text=" - ")
        self.listRegisteredSpecies.grid(row=1, column=0, columnspan=3, sticky="nswe", pady=5, padx=5)
        self.buttonAdd.grid(row=2, column=1, pady=5, padx=5)
        self.buttonDel.grid(row=2, column=2, pady=5, padx=5)

        # Set (minimum + max) Window size
        self.gui.update()
        self.gui.minsize(self.gui.winfo_width(), self.gui.winfo_height())
        #         self.gui.maxsize(self.gui.winfo_width(), self.gui.winfo_height())

        self.actionUpdate(None)
        self.gui.bind("<<Update>>", self.actionUpdate)
        self.gui.protocol("WM_DELETE_WINDOW", self.actionClose)

        self.buttonDel.bind("<ButtonRelease>", self.actionDel)
        self.buttonAdd.bind("<ButtonRelease>", self.actionAdd)

        self.gui.mainloop()

    def actionClose(self):
        self.parent.guiRoot.event_generate("<<Update>>", when="tail")
        self.gui.destroy()

    def actionUpdate(self, event):
        self.listRegisteredSpecies.delete(0, "end")
        for (taxid, name) in self.parent.optimizer.speciesList:
            self.listRegisteredSpecies.insert("end", taxid + ": " + name)

    def actionDel(self, event):
        try:
            selection = self.listRegisteredSpecies.selection_get()
            selectionSplit = selection.split(": ")
            self.parent.optimizer.speciesList.remove((selectionSplit[0], selectionSplit[1]))
            self.gui.event_generate("<<Update>>")
        except tkinter.TclError:
            # no selection
            pass

    def actionAdd(self, Event):
        SpeciesSearchDialog(self.parent, self)
开发者ID:hoerldavid,项目名称:codonoptimizer,代码行数:55,代码来源:OptimizerMainWindow.py

示例2: reactToClick

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

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

            # red for codons with restriction sites
            (r, g, b) = colorsys.hsv_to_rgb(5 / 360, i / 100, 1.0)
            colorHex = "#%02x%02x%02x" % (int(r * 255), int(g * 255), int(b * 255))

            self.textSourceSeq.tag_config("restrict" + str(i), background=colorHex)
            self.textResultSequence.tag_config("restrict" + str(i), background=colorHex)

        # Set (minimum + max) Window size
        self.guiRoot.update()
        self.guiRoot.minsize(self.guiRoot.winfo_width(), self.guiRoot.winfo_height())

        self.buttonRestricionAdd.bind("<ButtonRelease>", self.reactToClick)
        self.buttonRestricionDel.bind("<ButtonRelease>", self.actionRestrictionEnzymeDelete)
        self.buttonSpeciesList.bind("<ButtonRelease>", self.actionEditSpeciesButton)

        self.buttonSourceLoad.bind("<ButtonRelease>", self.actionLoadSequence)
        self.buttonSaveResult.bind("<ButtonRelease>", self.actionSaveSequence)

        # TEST
        #         self.listRestriction.insert("end", "EcoRI")
        #         self.listRestriction.insert("end", "BamHI")
        #

        # dummy event to manually trigger update
        self.guiRoot.bind("<<Update>>", self.actionUpdate)

        self.actionUpdate(None)

        self.guiRoot.mainloop()

    def actionRestrictionEnzymeDelete(self, event):
        try:
            selectedEnzyme = self.listRestriction.selection_get()
            self.optimizer.restrictionEnzymeList.remove(selectedEnzyme)
            self.guiRoot.event_generate("<<Update>>")
        except tkinter.TclError:
            # no selection
            pass

    def actionUpdate(self, event):
        #         print("update called")

        # clear list of restriction enzymes
        self.listRestriction.delete(0, "end")
        for r in self.optimizer.restrictionEnzymeList:
            self.listRestriction.insert("end", r)

        self.comboSourceSpecies.delete(0, "end")
        self.comboTargetSpecies.delete(0, "end")

        speciesValues = list()
        for (taxid, name) in self.optimizer.speciesList:
            speciesValues.append(taxid + ": " + name)

        self.comboSourceSpecies["values"] = speciesValues
        self.comboTargetSpecies["values"] = speciesValues

        if self.comboSourceSpecies.get() not in speciesValues:
            self.comboSourceSpecies.set("")
        if self.comboTargetSpecies.get() not in speciesValues:
            self.comboTargetSpecies.set("")

        self.textSourceSeq.edit_modified(True)
        self.textResultSequence.edit_modified(True)
开发者ID:hoerldavid,项目名称:codonoptimizer,代码行数:69,代码来源:OptimizerMainWindow.py

示例3: ChatGUI

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

#.........这里部分代码省略.........
            #print(m.group(0))
            #print(str(m.start(0)) + "_" + str(m.end(0)))
            #print("COUNTER")
            #print(str(self.lineCounter) + "." + str(m.start(0)+1) + "___" + str(self.lineCounter) + "." + str(m.end(0)))
            self.box.tag_add("header", str(self.lineCounter) + "." + str(m.start(0)), str(self.lineCounter) + "." + str(m.end(0)))
            self.box.tag_config("header", font=self.customFontHeader, foreground = "blue")
        
        
        self.box.config(state=DISABLED)
        #self.box.yview_scroll(10000,"units")
        self.box.see(END)

    
    def sendToServer(self, messageToSend):
        self.conn.send(messageToSend.encode(encoding='utf_8', errors='strict'))
    
    def sendFile(self):
        #aprire una dialog di quelle predefinite (Sfoglia...)
        #capire come fare la send di un file sul socket...
        pass
    def updateUsersFrame(self):
        
        global connectedClients
    
        self.userListbox.delete(0, END)
                    
        self.userListbox.insert(END, "Connected users")
        for item in connectedClients:
            self.userListbox.insert(END, item)
        #self.userListbox.update()
        #self.usersFrame.update()
    def privateChat(self, e):
        global conversationBoxList
        userselected = self.userListbox.selection_get()
        if not userselected == "Connected users":
            print("EVVAI CHAT PRIVATA con "+userselected)
            
            newWindow = Toplevel(self.parent)
            newWindow.title("Python Chat with "+userselected)
            newWindow.minsize(400, 475)
            newWindow.focus()
            
            def disconnectPM():
                del conversationBoxList[userselected]
                newWindow.destroy()
            newWindow.protocol('WM_DELETE_WINDOW', disconnectPM)
            
            #label = Label(newWindow, text="PROVA PROVA")
            #label.pack(side="top", fill="both", padx=10, pady=10)
            frame = Frame(newWindow)
            frame.pack(fill=BOTH, expand=1, side=LEFT)
            
            box = ScrolledText(frame, wrap=WORD, relief = GROOVE, width=30, height=18, font=self.customFontMessage)
            box.config(state=DISABLED)
            box.pack(expand="yes", fill=BOTH, side=TOP)
            
            textarea = Text(frame, width=30, height=5)
            textarea.bind("<KeyRelease-Return>", lambda event : self.getprivatetext(event, textarea, userselected)) 
            textarea.pack(expand="yes", fill=BOTH, side=TOP)
            
            #aggiungo alla mappa globale il box di conversazione
            conversationBoxList[userselected] = box
            

    def receivePrivateChat(self, connectingUser):
        global conversationBoxList
开发者ID:skimdz86,项目名称:Utilities,代码行数:70,代码来源:BlinkingChatGUIMultiClient.py


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