_tkinter.TclError: can't pack when trying to add ttkcalendar into tkinter GUI

Milano

I'm trying to add a ttk calendar into my Tkinter GUI. The problem is that it raises _tkinter.TclError: can't pack .34164128 inside .34161248.34161448.34161608

import Tkinter
import tkSimpleDialog

import ttkcalendar


class CalendarDialog(tkSimpleDialog.Dialog):
    """Dialog box that displays a calendar and returns the selected date"""

    def body(self, master):
        self.calendar = ttkcalendar.Calendar(master)
        self.calendar.pack()

    def apply(self):
        self.result = self.calendar.selection


# Demo code:
def main():
    root = Tkinter.Tk()
    root.wm_title("CalendarDialog Demo")

    def onclick():
        print 'click'

    cd = CalendarDialog(root)
    button = Tkinter.Button(root, text="Click me to see a calendar!", command=onclick)
    button.pack()
    root.update()

    root.mainloop()


if __name__ == "__main__":
    main()


TRACEBACK:
  File "C:/Users/Milano/PycharmProjects/MC/plots/ds.py", line 32, in <module>
    main()
  File "C:/Users/Milano/PycharmProjects/MC/plots/ds.py", line 23, in main
    cd = CalendarDialog(root)
  File "C:\Python27\lib\lib-tk\tkSimpleDialog.py", line 64, in __init__
    self.initial_focus = self.body(body)
  File "C:/Users/Milano/PycharmProjects/MC/plots/ds.py", line 9, in body
    self.calendar = ttkcalendar.Calendar(master)
  File "C:\Users\Milano\PycharmProjects\MC\plots\ttkcalendar.py", line 52, in __init__
    self.__place_widgets()      # pack/grid used widgets
  File "C:\Users\Milano\PycharmProjects\MC\plots\ttkcalendar.py", line 110, in __place_widgets
    self._calendar.pack(in_=self, expand=1, fill='both', side='bottom')
  File "C:\Python27\lib\lib-tk\Tkinter.py", line 1940, in pack_configure
    + self._options(cnf, kw))
_tkinter.TclError: can't pack .34164128 inside .34161248.34161448.34161608

Do you know where is the problem?

TheRandomGuy

The fault is that you don't have an __init__ method in the class CalendarDialog. So just rename the body method to __init__. Now you have initialized the instance every time one is made and a pack() method is defined.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

_tkinter TclError: can't find package Tix

From Dev

_tkinter TclError: can't find package Tix

From Dev

_tkinter.TclError: can't find package Tktable

From Dev

_tkinter.TclError: can't find package Tktable

From Dev

"_tkinter.TclError: bad screen distance" in python's tkinter when trying to modify object coordinates with Canvas.coords()

From Dev

Tkinter, using pack: can't keep footer bar at bottom

From Dev

Error: _tkinter.TclError: can't invoke "wm" command: application has been destroyed

From Dev

Retrieve Tkinter Checkbutton Status : TclError: can't read "PY_VAR": no such variable

From Dev

tkinter OptionMenu in combination with trace throws "TclError: No more menus can be allocated"

From Dev

_tkinter.TclError: when I click on an item from the listbox

From Dev

tkinter.TclError: image "pyimage3" doesn't exist

From Dev

tkinter.TclError: couldn't connect to display "localhost:18.0"

From Dev

docker _tkinter.TclError: couldn't connect to display

From Dev

Custom Tkinter Widget Won't Pack in Toplevel?

From Dev

tkinter can't add photo in class that not include mainloop

From Dev

Tkinter .pack layout understanding

From Dev

How can change the logo of Tkinter GUI screen

From Dev

can't background color in tkinter

From Dev

tkinter: label not displayed when pack() is called outside of a class' init function

From Dev

Why won't my frame pack python3 tkinter

From Dev

Python Tkinter .jpeg Image not displaying -- TclError

From Dev

"tkinter TclError: bad file type" using askopenfilename

From Dev

Python Tkinter .jpeg Image not displaying -- TclError

From Dev

_tkinter.TclError: format error in bitmap data

From Java

_tkinter.TclError: Item 1 already exists with tkinter treeview

From Dev

How to fix "_tkinter.TclError: couldn't open "Island1.png": no such file or directory" error?

From Dev

Tkinter: grid or pack inside a grid?

From Dev

How to pack properly in this Tkinter script?

From Dev

Tkinter pack() geometry manager confusion

Related Related

  1. 1

    _tkinter TclError: can't find package Tix

  2. 2

    _tkinter TclError: can't find package Tix

  3. 3

    _tkinter.TclError: can't find package Tktable

  4. 4

    _tkinter.TclError: can't find package Tktable

  5. 5

    "_tkinter.TclError: bad screen distance" in python's tkinter when trying to modify object coordinates with Canvas.coords()

  6. 6

    Tkinter, using pack: can't keep footer bar at bottom

  7. 7

    Error: _tkinter.TclError: can't invoke "wm" command: application has been destroyed

  8. 8

    Retrieve Tkinter Checkbutton Status : TclError: can't read "PY_VAR": no such variable

  9. 9

    tkinter OptionMenu in combination with trace throws "TclError: No more menus can be allocated"

  10. 10

    _tkinter.TclError: when I click on an item from the listbox

  11. 11

    tkinter.TclError: image "pyimage3" doesn't exist

  12. 12

    tkinter.TclError: couldn't connect to display "localhost:18.0"

  13. 13

    docker _tkinter.TclError: couldn't connect to display

  14. 14

    Custom Tkinter Widget Won't Pack in Toplevel?

  15. 15

    tkinter can't add photo in class that not include mainloop

  16. 16

    Tkinter .pack layout understanding

  17. 17

    How can change the logo of Tkinter GUI screen

  18. 18

    can't background color in tkinter

  19. 19

    tkinter: label not displayed when pack() is called outside of a class' init function

  20. 20

    Why won't my frame pack python3 tkinter

  21. 21

    Python Tkinter .jpeg Image not displaying -- TclError

  22. 22

    "tkinter TclError: bad file type" using askopenfilename

  23. 23

    Python Tkinter .jpeg Image not displaying -- TclError

  24. 24

    _tkinter.TclError: format error in bitmap data

  25. 25

    _tkinter.TclError: Item 1 already exists with tkinter treeview

  26. 26

    How to fix "_tkinter.TclError: couldn't open "Island1.png": no such file or directory" error?

  27. 27

    Tkinter: grid or pack inside a grid?

  28. 28

    How to pack properly in this Tkinter script?

  29. 29

    Tkinter pack() geometry manager confusion

HotTag

Archive