# Punch Clock

# main.py

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
import sys
import csv
from datetime import datetime
from pathlib import Path

from PySide6.QtWidgets import (
QApplication,
QWidget,
QHBoxLayout,
QVBoxLayout,
QPushButton,
QLCDNumber,
QTableView,
QHeaderView,
QFileDialog,
QItemDelegate,
QComboBox,
QAbstractItemView,
QMainWindow,
QMenu,
QStyle,
QLabel,
)
from PySide6.QtCore import (
Qt,
QTimer,
QAbstractTableModel,
QItemSelectionModel,
QSize,
)
from PySide6.QtGui import QIcon, QColor, QAction, QKeySequence

import qtmodern.styles
import qtmodern.windows


class ComboDelegate(QItemDelegate):
def __init__(self, parent):
super().__init__(parent)
self.parent = parent

def createEditor(self, parent, option, index):
combobox = QComboBox(parent)
combobox.addItems(self.items)
return combobox

def setItems(self, items):
self.items = items


class TableModel(QAbstractTableModel):
def __init__(self, data):
super(TableModel, self).__init__()
self._header = data[0]
self._data = data[1:]

def headerData(self, section, orientation, role=Qt.DisplayRole):
if orientation == Qt.Horizontal and role == Qt.DisplayRole:
return self._header[section]
return super().headerData(section, orientation, role)

def setData(self, index, value, role):
if role == Qt.EditRole:
self._data[index.row()][index.column()] = value
return True
return False

def rowCount(self, index):
return len(self._data)

def columnCount(self, index):
return len(self._data[0])

def flags(self, index):
return Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable

def data(self, index, role):
if role == Qt.DisplayRole or role == Qt.EditRole:
value = self._data[index.row()][index.column()]
return value

if role == Qt.DecorationRole:
value = self._data[index.row()][index.column()]

if index.column() in [3, 4]:
return QIcon("../assets/calendar-day.png")

if index.column() in [5, 6]:
return QIcon("../assets/calendar--minus.png")

if value == "是":
return QIcon("../assets/tick.png")

if value == "否":
return QIcon("../assets/cross.png")

if role == Qt.BackgroundRole:
value = self._data[index.row()][index.column()]

if index.column() == 5 and int(value[0:2]) < 9:
return QColor("#4CAF50")

if index.column() == 6 and value != "":
if int(value[0:2]) > 18:
return QColor("#2196F3")

def append(self, now: datetime):
day = now.strftime("%Y-%m-%d")
time = now.strftime("%H:%M")

row = [
"IT",
"ABC",
"JBN",
day,
day,
time,
"",
"否",
"平日加班",
"Daily Work",
"否",
"否",
]
self._data.append(row)

def update(self, now: datetime):
day = now.strftime("%Y-%m-%d")
time = now.strftime("%H:%M")
for index, item in enumerate(self._data):
if day in item:
self._data[index][6] = time

def get_data(self):
return [self._header, *self._data]

def remove_row(self, row):
self._data = [*self._data[0:row], *self._data[row + 1 :]]


class MainWindow(QMainWindow):
def __init__(self, init_filepath=None):
super().__init__()
self.filepath = str(Path(init_filepath).resolve())
self.setWindowTitle("Punch Clock")
self.setWindowIcon(QIcon("../assets/alarm-clock-blue.png"))
# self.showMaximized()
# self.showNormal()
self.setGeometry(0, 0, 1366, 700)

btn_size = QSize(48, 48)
icon_size = QSize(36, 36)

self.timer = QTimer()
self.timer.timeout.connect(self.refresh_lcd_display)

# menuBar
self.file_menu = QMenu("File")
self.open_file = QAction(
self.style().standardIcon(QStyle.StandardPixmap.SP_DialogOpenButton), "Open"
)
self.open_file.setShortcut(QKeySequence("Ctrl+o"))
self.open_file.triggered.connect(self.open)

self.save_file = QAction(
self.style().standardIcon(QStyle.StandardPixmap.SP_DialogSaveButton),
"Save",
)
self.save_file.setShortcut(QKeySequence("Ctrl+s"))
self.save_file.triggered.connect(self.save)

self.save_as_file = QAction(
self.style().standardIcon(QStyle.StandardPixmap.SP_DialogSaveButton),
"Save As",
)
self.save_as_file.setShortcut(QKeySequence("Ctrl+Shift+s"))
self.save_as_file.triggered.connect(self.save_as)

self.file_menu.addAction(self.open_file)
self.file_menu.addAction(self.save_file)
self.file_menu.addAction(self.save_as_file)
self.menuBar().addMenu(self.file_menu)

