init: pager
This commit is contained in:
parent
0b831e1622
commit
a6b68e31d8
1 changed files with 28 additions and 11 deletions
39
src/gui.py
39
src/gui.py
|
@ -91,21 +91,27 @@ class GUI:
|
||||||
|
|
||||||
def _analyse(self, start_row: int, path: str) -> None:
|
def _analyse(self, start_row: int, path: str) -> None:
|
||||||
"""Analyse les données"""
|
"""Analyse les données"""
|
||||||
|
|
||||||
self.f.destroy()
|
|
||||||
self.f = Frame(self.parent)
|
|
||||||
self.f.grid()
|
|
||||||
|
|
||||||
files = analyze_args([path])
|
files = analyze_args([path])
|
||||||
idx = start_row
|
data = []
|
||||||
for file in files:
|
for file in files:
|
||||||
clang_format_output = clang_format(file)
|
clang_format_output = clang_format(file)
|
||||||
parsed_output = parse_clang_format_output(clang_format_output)
|
data.append((file, parse_clang_format_output(clang_format_output)))
|
||||||
|
self._pager(1, data, start_row)
|
||||||
|
|
||||||
if parsed_output:
|
def _pager(self, num_page: int, errors: list, start_row: int) -> None:
|
||||||
for error in parsed_output:
|
self.f.destroy()
|
||||||
|
self.f = Frame(self.parent)
|
||||||
|
self.f.grid(columnspan=2)
|
||||||
|
|
||||||
|
idx = start_row
|
||||||
|
elem_per_page = 5
|
||||||
|
for file, error in errors:
|
||||||
|
if error:
|
||||||
|
for error in error[
|
||||||
|
elem_per_page * (num_page - 1) : elem_per_page * num_page
|
||||||
|
]:
|
||||||
Button(
|
Button(
|
||||||
self.parent,
|
self.f,
|
||||||
text=f"Avertissement dans {error.filename} "
|
text=f"Avertissement dans {error.filename} "
|
||||||
f"à la ligne {error.line_number}, "
|
f"à la ligne {error.line_number}, "
|
||||||
f"caractère {error.column_number}.",
|
f"caractère {error.column_number}.",
|
||||||
|
@ -119,8 +125,19 @@ class GUI:
|
||||||
idx += 1
|
idx += 1
|
||||||
else:
|
else:
|
||||||
Label(
|
Label(
|
||||||
self.parent,
|
self.f,
|
||||||
bg="MediumSpringGreen",
|
bg="MediumSpringGreen",
|
||||||
text=f"Aucun avertissement trouvé dans {file}.",
|
text=f"Aucun avertissement trouvé dans {file}.",
|
||||||
).grid(column=0, row=idx, columnspan=2)
|
).grid(column=0, row=idx, columnspan=2)
|
||||||
idx += 1
|
idx += 1
|
||||||
|
|
||||||
|
Button(
|
||||||
|
self.f,
|
||||||
|
text="Page précédente <",
|
||||||
|
command=lambda: print("avant"),
|
||||||
|
).grid(column=0, row=idx)
|
||||||
|
Button(
|
||||||
|
self.f,
|
||||||
|
text="Page suivante >",
|
||||||
|
command=lambda: print("apres"),
|
||||||
|
).grid(column=1, row=idx)
|
||||||
|
|
Reference in a new issue