Skip to content

Commit

Permalink
Set data paths in local storage
Browse files Browse the repository at this point in the history
  • Loading branch information
rakshith111 committed Jul 14, 2023
1 parent 4e33ee8 commit c591ed2
Showing 1 changed file with 16 additions and 23 deletions.
39 changes: 16 additions & 23 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
from PyQt6.QtWidgets import QMainWindow, QApplication, QFrame, QLabel, QTextEdit, QPushButton, QGridLayout, QDialog,QMessageBox
from PyQt6.QtGui import QPixmap, QIcon
from PyQt6.QtCore import Qt
import json
import os
import sys
from PyQt6.QtWidgets import QMainWindow, QApplication, QFrame, QLabel, QTextEdit, QPushButton, QGridLayout, QDialog,QMessageBox
from PyQt6.QtGui import QPixmap, QIcon
from PyQt6.QtCore import Qt


from ui_generated.basic import Ui_CopyPasta
from add_widget import AddEditDialog
class MainWindow(QMainWindow, Ui_CopyPasta):
'''
Main window of the application.
from PyQt6.QtCore import QStandardPaths

Args:
QMainWindow (QMainWindow): Main window class.
Ui_CopyPasta (Ui_CopyPasta): Generated UI class.
'''
class MainWindow(QMainWindow, Ui_CopyPasta):
def __init__(self):
super().__init__()
self.setupUi(self)
self.add_field.clicked.connect(self.show_add_dialog)
self.basic_frame_template.hide()
self.clipboard = QApplication.clipboard()
self.data_dir = os.path.join('src','user_data')
self.data_dir = os.path.join(QStandardPaths.writableLocation(QStandardPaths.StandardLocation.AppLocalDataLocation), 'CopyPasta')
os.makedirs(self.data_dir, exist_ok=True)
self.data_file = os.path.normpath(os.path.join(self.data_dir, "data.json"))
self.data_file = os.path.join(self.data_dir, "data.json")
self.huge = 69
self.frames = []
self.load_data()
Expand All @@ -33,21 +29,18 @@ def __init__(self):

def resource_path(self):
'''
Sets the path to the resource folder.
return os.path.join(base_path, relative_path)
'''
Gets the resource path.
Looks for the resource path in the sys._MEIPASS variable. When the program is bundled with PyInstaller, sys._MEIPASS is set to the path of the extracted data.
'''
if hasattr(sys, '_MEIPASS'):

# Bundled with PyInstaller
base_path = sys._MEIPASS

self.label.setPixmap(QPixmap(os.path.join(base_path,"src","ui_files","icons","title.png")))
self.setWindowIcon(QIcon(os.path.join(base_path,"src","ui_files","icons","icon.png")))

self.label.setPixmap(QPixmap(os.path.join(base_path, "src", "ui_files", "icons", "title.png")))
self.setWindowIcon(QIcon(os.path.join(base_path, "src", "ui_files", "icons", "icon.png")))
else:
base_path = os.path.abspath(os.path.dirname(__file__))
self.label.setPixmap(QPixmap(os.path.join("src","ui_files","icons","title.png")))
self.setWindowIcon(QIcon(os.path.join("src","ui_files","icons","icon.png")))
self.label.setPixmap(QPixmap(os.path.join( "src", "ui_files", "icons", "title.png")))
self.setWindowIcon(QIcon(os.path.join( "src", "ui_files", "icons", "icon.png")))


def show_add_dialog(self):
Expand Down

0 comments on commit c591ed2

Please sign in to comment.