Python - How to get the filename in tkinter file dialog
<p>I am trying to get just the file name of the selected file in tkinter file dialog</p>

<p>Here's my code:</p>

<pre><code>def browseFile(self):
    root = tk.Tk()
    root.withdraw()
    file_path = askopenfilename(filetypes=(("Video files", "*.mp4;*.flv;*.avi;*.mkv"),
                                       ("All files", "*.*") ))

    print file_path
</code></pre>

<p>What I am getting with this code is the whole path of the selected file, where I only need the file name. How can I do it?</p>

<p>results
with my code:</p>

<pre><code> C:/Users/Guest/vid1.mp4
</code></pre>

<p>what I want:</p>

<pre><code> vid1.mp4
</code></pre>