0
votes

I have this error in my code that I have searched online for answers for but have no clue how to fix. Not sure why I got a line 2000+ error when my code is only 165 lines long?

This is the error:

Traceback (most recent call last): File "/Applications/Wing101.app/Contents/Resources/src/debug/tserver/_sandbox.py", line 156, in File "/Applications/Wing101.app/Contents/Resources/src/debug/tserver/_sandbox.py", line 80, in init File "/Applications/Wing101.app/Contents/Resources/src/debug/tserver/_sandbox.py", line 38, in init File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 2591, in init Widget.init(self, master, 'label', cnf, kw) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 2090, in init (widgetName, self._w) + extra + self._options(cnf)) _tkinter.TclError: unknown option "-container"

Could anyone shed some light on whats going on?

EDIT 1: (this is my code)

from Tkinter import *
from Tkinter import Menu
import Tkinter as tk
import tkFont as tkfont
import os

class master(tk.Frame):
    def __init__(self, *args, **kwargs):
        tk.Frame.__init__(self, *args, **kwargs)
    def show(self):
        self.lift()

class DisplayPage(master):
    def __init__(self, *args, **kwargs):
        master.__init__(self, *args, **kwargs)
        # create all of the main containers

        frame_F = Frame(self, width=930, height=780)
        frame_G = Frame(self, width=465, height=170)
        frame_H = Frame(self, width=465, height=170)
        frame_I = Frame(self, width=465, height=170)
        frame_J = Frame(self, width=465, height=170)
        frame_K = Frame(self, width=465, height=85)

        # layout all of the main containers

        frame_F.grid(row=0, column=0, columnspan=2, rowspan=4)
        frame_G.grid(row=0, column=3)
        frame_H.grid(row=1, column=3)
        frame_I.grid(row=2, column=3)
        frame_J.grid(row=3, column=3)
        frame_K.grid(row=4, column=3)

        # create widget 1

        contentA = Frame(self, frame_G)

        namelbl5 = Label(self, contentA, text='Chosen Destination:', font =('Roboto Thin', 30), )

        # create widget 2

        contentB = Frame(self, frame_H)

        namelbl6 = Label(self, contentB, text='Distance From Destination:', font =('Roboto Thin', 30), )

        # create widget 3

        contentC = Frame(self, frame_I)

        namelbl7 = Label(self, contentC, text='Available Parking Spaces:', font=('Roboto Thin', 30), )

        # create widget 4

        contentD = Frame(self, frame_J)
        namelbl8 = Label(self, contentD, text='Price Per Hour:', font =('Roboto Thin', 30), )

        # next ok button

        contentE= Frame(self, frame_K)
        back = Button(self, contentE, text='Back', font =('Roboto Thin', 30))
        back.pack()

        # layout all widgets

        contentA.grid(column=0, row=0)
        contentB.grid(column=3, row=1)
        contentC.grid(column=3, row=2)
        contentD.grid(column=3, row=3)
        contentE.grid(column=3, row=4)

        namelbl5.grid(column=3, row=1)
        namelbl6.grid(column=3, row=3)
        namelbl7.grid(column=3, row=5)
        namelbl8.grid(column=3, row=7)
        back.grid(column=3, row=9)

class MainPage(tk.Frame):
    def __init__(self, *args, **kwargs):
        tk.Frame.__init__(self, *args, **kwargs)
        p1 = DisplayPage(self)        

# create all of the main containers 
        frame_A = Frame(self, width=930, height=780)
        frame_B = Frame(self, width=465, height=280)
        frame_C = Frame(self, width=465, height=280)
        frame_D = Frame(self, width=465, height=140)
        frame_E = Frame(self, width=465, height=70)

        # layout all of the main containers

        frame_A.grid(row=0, column=0, columnspan=2, rowspan=3)
        frame_B.grid(row=0, column=3)
        frame_C.grid(row=1, column=3)
        frame_D.grid(row=2, column=3)
        frame_E.grid(row=3, column=3)

        # create widget 1

        content1 = Frame(self, frame_B)

        onevar = BooleanVar()
        twovar = BooleanVar()
        threevar = BooleanVar()
        onevar.set(False)
        twovar.set(False)
        threevar.set(False)

        namelbl = Label(self, content1, text='Filter System', font =('Roboto Thin', 30), )
        one = Checkbutton(self, content1, text='Closest', font =('Roboto Thin', 30), variable=onevar, onvalue=True)
        two = Checkbutton(self, content1, text='Cheapest', font =('Roboto Thin', 30), variable=twovar, onvalue=True)
        three = Checkbutton(self, content1, text='Most Available Space', font =('Roboto Thin', 30), variable=threevar, onvalue=True)

        # create widget 2

        content2 = Frame(self, frame_C)

        namelbl2 = Label(self, content2, text='Starting Location', font =('Roboto Thin', 30), )
        name = Entry(self, content2)
        namelbl3 = Label(self, content2, text='Destination', font=('Roboto Thin', 30), )
        name2 = Entry(self, content2)

        # create widget 3

        content3 = Frame(self, frame_D)

        namelbl4 = Label(self, content3, text='Chosen Car Park', font =('Roboto Thin', 30), )
        name3 = Entry(self, content3)

        # next ok button

        content4= Frame(self, frame_E)
        ok = tk.Button(self, content4, text="Locate",command=p1.lift)
        ok.pack()

        # layout all widgets

        content1.grid(column=0, row=0)
        content2.grid(column=3, row=1)
        content3.grid(column=3, row=2)
        content4.grid(column=3, row=3)

        namelbl.grid(column=3, row=1)
        name.grid(column=3, row=6)
        namelbl2.grid(column=3, row=5)
        name2.grid(column=3, row=8)
        namelbl3.grid(column=3, row=7)
        name3.grid(column=3, row=10)
        one.grid(column=3, row=2)
        two.grid(column=3, row=3)
        three.grid(column=3, row=4)
        ok.grid(column=3, row=11)
        namelbl4.grid(column=3, row=9)                   