# Layout LCDNumber
self.h_layout_lcd = QHBoxLayout()
self.lcd_hour = QLCDNumber()
self.lcd_hour.setMinimumHeight(60)
self.lcd_hour.setDigitCount(2)
self.lcd_minute = QLCDNumber()
self.lcd_minute.setDigitCount(2)
self.lcd_second = QLCDNumber()
self.lcd_second.setDigitCount(2)
self.h_layout_lcd.addWidget(self.lcd_hour)
self.h_layout_lcd.addWidget(self.lcd_minute)
self.h_layout_lcd.addWidget(self.lcd_second)

# Layout PushButton
self.h_layout_btn = QHBoxLayout()
self.btn_flip = QPushButton()
self.btn_flip.setIcon(QIcon("../assets/start.png"))
self.btn_flip.setCheckable(True)
self.btn_flip.setObjectName("btn_flip")
self.btn_flip.setMinimumSize(btn_size)
self.btn_flip.setIconSize(icon_size)
self.btn_flip.clicked.connect(self.flip)

self.btn_delete = QPushButton()
self.btn_delete.setIcon(QIcon("../assets/remove_icon.png"))
self.btn_delete.setMinimumSize(btn_size)
self.btn_delete.setIconSize(icon_size)
self.btn_delete.clicked.connect(self.remove_selection)

# Not neeed, save at closeEvent
# self.btn_save = QPushButton()
# self.btn_save.setIcon(QIcon("../assets/save.png"))
# self.btn_save.setMinimumSize(btn_size)
# self.btn_save.setIconSize(icon_size)
# self.btn_save.clicked.connect(self.save)

self.h_layout_btn.addWidget(self.btn_flip)
self.h_layout_btn.addWidget(self.btn_delete)

# TableView
self.table_view = QTableView()
self.table_view.horizontalHeader().setSectionResizeMode(
QHeaderView.ResizeMode.Stretch
)
self.table_view.setSelectionBehavior(QAbstractItemView.SelectRows)
self.table_view.horizontalHeader().setDefaultAlignment(Qt.AlignLeft)

# ContextMenu of TableView
self.table_view.setContextMenuPolicy(Qt.ContextMenuPolicy.ActionsContextMenu)
self.remove_action = QAction("Remove Selection")
self.remove_action.triggered.connect(self.remove_selection)
self.table_view.addAction(self.remove_action)

# Delegte for Tableview Column
self.combo_delegate = ComboDelegate(self)
self.combo_delegate.setItems(["是", "否"])
self.table_view.setItemDelegateForColumn(7, self.combo_delegate)
self.table_view.setItemDelegateForColumn(10, self.combo_delegate)
self.table_view.setItemDelegateForColumn(11, self.combo_delegate)
self.combo_overtime_delegate = ComboDelegate(self)
self.combo_overtime_delegate.setItems(["平日加班", "休息日加班", "假日加班"])
self.table_view.setItemDelegateForColumn(8, self.combo_overtime_delegate)

if self.filepath:
self.load_data(self.filepath)

self.main_layout = QVBoxLayout()
self.main_layout.addLayout(self.h_layout_lcd)
self.main_layout.addLayout(self.h_layout_btn)
self.main_layout.addWidget(self.table_view)

self.central_widget = QWidget()
self.central_widget.setLayout(self.main_layout)
self.setCentralWidget(self.central_widget)

# statusBar
# self.label_icon = QLabel()
# self.label_icon.setFixedSize(QSize(30, 30))
# pixmap = QPixmap("../assets/file_text_icon.png")
# pixmap.scaled(30, 30, Qt.KeepAspectRatioByExpanding)
# self.label_icon.setPixmap(pixmap)
self.label_fileinfo = QLabel(self.filepath)
# self.status_bar.addWidget(self.label_icon)
self.statusBar().addWidget(self.label_fileinfo)

def flip(self, checkable):
if checkable:
self.btn_flip.setIcon(QIcon("../assets/stop_icon.png"))

self.timer.start(1000)

self.table_model.append(datetime.now())
else:
self.btn_flip.setIcon(QIcon("../assets/start.png"))

self.timer.stop()

self.table_model.update(datetime.now())

self.table_view.model().layoutChanged.emit()

def refresh_lcd_display(self):
now = datetime.now()

def pad_zero(num):
if num < 10:
return "0" + str(num)
return num

self.lcd_hour.display(pad_zero(now.hour))
self.lcd_minute.display(pad_zero(now.minute))
self.lcd_second.display(pad_zero(now.second))

def load_data(self, filepath):
with open(filepath, encoding="utf-8") as file:
self.data = list(csv.reader(file))
self.table_model = TableModel(self.data)
self.table_selection_model = QItemSelectionModel()
self.table_selection_model.setModel(self.table_model)
self.table_view.setModel(self.table_model)
self.table_view.setSelectionModel(self.table_selection_model)

