-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from redromnon/testing
[Tech|UI] Display operation execution + Refactor
- Loading branch information
Showing
3 changed files
with
123 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import flet as ft | ||
from libutilities import Action | ||
|
||
class Operation(ft.UserControl): | ||
|
||
def build(self): | ||
|
||
self.action = Action() | ||
|
||
self.lib_output = ft.TextField(value="", filled=True, read_only=True, multiline=True, text_size=13, color=ft.colors.AMBER) | ||
|
||
self.close_button = ft.TextButton("Close", disabled=True, on_click=self.close_dialog) | ||
self.cancel_button = ft.TextButton("Cancel", disabled=False, on_click=self.cancel_op) | ||
|
||
self.loading = ft.ProgressBar() | ||
|
||
self.result_dialog = ft.AlertDialog( | ||
content=ft.Column( | ||
[ | ||
self.loading, | ||
ft.Column( | ||
[self.lib_output], | ||
horizontal_alignment="center", expand=True, auto_scroll=True, scroll="auto", | ||
width=400 | ||
), | ||
], width=400 | ||
), | ||
content_padding=30, modal=True, | ||
actions=[self.close_button, self.cancel_button] | ||
) | ||
|
||
return self.result_dialog | ||
|
||
def backup(self, folder, pwd): | ||
|
||
self.result_dialog.open = True | ||
self.result_dialog.title = ft.Text("Backing Up", text_align="center") | ||
self.lib_output.value = "...\n" | ||
self.update() | ||
|
||
process = self.action.backup(folder, pwd) | ||
|
||
for line in process.stdout: | ||
print(line, end="") | ||
self.lib_output.value += line | ||
self.update() | ||
|
||
process.wait() | ||
|
||
self.close_button.disabled = False | ||
self.cancel_button.disabled = True | ||
self.loading.value = 0.0 | ||
self.update() | ||
|
||
|
||
def restore(self, folder, pwd): | ||
|
||
self.result_dialog.open = True | ||
self.result_dialog.title = ft.Text("Restoring", text_align="center") | ||
self.lib_output.value = "...\n" | ||
self.update() | ||
|
||
process = self.action.restore(folder, pwd) | ||
|
||
for line in process.stdout: | ||
print(line, end="") | ||
self.lib_output.value += line | ||
self.update() | ||
|
||
process.wait() | ||
|
||
self.close_button.disabled = False | ||
self.cancel_button.disabled = True | ||
self.loading.value = 0.0 | ||
self.update() | ||
|
||
|
||
def close_dialog(self, e): | ||
|
||
#Reset properties to default | ||
self.lib_output.value = "" | ||
self.close_button.disabled = True | ||
self.cancel_button.disabled = False | ||
self.loading.value = None | ||
self.result_dialog.open = False | ||
self.update() | ||
|
||
|
||
def cancel_op(self, e): | ||
|
||
self.lib_output.value += "\n--CANCELLED BY USER--" | ||
self.loading.value = 0.0 | ||
self.update() | ||
|
||
self.action.cancel() | ||
|
||
|
||
|