Skip to content

player.play() -> Attribute error #60

@AntonyKozm

Description

@AntonyKozm

I have a problem. When I select an item in treeview I update the video path. It throws an error that the container is NoneType

Code:

    def _init_widgets(self):
        self.columnconfigure(0, weight=1)
        self.columnconfigure(1, weight=1, minsize=200)

        self.rowconfigure(0, weight=1)
        self.rowconfigure(1, minsize=20)

        columns = ("index", "name", "checked")

        self.treeview = ttk.Treeview(self, show="headings", columns=columns)

        self.treeview.heading("index", text="ID")
        self.treeview.heading("name", text="Name")
        self.treeview.heading("checked", text="Checked")

        self.scrollbar = ttk.Scrollbar(
            self, orient=VERTICAL, command=self.treeview.yview
        )

        self.treeview.config(yscroll=self.scrollbar.set)

        self.treeview.grid(column=0, row=0, sticky=NSEW)

        self.treeview.bind("<<TreeviewSelect>>", self.on_treeview_select)

        self.label = ttk.Label(self, textvariable=self._last_path)
        self.label.grid(row=1, sticky=NSEW)
        
        self.player = TkinterVideo(master=self, scaled=True, keep_aspect=True)
        self.player.grid(column=1, row=0, sticky=NSEW)

    def on_treeview_select(self, ev):
        video_item = self._get_video_item() # returns a tuple with index, video object and its state

        video: Video = video_item[1]

        self.player.load(video.local_path)

        self.player.play()

Traceback:

Exception in thread Thread-2 (_load):
Traceback (most recent call last):
  File "C:\Users\Antony\.pyenv\pyenv-win\versions\3.10.11\lib\threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "C:\Users\Antony\.pyenv\pyenv-win\versions\3.10.11\lib\threading.py", line 953, 
in run
    self._target(*self._args, **self._kwargs)
  File "d:\Files\Projects\Python\tiktok_automation\.venv\lib\site-packages\tkVideoPlayer\tkvideoplayer.py", line 201, in _load
    self._container.close()
AttributeError: 'NoneType' object has no attribute 'close'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions