better grid
This commit is contained in:
parent
a6b68e31d8
commit
a1f2410294
1 changed files with 17 additions and 8 deletions
25
src/gui.py
25
src/gui.py
|
@ -13,6 +13,8 @@ class GUI:
|
||||||
self.parent.resizable(False, False)
|
self.parent.resizable(False, False)
|
||||||
self.f = Frame(self.parent)
|
self.f = Frame(self.parent)
|
||||||
|
|
||||||
|
self.columnspan = 3
|
||||||
|
|
||||||
def start(self) -> None:
|
def start(self) -> None:
|
||||||
"""Affiche la fenêtre"""
|
"""Affiche la fenêtre"""
|
||||||
self._main_screen()
|
self._main_screen()
|
||||||
|
@ -64,7 +66,7 @@ class GUI:
|
||||||
self.parent,
|
self.parent,
|
||||||
text=f"{self.name} est une application qui permet de lire "
|
text=f"{self.name} est une application qui permet de lire "
|
||||||
"plus facilement clang-format",
|
"plus facilement clang-format",
|
||||||
).grid(column=0, row=0, columnspan=2)
|
).grid(column=0, row=0, columnspan=self.columnspan)
|
||||||
|
|
||||||
start = 2
|
start = 2
|
||||||
Button(
|
Button(
|
||||||
|
@ -76,7 +78,7 @@ class GUI:
|
||||||
self.parent,
|
self.parent,
|
||||||
text="Ouvrir un dossier",
|
text="Ouvrir un dossier",
|
||||||
command=lambda: self._open_directory(start),
|
command=lambda: self._open_directory(start),
|
||||||
).grid(column=1, row=1)
|
).grid(column=self.columnspan - 1, row=1)
|
||||||
|
|
||||||
def _show_info(self, name_err: str, msg: str) -> None:
|
def _show_info(self, name_err: str, msg: str) -> None:
|
||||||
title = f"{name_err} - {self.name}"
|
title = f"{name_err} - {self.name}"
|
||||||
|
@ -98,10 +100,14 @@ class GUI:
|
||||||
data.append((file, parse_clang_format_output(clang_format_output)))
|
data.append((file, parse_clang_format_output(clang_format_output)))
|
||||||
self._pager(1, data, start_row)
|
self._pager(1, data, start_row)
|
||||||
|
|
||||||
def _pager(self, num_page: int, errors: list, start_row: int) -> None:
|
def _reset_frame(self) -> None:
|
||||||
|
"""Reset frame"""
|
||||||
self.f.destroy()
|
self.f.destroy()
|
||||||
self.f = Frame(self.parent)
|
self.f = Frame(self.parent)
|
||||||
self.f.grid(columnspan=2)
|
self.f.grid(columnspan=self.columnspan)
|
||||||
|
|
||||||
|
def _pager(self, num_page: int, errors: list, start_row: int) -> None:
|
||||||
|
self._reset_frame()
|
||||||
|
|
||||||
idx = start_row
|
idx = start_row
|
||||||
elem_per_page = 5
|
elem_per_page = 5
|
||||||
|
@ -121,23 +127,26 @@ class GUI:
|
||||||
command=lambda: self._show_info(
|
command=lambda: self._show_info(
|
||||||
error.warning_message, error.warning_content
|
error.warning_message, error.warning_content
|
||||||
),
|
),
|
||||||
).grid(column=0, row=idx, columnspan=2)
|
).grid(column=0, row=idx, columnspan=self.columnspan)
|
||||||
idx += 1
|
idx += 1
|
||||||
else:
|
else:
|
||||||
Label(
|
Label(
|
||||||
self.f,
|
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=self.columnspan)
|
||||||
idx += 1
|
idx += 1
|
||||||
|
|
||||||
Button(
|
Button(
|
||||||
self.f,
|
self.f,
|
||||||
text="Page précédente <",
|
text="< Page précédente",
|
||||||
command=lambda: print("avant"),
|
command=lambda: print("avant"),
|
||||||
).grid(column=0, row=idx)
|
).grid(column=0, row=idx)
|
||||||
|
Label(
|
||||||
|
self.f, text=f"Page {num_page}/{round(len(errors) / elem_per_page)}"
|
||||||
|
).grid(column=1, row=idx)
|
||||||
Button(
|
Button(
|
||||||
self.f,
|
self.f,
|
||||||
text="Page suivante >",
|
text="Page suivante >",
|
||||||
command=lambda: print("apres"),
|
command=lambda: print("apres"),
|
||||||
).grid(column=1, row=idx)
|
).grid(column=2, row=idx)
|
||||||
|
|
Reference in a new issue