question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

messagebox error: AttributeError: 'str' object has no attribute 'invoke'

See original GitHub issue

Desktop (please complete the following information):

ttkbootstrap Version [1.8.0] --> pip3 install ttkbootstrap-master.zip OS: Linux Mint Cinnamon x64 X11

Describe the bug

When pressing the Enter button in a message box, it displays error:

~/.local/lib/python3.8/site-packages/ttkbootstrap/window.py", line 45, in <lambda> window.bind_class(“TButton”, “<Key-Return>”, lambda event: event.widget.invoke()) AttributeError: ‘str’ object has no attribute ‘invoke’

To Reproduce

import tkinter as tk
import ttkbootstrap as ttk
from ttkbootstrap.constants import *
from tkinter import messagebox as msg

root = ttk.Window()

def show_msg():
    msg.showwarning('Warning', 'Test!', parent=root)
    return

b1 = ttk.Button(root, text="Button 1", bootstyle=SUCCESS, command=show_msg)
b1.pack(side=LEFT, padx=5, pady=10)

root.mainloop()

Using the code above,

  1. Click on the Button 1 button
  2. a message will be displayed on the screen
  3. I press the “Enter” key (Return) and the error occurs.

Expected behavior

Pressing Enter should close the message box without displaying an error.

And as soon as you have time, if possible, also ‘bind’ the <KP_Enter> key in the same event on the <Return> screen for that event

Screenshots

No response

Additional context

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
israel-dryercommented, Jul 13, 2022

@antrrax, sorry, forgot to push the change to that branch. It should be there now.

1reaction
israel-dryercommented, Jul 12, 2022

@antrrax, I setup a Linux VM and tested it there. The messagebox you are using has an embedded Tcl/Tk button. So, what I did was called the invoke command on the Tcl/Tk widget directly when there is not an associated Python object. This should work for any embedded button that is not represented by a Python object. Try installing this again and see if it works on your distro:

python -m pip install --upgrade git+https://github.com/israel-dryer/ttkbootstrap.git@fix_default_enter_button_key_binding
Read more comments on GitHub >

github_iconTop Results From Across the Web

class - Python - str' object has no attribute 'studentsinTeam'
When I try to do this, it produces AttributeError: 'str' object has no attribute 'studentsinTeam'. Im not entirely sure how to fix this....
Read more >
AttributeError: 'str' object has no attribute 'pre' #160 - GitHub
I want to lint my Python code, using invoke to call the individual lint programs. Instead of running the programs, invoke throws an...
Read more >
AttributeError: 'str' object has no attribute 'fetch' - Python Help
I'm trying to get working the python code at the following website: After several days I'm still not able to succeed since it...
Read more >
AttributeError: 'str' object has no attribute 'send' : r/learnpython
Im trying to get text from a entry in tkinter and send it to the server but it keeps doing this.
Read more >
QMessageBox — Qt for Python - Qt Documentation
Constructs a message box with no text and no buttons. parent is passed to the QDialog constructor. On macOS, if you want your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found