vunghixuan 0.1.3__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- vunghixuan-0.1.3/PKG-INFO +7 -0
- vunghixuan-0.1.3/setup.cfg +4 -0
- vunghixuan-0.1.3/setup.py +82 -0
- vunghixuan-0.1.3/src/vunghixuan/__init__.py +1 -0
- vunghixuan-0.1.3/src/vunghixuan/api_and_otp.py +23 -0
- vunghixuan-0.1.3/src/vunghixuan/create_gui.py +310 -0
- vunghixuan-0.1.3/src/vunghixuan/create_project.py +66 -0
- vunghixuan-0.1.3/src/vunghixuan/login.py +84 -0
- vunghixuan-0.1.3/src/vunghixuan/main.py +38 -0
- vunghixuan-0.1.3/src/vunghixuan/settings.py +24 -0
- vunghixuan-0.1.3/src/vunghixuan.egg-info/PKG-INFO +7 -0
- vunghixuan-0.1.3/src/vunghixuan.egg-info/SOURCES.txt +16 -0
- vunghixuan-0.1.3/src/vunghixuan.egg-info/dependency_links.txt +1 -0
- vunghixuan-0.1.3/src/vunghixuan.egg-info/entry_points.txt +2 -0
- vunghixuan-0.1.3/src/vunghixuan.egg-info/requires.txt +1 -0
- vunghixuan-0.1.3/src/vunghixuan.egg-info/top_level.txt +1 -0
- vunghixuan-0.1.3/test/test_api_otp.py +14 -0
- vunghixuan-0.1.3/test/test_create_gui.py +18 -0
@@ -0,0 +1,82 @@
|
|
1
|
+
# setup.py
|
2
|
+
|
3
|
+
from setuptools import setup, find_packages
|
4
|
+
|
5
|
+
# setup(
|
6
|
+
# name='vunghixuan_package',
|
7
|
+
# version='0.1.0',
|
8
|
+
# description='API, OTP, Create Project',
|
9
|
+
# author='Đăng Thanh Vũ',
|
10
|
+
# author_email='vunghixuan@gmail.com',
|
11
|
+
# packages=find_packages(where='src'), #Tìm kiếm và liệt kê các gói con trong thư mục src, nơi chứa mã nguồn chính.
|
12
|
+
# package_dir={'': 'src'}, #Chỉ định thư mục chứa các gói, ở đây là {'': 'src'} nghĩa là gói nằm trong thư mục src.
|
13
|
+
# install_requires=['python-dotenv','requests', 'pyotp', 'setuptools'], # Các gói phụ thuộc
|
14
|
+
# entry_points={
|
15
|
+
# 'console_scripts': [
|
16
|
+
# 'vunghixuan_package=vunghixuan_package.main:main'
|
17
|
+
# ]
|
18
|
+
# }
|
19
|
+
# )
|
20
|
+
|
21
|
+
|
22
|
+
from setuptools import setup, find_packages
|
23
|
+
|
24
|
+
setup(
|
25
|
+
name='vunghixuan',
|
26
|
+
version='0.1.3',
|
27
|
+
packages=find_packages(where='src'),
|
28
|
+
description='Get API, OTP, Create Project, Date_created = 2025-01-08',
|
29
|
+
author='Đặng Thanh Vũ',
|
30
|
+
author_email='vunghixuan@gmail.com',
|
31
|
+
package_dir={'': 'src'},
|
32
|
+
install_requires=[
|
33
|
+
'pyotp',
|
34
|
+
],
|
35
|
+
entry_points={
|
36
|
+
'console_scripts': [
|
37
|
+
'vunghixuan = vunghixuan.main:main',
|
38
|
+
],
|
39
|
+
},
|
40
|
+
)
|
41
|
+
|
42
|
+
"""
|
43
|
+
Quy trình phát hành gói Python bao gồm nhiều bước quan trọng, mỗi bước đều có chức năng riêng biệt:
|
44
|
+
|
45
|
+
1. pip install .: Lệnh này được sử dụng để cài đặt gói Python từ thư mục hiện tại. Nó sẽ tìm kiếm file setup.py và cài đặt gói theo cấu hình đã định nghĩa.
|
46
|
+
|
47
|
+
2. python setup.py sdist bdist_wheel: Lệnh này tạo ra các gói phân phối. sdist tạo ra gói nguồn, trong khi bdist_wheel tạo ra gói nhị phân (wheel). Điều này giúp người dùng có thể cài đặt gói một cách dễ dàng hơn.
|
48
|
+
|
49
|
+
Vào folder dist lấy thông tin file và: Sau khi tạo gói, bạn cần vào thư mục dist để tìm file gói đã tạo.
|
50
|
+
|
51
|
+
3. pip install dist/vunghixuan-0.1.2-py3-none-any.whl: Lệnh này cài đặt gói đã được tạo ra từ thư mục dist.
|
52
|
+
|
53
|
+
4. Cập nhật nếu hỏi: pip install dist/vunghixuan-0.1.1-py3-none-any.whl --force-reinstall: Nếu bạn cần cập nhật gói đã cài đặt, lệnh này sẽ cài đặt lại gói, bất kể phiên bản hiện tại.
|
54
|
+
|
55
|
+
5. Chạy file main lấy opt 6 chứ số và mở pypi đưa vào
|
56
|
+
|
57
|
+
5. Bản 0.1.2: twine upload dist/* -u __token__ -p pypi-AgEIcHlwaS5vcmcCJDdmZmViYzIwLWJkYjctNDhmZC1hOTI3LTM0ZTIyYzQ4Mzk5YgACKlszLCI4OWIwMTU4NS0wNzFhLTQ1M2ItYTU2Yi1lMjU2YTAyYzUzMzkiXQAABiAwRKMR8U-1QAq-lIozrcJy9SwZhwaCG0VUyE1gsZKLWA --verbose
|
58
|
+
|
59
|
+
|
60
|
+
pypi-AgEIcHlwaS5vcmcCJDdmZmViYzIwLWJkYjctNDhmZC1hOTI3LTM0ZTIyYzQ4Mzk5YgACKlszLCI4OWIwMTU4NS0wNzFhLTQ1M2ItYTU2Yi1lMjU2YTAyYzUzMzkiXQAABiAwRKMR8U-1QAq-lIozrcJy9SwZhwaCG0VUyE1gsZKLWA
|
61
|
+
|
62
|
+
Tóm lại, bước 1 và 2 tạo môi trường local, trong khi bước 5 là bước tải lên gói lên PyPI.
|
63
|
+
|
64
|
+
6. Sử dụng lệnh gỡ bỏ: twine remove <tên-gói> --version <phiên-bản> -u __token__ -p pypi
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
Mã Otp:
|
71
|
+
obj = Otp('OXATAFVTTUIVMXNQCKMZAOFZYUYE6MGZ').get_otp()
|
72
|
+
|
73
|
+
src/
|
74
|
+
│ │
|
75
|
+
│ └── vunghixuan/
|
76
|
+
│ ├── __init__.py
|
77
|
+
│ ├── create_project.py
|
78
|
+
│ ├── api_and_otp.py
|
79
|
+
│ └── main.py
|
80
|
+
│
|
81
|
+
└── setup.py
|
82
|
+
"""
|
@@ -0,0 +1 @@
|
|
1
|
+
from .api_and_otp import APIKey, Otp
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# src/vunghixuan/create_project.py
|
2
|
+
import pyotp
|
3
|
+
class APIKey:
|
4
|
+
def __init__(self, key):
|
5
|
+
self.key = key
|
6
|
+
|
7
|
+
def get_api(self):
|
8
|
+
# Thực hiện các tác vụ của bạn
|
9
|
+
print(self.key)
|
10
|
+
|
11
|
+
class Otp:
|
12
|
+
def __init__(self):
|
13
|
+
pass
|
14
|
+
|
15
|
+
def get_otp(self, key):
|
16
|
+
# Thực hiện các tác vụ của bạn
|
17
|
+
topt = pyotp.TOTP(key)
|
18
|
+
print(topt.now())
|
19
|
+
|
20
|
+
# Đây là mã của pypi vunghixuan
|
21
|
+
def otp_vunghixuan(self):
|
22
|
+
key = 'OXATAFVTTUIVMXNQCKMZAOFZYUYE6MGZ'
|
23
|
+
self.get_otp(key)
|
@@ -0,0 +1,310 @@
|
|
1
|
+
import sys
|
2
|
+
from PySide6.QtWidgets import(
|
3
|
+
QApplication,
|
4
|
+
QMainWindow,
|
5
|
+
QWidget,
|
6
|
+
QHBoxLayout,
|
7
|
+
QVBoxLayout,
|
8
|
+
QLabel,
|
9
|
+
QLineEdit,
|
10
|
+
QPushButton,
|
11
|
+
QTabBar, QTabWidget,
|
12
|
+
QMessageBox,
|
13
|
+
QComboBox
|
14
|
+
|
15
|
+
)
|
16
|
+
from PySide6.QtGui import QColor, QFont
|
17
|
+
from vunghixuan.login import LoginGroupBox
|
18
|
+
from PySide6.QtGui import QPixmap
|
19
|
+
from vunghixuan.settings import COLOR_FONT_BACKGROUND, color_fnt_bg
|
20
|
+
# color_default = COLOR_FONT_BACKGROUND['Xanh lục, chữ trắng']
|
21
|
+
# print(color_font_background)
|
22
|
+
|
23
|
+
class LoginForm(QWidget):
|
24
|
+
def __init__(self):
|
25
|
+
super().__init__()
|
26
|
+
self.initUI()
|
27
|
+
|
28
|
+
def initUI(self):
|
29
|
+
layout = QVBoxLayout()
|
30
|
+
self.username = QLineEdit(self)
|
31
|
+
self.password = QLineEdit(self)
|
32
|
+
self.password.setEchoMode(QLineEdit.Password)
|
33
|
+
login_button = QPushButton('Đăng Nhập', self)
|
34
|
+
login_button.clicked.connect(self.handle_login)
|
35
|
+
|
36
|
+
layout.addWidget(QLabel("Tên đăng nhập:"))
|
37
|
+
layout.addWidget(self.username)
|
38
|
+
layout.addWidget(QLabel("Mật khẩu:"))
|
39
|
+
layout.addWidget(self.password)
|
40
|
+
layout.addWidget(login_button)
|
41
|
+
|
42
|
+
self.setLayout(layout)
|
43
|
+
|
44
|
+
def handle_login(self):
|
45
|
+
# Kiểm tra thông tin đăng nhập (đơn giản)
|
46
|
+
if self.username.text() == "admin" and self.password.text() == "password":
|
47
|
+
self.parent().show_content() # Hiện nội dung chính
|
48
|
+
self.close() # Đóng form đăng nhập
|
49
|
+
|
50
|
+
# Create Header
|
51
|
+
class Header(QWidget):
|
52
|
+
def __init__(self):
|
53
|
+
super().__init__()
|
54
|
+
self.initUI()
|
55
|
+
|
56
|
+
def initUI(self):
|
57
|
+
# self.dic_theme = {}
|
58
|
+
self.set_background(color_fnt_bg)
|
59
|
+
# self.set_background(QColor(0, 127, 140)) ##FF5733
|
60
|
+
# self.set_background(QColor('#FF5733')) ##FF5733
|
61
|
+
|
62
|
+
|
63
|
+
layout = QHBoxLayout()
|
64
|
+
layout.setContentsMargins(10, 10, 10, 10) # Căn chỉnh nội dung
|
65
|
+
|
66
|
+
# Logo trái
|
67
|
+
# ico = QPixmap("src/vunghixuan/img/vunghixuan_logo.png")
|
68
|
+
# scaled_ico = ico.scaled(100, 100) # Thay đổi kích thước thành 100x100 pixel
|
69
|
+
# logo = QLabel()
|
70
|
+
# logo.setPixmap(scaled_ico)
|
71
|
+
|
72
|
+
logo = QLabel('VuNghiXuan')
|
73
|
+
|
74
|
+
font = QFont('Brush Script MT', 30)
|
75
|
+
# font = QFont('Dancing Script', 20)#('Segoe Script', 20)#('Lucida Handwriting', 20)#('Brush Script MT', 20) # Thay đổi font chữ ở đây
|
76
|
+
|
77
|
+
logo.setFont(font)
|
78
|
+
logo.setStyleSheet("color: gold;")
|
79
|
+
|
80
|
+
# logo.setStyleSheet("font-size: 20px; color: gold;")
|
81
|
+
layout.addWidget(logo)
|
82
|
+
|
83
|
+
layout.addStretch()
|
84
|
+
|
85
|
+
|
86
|
+
# # Nút để chuyển đổi giữa chế độ sáng và tối
|
87
|
+
# toggle_button = QPushButton('Chế độ sáng/tối', self)
|
88
|
+
# toggle_button.clicked.connect(self.toggle_theme)
|
89
|
+
# layout.addWidget(toggle_button)
|
90
|
+
|
91
|
+
# Combobox
|
92
|
+
self.theme_selector = QComboBox(self)
|
93
|
+
list_color = ['-- Chọn nền và màu chữ --']
|
94
|
+
for color in COLOR_FONT_BACKGROUND.keys():
|
95
|
+
list_color.append(color)
|
96
|
+
|
97
|
+
# self.theme_selector.addItems(["Chế độ sáng", "Chế độ tối"])
|
98
|
+
self.theme_selector.addItems(list_color)
|
99
|
+
self.theme_selector.currentIndexChanged.connect(self.change_theme)
|
100
|
+
layout.addWidget(self.theme_selector)
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
# login and register
|
105
|
+
login = QPushButton('Đăng nhập')
|
106
|
+
register = QPushButton('Đăng ký')
|
107
|
+
layout.addWidget(login)
|
108
|
+
layout.addWidget(register)
|
109
|
+
|
110
|
+
# Tạo layout chính
|
111
|
+
main_layout = QVBoxLayout()
|
112
|
+
main_layout.addLayout(layout)
|
113
|
+
main_layout.setContentsMargins(0, 0, 0, 0) # Loại bỏ khoảng cách mặc định
|
114
|
+
|
115
|
+
self.setLayout(main_layout)
|
116
|
+
|
117
|
+
# Đặt kích thước cho Header
|
118
|
+
self.setFixedHeight(50) # Bạn có thể điều chỉnh chiều cao theo ý muốn
|
119
|
+
|
120
|
+
def change_theme(self, index):
|
121
|
+
if index != 0:
|
122
|
+
color_name = self.theme_selector.currentText()
|
123
|
+
color_fnt_bg = COLOR_FONT_BACKGROUND[color_name]
|
124
|
+
|
125
|
+
|
126
|
+
# Tìm kiếm đối tượng MyWindow và gọi phương thức change_theme
|
127
|
+
main_window = self.window() # Lấy đối tượng MyWindow
|
128
|
+
main_window.change_theme(color_fnt_bg)
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
def set_background(self, color_fnt_bg):
|
134
|
+
# Thay toàn bộ màu nền
|
135
|
+
palette = self.palette()
|
136
|
+
palette.setColor(self.backgroundRole(), color_fnt_bg[0]) # Thay đổi màu nền
|
137
|
+
palette.setColor(self.foregroundRole(), color_fnt_bg[1]) # Thay đổi màu chữ
|
138
|
+
self.setAutoFillBackground(True)
|
139
|
+
self.setPalette(palette)
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
# Create Header
|
144
|
+
class Footer(QWidget):
|
145
|
+
def __init__(self):
|
146
|
+
super().__init__()
|
147
|
+
self.initUI()
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
def initUI(self):
|
152
|
+
# self.set_background(QColor(0, 127, 140))
|
153
|
+
|
154
|
+
layout = QHBoxLayout()
|
155
|
+
layout.setContentsMargins(10, 10, 10, 10) # Căn chỉnh nội dung
|
156
|
+
|
157
|
+
# Logo
|
158
|
+
logo = QLabel("@Copyright 2025 by VuNghiXuan")
|
159
|
+
layout.addWidget(logo)
|
160
|
+
|
161
|
+
|
162
|
+
# Tạo layout chính
|
163
|
+
main_layout = QVBoxLayout()
|
164
|
+
main_layout.addLayout(layout)
|
165
|
+
main_layout.setContentsMargins(0, 0, 0, 0) # Loại bỏ khoảng cách mặc định
|
166
|
+
|
167
|
+
self.setLayout(main_layout)
|
168
|
+
|
169
|
+
# Đặt kích thước cho Header
|
170
|
+
self.setFixedHeight(50) # Bạn có thể điều chỉnh chiều cao theo ý muốn
|
171
|
+
|
172
|
+
# Set background
|
173
|
+
self.set_background(color_fnt_bg)
|
174
|
+
|
175
|
+
def set_background(self, color_fnt_bg):
|
176
|
+
palette = self.palette()
|
177
|
+
palette.setColor(self.backgroundRole(), color_fnt_bg[0])
|
178
|
+
palette.setColor(self.foregroundRole(), color_fnt_bg[1])
|
179
|
+
self.setAutoFillBackground(True)
|
180
|
+
self.setPalette(palette)
|
181
|
+
|
182
|
+
|
183
|
+
class Content(QWidget):
|
184
|
+
def __init__(self):
|
185
|
+
super().__init__()
|
186
|
+
self.initUI()
|
187
|
+
|
188
|
+
def initUI(self):
|
189
|
+
self.login_widget = LoginGroupBox() # Sử dụng LoginGroupBox
|
190
|
+
self.tab_widget = QTabWidget()
|
191
|
+
self.tab1 = QWidget()
|
192
|
+
self.tab2 = QWidget()
|
193
|
+
|
194
|
+
self.tab_widget.addTab(self.tab1, "Tab 1")
|
195
|
+
self.tab_widget.addTab(self.tab2, "Tab 2")
|
196
|
+
|
197
|
+
layout = QVBoxLayout()
|
198
|
+
layout.addWidget(self.login_widget)
|
199
|
+
layout.addWidget(self.tab_widget)
|
200
|
+
self.setLayout(layout)
|
201
|
+
|
202
|
+
self.tab_widget.hide() # Ẩn tab ban đầu
|
203
|
+
|
204
|
+
def set_background(self, color_fnt_bg):
|
205
|
+
# palette = self.palette()
|
206
|
+
# palette.setColor(self.backgroundRole(), color_fnt_bg[0])
|
207
|
+
# palette.setColor(self.foregroundRole(), color_fnt_bg[1])
|
208
|
+
# self.setAutoFillBackground(True)
|
209
|
+
# self.setPalette(palette)
|
210
|
+
# Cập nhật màu cho các nhãn
|
211
|
+
for widget in self.findChildren(QLabel):
|
212
|
+
# widget.setStyleSheet(f"background-color: {color_fnt_bg[0]}; color: {color_fnt_bg[1]};")
|
213
|
+
widget.setStyleSheet(f"background-color: {color_fnt_bg[0]}; color: {color_fnt_bg[1]}; font-size: 18px;")
|
214
|
+
|
215
|
+
class BackgroundManager:
|
216
|
+
def __init__(self, widgets):
|
217
|
+
self.widgets = widgets # Danh sách các widget cần thay đổi màu nền
|
218
|
+
|
219
|
+
|
220
|
+
def set_background(self, color_fnt_bg):
|
221
|
+
for widget in self.widgets:
|
222
|
+
widget.set_background(color_fnt_bg)
|
223
|
+
# palette = widget.palette()
|
224
|
+
# palette.setColor(widget.backgroundRole(), color)
|
225
|
+
# widget.setAutoFillBackground(True)
|
226
|
+
# widget.setPalette(palette)
|
227
|
+
|
228
|
+
|
229
|
+
# Create window
|
230
|
+
class MyWindow(QMainWindow):
|
231
|
+
def __init__(self):
|
232
|
+
super().__init__()
|
233
|
+
self.initUI()
|
234
|
+
|
235
|
+
def initUI(self):
|
236
|
+
|
237
|
+
self.setGeometry(100, 100, 800, 600)
|
238
|
+
self.setWindowTitle('Phần mềm VuNghiXuan')
|
239
|
+
|
240
|
+
# Tạo ra Qwidget trung tâm
|
241
|
+
center_layout = QWidget()
|
242
|
+
|
243
|
+
# Put layout Header
|
244
|
+
main_layout = QVBoxLayout()
|
245
|
+
self.header = Header()
|
246
|
+
main_layout.addWidget(self.header)
|
247
|
+
|
248
|
+
# Put Content
|
249
|
+
self.content = Content()
|
250
|
+
main_layout.addWidget(self.content)
|
251
|
+
|
252
|
+
|
253
|
+
# Thêm lớp co dãn
|
254
|
+
# main_layout.addStretch()
|
255
|
+
|
256
|
+
|
257
|
+
# Put layout Footer
|
258
|
+
self.footer = Footer()
|
259
|
+
main_layout.addWidget(self.footer)
|
260
|
+
|
261
|
+
center_layout.setLayout(main_layout)
|
262
|
+
|
263
|
+
# Căn chỉnh nội dung
|
264
|
+
main_layout.setContentsMargins(0, 0, 0, 0)
|
265
|
+
|
266
|
+
# Set center_layout
|
267
|
+
self.setCentralWidget(center_layout)
|
268
|
+
|
269
|
+
# Setting background_manager
|
270
|
+
self.background_manager = BackgroundManager([self.header, self.footer, self.content])
|
271
|
+
|
272
|
+
|
273
|
+
def change_theme(self, color_fnt_bg):
|
274
|
+
self.background_manager.set_background(color_fnt_bg)
|
275
|
+
self.update_color_theme()
|
276
|
+
|
277
|
+
def update_color_theme(self):
|
278
|
+
color_fnt_bg = self.header.theme_selector.currentText()
|
279
|
+
with open('vunghixuan/settings.py', 'r', encoding='utf-8' ) as file:
|
280
|
+
lines = file.readlines()
|
281
|
+
|
282
|
+
with open('vunghixuan/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
|
+
|
289
|
+
# def toggle_theme(self):
|
290
|
+
# current_color = self.palette().color(self.backgroundRole())
|
291
|
+
# new_color = QColor(255, 255, 255) if current_color == QColor(0, 127, 140) else QColor(0, 127, 140)
|
292
|
+
# self.change_theme(new_color)
|
293
|
+
|
294
|
+
|
295
|
+
|
296
|
+
def create_gui():
|
297
|
+
app = QApplication(sys.argv)
|
298
|
+
window = MyWindow()
|
299
|
+
window.show()
|
300
|
+
sys.exit(app.exec())
|
301
|
+
|
302
|
+
|
303
|
+
|
304
|
+
if __name__=='__main__':
|
305
|
+
create_gui()
|
306
|
+
# app = QApplication(sys.argv)
|
307
|
+
# window = MyWindow()
|
308
|
+
# window.show()
|
309
|
+
# sys.exit(app.exec())
|
310
|
+
# main()
|
@@ -0,0 +1,66 @@
|
|
1
|
+
|
2
|
+
# src/vunghixuan/create_project.py
|
3
|
+
import os
|
4
|
+
from pathlib import Path
|
5
|
+
|
6
|
+
class Project:
|
7
|
+
def __init__(self):
|
8
|
+
# self.root_path = Path(__file__).parent
|
9
|
+
self.root_path = Path(os.getcwd()) # Lấy đường dẫn hiện tại
|
10
|
+
# self.create_project()
|
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
|
23
|
+
def create_folder(self, folder_path, name):
|
24
|
+
folder_path = os.path.join(folder_path, name)
|
25
|
+
os.makedirs(folder_path, exist_ok=True)
|
26
|
+
|
27
|
+
# Tạo ra folder apps
|
28
|
+
def create_project(self):
|
29
|
+
list_folder = ['apps', 'config', 'data_base']
|
30
|
+
for folder in list_folder:
|
31
|
+
self.create_folder(self.root_path, folder)
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
def create_app(self, app_name):
|
36
|
+
folder_path = os.path.join(self.root_path, 'apps')
|
37
|
+
|
38
|
+
if not os.path.exists(folder_path):
|
39
|
+
self.create_project()
|
40
|
+
self.create_app(app_name)
|
41
|
+
else:
|
42
|
+
self.create_folder(folder_path, app_name)
|
43
|
+
folder_path = os.path.join(self.root_path, 'apps', app_name)
|
44
|
+
|
45
|
+
list_folder = ['models', 'views', 'controlers']
|
46
|
+
for folder in list_folder:
|
47
|
+
self.create_folder(folder_path, folder)
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
if __name__=="__main__":
|
58
|
+
|
59
|
+
project = Project()
|
60
|
+
|
61
|
+
# 1. Tạo ra project
|
62
|
+
# project.create_project()
|
63
|
+
|
64
|
+
# 2. Tạo app
|
65
|
+
project.create_app('app1')
|
66
|
+
|
@@ -0,0 +1,84 @@
|
|
1
|
+
from PySide6.QtWidgets import(
|
2
|
+
|
3
|
+
QWidget,
|
4
|
+
|
5
|
+
QVBoxLayout,
|
6
|
+
QLabel,
|
7
|
+
QLineEdit,
|
8
|
+
QPushButton,
|
9
|
+
QTabWidget,
|
10
|
+
QMessageBox,
|
11
|
+
QGroupBox,
|
12
|
+
QSizePolicy
|
13
|
+
|
14
|
+
)
|
15
|
+
from PySide6.QtCore import Qt
|
16
|
+
from PySide6.QtGui import QColor
|
17
|
+
from vunghixuan.settings import color_fnt_bg
|
18
|
+
|
19
|
+
class LoginGroupBox(QWidget):
|
20
|
+
def __init__(self):
|
21
|
+
super().__init__()
|
22
|
+
self.initUI()
|
23
|
+
|
24
|
+
def set_background(self):
|
25
|
+
# Tạo nền xanh
|
26
|
+
palette = self.palette()
|
27
|
+
palette.setColor(self.backgroundRole(), color_fnt_bg[0]) # Màu xanh lục
|
28
|
+
palette.setColor(self.backgroundRole(), color_fnt_bg[1]) # Màu xanh lục
|
29
|
+
|
30
|
+
self.setAutoFillBackground(True)
|
31
|
+
self.setPalette(palette)
|
32
|
+
|
33
|
+
def initUI(self):
|
34
|
+
# self.set_background()
|
35
|
+
|
36
|
+
layout = QVBoxLayout()
|
37
|
+
group_box = QGroupBox("") #Đăng Nhập
|
38
|
+
|
39
|
+
lb_login = QLabel('ĐĂNG NHẬP HỆ THỐNG')
|
40
|
+
# lb_login.setStyleSheet("font-size: 20px; color: white;")
|
41
|
+
lb_login.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
42
|
+
lb_login.setFixedHeight(30) # Thiết lập chiều cao cố định cho lb_login
|
43
|
+
|
44
|
+
|
45
|
+
lb_login.setStyleSheet(f"background-color: {color_fnt_bg[0]}; color: {color_fnt_bg[1]}; font-size: 18px;")
|
46
|
+
# lb_login.setStyleSheet('background-color: #007f8c; font-size: 20px; color: white;')
|
47
|
+
# lb_login.setStyleSheet(f"background-color: {QColor(0, 127, 140).name()};")
|
48
|
+
# '#007f8c'
|
49
|
+
# print(QColor(0, 127, 140).name())
|
50
|
+
|
51
|
+
self.username_input = QLineEdit()
|
52
|
+
self.username_input.setPlaceholderText("Tên người dùng")
|
53
|
+
self.password_input = QLineEdit()
|
54
|
+
self.password_input.setPlaceholderText("Mật khẩu")
|
55
|
+
self.password_input.setEchoMode(QLineEdit.Password)
|
56
|
+
|
57
|
+
login_button = QPushButton("Đăng Nhập")
|
58
|
+
login_button.clicked.connect(self.handle_login)
|
59
|
+
|
60
|
+
layout.addWidget(lb_login)
|
61
|
+
layout.addWidget(self.username_input)
|
62
|
+
layout.addWidget(self.password_input)
|
63
|
+
layout.addWidget(login_button)
|
64
|
+
group_box.setLayout(layout)
|
65
|
+
|
66
|
+
main_layout = QVBoxLayout()
|
67
|
+
main_layout.addWidget(group_box)
|
68
|
+
self.setLayout(main_layout)
|
69
|
+
|
70
|
+
# Thiết lập kích thước tối thiểu cho form
|
71
|
+
self.setMaximumSize(350, 250)
|
72
|
+
# self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
73
|
+
|
74
|
+
def handle_login(self):
|
75
|
+
username = self.username_input.text()
|
76
|
+
password = self.password_input.text()
|
77
|
+
|
78
|
+
if username == "admin" and password == "password":
|
79
|
+
QMessageBox.information(self, "Thành công", "Đăng nhập thành công!")
|
80
|
+
self.parent().tab_widget.show() # Hiện tab
|
81
|
+
self.hide() # Ẩn form đăng nhập
|
82
|
+
else:
|
83
|
+
QMessageBox.warning(self, "Lỗi", "Tên người dùng hoặc mật khẩu không đúng.")
|
84
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# src/vunghixuan/main.py
|
2
|
+
import sys
|
3
|
+
from .api_and_otp import APIKey, Otp
|
4
|
+
from .create_project import Project
|
5
|
+
from . import create_gui
|
6
|
+
# from PySide6.QtWidgets import QApplication
|
7
|
+
def main():
|
8
|
+
args = sys.argv[1:]
|
9
|
+
if '-h' in args or '--help' in args:
|
10
|
+
print("Help message")
|
11
|
+
else:
|
12
|
+
key = args[1] if len(args) > 1 else None
|
13
|
+
if key:
|
14
|
+
if '-api' in args:
|
15
|
+
obj = APIKey(key)
|
16
|
+
obj.get_api()
|
17
|
+
if '-otp' in args or '-totp' in args:
|
18
|
+
obj = Otp(key)
|
19
|
+
obj.get_otp()
|
20
|
+
if '-create_project' in args :
|
21
|
+
obj = Project(key)
|
22
|
+
obj.create_project()
|
23
|
+
if '-create_app' in args :
|
24
|
+
obj = Project(key)
|
25
|
+
obj.create_app()
|
26
|
+
else:
|
27
|
+
print("Missing API key")
|
28
|
+
|
29
|
+
# Tạo giao diên chính
|
30
|
+
# create_gui.create_gui()
|
31
|
+
|
32
|
+
|
33
|
+
if __name__ == '__main__':
|
34
|
+
main()
|
35
|
+
# app = QApplication(sys.argv)
|
36
|
+
# window = MyWindow()
|
37
|
+
# window.show()
|
38
|
+
# sys.exit(app.exec())
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# src/vunghixuan/settings.py
|
2
|
+
|
3
|
+
# Cặp màu nền và chữ
|
4
|
+
COLOR = {
|
5
|
+
'Trắng' : '#FFFFFF',
|
6
|
+
'Đen' : '#000000',
|
7
|
+
'Đỏ': 'F70000',
|
8
|
+
'Xanh lục' : '#007f8c',
|
9
|
+
'Xanh lục tối':'#29465B',
|
10
|
+
'Xanh lá cây':'#006400',
|
11
|
+
'Vàng gold': '#FFD700',
|
12
|
+
|
13
|
+
|
14
|
+
}
|
15
|
+
COLOR_FONT_BACKGROUND ={
|
16
|
+
'Nền xanh lục, chữ trắng': ['#007f8c', '#FFFFFF'], # xanh lục tối
|
17
|
+
'Nền xanh xám, chữ vàng Gold': ['#29465B', '#FFD700'], #Gold (W3C)
|
18
|
+
'Nền xanh xám, chữ trắng': ['#29465B', '#FFFFFF'], # xanh lục tối #29465B
|
19
|
+
'Nền đen, chữ trắng': ['#000000', '#FFFFFF'],
|
20
|
+
'Nền đen, chữ vàng': ['#000000', '#FFD700'],
|
21
|
+
|
22
|
+
}
|
23
|
+
color_fnt_bg = COLOR_FONT_BACKGROUND['Nền xanh xám, chữ vàng Gold']
|
24
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
setup.py
|
2
|
+
src/vunghixuan/__init__.py
|
3
|
+
src/vunghixuan/api_and_otp.py
|
4
|
+
src/vunghixuan/create_gui.py
|
5
|
+
src/vunghixuan/create_project.py
|
6
|
+
src/vunghixuan/login.py
|
7
|
+
src/vunghixuan/main.py
|
8
|
+
src/vunghixuan/settings.py
|
9
|
+
src/vunghixuan.egg-info/PKG-INFO
|
10
|
+
src/vunghixuan.egg-info/SOURCES.txt
|
11
|
+
src/vunghixuan.egg-info/dependency_links.txt
|
12
|
+
src/vunghixuan.egg-info/entry_points.txt
|
13
|
+
src/vunghixuan.egg-info/requires.txt
|
14
|
+
src/vunghixuan.egg-info/top_level.txt
|
15
|
+
test/test_api_otp.py
|
16
|
+
test/test_create_gui.py
|
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
pyotp
|
@@ -0,0 +1 @@
|
|
1
|
+
vunghixuan
|
@@ -0,0 +1,14 @@
|
|
1
|
+
from vunghixuan import APIKey, Otp
|
2
|
+
# obj = APIKey("your_api_key")
|
3
|
+
# obj.get_api()
|
4
|
+
|
5
|
+
obj = Otp('OXATAFVTTUIVMXNQCKMZAOFZYUYE6MGZ').get_otp()
|
6
|
+
obj = Otp()
|
7
|
+
obj.otp_vunghixuan()
|
8
|
+
|
9
|
+
# from vunghixuan.create_project import Project
|
10
|
+
|
11
|
+
# obj = Project()
|
12
|
+
# obj.create_project()
|
13
|
+
|
14
|
+
# from .sr
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# from vunghixuan import APIKey, Otp
|
2
|
+
# obj = APIKey("your_api_key")
|
3
|
+
# obj.get_api()
|
4
|
+
|
5
|
+
# obj = Otp('OXATAFVTTUIVMXNQCKMZAOFZYUYE6MGZ').get_otp()
|
6
|
+
# obj = Otp()
|
7
|
+
# obj.otp_vunghixuan()
|
8
|
+
|
9
|
+
# from vunghixuan.create_project import Project
|
10
|
+
|
11
|
+
# obj = Project()
|
12
|
+
# obj.create_project()
|
13
|
+
|
14
|
+
# from .sr
|
15
|
+
|
16
|
+
from src.vunghixuan import create_gui
|
17
|
+
|
18
|
+
create_gui.create_gui()
|