#๐Ÿ”’ I don't understand the use of "display"

5 messages ยท Page 1 of 1 (latest)

outer rain
#
import tkinter as tk

def winfo_cont():
    display = v.get()
    if display == "no arg": display = 0
    x, y = spinx.get(), spiny.get()
    w = root.winfo_containing(x, y, display)
    resultat.configure(text=w)
    patron = "winfo_containin({}, {}, {}) --> {}"
    print(patron.format(x, y, repr(display), w))

def pointeur(event):
    x, y = root.winfo_pointerxy()
    labelx.configure(text=str(x))
    labely.configure(text = str(y))

root = tk.Tk()
root.bind("<Motion>", pointeur)
WIDTH = root.winfo_screenmmwidth()
HEIGHT = root.winfo_screenheight()
label = tk.Label(master=root, text="Label titre", bg="yellow", name="label")
label.grid(row=1, column=1, columnspan=3, sticky="EW")
frame = tk.Frame(master=root, bg="red", width=250, height=250, name="cadre")
frame.grid(row=2, column=1, columnspan=3, sticky="EW")
frame.grid_propagate(False)
b1 = tk.Button(frame, text="B1", name="bouton1")
b1.grid(row=1, column=1)
b2 = tk.Button(master=frame, text="B2", name="bouton2")
b2.grid(row=1, column=3)
b3 = tk.Button(frame, text="B3", name="bouton3")
b3.grid(row=2, column=2)
spinx = tk.Spinbox(root, from_=0, to=WIDTH, increment=100, width=4)
spinx.grid(row=3, column=1)
spiny = tk.Spinbox(root, from_=0, to=HEIGHT, increment=100, width=4)
spiny.grid(row=3, column=2)
bouton = tk.Button(root, text="TEST", command=winfo_cont)
bouton.grid(row=3, column=3)
labelx = tk.Label(master=root, text="****", bg="yellow", width=4)
labelx.grid(row=4, column=1)
labely = tk.Label(root, text="****", bg="yellow", width=4)
labely.grid(row=4, column=2)
resultat = tk.Label(root, text="****", bg="yellow", width=4)
resultat.grid(row=4, column=3)
liste = [label, frame, b1, b2, b3]
liste = [str(k) for k in liste]
liste.extend([".", "no arg"])
v = tk.StringVar(root, liste[0])
optionmenu = tk.OptionMenu(root, v, *liste)
optionmenu.grid(row=5, column=1, columnspan=3, sticky="EW")

root.mainloop()

karmic mortarBOT
#

@outer rain

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

wispy creek
karmic mortarBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.