def remove_selection(self):
indexes = self.table_view.selectionModel().selectedRows()
for index in reversed(sorted(indexes)):
self.table_model.remove_row(index.row())

self.table_view.model().layoutChanged.emit()

def open(self):
filepath, _ = QFileDialog.getOpenFileName(
self,
"Clock",
".",
"Comma seperate file(*.csv)",
)
if filepath:
self.filepath = filepath
self.label_fileinfo.setText(filepath)
self.load_data(filepath)

def save_as(self, filepath=None):
if not filepath:
filepath, _ = QFileDialog.getSaveFileName(
self,
"Clock",
".",
"Comma seperate file(*.csv)",
)

if filepath:
with open(filepath, "w", encoding="utf-8", newline="") as file:
csv_writer = csv.writer(file)
csv_writer.writerows(self.table_model.get_data())

self.filepath = None

def save(self):
if self.filepath:
self.save_as(self.filepath)

# Not save automatically when window close
# def closeEvent(self, event):
# if self.filepath:
# self.save(self.filepath)

# return super().closeEvent(event)


if __name__ == "__main__":
app = QApplication(sys.argv)
# app.setStyleSheet(Path("clock.qss").read_text())
path = "./clock.csv"
if Path(path).exists():
window = MainWindow(path)
else:
window = MainWindow()

qtmodern.styles.light(app)
modern_window = qtmodern.windows.ModernWindow(window)
modern_window.show()

app.exec()

# clock.csv

1
2
3
4
組織,員編,姓名,出勤日期,加班日期,開始時間,結束時間,結束日期為後一天,加班類型,加班原因,是否轉補休,是否扣除用餐時間
IT,ABC,JBN,2023-07-25,2023-07-25,09:00,20:00,否,平日加班,Daily Work,是,否
IT,ABC,JBN,2023-07-26,2023-07-26,08:30,18:00,否,平日加班,Daily Work,否,否
IT,ABC,JBN,2023-08-01,2023-08-01,20:01,20:03,否,平日加班,Daily Work,否,否

# result

# Excel to XML

# main.py

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
import pandas as pd
import xml.etree.ElementTree as ET
from pathlib import Path

from PySide6.QtWidgets import (
QApplication,
QFileDialog,
QMainWindow,
QMenu,
QStyle,
QMessageBox,
)
from PySide6.QtCore import QStandardPaths
from PySide6.QtGui import QAction, QKeySequence, QIcon
from excel_to_xml_ui import Ui_MainWindow
import qtmodern.styles
import qtmodern.windows

# from qt_material import apply_stylesheet, list_themes
# import qdarktheme
# import qdarkstyle

theme_name = "Light"


def trim_dataframe(df):
return df.applymap(lambda x: x.strip() if isinstance(x, str) else x)


class MainWindow(QMainWindow, Ui_MainWindow):
def __init__(self):
super().__init__()
self.setupUi(self)
self.setWindowTitle("~Excel to XML~")
self.setWindowIcon(QIcon("../assets/xml_icon.png"))
self.setGeometry(300, 30, 520, 520)

self.filepath = ""

# menuBar File
self.menu_bar = self.menuBar()

self.file_menu = QMenu("File")
self.open_action = QAction(
self.style().standardIcon(QStyle.StandardPixmap.SP_DirOpenIcon), "Open"
)
self.open_action.setShortcut(QKeySequence("Ctrl+o"))
self.open_action.triggered.connect(self.open)
self.file_menu.addAction(self.open_action)
self.menu_bar.addMenu(self.file_menu)

self.help_menu = QMenu("Help")
self.help_action = QAction(
self.style().standardIcon(QStyle.StandardPixmap.SP_DialogHelpButton),
"Usage",
)
self.help_action.triggered.connect(self.help)

self.about_action = QAction(
self.style().standardIcon(QStyle.StandardPixmap.SP_DialogHelpButton),
"About",
)
self.about_action.triggered.connect(self.about)

self.help_menu.addAction(self.help_action)
self.help_menu.addAction(self.about_action)
self.menu_bar.addMenu(self.help_menu)

# menuBar Theme
# self.theme_menu = QMenu("Theme")
# self.light_action = QAction("Light")
# self.light_action.setShortcut(QKeySequence("Ctrl+l"))
# self.light_action.triggered.connect(lambda: self.change_theme("Light"))
# self.dark_action = QAction("Dark")
# self.dark_action.setShortcut(QKeySequence("Ctrl+d"))
# self.dark_action.triggered.connect(lambda: self.change_theme("Dark"))
# self.theme_menu.addAction(self.light_action)
# self.theme_menu.addAction(self.dark_action)
# self.menu_bar.addMenu(self.theme_menu)