if __name__ == "__main__":
    root = tk.Tk()
    main = MainPage(root)
    main.pack(side="top", fill="both", expand=True)
    menu = Menu(root)
    root.config(menu=menu)
    root.wm_title('MobilePark Simulator')
    root.wm_geometry("1300x830")
    new_item = Menu(menu)
    new_item.add_command(label='Save')
    menu.add_cascade(label='File', menu=new_item) 
    root.mainloop()  
1
The error you're talking about is because the root of the error is in one of the libraries your code uses, not in your code itself. Make sure you've upgraded to the latest version of tkinter. Is _sandbox.py the file you're editing? - Green Cloak Guy
If needed I can also add the code however it is extremely long (and I know that it will be a pain for people to sift through) sorry for all the inconvenience caused and thanks for all the help! - Jasper Yip
You should post a minimal verifiable code example, i.e. remove as much unnecessary code as possible until you are left with the smallest version that still displays the error - visibleman
@GreenCloakGuy not sure what _sandbox.py is but my file name is called MobilePark Simulator.py - Jasper Yip
Please try to reduce this code down to a minimal reproducible example. I doubt that you need several dozen frames, labels, and buttons to reproduce this problem. - Bryan Oakley

1 Answers

2
votes

Well, the segment with that large line number is:

File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py",
    line 2090, in init (widgetName, self._w) + extra + self._options(cnf)) _tkinter.TclError:
    unknown option "-container"

That means it's not your code it's complaining about but rather something well down the call stack, in the Tkinter code itself.

Having said that, it's usually because of something you've done incorrectly in your code such as passing an invalid parameter or something like that.

I'm not sure that's the case here since the entire call stack seems to be composed of code that isn't yours. That means it may possibly be an incompatibility between _sandbox.py and Tkinter.

Given that the sandbox appears to belong to Wing101 (an IDE, so is likely to be a sandbox to contain the application while running under the IDE), the first thing I'd do is take that out of the equation by trying to run your code directly from the command line. If it works there, there's almost certainly a problem with your IDE setup. If not, there's something wrong with what your code is doing.


Having done so myself and seen the error remain, I have to ask what you are trying to do with the following:

# create widget 1
contentA = Frame(self, frame_G)
namelbl5 = Label(self, contentA, text='Chosen Destination:', font =('Roboto Thin',30), )

Specifically, the presence of contentA in the label constructor appears to be what's setting the configuration to a large dictionary, one that contains a whole lot of keys unsuited to the widget:

{'bd': 0, 'bg': '#d9d9d9', 'container': 0, 'colormap': '', 'text': 'Chosen Destination:', 'font': ('Roboto Thin', 30), 'height': 170, 'cursor': '', 'width': 465, 'visual': '', 'highlightcolor': '#000000', 'relief': 'flat', 'background': '#d9d9d9', 'padx': <pixel object at 0x1d1ac40>, 'pady': <pixel object at 0x1d1ac70>, 'highlightthickness': 0, 'highlightbackground': '#d9d9d9', 'class': 'Frame', 'takefocus': '0', 'borderwidth': 0}

I would say (from first glance) that you appear to have too many parents in the constructor. In other words, either self or contentX should be the parent, such as with:

namelbl5 = Label(contentA, text='Chosen Destination:', font =('Roboto Thin',30), )

Now whether that's your actual intent or not, I can't be sure but I can guarantee that removing one or the other gets rid of your immediate problem.


My advice would be to try and simplify the hierarchy of controls as much as possible. You have three or four layers in there when I suspect you could get away with the main frame and a single layout manager.