From 54d37ece7d55e53b933c9875c5972484da3bf07c Mon Sep 17 00:00:00 2001 From: davidinations Date: Sat, 30 Mar 2024 10:18:25 +0700 Subject: [PATCH] Update File Path --- src/features.py | 10 +++++++++- src/main.py | 22 ++++++++++++++++++---- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/features.py b/src/features.py index 642f845..bc90925 100644 --- a/src/features.py +++ b/src/features.py @@ -1,6 +1,14 @@ import csv +import os -path = "../data/data.csv" +# Get the absolute path to the directory of the current script file +script_dir = os.path.dirname(os.path.abspath(__file__)) + +# Go up one level to get the base path +base_path = os.path.dirname(script_dir) + +# Define the path to the csv file +path = os.path.join(base_path, 'data', 'data.csv') def nik_validate(data_nik): """ diff --git a/src/main.py b/src/main.py index 0fc46ec..c9a8309 100644 --- a/src/main.py +++ b/src/main.py @@ -1,6 +1,7 @@ import features as ft import tkinter import re +import os import babel.numbers from tkinter import * from tkinter import ttk @@ -13,9 +14,22 @@ # Initialize the mixer module pygame.mixer.init() -click_sound = pygame.mixer.Sound("../assets/sounds/Click.wav") -error_sound = pygame.mixer.Sound("../assets/sounds/Error.wav") -success_sound = pygame.mixer.Sound("../assets/sounds/Success.wav") +# Get the absolute path to the directory of the current script file +script_dir = os.path.dirname(os.path.abspath(__file__)) + +# Go up one level to get the base path +base_path = os.path.dirname(script_dir) + +# Construct the paths to the sound files +click_sound_path = os.path.join(base_path, "assets", "sounds", "Click.wav") +error_sound_path = os.path.join(base_path, "assets", "sounds", "Error.wav") +success_sound_path = os.path.join(base_path, "assets", "sounds", "Success.wav") +icon_path = os.path.join(base_path, "assets", "images", "favicon.ico") + +# Load the sounds Into Variables +click_sound = pygame.mixer.Sound(click_sound_path) +error_sound = pygame.mixer.Sound(error_sound_path) +success_sound = pygame.mixer.Sound(success_sound_path) def sort_data(treeview, column, reverse): """ @@ -677,7 +691,7 @@ def exit_menu(): # create a windows root = tkinter.Tk() # config icon windows - root.iconbitmap("../assets/images/favicon.ico") + root.iconbitmap(icon_path) # config size windows root.geometry("1280x720+150-50") # x++ # make a windows size fixed