vunghixuan 0.1.4__py3-none-any.whl → 0.1.5__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- config/__init__.py +0 -0
- config/config_menubar.py +107 -0
- config/settings.py +105 -0
- config/settings_1.py +84 -0
- config/settings_2.py +24 -0
- vunghixuan/__init__.py +3 -0
- vunghixuan/create_files_for_package.py +48 -0
- vunghixuan/{create_gui.py → gui_main.py} +37 -10
- vunghixuan/login.py +2 -0
- vunghixuan/main.py +4 -6
- vunghixuan/{create_project.py → project.py} +24 -19
- vunghixuan/setting_controlls.py +67 -0
- vunghixuan/settings.py +137 -1
- vunghixuan-0.1.5.dist-info/METADATA +21 -0
- vunghixuan-0.1.5.dist-info/RECORD +19 -0
- {vunghixuan-0.1.4.dist-info → vunghixuan-0.1.5.dist-info}/WHEEL +1 -1
- vunghixuan-0.1.5.dist-info/entry_points.txt +2 -0
- {vunghixuan-0.1.4.dist-info → vunghixuan-0.1.5.dist-info}/top_level.txt +1 -0
- vunghixuan-0.1.4.dist-info/METADATA +0 -7
- vunghixuan-0.1.4.dist-info/RECORD +0 -12
- vunghixuan-0.1.4.dist-info/entry_points.txt +0 -2
config/__init__.py
ADDED
File without changes
|
config/config_menubar.py
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
|
2
|
+
"4. Khai báo cho menu và actions"
|
3
|
+
# Định nghĩa Action và tên các sheét sử dụng trong Excel
|
4
|
+
class ACTION:
|
5
|
+
def __init__(self, name, sheet_name_used=None):
|
6
|
+
self.name = name
|
7
|
+
self.isChoice = False
|
8
|
+
|
9
|
+
# khai báo Sheet sử dụng cho hành động Action
|
10
|
+
if sheet_name_used!=None:
|
11
|
+
self.sheet_name_used = sheet_name_used
|
12
|
+
else:
|
13
|
+
self.sheet_name_used = ''
|
14
|
+
|
15
|
+
|
16
|
+
# Định nghĩa Menu
|
17
|
+
class MENU:
|
18
|
+
def __init__(self, name, actions):
|
19
|
+
self.name = name
|
20
|
+
self.actions = actions
|
21
|
+
self.isChoice = False #Menu đang đuọc chọn
|
22
|
+
# sheet_names_used = sheet_names_used
|
23
|
+
|
24
|
+
# Thay đổi isChoice
|
25
|
+
# Lấy danh sách actions
|
26
|
+
def get_action_names(self):
|
27
|
+
action_names = []
|
28
|
+
for act in self.actions:
|
29
|
+
action_names.append(act.name)
|
30
|
+
return action_names
|
31
|
+
|
32
|
+
# Lấy danh sách sheets tương ứng actions
|
33
|
+
def get_sheet_names(self):
|
34
|
+
sheet_names = []
|
35
|
+
for act in self.actions:
|
36
|
+
sheet_names.append(act.sheet_name_used)
|
37
|
+
return sheet_names
|
38
|
+
|
39
|
+
|
40
|
+
class MENU_BAR():
|
41
|
+
def __init__(self, name, menus):
|
42
|
+
self.name = name
|
43
|
+
self.menus = menus
|
44
|
+
|
45
|
+
# Lấy danh sách tên menus
|
46
|
+
def get_menu_names(self):
|
47
|
+
menus_names =[]
|
48
|
+
for menu in self.menus:
|
49
|
+
menus_names.append(menu.name)
|
50
|
+
return menus_names
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
# Khởi tạo MenuBar
|
56
|
+
menubar_name = 'MenuBar cho phần Phân Kim'
|
57
|
+
dic_menus = {
|
58
|
+
"Nhập dữ liệu":{
|
59
|
+
'Đổi dẻ': 'Nhap_DoiDe',
|
60
|
+
'Mua dẻ': 'Nhap_MuaDe',
|
61
|
+
'Bán dẻ': 'Nhap_BanDe',
|
62
|
+
'Giá vàng': 'GiaVang',
|
63
|
+
'Loại vàng': 'LoaiVang'
|
64
|
+
},
|
65
|
+
"Báo cáo": {
|
66
|
+
'Đổi dẻ': 'Nhap_DoiDe',
|
67
|
+
'Mua dẻ': 'Nhap_MuaDe',
|
68
|
+
'Bán dẻ': 'Nhap_BanDe',
|
69
|
+
'Công nợ': 'Chưa có sheet'
|
70
|
+
},
|
71
|
+
"Phiếu xuất":{
|
72
|
+
'Nhập kho': 'Chưa có sheet',
|
73
|
+
'Xuất kho': 'Chưa có sheet',
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
def create_menubar():
|
78
|
+
menu_objs = []
|
79
|
+
for menu, actions in dic_menus.items():
|
80
|
+
action_objs = []
|
81
|
+
for act, sh in actions.items():
|
82
|
+
action = ACTION(act, sh)
|
83
|
+
action_objs.append(action)
|
84
|
+
menu = MENU(menu, action_objs)
|
85
|
+
menu_objs.append(menu)
|
86
|
+
|
87
|
+
menubar = MENU_BAR(menubar_name,menu_objs)
|
88
|
+
return menubar
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
if __name__ == "__main__":
|
96
|
+
|
97
|
+
|
98
|
+
MENUBAR = create_menubar(menubar_name)
|
99
|
+
|
100
|
+
print("Danh sách tên menu", MENUBAR.get_menu_names())
|
101
|
+
|
102
|
+
for menu in MENUBAR.menus:
|
103
|
+
print(f'Tên menu: {menu.name}, Danh mục actions{menu.get_action_names()}')
|
104
|
+
print(f'Tên menu: {menu.name}, Danh mục sheets{menu.get_sheet_names()}')
|
105
|
+
|
106
|
+
# print("Danh sách tên actions", MENUBAR.menus.get_action_names())
|
107
|
+
# print("Danh sách tên sheet",MENUBAR.menus.get_sheet_names())
|
config/settings.py
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
from pathlib import Path
|
2
|
+
import os
|
3
|
+
import sys
|
4
|
+
|
5
|
+
"1. Khai báo đường dẫn chung dự án"
|
6
|
+
# BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
7
|
+
BASE_DIR = str(Path(__file__).parent.parent)
|
8
|
+
sys.path.append(BASE_DIR)
|
9
|
+
|
10
|
+
# BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
11
|
+
DATABASE_URL = 'sqlite:///data.db' # Thay đổi nếu sử dụng DB khác
|
12
|
+
|
13
|
+
STATIC_DIR = os.path.join(BASE_DIR, 'static')
|
14
|
+
|
15
|
+
MENUS_INFO = {
|
16
|
+
"File": {
|
17
|
+
"New": f'{STATIC_DIR}/icon/icons8-file-64.png',
|
18
|
+
"Open": f'{STATIC_DIR}/icon/icons8-opened-folder-50.png',
|
19
|
+
"Save": None,
|
20
|
+
},
|
21
|
+
|
22
|
+
|
23
|
+
"Edit": {
|
24
|
+
"Cut": f'{STATIC_DIR}/icon/icons8-file-64.png',
|
25
|
+
"Copy": f'{STATIC_DIR}/icon/icons8-opened-folder-50.png',
|
26
|
+
"Paste": None,
|
27
|
+
},
|
28
|
+
|
29
|
+
"Help": {
|
30
|
+
"About": None,
|
31
|
+
"Documentation": None
|
32
|
+
}
|
33
|
+
|
34
|
+
}
|
35
|
+
# TABS_INFO = {
|
36
|
+
# "Xi Ngoài": [["Xi ngoài", "Xi nội bộ", "Xuất tạm"]],
|
37
|
+
# "Phân Kim": [["Chưa code 1", "chưa code 2", "chưa code 2---------------------------------------------------------"]],
|
38
|
+
# "Hàng O": [["Chưa code 1", "chưa code 2"]],
|
39
|
+
# "Hệ thống": [["Đăng ký", "Nhóm truy cập", 'Quyền truy cập']],
|
40
|
+
# }
|
41
|
+
|
42
|
+
TABS_INFO = {
|
43
|
+
"Quản lý tài khoản": {
|
44
|
+
"Đăng nhập": f'{STATIC_DIR}/icon/icon_sys.png',
|
45
|
+
"Đăng ký": f'{STATIC_DIR}/icon/icon_user_64.png',
|
46
|
+
"Cập nhật": f'{STATIC_DIR}/icon/update.png',
|
47
|
+
},
|
48
|
+
|
49
|
+
"Nhập dữ liêu Xi ngoài": {
|
50
|
+
"Xi ngoài": f'{STATIC_DIR}/icon/icons8-file-64.png',
|
51
|
+
"Xi nội bộ": f'{STATIC_DIR}/icon/icons8-opened-folder-50.png',
|
52
|
+
"Xuất tạm": None,
|
53
|
+
},
|
54
|
+
"Tab 2": {
|
55
|
+
"Action 1": None,
|
56
|
+
"Action 2": None,
|
57
|
+
},
|
58
|
+
"Tab 3": {
|
59
|
+
"Action 3": None,
|
60
|
+
"Action 4": None,
|
61
|
+
},
|
62
|
+
}
|
63
|
+
|
64
|
+
# https://getemoji.com/
|
65
|
+
ICON = {
|
66
|
+
'eye_open': '👁️', # Mắt mở
|
67
|
+
'eye_closed': '👁️🗨️', # Mắt đóng
|
68
|
+
'smile': '😀',
|
69
|
+
'party': '🎉',
|
70
|
+
'rocket': '🚀',
|
71
|
+
'star': '🌟',
|
72
|
+
'heart': '❤️',
|
73
|
+
'thumbs_up': '👍',
|
74
|
+
'fire': '🔥',
|
75
|
+
'check_mark': '✔️',
|
76
|
+
'clap': '👏',
|
77
|
+
'sun': '☀️',
|
78
|
+
'moon': '🌙',
|
79
|
+
'sparkles': '✨',
|
80
|
+
'gift': '🎁',
|
81
|
+
'music': '🎵',
|
82
|
+
'folder': '📁',
|
83
|
+
'file': '📄',
|
84
|
+
'add_button': '➕',
|
85
|
+
'remove_button': '➖',
|
86
|
+
'edit_button': '✏️',
|
87
|
+
'open_folder': '📂',
|
88
|
+
'close_folder': '📁',
|
89
|
+
'user': '👤',
|
90
|
+
'sys': '🖥️',
|
91
|
+
'lock': '🔒',
|
92
|
+
'unlock': '🔓',
|
93
|
+
'search': '🔍',
|
94
|
+
'settings': '⚙️',
|
95
|
+
'warning': '⚠️',
|
96
|
+
}
|
97
|
+
|
98
|
+
|
99
|
+
# {
|
100
|
+
# "Xi Ngoài": ["Xi ngoài", "Xi nội bộ", "Xuất tạm"],
|
101
|
+
# "Hệ thống": ["Đăng ký", "Nhóm truy cập", 'Quyền truy cập'],
|
102
|
+
# }
|
103
|
+
|
104
|
+
if __name__ == "__main__":
|
105
|
+
print(STATIC_DIR)
|
config/settings_1.py
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# config.py
|
2
|
+
from pathlib import Path
|
3
|
+
import os
|
4
|
+
import sys
|
5
|
+
from config_menubar import create_menubar
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
"1. Khai báo đường dẫn chung dự án"
|
10
|
+
# BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
11
|
+
BASE_DIR = Path(__file__).parent
|
12
|
+
sys.path.append(BASE_DIR)
|
13
|
+
|
14
|
+
class Config:
|
15
|
+
def __init__(self):
|
16
|
+
# self.apps_dir = os.path.join(BASE_DIR, 'apps')
|
17
|
+
self.resources_url = os.path.join(BASE_DIR, 'resources')
|
18
|
+
# self.database_url = f"sqlite:///{BASE_DIR}/resources/database.db"
|
19
|
+
self.templates_url = f"{BASE_DIR}/resources/templates"
|
20
|
+
self.logo_url = f"{BASE_DIR}/resources/logo"
|
21
|
+
|
22
|
+
# 1. app_mainGui
|
23
|
+
self.app_mainGui = f"{BASE_DIR}/app_mainGui"
|
24
|
+
|
25
|
+
"2. Khai báo các app được sử dụng"
|
26
|
+
self.apps = ['app_mainGui', 'resources']
|
27
|
+
self.apps_dir = {}
|
28
|
+
# Thêm đường dẫn của các thư mục con nếu cần
|
29
|
+
for app in self.apps:
|
30
|
+
app_dir = os.path.join(BASE_DIR, app)
|
31
|
+
|
32
|
+
# Thêm đường dẫn vào danh mục đường dẫn dự án
|
33
|
+
sys.path.append(app_dir)
|
34
|
+
self.apps_dir[app] = app_dir
|
35
|
+
|
36
|
+
|
37
|
+
"3. File Excel"
|
38
|
+
# Khai báo file Excel và các sheet sử dụng
|
39
|
+
EXCEL_FILE = {
|
40
|
+
"path": f"{self.apps_dir['resources']}/templates/input.xlsm",
|
41
|
+
'sheet_names': ['Nhap_DoiDe', 'Nhap_MuaDe', 'Nhap_BanDe', 'GiaVang', 'LoaiVang'],
|
42
|
+
|
43
|
+
}
|
44
|
+
|
45
|
+
"4. Khởi tạo menubar"
|
46
|
+
self.menubar = create_menubar()
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
# self.app_metalStool = os.path.join(self.apps_dir, 'app_metalStool')
|
51
|
+
# self.app2_dir = os.path.join(self.apps_dir, 'App2')
|
52
|
+
# self.app3_dir = os.path.join(self.apps_dir, 'App3')
|
53
|
+
# ... thêm các đường dẫn khác theo nhu cầu
|
54
|
+
# url_config = Config() # Khởi tạo biến toàn cục
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
# class UrlConfig:
|
62
|
+
# def __init__(self) -> None:
|
63
|
+
# self.base_dir = Path(__file__).resolve().parent
|
64
|
+
# self.database_url = f"sqlite:///{self.base_dir}/resources/database.db"
|
65
|
+
# self.logo_url = f"{self.base_dir}/resources/logo"
|
66
|
+
|
67
|
+
# url_config = UrlConfig() # Khởi tạo biến toàn cục
|
68
|
+
|
69
|
+
# main.py
|
70
|
+
# import config
|
71
|
+
|
72
|
+
# # Kết nối đến database
|
73
|
+
# engine = create_engine(config.DATABASE_URL)
|
74
|
+
|
75
|
+
if __name__ == "__main__":
|
76
|
+
|
77
|
+
config = Config()
|
78
|
+
print('BASE_DIR:', BASE_DIR)
|
79
|
+
print('apps_dir:', config.apps_dir)
|
80
|
+
print('DATABASE_URL:',config.templates_url)
|
81
|
+
print('LOGO_URL:', config.logo_url)
|
82
|
+
print('app_gui_excel:', config.app_mainGui)
|
83
|
+
|
84
|
+
|
config/settings_2.py
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# config/settings.py
|
2
|
+
|
3
|
+
DATABASE_CONFIG = {
|
4
|
+
'HOST': 'localhost',
|
5
|
+
'PORT': 5432,
|
6
|
+
'USER': 'your_username',
|
7
|
+
'PASSWORD': 'your_password',
|
8
|
+
'DB_NAME': 'your_database'
|
9
|
+
}
|
10
|
+
|
11
|
+
APPS = [
|
12
|
+
'apps.app_mainGui'
|
13
|
+
# 'apps.users',
|
14
|
+
# 'apps.products',
|
15
|
+
# 'apps.orders'
|
16
|
+
]
|
17
|
+
|
18
|
+
def register_apps():
|
19
|
+
for app in APPS:
|
20
|
+
__import__(app)
|
21
|
+
|
22
|
+
def get_model(app_name, model_name):
|
23
|
+
app = __import__(app_name)
|
24
|
+
return getattr(app.models, model_name)
|
vunghixuan/__init__.py
CHANGED
@@ -0,0 +1,48 @@
|
|
1
|
+
import os
|
2
|
+
import shutil
|
3
|
+
import importlib.util as is_package
|
4
|
+
import site
|
5
|
+
|
6
|
+
# Kiểm tra sự tồn tại file
|
7
|
+
def path_exists(path):
|
8
|
+
return os.path.exists(path)
|
9
|
+
|
10
|
+
# Kiểm tra sự tồn tại gói
|
11
|
+
def package_exists(package_name):
|
12
|
+
return is_package.find_spec(package_name) is not None
|
13
|
+
|
14
|
+
# Chép file từ nguồn đến đích
|
15
|
+
def copy_file(source_file, destination):
|
16
|
+
if path_exists(source_file):
|
17
|
+
shutil.copy(source_file, destination)
|
18
|
+
|
19
|
+
|
20
|
+
def copy_file_from_vunghixuan_package(settings_path, requirements_path):
|
21
|
+
source_file = 'vunghixuan/settings.py'
|
22
|
+
copy_file(source_file, settings_path)
|
23
|
+
copy_file('vunghixuan/requirements.txt', requirements_path)
|
24
|
+
|
25
|
+
def create_file():
|
26
|
+
base_dir = os.getcwd()
|
27
|
+
settings_path = os.path.join('settings', 'settings.py')
|
28
|
+
requirements_path = os.path.join(base_dir, 'requirements.txt')
|
29
|
+
|
30
|
+
if not path_exists(settings_path):
|
31
|
+
package_name = 'vunghixuan'
|
32
|
+
source_file = 'vunghixuan/settings.py'
|
33
|
+
|
34
|
+
if package_exists(package_name):
|
35
|
+
source_folder = os.path.join(site.getsitepackages()[1], package_name)
|
36
|
+
setting_file = os.path.join(source_folder, 'settings.py')
|
37
|
+
requirement_file = os.path.join(source_folder, 'requirements.txt')
|
38
|
+
|
39
|
+
# Kiểm tra file do có sự tòn tại cả cache
|
40
|
+
if path_exists(setting_file):
|
41
|
+
copy_file(setting_file, settings_path)
|
42
|
+
copy_file(requirement_file, requirements_path)
|
43
|
+
else:
|
44
|
+
copy_file_from_vunghixuan_package(settings_path, requirements_path)
|
45
|
+
else:
|
46
|
+
copy_file_from_vunghixuan_package(settings_path, requirements_path)
|
47
|
+
|
48
|
+
create_file()
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import sys
|
1
|
+
import sys, os
|
2
2
|
from PySide6.QtWidgets import(
|
3
3
|
QApplication,
|
4
4
|
QMainWindow,
|
@@ -16,7 +16,9 @@ from PySide6.QtWidgets import(
|
|
16
16
|
from PySide6.QtGui import QColor, QFont
|
17
17
|
from vunghixuan.login import LoginGroupBox
|
18
18
|
from PySide6.QtGui import QPixmap
|
19
|
+
# from vunghixuan.settings import COLOR_FONT_BACKGROUND, color_fnt_bg
|
19
20
|
from vunghixuan.settings import COLOR_FONT_BACKGROUND, color_fnt_bg
|
21
|
+
|
20
22
|
# color_default = COLOR_FONT_BACKGROUND['Xanh lục, chữ trắng']
|
21
23
|
# print(color_font_background)
|
22
24
|
|
@@ -71,7 +73,7 @@ class Header(QWidget):
|
|
71
73
|
|
72
74
|
logo = QLabel('VuNghiXuan')
|
73
75
|
|
74
|
-
font = QFont('Brush Script MT',
|
76
|
+
font = QFont('Brush Script MT', 20)
|
75
77
|
# font = QFont('Dancing Script', 20)#('Segoe Script', 20)#('Lucida Handwriting', 20)#('Brush Script MT', 20) # Thay đổi font chữ ở đây
|
76
78
|
|
77
79
|
logo.setFont(font)
|
@@ -275,17 +277,42 @@ class MyWindow(QMainWindow):
|
|
275
277
|
self.update_color_theme()
|
276
278
|
|
277
279
|
def update_color_theme(self):
|
280
|
+
from vunghixuan import setting_controlls
|
281
|
+
|
282
|
+
|
283
|
+
# Lấy thông tin thay đỏi từ giao diện
|
278
284
|
color_fnt_bg = self.header.theme_selector.currentText()
|
279
|
-
with open('settings.py', 'r', encoding='utf-8' ) as file:
|
280
|
-
lines = file.readlines()
|
281
285
|
|
282
|
-
with open('settings.py', 'w', encoding='utf-8') as file:
|
283
|
-
for line in lines:
|
284
|
-
if line.startswith('color_fnt_bg'):
|
285
|
-
file.write(f"color_fnt_bg = COLOR_FONT_BACKGROUND['{color_fnt_bg}']\n")
|
286
|
-
else:
|
287
|
-
file.write(line)
|
288
286
|
|
287
|
+
setting_controlls.update_theme(color_fnt_bg)
|
288
|
+
|
289
|
+
# file_path = 'settings/settings.py'
|
290
|
+
# if os.path.exists(file_path):
|
291
|
+
# color_fnt_bg = self.header.theme_selector.currentText()
|
292
|
+
# with open(setting_file, 'r', encoding='utf-8' ) as file:
|
293
|
+
# lines = file.readlines()
|
294
|
+
|
295
|
+
# with open(setting_file, 'w', encoding='utf-8') as file:
|
296
|
+
# for line in lines:
|
297
|
+
# if line.startswith('color_fnt_bg'):
|
298
|
+
# file.write(f"color_fnt_bg = COLOR_FONT_BACKGROUND['{color_fnt_bg}']\n")
|
299
|
+
# else:
|
300
|
+
# file.write(line)
|
301
|
+
# file.close()
|
302
|
+
|
303
|
+
# # Copy file settings qua venv
|
304
|
+
# import site, shutil
|
305
|
+
# package_name = 'vunghixuan'
|
306
|
+
# source_folder = os.path.join(site.getsitepackages()[1], package_name)
|
307
|
+
|
308
|
+
# setting_file = os.path.join(source_folder, 'settings.py')
|
309
|
+
|
310
|
+
# if os.path.exists(setting_file):
|
311
|
+
# shutil.copy(file_path, setting_file)
|
312
|
+
|
313
|
+
|
314
|
+
# else:
|
315
|
+
# print(f"File {setting_file} không tồn tại.")
|
289
316
|
# def toggle_theme(self):
|
290
317
|
# current_color = self.palette().color(self.backgroundRole())
|
291
318
|
# new_color = QColor(255, 255, 255) if current_color == QColor(0, 127, 140) else QColor(0, 127, 140)
|
vunghixuan/login.py
CHANGED
@@ -14,8 +14,10 @@ from PySide6.QtWidgets import(
|
|
14
14
|
)
|
15
15
|
from PySide6.QtCore import Qt
|
16
16
|
from PySide6.QtGui import QColor
|
17
|
+
# from vunghixuan.settings import color_fnt_bg
|
17
18
|
from vunghixuan.settings import color_fnt_bg
|
18
19
|
|
20
|
+
|
19
21
|
class LoginGroupBox(QWidget):
|
20
22
|
def __init__(self):
|
21
23
|
super().__init__()
|
vunghixuan/main.py
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# src/vunghixuan/main.py
|
2
2
|
import sys
|
3
3
|
from .api_and_otp import APIKey, Otp
|
4
|
-
from .
|
5
|
-
from . import
|
4
|
+
from .project import Project
|
5
|
+
# from . import gui_main
|
6
6
|
# from PySide6.QtWidgets import QApplication
|
7
7
|
def main():
|
8
8
|
args = sys.argv[1:]
|
@@ -18,11 +18,9 @@ def main():
|
|
18
18
|
obj = Otp(key)
|
19
19
|
obj.get_otp()
|
20
20
|
if '-create_project' in args :
|
21
|
-
|
22
|
-
obj.create_project()
|
21
|
+
Project().create_project()
|
23
22
|
if '-create_app' in args :
|
24
|
-
|
25
|
-
obj.create_app()
|
23
|
+
Project().create_app()
|
26
24
|
else:
|
27
25
|
print("Missing API key")
|
28
26
|
|
@@ -7,30 +7,26 @@ class Project:
|
|
7
7
|
def __init__(self):
|
8
8
|
# self.root_path = Path(__file__).parent
|
9
9
|
self.root_path = Path(os.getcwd()) # Lấy đường dẫn hiện tại
|
10
|
-
|
11
|
-
|
12
|
-
# def create_project(self):
|
13
|
-
# for folder, content in structure.items():
|
14
|
-
# if isinstance(content, dict):
|
15
|
-
# folder_path = os.path.join(self.root_path, folder)
|
16
|
-
# os.makedirs(folder_path)
|
17
|
-
# self.create_project()
|
18
|
-
# else:
|
19
|
-
# with open(os.path.join(folder_path, 'models', '__init__.py'), 'w') as f:
|
20
|
-
# f.write("# Init file for models\n")
|
21
|
-
|
22
|
-
# Tạo ra folder
|
10
|
+
|
11
|
+
# Tạo ra folder cần thiết cho dự án
|
23
12
|
def create_folder(self, folder_path, name):
|
24
13
|
folder_path = os.path.join(folder_path, name)
|
25
14
|
os.makedirs(folder_path, exist_ok=True)
|
26
15
|
|
16
|
+
|
17
|
+
|
27
18
|
# Tạo ra folder apps
|
28
19
|
def create_project(self):
|
29
|
-
|
20
|
+
# Tạo ra các app
|
21
|
+
list_folder = ['apps', 'settings']
|
30
22
|
for folder in list_folder:
|
31
23
|
self.create_folder(self.root_path, folder)
|
32
24
|
|
33
|
-
|
25
|
+
# Tạo ra file settings
|
26
|
+
from . import create_files_for_package
|
27
|
+
create_files_for_package.create_file()
|
28
|
+
|
29
|
+
|
34
30
|
|
35
31
|
def create_app(self, app_name):
|
36
32
|
folder_path = os.path.join(self.root_path, 'apps')
|
@@ -40,12 +36,21 @@ class Project:
|
|
40
36
|
self.create_app(app_name)
|
41
37
|
else:
|
42
38
|
self.create_folder(folder_path, app_name)
|
43
|
-
|
39
|
+
app_folder_path = os.path.join(self.root_path, 'apps', app_name)
|
40
|
+
|
41
|
+
# list_folder = ['models', 'views', 'tests.py', f'{app_name}.py']
|
42
|
+
# for folder in list_folder:
|
43
|
+
# self.create_folder(folder_path, folder)
|
44
|
+
|
45
|
+
list_files = ['models', 'views', 'tests', app_name]
|
44
46
|
|
45
|
-
|
46
|
-
for folder in list_folder:
|
47
|
-
self.create_folder(folder_path, folder)
|
47
|
+
for file in list_files:
|
48
48
|
|
49
|
+
# Tạo các file cần thiết cho ứng dụng
|
50
|
+
with open(os.path.join(app_folder_path, file), 'w', encoding='utf-8') as f:
|
51
|
+
f.write("# Đây là file chính của ứng dụng\n")
|
52
|
+
|
53
|
+
|
49
54
|
|
50
55
|
|
51
56
|
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# vugnhixuan/update_setting_file.py
|
2
|
+
|
3
|
+
import os, site, shutil
|
4
|
+
import importlib.util as is_package
|
5
|
+
|
6
|
+
# Kiểm tra sự tồn tại file
|
7
|
+
def path_exists(path):
|
8
|
+
return os.path.exists(path)
|
9
|
+
|
10
|
+
# Kiểm tra sự tồn tại gói
|
11
|
+
def package_exists(package_name):
|
12
|
+
return is_package.find_spec(package_name) is not None
|
13
|
+
|
14
|
+
# Chép file từ nguồn đến đích
|
15
|
+
def copy_file(source_file, destination):
|
16
|
+
if path_exists(source_file):
|
17
|
+
shutil.copy(source_file, destination)
|
18
|
+
|
19
|
+
# Kiểm tra gói VuNghiXuan đã cài đặt bằng pip chưa?
|
20
|
+
def chk_VuNghixuan_package():
|
21
|
+
package_name = 'vunghixuan'
|
22
|
+
package_folder = os.path.join(site.getsitepackages()[1], package_name)
|
23
|
+
|
24
|
+
package_setting_file = os.path.join(package_folder, 'settings.py')
|
25
|
+
|
26
|
+
# Kiểm tra gói VuNghiXuan đã cài đaetj chưa
|
27
|
+
if os.path.exists(package_setting_file):
|
28
|
+
# Tiếp tục kiểm tra sụe tồn tại 'settings/settings.py'
|
29
|
+
return package_setting_file
|
30
|
+
else:
|
31
|
+
print(f'Chưa cài đặt gói "VuNghiXuan" hoặc không tồn tại "{package_setting_file}"')
|
32
|
+
return False
|
33
|
+
|
34
|
+
# Tiếp tục kiểm tra sự tồn tại 'settings/settings.py'
|
35
|
+
def chk_file_setting_from_folder_setting():
|
36
|
+
setting_file = 'settings/settings.py'
|
37
|
+
# Kiểm tra tồn tại file
|
38
|
+
if not os.path.exists(setting_file):
|
39
|
+
print('Không tồn tại ', setting_file)
|
40
|
+
return False
|
41
|
+
else:
|
42
|
+
return setting_file
|
43
|
+
|
44
|
+
# Update file settings from giao diện
|
45
|
+
def change_theme_for_setting_file(color_fnt_bg, setting_file):
|
46
|
+
# color_fnt_bg = self.header.theme_selector.currentText()
|
47
|
+
with open(setting_file, 'r', encoding='utf-8' ) as file:
|
48
|
+
lines = file.readlines()
|
49
|
+
|
50
|
+
with open(setting_file, 'w', encoding='utf-8') as file:
|
51
|
+
for line in lines:
|
52
|
+
if line.startswith('color_fnt_bg'):
|
53
|
+
file.write(f"color_fnt_bg = COLOR_FONT_BACKGROUND['{color_fnt_bg}']\n")
|
54
|
+
else:
|
55
|
+
file.write(line)
|
56
|
+
file.close()
|
57
|
+
|
58
|
+
def update_theme(color_fnt_bg):
|
59
|
+
package_setting_file = chk_VuNghixuan_package()
|
60
|
+
setting_file = chk_file_setting_from_folder_setting()
|
61
|
+
if package_setting_file and setting_file:
|
62
|
+
# Update file settings from giao diện
|
63
|
+
change_theme_for_setting_file(color_fnt_bg, setting_file)
|
64
|
+
# Copy settings file vào gói VuNghiXuan
|
65
|
+
copy_file(setting_file, package_setting_file)
|
66
|
+
print('update setting file thành công!')
|
67
|
+
|
vunghixuan/settings.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# settings/settings.py
|
2
2
|
|
3
3
|
# Cặp màu nền và chữ
|
4
4
|
COLOR = {
|
@@ -22,3 +22,139 @@ COLOR_FONT_BACKGROUND ={
|
|
22
22
|
}
|
23
23
|
color_fnt_bg = COLOR_FONT_BACKGROUND['Nền xanh xám, chữ vàng Gold']
|
24
24
|
|
25
|
+
from pathlib import Path
|
26
|
+
import os
|
27
|
+
import sys
|
28
|
+
import site
|
29
|
+
import importlib.util as is_package
|
30
|
+
|
31
|
+
class Settings:
|
32
|
+
def __init__(self):
|
33
|
+
self.APP_NAME = "My PySide6 App"
|
34
|
+
self.VERSION = "1.0.0"
|
35
|
+
self.DEBUG = True
|
36
|
+
self.BASE_DIR = str(Path(__file__).parent.parent)
|
37
|
+
# self.path = self.get_path()
|
38
|
+
# sys.path.append(self.BASE_DIR)
|
39
|
+
|
40
|
+
# # BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
41
|
+
self.DATABASE_URL = 'sqlite:///data.db' # Thay đổi nếu sử dụng DB khác
|
42
|
+
|
43
|
+
# STATIC_DIR = os.path.join(BASE_DIR, 'static')
|
44
|
+
|
45
|
+
# self.DATABASE = self.get_database_config()
|
46
|
+
# self.FNT_BG_COLOR = self.get_color_config()
|
47
|
+
self.MENUS_INFO = self.get_menus_info()
|
48
|
+
self.TABS_INFO = self.get_tabs_info()
|
49
|
+
self.ICON = self.get_icon_config()
|
50
|
+
self.STATIC_DIR = self.get_static_dir()
|
51
|
+
|
52
|
+
# def get_database_config(self):
|
53
|
+
# # return {
|
54
|
+
# # 'NAME': 'mydatabase.db',
|
55
|
+
# # 'USER': 'user',
|
56
|
+
# # 'PASSWORD': 'password',
|
57
|
+
# # 'HOST': 'localhost',
|
58
|
+
# # 'PORT': 5432,
|
59
|
+
# # }
|
60
|
+
# return {
|
61
|
+
# 'ENGINE': 'sqlite',
|
62
|
+
# 'NAME': self.BASE_DIR / "db.sqlite3",
|
63
|
+
# }
|
64
|
+
|
65
|
+
|
66
|
+
def get_color_config(self):
|
67
|
+
return {
|
68
|
+
'Trắng': '#FFFFFF',
|
69
|
+
'Đen': '#000000',
|
70
|
+
'Đỏ': '#F70000',
|
71
|
+
'Xanh lục': '#007f8c',
|
72
|
+
'Xanh lục tối': '#29465B',
|
73
|
+
'Xanh lá cây': '#006400',
|
74
|
+
'Vàng gold': '#FFD700',
|
75
|
+
}
|
76
|
+
def get_color_fnt_bg(self):
|
77
|
+
return {
|
78
|
+
'Nền xanh lục, chữ trắng': ['#007f8c', '#FFFFFF'], # xanh lục tối
|
79
|
+
'Nền xanh xám, chữ vàng Gold': ['#29465B', '#FFD700'], #Gold (W3C)
|
80
|
+
'Nền xanh xám, chữ trắng': ['#29465B', '#FFFFFF'], # xanh lục tối #29465B
|
81
|
+
'Nền đen, chữ trắng': ['#000000', '#FFFFFF'],
|
82
|
+
'Nền đen, chữ vàng': ['#000000', '#FFD700'],
|
83
|
+
|
84
|
+
}
|
85
|
+
# color_fnt_bg = COLOR_FONT_BACKGROUND['Nền xanh xám, chữ vàng Gold']
|
86
|
+
|
87
|
+
def get_menus_info(self):
|
88
|
+
static_dir = self.get_static_dir()
|
89
|
+
return {
|
90
|
+
"File": {
|
91
|
+
"New": f'{static_dir}/icon/icons8-file-64.png',
|
92
|
+
"Open": f'{static_dir}/icon/icons8-opened-folder-50.png',
|
93
|
+
"Save": None,
|
94
|
+
},
|
95
|
+
"Edit": {
|
96
|
+
"Cut": f'{static_dir}/icon/icons8-file-64.png',
|
97
|
+
"Copy": f'{static_dir}/icon/icons8-opened-folder-50.png',
|
98
|
+
"Paste": None,
|
99
|
+
},
|
100
|
+
"Help": {
|
101
|
+
"About": None,
|
102
|
+
"Documentation": None
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
106
|
+
def get_tabs_info(self):
|
107
|
+
static_dir = self.get_static_dir()
|
108
|
+
return {
|
109
|
+
"Quản lý tài khoản": {
|
110
|
+
"Đăng nhập": f'{static_dir}/icon/icon_sys.png',
|
111
|
+
"Đăng ký": f'{static_dir}/icon/icon_user_64.png',
|
112
|
+
"Cập nhật": f'{static_dir}/icon/update.png',
|
113
|
+
},
|
114
|
+
"Nhập dữ liệu Xi ngoài": {
|
115
|
+
"Xi ngoài": f'{static_dir}/icon/icons8-file-64.png',
|
116
|
+
"Xi nội bộ": f'{static_dir}/icon/icons8-opened-folder-50.png',
|
117
|
+
"Xuất tạm": None,
|
118
|
+
},
|
119
|
+
}
|
120
|
+
|
121
|
+
def get_icon_config(self):
|
122
|
+
return {
|
123
|
+
'eye_open': '👁️',
|
124
|
+
'eye_closed': '👁️🗨️',
|
125
|
+
'smile': '😀',
|
126
|
+
'party': '🎉',
|
127
|
+
'rocket': '🚀',
|
128
|
+
'star': '🌟',
|
129
|
+
'heart': '❤️',
|
130
|
+
'thumbs_up': '👍',
|
131
|
+
'fire': '🔥',
|
132
|
+
'check_mark': '✔️',
|
133
|
+
'clap': '👏',
|
134
|
+
'sun': '☀️',
|
135
|
+
'moon': '🌙',
|
136
|
+
'sparkles': '✨',
|
137
|
+
'gift': '🎁',
|
138
|
+
'music': '🎵',
|
139
|
+
'folder': '📁',
|
140
|
+
'file': '📄',
|
141
|
+
'add_button': '➕',
|
142
|
+
'remove_button': '➖',
|
143
|
+
'edit_button': '✏️',
|
144
|
+
'open_folder': '📂',
|
145
|
+
'close_folder': '📁',
|
146
|
+
'user': '👤',
|
147
|
+
'sys': '🖥️',
|
148
|
+
'lock': '🔒',
|
149
|
+
'unlock': '🔓',
|
150
|
+
'search': '🔍',
|
151
|
+
'settings': '⚙️',
|
152
|
+
'warning': '⚠️',
|
153
|
+
}
|
154
|
+
|
155
|
+
def get_static_dir(self):
|
156
|
+
return str(Path(__file__).parent.parent / 'static')
|
157
|
+
|
158
|
+
if __name__ == "__main__":
|
159
|
+
settings = Settings()
|
160
|
+
print(settings.STATIC_DIR)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: vunghixuan
|
3
|
+
Version: 0.1.5
|
4
|
+
Summary: Get API, OTP, Create Project
|
5
|
+
Home-page: https://github.com/VuNghiXuan/pypi_package
|
6
|
+
Author: Đặng Thanh Vũ
|
7
|
+
Author-email: vunghixuan.info@gmail.com
|
8
|
+
License: MIT
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
11
|
+
Classifier: Operating System :: OS Independent
|
12
|
+
Requires-Python: >=3.11
|
13
|
+
Requires-Dist: pyotp==2.9.0
|
14
|
+
Requires-Dist: PySide6==6.8.0.1
|
15
|
+
Requires-Dist: PySide6-Addons==6.8.0.1
|
16
|
+
Requires-Dist: PySide6-Essentials==6.8.0.1
|
17
|
+
Requires-Dist: shiboken6==6.8.0.1
|
18
|
+
Requires-Dist: SQLAlchemy==2.0.36
|
19
|
+
Requires-Dist: typing-extensions==4.12.2
|
20
|
+
|
21
|
+
Gói này cung cấp các chức năng để lấy API, tạo OTP và quản lý dự án.Tạo giao diện User - date: 250217
|
@@ -0,0 +1,19 @@
|
|
1
|
+
config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
+
config/config_menubar.py,sha256=1kLsVReyioT1bXKAb3m3kYLEigCr4wMtWem9PssNGiI,2981
|
3
|
+
config/settings.py,sha256=plVjj17BEJDI-0svHemrX4wX3ha8hzzqENFnMqu6unE,3268
|
4
|
+
config/settings_1.py,sha256=j9oPVI1CCMGbiljtBsriyBwqqpR0LBwRBs2-mLqYW2Y,2639
|
5
|
+
config/settings_2.py,sha256=0YEc52bvgZqMG5aECLv2CYzN5ZhFfWVjV-rCSUDTQvw,481
|
6
|
+
vunghixuan/__init__.py,sha256=QGSw4yETjDxxoQjcid82l4nXZkEEU5qr4aviomuhkrs,56
|
7
|
+
vunghixuan/api_and_otp.py,sha256=qmqVzLgnqYW1fFIpuh8PefTChiFXRHG3yhZb8aJwlZ8,568
|
8
|
+
vunghixuan/create_files_for_package.py,sha256=Ke8vnvdasuZDs2iYuEbAHQrFmh5M9coQHH1AO03X0_w,1754
|
9
|
+
vunghixuan/gui_main.py,sha256=GIA5-U8X_fBNURabAAKPZ9Ke5rp2qhlbVV2sXDkLvK0,11162
|
10
|
+
vunghixuan/login.py,sha256=WRbCSx8TL_bsf5aNSk_V6VUe145RhTBTAhqwPAWElqY,3054
|
11
|
+
vunghixuan/main.py,sha256=WhPjThCtLvgsgbhK-I-kP30Zt7EW-OYb0ZCsNstchq4,1022
|
12
|
+
vunghixuan/project.py,sha256=BN8v9EjUjPTSLE88qiA0xgxsAkPoTOtmEuXAyvxyNEU,1995
|
13
|
+
vunghixuan/setting_controlls.py,sha256=63oN7Moc-oK87lFezzjk-ZIG6WXuhmYwYf_3nh_pvPo,2542
|
14
|
+
vunghixuan/settings.py,sha256=EqDmb9-Kx0nk1zkXBG9nGQ_Ymg4MjLwN3hSLwL4-uUA,5349
|
15
|
+
vunghixuan-0.1.5.dist-info/METADATA,sha256=78MTYuiES2NsE8PtUnke4z9w-IfKyiF8jaIbpiVX8Lc,796
|
16
|
+
vunghixuan-0.1.5.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
17
|
+
vunghixuan-0.1.5.dist-info/entry_points.txt,sha256=Utdw3O49hu1VQ86htVBlrYCn3XhMzMBEOosiSHz9jGs,47
|
18
|
+
vunghixuan-0.1.5.dist-info/top_level.txt,sha256=yxe7ZwtEd9zQ2VvXcytSUQtodALb2Iogjkwc22-1tp4,18
|
19
|
+
vunghixuan-0.1.5.dist-info/RECORD,,
|
@@ -1,12 +0,0 @@
|
|
1
|
-
vunghixuan/__init__.py,sha256=XJZldrnzPcJ9Okg129nZo82TDpxOm6amb5xAX5rkzyg,38
|
2
|
-
vunghixuan/api_and_otp.py,sha256=qmqVzLgnqYW1fFIpuh8PefTChiFXRHG3yhZb8aJwlZ8,568
|
3
|
-
vunghixuan/create_gui.py,sha256=CBmDHKrU8XDh5D23NjO9-aR0Z1AXjgaiUFKwJao8kA4,10161
|
4
|
-
vunghixuan/create_project.py,sha256=em94tNc1Wj8jL8CCf9MLNqjBMecF78zx6VtmloTHSiI,1917
|
5
|
-
vunghixuan/login.py,sha256=f_D1Q8u3HMxMGTc9MX76oGyttSLf0OMKLZDGAV4d5p8,3004
|
6
|
-
vunghixuan/main.py,sha256=UXIPv09rCDvozi73EFYdCfbVUSJ0FhNWlPh8bwoGVfw,1089
|
7
|
-
vunghixuan/settings.py,sha256=srShsnEDDr_74JPBMRhnITQwgy8uW4RhwUi5zhsvj3I,742
|
8
|
-
vunghixuan-0.1.4.dist-info/METADATA,sha256=9r5D_bdRGH8zwqQtIA_SgtyyBXMi2VtAiwVMd9uTiTU,208
|
9
|
-
vunghixuan-0.1.4.dist-info/WHEEL,sha256=A3WOREP4zgxI0fKrHUG8DC8013e3dK3n7a6HDbcEIwE,91
|
10
|
-
vunghixuan-0.1.4.dist-info/entry_points.txt,sha256=ItPfGjQnpyp6eR1oHdSbpfuf309GxCvEpX64UwBBTAU,52
|
11
|
-
vunghixuan-0.1.4.dist-info/top_level.txt,sha256=_Q6TIeNruS-ZEyAlP1gS80DCPggKksv8GoO396v9gr8,11
|
12
|
-
vunghixuan-0.1.4.dist-info/RECORD,,
|