python tkinter relative path code example
Example 1: python open file relative to module
import os
TEST_FILENAME = os.path.join(os.path.dirname(__file__), 'test.txt')
Example 2: get resource path python
def resource_path(relative_path):
base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__)))
return os.path.join(base_path, relative_path)