# # statusBar
# self.status_bar = self.statusBar()
# self.label_fileinfo_in = QLabel(self.filepath)
# # self.label_fileinfo_out = QLabel(self.filepath)
# self.status_bar.addWidget(self.label_fileinfo_in)
# # self.status_bar.addPermanentWidget(self.label_fileinfo_out)

self.btn_generate_xml.clicked.connect(self.generate_xml)
self.group_one_sheet.clicked.connect(self.group_one_sheet_state_changed)
self.group_different_sheet.clicked.connect(
self.group_different_sheet_state_changed
)
self.group_one_sheet_head.clicked.connect(self.group_head_state_changed)
self.group_different_sheet_head.clicked.connect(self.group_head_state_changed)
self.group_xml_head.clicked.connect(self.group_head_state_changed)

# self.timer = QTimer()
# self.timer.timeout.connect(self.clear_label_info_out)

def group_one_sheet_state_changed(self, checked):
if checked:
self.group_different_sheet.setChecked(False)

def group_different_sheet_state_changed(self, checked):
if checked:
self.group_one_sheet.setChecked(False)

def group_head_state_changed(self, checked):
self.group_one_sheet_head.setChecked(checked)
self.group_different_sheet_head.setChecked(checked)
self.group_xml_head.setChecked(checked)

# def clear_label_info_out(self):
# self.timer.stop()
# self.label_fileinfo_out.setText("")

def open(self):
filepath, _ = QFileDialog.getOpenFileName(
self,
"Open Excel",
QStandardPaths.standardLocations(QStandardPaths.DesktopLocation)[0],
"Microsoft Excel File(*.xls *.xlsx)",
)
if filepath:
self.filepath = filepath
# self.label_fileinfo_in.setText(filepath)

def generate_xml(self):
save_file_name, _ = QFileDialog.getSaveFileName(
self,
"XML",
".".join(self.filepath.split(".")[:-1]),
"XML File(*.xml)",
)

# self.label_fileinfo_out.setText(save_file_name)

if save_file_name:
head_root_name = self.line_edit_head_root_name.text()
head_row_name = self.line_edit_head_row_name.text()
line_root_name = self.line_edit_line_root_name.text()
line_row_name = self.line_edit_line_row_name.text()
# check_trim = self.check_trim.isChecked()
# radio_lower = self.radio_lower.isChecked()
# radio_upper = self.radio_upper.isChecked()

if self.group_xml_head.isChecked():
if self.group_one_sheet.isChecked():
head_start = self.spin_head_start.value() - 1
head_end = self.spin_head_end.value()
head_end = None if head_end == -1 else head_end - 1
line_start = self.spin_line_start.value()
line_end = self.spin_line_end.value()
line_end = None if line_end == -1 else line_end - 1

df = pd.read_excel(self.filepath)

df = self.clean_dataframe(df)

df_head = df.iloc[:, head_start:head_end]
df_head.drop_duplicates(inplace=True)

df_line = df.iloc[:, line_start:line_end]
elif self.group_different_sheet.isChecked():
head_sheet = self.line_edit_head_sheet.text()
line_sheet = self.line_edit_line_sheet.text()

if not head_sheet:
head_sheet = 0

if not line_sheet:
line_sheet = 1

df_head = pd.read_excel(self.filepath, head_sheet)
df_line = pd.read_excel(self.filepath, line_sheet)

df_head = self.clean_dataframe(df_head)
df_line = self.clean_dataframe(df_line)

xml_head = df_head.to_xml(
index=False,
root_name=head_root_name,
row_name=head_row_name,
xml_declaration=False,
)
root_element = ET.fromstring(xml_head)
xml_line = df_line.to_xml(
index=False,
root_name=line_root_name,
row_name=line_row_name,
xml_declaration=False,
)
xml_line_root_element = ET.fromstring(xml_line)
root_element.append(xml_line_root_element)
tree = ET.ElementTree(root_element)
ET.indent(tree, "\t", level=0)
file = open(save_file_name, "wb")
file.write(b'<?xml version="1.0" encoding="ASCII" standalone="yes"?>\n')
tree.write(file)
else:
if self.group_one_sheet.isChecked():
line_start = self.spin_line_start.value()
line_end = self.spin_line_end.value()
line_end = None if line_end == -1 else line_end - 1

df = pd.read_excel(self.filepath)
df = self.clean_dataframe(df)
df_line = df.iloc[:, line_start:line_end]
elif self.group_different_sheet.isChecked():
df_line = pd.read_excel(self.filepath, line_sheet)
df_line = self.clean_dataframe(df_line)

