Bottom Page

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
Quote
#2
please post entire unaltered error trace, also please use error tags (see: BBCode ).
your posting seems to be missing information.
Quote
#3
hello everyone no one has an idea help solve the problem?
thank you in davance for your time
Quote
#4
Please, Need to see the error trace.
Quote
#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
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  How to retreive the grid location of an Entry widget kenwatts275 7 190 Apr-24-2020, 11:39 PM
Last Post: Larz60+
  Entry Widget issue PA3040 13 508 Mar-06-2020, 10:24 AM
Last Post: Larz60+
  Transfer Toplevel window entry to root window entry with TKinter HBH 0 1,032 Jan-23-2020, 09:00 PM
Last Post: HBH
  The coordinates of the Entry widget (canvas) when moving berckut72 8 535 Jan-07-2020, 09:26 AM
Last Post: berckut72
  [Tkinter] Entry widget to variable Zeiphar 4 554 Sep-21-2019, 05:41 AM
Last Post: Zeiphar
  [Tkinter] Inserting numbers into entry box in a widget richard13 1 969 Aug-11-2019, 11:37 AM
Last Post: Yoriz
  [PyQt] Collect entry from textline Widget via UI file mart79 3 508 Aug-05-2019, 01:40 PM
Last Post: Denni
  [Tkinter] how to get the entry information using Entry.get() ? SamyPyth 2 992 Mar-18-2019, 05:36 PM
Last Post: woooee
  Update plot by <Return> bind with entry widget Zorro 1 1,000 Mar-09-2019, 12:27 PM
Last Post: Zorro
  [Tkinter] Tkinter Entry widget and KeyPad intrgration chiragarya1992 0 2,206 Aug-11-2018, 01:09 AM
Last Post: chiragarya1992

Forum Jump:


Users browsing this thread: 1 Guest(s)