Python Forum
POPUP on widget Entry
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
POPUP on widget Entry
#1
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
Reply
#2
please post entire unaltered error trace, also please use error tags (see: BBCode ).
your posting seems to be missing information.
Reply
#3
hello everyone no one has an idea help solve the problem?
thank you in davance for your time
Reply
#4
Please, Need to see the error trace.
Reply
#5
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  ValueError: could not convert string to float: '' fron Entry Widget russellm44 5 497 Mar-06-2024, 08:42 PM
Last Post: russellm44
  [Tkinter] entry widget DPaul 5 1,433 Jul-28-2023, 02:31 PM
Last Post: deanhystad
  [PyQt] Hover over highlighted text and open popup window DrakeSoft 2 1,448 Oct-29-2022, 04:30 PM
Last Post: DrakeSoft
  Tkinter Exit Code based on Entry Widget Nu2Python 6 2,876 Oct-21-2021, 03:01 PM
Last Post: Nu2Python
  method to add entries in multi columns entry frames in self widget sudeshna24 2 2,214 Feb-19-2021, 05:24 PM
Last Post: BashBedlam
  Entry Widget issue PA3040 16 6,657 Jan-20-2021, 02:21 PM
Last Post: pitterbrayn
  [Tkinter] password with Entry widget TAREKYANGUI 9 5,775 Sep-24-2020, 05:27 PM
Last Post: TAREKYANGUI
  [Tkinter] Get the last entry in my text widget Pedroski55 3 6,295 Jul-13-2020, 10:34 PM
Last Post: Pedroski55
  How to retreive the grid location of an Entry widget kenwatts275 7 4,478 Apr-24-2020, 11:39 PM
Last Post: Larz60+
  Transfer Toplevel window entry to root window entry with TKinter HBH 0 4,422 Jan-23-2020, 09:00 PM
Last Post: HBH

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020