df_line.to_xml(
save_file_name,
index=False,
root_name=line_root_name,
row_name=line_row_name,
xml_declaration=True,
encoding="ASCII",
)

QMessageBox.information(
self,
"Generate XML Success!",
f"Record row is {df_line.shape[0]}.",
)

# self.timer.start(2000)

def help(self):
QMessageBox.information(
self,
"~Excel to XML~",
f"""1. File/Open Select the Excel(.xls/xlsx) that needs to be converted into XML.
2. Click Genereate XML Select the save path, and wait for the conversion to complete.""",
)

def about(self):
QMessageBox.information(
self,
"~Excel to XML~",
f"""Version: 1.0.0
Date: 2023-08-09
Python: 3.9.6
PySide6: 6.5.1.1
pandas: 1.4.1
qtmodern: 0.2.0
""",
)

def clean_dataframe(self, df):
if self.radio_lower.isChecked():
df.columns = df.columns.str.lower()

if self.radio_upper.isChecked():
df.columns = df.columns.str.lower()

if self.check_trim.isChecked():
df = trim_dataframe(df)

return df


if __name__ == "__main__":
app = QApplication()

# qmaterial
# print(list_themes())
# apply_stylesheet(app, "dark_cyan.xml")

# qdarktheme
# qdarktheme.setup_theme()
# qdarktheme.setup_theme("light")

# qdarkstyle
# app.setStyleSheet(qdarkstyle.load_stylesheet(qt_api="pyside6"))

# window = MainWindow()
# window.show()

# qtmodern
if theme_name == "Light":
qtmodern.styles.light(app)
else:
qtmodern.styles.dark(app)

window = MainWindow()
modern_window = qtmodern.windows.ModernWindow(window)
modern_window.show()
app.exec()

# UI excel_to_xml_ui.py

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
# -*- coding: utf-8 -*-

################################################################################
## Form generated from reading UI file 'excel_to_xml.ui'
##
## Created by: Qt User Interface Compiler version 6.5.1
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################

from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
QMetaObject, QObject, QPoint, QRect,
QSize, QTime, QUrl, Qt)
from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
QFont, QFontDatabase, QGradient, QIcon,
QImage, QKeySequence, QLinearGradient, QPainter,
QPalette, QPixmap, QRadialGradient, QTransform)
from PySide6.QtWidgets import (QApplication, QCheckBox, QGridLayout, QGroupBox,
QHBoxLayout, QLabel, QLineEdit, QMainWindow,
QMenuBar, QPushButton, QRadioButton, QSizePolicy,
QSpacerItem, QSpinBox, QStatusBar, QWidget)

class Ui_MainWindow(object):
def setupUi(self, MainWindow):
if not MainWindow.objectName():
MainWindow.setObjectName(u"MainWindow")
MainWindow.resize(592, 549)
self.centralwidget = QWidget(MainWindow)
self.centralwidget.setObjectName(u"centralwidget")
self.gridLayout_13 = QGridLayout(self.centralwidget)
self.gridLayout_13.setObjectName(u"gridLayout_13")
self.group_one_sheet = QGroupBox(self.centralwidget)
self.group_one_sheet.setObjectName(u"group_one_sheet")
self.group_one_sheet.setCheckable(True)
self.group_one_sheet.setChecked(False)
self.gridLayout = QGridLayout(self.group_one_sheet)
self.gridLayout.setObjectName(u"gridLayout")
self.group_one_sheet_head = QGroupBox(self.group_one_sheet)
self.group_one_sheet_head.setObjectName(u"group_one_sheet_head")
self.group_one_sheet_head.setCheckable(True)
self.gridLayout_4 = QGridLayout(self.group_one_sheet_head)
self.gridLayout_4.setObjectName(u"gridLayout_4")
self.horizontalLayout_11 = QHBoxLayout()
self.horizontalLayout_11.setObjectName(u"horizontalLayout_11")
self.label_23 = QLabel(self.group_one_sheet_head)
self.label_23.setObjectName(u"label_23")

self.horizontalLayout_11.addWidget(self.label_23)

self.spin_head_start = QSpinBox(self.group_one_sheet_head)
self.spin_head_start.setObjectName(u"spin_head_start")
self.spin_head_start.setMinimum(1)
self.spin_head_start.setValue(1)

self.horizontalLayout_11.addWidget(self.spin_head_start)

self.label_24 = QLabel(self.group_one_sheet_head)
self.label_24.setObjectName(u"label_24")

self.horizontalLayout_11.addWidget(self.label_24)

