1

i was wondering whether the entery text from within tkinter can take more than one function? if not is there any other way of doing it?

Here is my code:

        self.UI_lbl = tk.Label(self, text="Choose Piece: ")
        self.UI_lbl.grid(row=1, column=0, sticky="e")
        self.UI_entry1 = tk.Entry(self)
        self.UI_entry1.grid(row=1, column=1, sticky="w")

        self.UI_lbl = tk.Label(self, text="Choose Row: ")
        self.UI_lbl.grid(row=2, column=0, sticky="e")
        self.UI_entry2 = tk.Entry(self)
        self.UI_entry2.grid(row=2, column=1, sticky="w")

        self.UI_lbl2 = tk.Label(self, text="Choose Column: ")
        self.UI_lbl2.grid(row=3, column=0, sticky="e")
        self.UI_entry3 = tk.Entry(self)
        self.UI_entry3.grid(row=3, column=1, sticky="w")

        self.UI_lbl = tk.Label(self, text="Move Row: ")
        self.UI_lbl.grid(row=4, column=0, sticky="e")
        self.UI_entry4 = tk.Entry(self)
        self.UI_entry4.grid(row=4, column=1, sticky="w")

        self.UI_lbl2 = tk.Label(self, text="Move Column: ")
        self.UI_lbl2.grid(row=5, column=0, sticky="e")
        self.UI_entry5 = tk.Entry(self)
        self.UI_entry5.grid(row=5, column=1, sticky="w")

        self.UI_entry1.bind("<Return>", self.Player1)
        self.UI_entry2.bind("<Return>", self.Player1)
        self.UI_entry3.bind("<Return>", self.Player1)
        self.UI_entry4.bind("<Return>", self.Player1)
        self.UI_entry5.bind("<Return>", self.Player1)

i would like to use these entries in mutiple functioins but currently have one big one as i cannot assign multiple parameters, how would i be able to fix this?

HAHAHAHAHA
  • 25
  • 6
  • `bind` takes one function; that function can call as many other functions as you want. You mention that you want to assign multiple parameters -- what parameters are you wanting to assign? And what does `self.Player1` do? – Bryan Oakley Apr 11 '18 at 22:55
  • I am creating a chess game, i would basically like to clean up my code and make it easier to read by adding more functions which can use all these entries. Right now self.Player1 is my main function where all the pieces moves are made. – HAHAHAHAHA Apr 12 '18 at 00:35
  • so how would i be able to use the bind function to call multiple other functions? – HAHAHAHAHA Apr 12 '18 at 05:21
  • Call one function. Have that function call as many functions as you want. – Bryan Oakley Apr 12 '18 at 11:39

0 Answers0