# Path: celestia/gui/scrolledframe.py
# class ScrolledFrame(ttk.Frame, object):
#     def __init__(self, parent, *args, **kw):
#         ttk.Frame.__init__(self, parent, *args, **kw)
# 
#         vscrollbar = ttk.Scrollbar(self, orient=VERTICAL)
#         vscrollbar.pack(fill=Y, side=RIGHT, expand=False)
#         canvas = tk.Canvas(self, bd=0, highlightthickness=0,
#                            yscrollcommand=vscrollbar.set)
#         canvas.pack(side=LEFT, fill=BOTH, expand=True)
#         vscrollbar.config(command=canvas.yview)
# 
#         canvas.xview_moveto(0)
#         canvas.yview_moveto(0)
# 
#         self.interior = interior = ttk.Frame(canvas)
#         interior_id = canvas.create_window(0, 0, window=interior,
#                                            anchor=NW)
# 
#         def _configure_interior(event):
#             size = (interior.winfo_reqwidth(), interior.winfo_reqheight())
#             canvas.config(scrollregion="0 0 %s %s" % size)
#             if interior.winfo_reqwidth() != canvas.winfo_width():
#                 canvas.config(width=interior.winfo_reqwidth())
#         interior.bind('<Configure>', _configure_interior)
# 
#         def _configure_canvas(event):
#             if interior.winfo_reqwidth() != canvas.winfo_width():
#                 canvas.itemconfigure(interior_id, width=canvas.winfo_width())
#         canvas.bind('<Configure>', _configure_canvas)
# 
# Path: celestia/utility/tkvardescriptor.py
# class TkVarDescriptor(object):
#     def __init__(self, klass):
#         self.label = None
#         self.klass = klass
# 
#     def __get__(self, instance, objtype=None):
#         if instance is None:
#             return self
#         return instance.__dict__[self.label].get()
# 
#     def __set__(self, instance, value):
#         if self.label not in instance.__dict__:
#             instance.__dict__[self.label] = self.klass(instance)
#         instance.__dict__[self.label].set(value)
# 
#     def raw_klass(self, instance):
#         return instance.__dict__[self.label]
# 
# class TkVarDescriptorOwner(type):
#     def __new__(cls, name, bases, attrs):
#         for key, value in attrs.items():
#             if isinstance(value, TkVarDescriptor):
#                 value.label = key
#         return super(TkVarDescriptorOwner, cls).__new__(cls, name, bases, attrs)


import six
    import tkinter as tk
    import tkinter.ttk as ttk
    import Tkinter as tk
    import ttk
    from tkinter.constants import N, S, E, W, NSEW
    from Tkconstants import N, S, E, W, NSEW
from .scrolledframe import ScrolledFrame
from celestia.utility.tkvardescriptor import TkVarDescriptor, TkVarDescriptorOwner
@six.add_metaclass(TkVarDescriptorOwner)
class MissingPony(ttk.Frame, object):
    checked = TkVarDescriptor(tk.BooleanVar)

    def __init__(self, parent, name, offset):
        ttk.Frame.__init__(self, parent)
        self.parent = parent

        self.checked = False
        self._chkbox = ttk.Checkbutton(self.parent,
                                       text="Add {} to inventory".format(name),
                                       variable=MissingPony.checked.raw_klass(self))

        self._chkbox.grid(row=offset, column=0, sticky=W, padx=3, pady=2)

    def grid_remove(self):
        self._chkbox.grid_remove()


class MissingEverypony(MissingPony):
    def __init__(self, missing_ponies, *args):
        MissingPony.__init__(self, *args)
        self._missing_ponies = missing_ponies
        MissingPony.checked.raw_klass(self).trace("w", self._checked_change)

    def _checked_change(self, *args):
        for pony in self._missing_ponies.values():
            pony.checked = self.checked



# Path: celestia/gui/scrolledframe.py
# class ScrolledFrame(ttk.Frame, object):
#     def __init__(self, parent, *args, **kw):
#         ttk.Frame.__init__(self, parent, *args, **kw)
# 
#         vscrollbar = ttk.Scrollbar(self, orient=VERTICAL)
#         vscrollbar.pack(fill=Y, side=RIGHT, expand=False)
#         canvas = tk.Canvas(self, bd=0, highlightthickness=0,
#                            yscrollcommand=vscrollbar.set)
#         canvas.pack(side=LEFT, fill=BOTH, expand=True)
#         vscrollbar.config(command=canvas.yview)
# 
#         canvas.xview_moveto(0)
#         canvas.yview_moveto(0)
# 
#         self.interior = interior = ttk.Frame(canvas)
#         interior_id = canvas.create_window(0, 0, window=interior,
#                                            anchor=NW)
# 
#         def _configure_interior(event):
#             size = (interior.winfo_reqwidth(), interior.winfo_reqheight())
#             canvas.config(scrollregion="0 0 %s %s" % size)
#             if interior.winfo_reqwidth() != canvas.winfo_width():
#                 canvas.config(width=interior.winfo_reqwidth())
#         interior.bind('<Configure>', _configure_interior)
# 
#         def _configure_canvas(event):
#             if interior.winfo_reqwidth() != canvas.winfo_width():
#                 canvas.itemconfigure(interior_id, width=canvas.winfo_width())
#         canvas.bind('<Configure>', _configure_canvas)
# 
# Path: celestia/utility/tkvardescriptor.py
# class TkVarDescriptor(object):
#     def __init__(self, klass):
#         self.label = None
#         self.klass = klass
# 
#     def __get__(self, instance, objtype=None):
#         if instance is None:
#             return self
#         return instance.__dict__[self.label].get()
# 
#     def __set__(self, instance, value):
#         if self.label not in instance.__dict__:
#             instance.__dict__[self.label] = self.klass(instance)
#         instance.__dict__[self.label].set(value)
# 
#     def raw_klass(self, instance):
#         return instance.__dict__[self.label]
# 
# class TkVarDescriptorOwner(type):
#     def __new__(cls, name, bases, attrs):
#         for key, value in attrs.items():
#             if isinstance(value, TkVarDescriptor):
#                 value.label = key
#         return super(TkVarDescriptorOwner, cls).__new__(cls, name, bases, attrs)


# Path: celestia/gui/missingponiesframe.py
import six
    import tkinter as tk
    import tkinter.ttk as ttk
    import Tkinter as tk
    import ttk
    from tkinter.constants import N, S, E, W, NSEW
    from Tkconstants import N, S, E, W, NSEW
from .scrolledframe import ScrolledFrame
from celestia.utility.tkvardescriptor import TkVarDescriptor, TkVarDescriptorOwner

@six.add_metaclass(TkVarDescriptorOwner)
class MissingPony(ttk.Frame, object):
    checked = TkVarDescriptor(tk.BooleanVar)

    def __init__(self, parent, name, offset):
        ttk.Frame.__init__(self, parent)
        self.parent = parent

        self.checked = False
        self._chkbox = ttk.Checkbutton(self.parent,
                                       text="Add {} to inventory".format(name),
                                       variable=MissingPony.checked.raw_klass(self))

        self._chkbox.grid(row=offset, column=0, sticky=W, padx=3, pady=2)

    def grid_remove(self):
        self._chkbox.grid_remove()


class MissingEverypony(MissingPony):
    def __init__(self, missing_ponies, *args):
        MissingPony.__init__(self, *args)
        self._missing_ponies = missing_ponies
        MissingPony.checked.raw_klass(self).trace("w", self._checked_change)

    def _checked_change(self, *args):
        for pony in self._missing_ponies.values():
            pony.checked = self.checked



class MissingPoniesFrame(ScrolledFrame):