self.spin_head_end = QSpinBox(self.group_one_sheet_head)
self.spin_head_end.setObjectName(u"spin_head_end")
self.spin_head_end.setMinimum(1)
self.spin_head_end.setMaximum(100)
self.spin_head_end.setValue(5)

self.horizontalLayout_11.addWidget(self.spin_head_end)

self.horizontalLayout_11.setStretch(1, 1)
self.horizontalLayout_11.setStretch(3, 1)

self.gridLayout_4.addLayout(self.horizontalLayout_11, 0, 0, 1, 1)


self.gridLayout.addWidget(self.group_one_sheet_head, 0, 0, 1, 1)

self.groupBox_3 = QGroupBox(self.group_one_sheet)
self.groupBox_3.setObjectName(u"groupBox_3")
self.gridLayout_9 = QGridLayout(self.groupBox_3)
self.gridLayout_9.setObjectName(u"gridLayout_9")
self.horizontalLayout_17 = QHBoxLayout()
self.horizontalLayout_17.setObjectName(u"horizontalLayout_17")
self.label_35 = QLabel(self.groupBox_3)
self.label_35.setObjectName(u"label_35")

self.horizontalLayout_17.addWidget(self.label_35)

self.spin_line_start = QSpinBox(self.groupBox_3)
self.spin_line_start.setObjectName(u"spin_line_start")
self.spin_line_start.setValue(6)

self.horizontalLayout_17.addWidget(self.spin_line_start)

self.label_36 = QLabel(self.groupBox_3)
self.label_36.setObjectName(u"label_36")

self.horizontalLayout_17.addWidget(self.label_36)

self.spin_line_end = QSpinBox(self.groupBox_3)
self.spin_line_end.setObjectName(u"spin_line_end")
self.spin_line_end.setEnabled(False)
self.spin_line_end.setMinimum(-1)
self.spin_line_end.setValue(-1)

self.horizontalLayout_17.addWidget(self.spin_line_end)

self.horizontalLayout_17.setStretch(1, 1)
self.horizontalLayout_17.setStretch(3, 1)

self.gridLayout_9.addLayout(self.horizontalLayout_17, 0, 0, 1, 1)


self.gridLayout.addWidget(self.groupBox_3, 1, 0, 1, 1)


self.gridLayout_13.addWidget(self.group_one_sheet, 0, 0, 1, 1)

self.group_different_sheet = QGroupBox(self.centralwidget)
self.group_different_sheet.setObjectName(u"group_different_sheet")
self.group_different_sheet.setCheckable(True)
self.group_different_sheet.setChecked(True)
self.gridLayout_10 = QGridLayout(self.group_different_sheet)
self.gridLayout_10.setObjectName(u"gridLayout_10")
self.group_different_sheet_head = QGroupBox(self.group_different_sheet)
self.group_different_sheet_head.setObjectName(u"group_different_sheet_head")
self.group_different_sheet_head.setCheckable(True)
self.gridLayout_11 = QGridLayout(self.group_different_sheet_head)
self.gridLayout_11.setObjectName(u"gridLayout_11")
self.horizontalLayout_18 = QHBoxLayout()
self.horizontalLayout_18.setObjectName(u"horizontalLayout_18")
self.label_37 = QLabel(self.group_different_sheet_head)
self.label_37.setObjectName(u"label_37")

self.horizontalLayout_18.addWidget(self.label_37)

self.line_edit_head_sheet = QLineEdit(self.group_different_sheet_head)
self.line_edit_head_sheet.setObjectName(u"line_edit_head_sheet")

self.horizontalLayout_18.addWidget(self.line_edit_head_sheet)


self.gridLayout_11.addLayout(self.horizontalLayout_18, 0, 0, 1, 1)


self.gridLayout_10.addWidget(self.group_different_sheet_head, 0, 0, 1, 1)

self.groupBox_9 = QGroupBox(self.group_different_sheet)
self.groupBox_9.setObjectName(u"groupBox_9")
self.gridLayout_12 = QGridLayout(self.groupBox_9)
self.gridLayout_12.setObjectName(u"gridLayout_12")
self.horizontalLayout_19 = QHBoxLayout()
self.horizontalLayout_19.setObjectName(u"horizontalLayout_19")
self.label_38 = QLabel(self.groupBox_9)
self.label_38.setObjectName(u"label_38")

self.horizontalLayout_19.addWidget(self.label_38)

self.line_edit_line_sheet = QLineEdit(self.groupBox_9)
self.line_edit_line_sheet.setObjectName(u"line_edit_line_sheet")

self.horizontalLayout_19.addWidget(self.line_edit_line_sheet)


self.gridLayout_12.addLayout(self.horizontalLayout_19, 0, 0, 1, 1)


self.gridLayout_10.addWidget(self.groupBox_9, 1, 0, 1, 1)


