Python Forum

Full Version: POPUP on widget Entry
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi everyone,

I made a script in python version 3.7, to test the context menu on the Entry widget via the right mouse button. The command is "Paste". I get this error message:

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\master\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 1705, in __call__
    return self.func(*args)
  File "C:/!TEST!/!/Projet/Sample_[OK]_V1k - test.py", line 122, in <lambda>
    Input1.bind("<3>", lambda event, obj=Input1: onClick_Dtr(event, obj))
  File "C:/!TEST!/!/Projet/Sample_[OK]_V1k - test.py", line 94, in onClick_Dtr
    MenuContextuel.tk_popup(event.x_root, event.y_root, 0)
  File "C:\Users\master\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 2871, in tk_popup
    self.tk.call('tk_popup', self._w, x, y, entry)
_tkinter.TclError: unknown option "-state"
here is the script test :
#!usrbinpython3
# -- coding utf-8 --
# coding: utf8

import youtube_dl
from tkinter import *
from tkinter import ttk
from tkinter import filedialog
from PIL import Image, ImageTk, ImageSequence               # Animation GIF
import time
from time import sleep


class Root(Tk):
    def __init__(self):
        super(Root, self).__init__()
        self.title("Embedding yt-dl [GUI]")
        # self.wm_iconbitmap('icon.ico')
        self.geometry("600x120+10+10")
        self.resizable(width=False, height=False)

##############################################################################
# Remonte les messages de mise au point (log). C'est nécessaire au moins pour les "vraies" erreurs.
# Rien n'empêche de créer un fichier log avec l'écriture de tous les messages pour garder une trace de ce qui s'est passé.

# Enregistreur
class MyLogger(object):

    def debug(self, msg):
        pass
    def warning(self, msg):
        pass
    def error(self, msg):
        print(msg)
    def info(self, msg):
        print(msg)



# ------------   Début - Menu Contextuel ---------------
def onClick_Dtr(event, obj):
    obj.delete(0, END)
    # display the popup menu
    try:
        MenuContextuel.tk_popup(event.x_root, event.y_root, 0)
    finally:
        # make sure to release the grab (Tk 8.0a1 only)
        print("---")
        MenuContextuel.grab_release()

def Paste():
    Input1.event_generate('<<Paste>>')
# ------------   Fin - Menu Contextuel ---------------

root = Root()
var_URL = StringVar()                                       # Widget - Entry URL

Input1 = Entry(bd=2, justify=CENTER, textvariable=var_URL)
Input1.place(x=5, y=55, width=590, height=22)

# Création du menu contextuel
MenuContextuel = Menu(root, tearoff=0)
MenuContextuel.add_separator()
MenuContextuel.add_command(label="Coller     ", command=Paste)
MenuContextuel.add_separator()
# Affiche le menu contextuel
root.config(menu=MenuContextuel)

# menu Contextuel Bouton Dtr. Souris sur Input1
Input1.bind("<3>", lambda event, obj=Input1: onClick_Dtr(event, obj))

root.mainloop()
I skim the internet without success. This case is beyond my competence.
Do you have a solution? thank you for your time
please post entire unaltered error trace, also please use error tags (see: BBCode ).
your posting seems to be missing information.
hello everyone no one has an idea help solve the problem?
thank you in davance for your time
Please, Need to see the error trace.
you mean about that?
Error:
Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\master\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 1705, in __call__ return self.func(*args) File "C:/!TEST!/!/Projet/Sample_[OK]_V1k - test.py", line 122, in <lambda> Input1.bind("<3>", lambda event, obj=Input1: onClick_Dtr(event, obj)) File "C:/!TEST!/!/Projet/Sample_[OK]_V1k - test.py", line 94, in onClick_Dtr MenuContextuel.tk_popup(event.x_root, event.y_root, 0) File "C:\Users\master\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 2871, in tk_popup self.tk.call('tk_popup', self._w, x, y, entry) _tkinter.TclError: unknown option "-state
or about these too link
Error traceback_1
Error traceback_2