self.gridLayout_13.addWidget(self.group_different_sheet, 0, 1, 1, 1)

self.btn_generate_xml = QPushButton(self.centralwidget)
self.btn_generate_xml.setObjectName(u"btn_generate_xml")
self.btn_generate_xml.setMinimumSize(QSize(0, 35))

self.gridLayout_13.addWidget(self.btn_generate_xml, 2, 0, 1, 2)

self.groupBox_4 = QGroupBox(self.centralwidget)
self.groupBox_4.setObjectName(u"groupBox_4")
self.gridLayout_2 = QGridLayout(self.groupBox_4)
self.gridLayout_2.setObjectName(u"gridLayout_2")
self.group_xml_head = QGroupBox(self.groupBox_4)
self.group_xml_head.setObjectName(u"group_xml_head")
self.group_xml_head.setCheckable(True)
self.gridLayout_8 = QGridLayout(self.group_xml_head)
self.gridLayout_8.setObjectName(u"gridLayout_8")
self.horizontalLayout_9 = QHBoxLayout()
self.horizontalLayout_9.setObjectName(u"horizontalLayout_9")
self.label_19 = QLabel(self.group_xml_head)
self.label_19.setObjectName(u"label_19")

self.horizontalLayout_9.addWidget(self.label_19)

self.line_edit_head_root_name = QLineEdit(self.group_xml_head)
self.line_edit_head_root_name.setObjectName(u"line_edit_head_root_name")

self.horizontalLayout_9.addWidget(self.line_edit_head_root_name)

self.label_20 = QLabel(self.group_xml_head)
self.label_20.setObjectName(u"label_20")

self.horizontalLayout_9.addWidget(self.label_20)

self.line_edit_head_row_name = QLineEdit(self.group_xml_head)
self.line_edit_head_row_name.setObjectName(u"line_edit_head_row_name")

self.horizontalLayout_9.addWidget(self.line_edit_head_row_name)


self.gridLayout_8.addLayout(self.horizontalLayout_9, 0, 0, 1, 1)


self.gridLayout_2.addWidget(self.group_xml_head, 2, 0, 1, 1)

self.groupBox_5 = QGroupBox(self.groupBox_4)
self.groupBox_5.setObjectName(u"groupBox_5")
self.groupBox_5.setCheckable(False)
self.gridLayout_7 = QGridLayout(self.groupBox_5)
self.gridLayout_7.setObjectName(u"gridLayout_7")
self.horizontalLayout_7 = QHBoxLayout()
self.horizontalLayout_7.setObjectName(u"horizontalLayout_7")
self.label_15 = QLabel(self.groupBox_5)
self.label_15.setObjectName(u"label_15")

self.horizontalLayout_7.addWidget(self.label_15)

self.line_edit_line_root_name = QLineEdit(self.groupBox_5)
self.line_edit_line_root_name.setObjectName(u"line_edit_line_root_name")

self.horizontalLayout_7.addWidget(self.line_edit_line_root_name)

self.label_16 = QLabel(self.groupBox_5)
self.label_16.setObjectName(u"label_16")

self.horizontalLayout_7.addWidget(self.label_16)

self.line_edit_line_row_name = QLineEdit(self.groupBox_5)
self.line_edit_line_row_name.setObjectName(u"line_edit_line_row_name")

self.horizontalLayout_7.addWidget(self.line_edit_line_row_name)

self.horizontalLayout_7.setStretch(1, 1)
self.horizontalLayout_7.setStretch(3, 1)

self.gridLayout_7.addLayout(self.horizontalLayout_7, 0, 0, 1, 1)


self.gridLayout_2.addWidget(self.groupBox_5, 3, 0, 1, 1)

self.horizontalLayout = QHBoxLayout()
self.horizontalLayout.setObjectName(u"horizontalLayout")
self.label = QLabel(self.groupBox_4)
self.label.setObjectName(u"label")

self.horizontalLayout.addWidget(self.label)

self.radio_normal = QRadioButton(self.groupBox_4)
self.radio_normal.setObjectName(u"radio_normal")
self.radio_normal.setChecked(True)

self.horizontalLayout.addWidget(self.radio_normal)

self.radio_lower = QRadioButton(self.groupBox_4)
self.radio_lower.setObjectName(u"radio_lower")

self.horizontalLayout.addWidget(self.radio_lower)

self.radio_upper = QRadioButton(self.groupBox_4)
self.radio_upper.setObjectName(u"radio_upper")

self.horizontalLayout.addWidget(self.radio_upper)

self.horizontalSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)

self.horizontalLayout.addItem(self.horizontalSpacer)

self.check_trim = QCheckBox(self.groupBox_4)
self.check_trim.setObjectName(u"check_trim")

self.horizontalLayout.addWidget(self.check_trim)

self.horizontalLayout.setStretch(4, 1)
self.horizontalLayout.setStretch(5, 1)

self.gridLayout_2.addLayout(self.horizontalLayout, 0, 0, 1, 1)

self.verticalSpacer = QSpacerItem(20, 20, QSizePolicy.Minimum, QSizePolicy.Fixed)

self.gridLayout_2.addItem(self.verticalSpacer, 1, 0, 1, 1)


self.gridLayout_13.addWidget(self.groupBox_4, 1, 0, 1, 2)

MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QMenuBar(MainWindow)
self.menubar.setObjectName(u"menubar")
self.menubar.setGeometry(QRect(0, 0, 592, 21))
MainWindow.setMenuBar(self.menubar)
self.statusbar = QStatusBar(MainWindow)
self.statusbar.setObjectName(u"statusbar")
MainWindow.setStatusBar(self.statusbar)

self.retranslateUi(MainWindow)

QMetaObject.connectSlotsByName(MainWindow)
# setupUi

def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"Excel to XML", None))
self.group_one_sheet.setTitle(QCoreApplication.translate("MainWindow", u"Excel Header and Records in One Sheet", None))
self.group_one_sheet_head.setTitle(QCoreApplication.translate("MainWindow", u"Header", None))
self.label_23.setText(QCoreApplication.translate("MainWindow", u"Column Span", None))
self.label_24.setText(QCoreApplication.translate("MainWindow", u"-", None))
#if QT_CONFIG(tooltip)
self.spin_head_end.setToolTip("")
#endif // QT_CONFIG(tooltip)
self.groupBox_3.setTitle(QCoreApplication.translate("MainWindow", u"Records", None))
self.label_35.setText(QCoreApplication.translate("MainWindow", u"Column Span", None))
self.label_36.setText(QCoreApplication.translate("MainWindow", u"-", None))
#if QT_CONFIG(tooltip)
self.spin_line_end.setToolTip(QCoreApplication.translate("MainWindow", u"-1 represents to the last", None))
#endif // QT_CONFIG(tooltip)
self.group_different_sheet.setTitle(QCoreApplication.translate("MainWindow", u"Excel Header and Records in Different Sheet", None))
self.group_different_sheet_head.setTitle(QCoreApplication.translate("MainWindow", u"Header", None))
self.label_37.setText(QCoreApplication.translate("MainWindow", u"Sheet Name", None))
self.line_edit_head_sheet.setPlaceholderText(QCoreApplication.translate("MainWindow", u"Default is 1st sheet ", None))
self.groupBox_9.setTitle(QCoreApplication.translate("MainWindow", u"Records", None))
self.label_38.setText(QCoreApplication.translate("MainWindow", u"Sheet Name", None))
self.line_edit_line_sheet.setPlaceholderText(QCoreApplication.translate("MainWindow", u"Default is 2nd sheet ", None))
self.btn_generate_xml.setText(QCoreApplication.translate("MainWindow", u"Generate XML", None))
self.groupBox_4.setTitle(QCoreApplication.translate("MainWindow", u"XML", None))
self.group_xml_head.setTitle(QCoreApplication.translate("MainWindow", u"Header", None))
self.label_19.setText(QCoreApplication.translate("MainWindow", u"Root Tag Name", None))
self.line_edit_head_root_name.setText(QCoreApplication.translate("MainWindow", u"file", None))
self.label_20.setText(QCoreApplication.translate("MainWindow", u"Row Tag Name", None))
self.line_edit_head_row_name.setText(QCoreApplication.translate("MainWindow", u"header", None))
self.groupBox_5.setTitle(QCoreApplication.translate("MainWindow", u"Records", None))
self.label_15.setText(QCoreApplication.translate("MainWindow", u"Root Tag Name", None))
self.line_edit_line_root_name.setText(QCoreApplication.translate("MainWindow", u"records", None))
self.label_16.setText(QCoreApplication.translate("MainWindow", u"Row tag Name", None))
self.line_edit_line_row_name.setText(QCoreApplication.translate("MainWindow", u"record", None))
self.label.setText(QCoreApplication.translate("MainWindow", u"Tag Case", None))
self.radio_normal.setText(QCoreApplication.translate("MainWindow", u"Normal", None))
self.radio_lower.setText(QCoreApplication.translate("MainWindow", u"Lower", None))
self.radio_upper.setText(QCoreApplication.translate("MainWindow", u"Upper", None))
self.check_trim.setText(QCoreApplication.translate("MainWindow", u"Trim Data", None))
# retranslateUi

# result

Edited on