Skip to content

Commit

Permalink
chore: Remove uses of nicegui and clean up files
Browse files Browse the repository at this point in the history
  • Loading branch information
KIRA009 committed Nov 8, 2024
1 parent 7eaeca7 commit 8bb6fc1
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 930 deletions.
110 changes: 0 additions & 110 deletions openadapt/deprecated/app/cards.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
import multiprocessing
import time

from nicegui import ui

from openadapt.deprecated.app.objects.local_file_picker import LocalFilePicker
from openadapt.deprecated.app.util import get_scrub, set_dark, set_scrub, sync_switch
from openadapt.record import record
from openadapt.utils import WrapStdout

Expand Down Expand Up @@ -67,55 +63,6 @@ def start(self, func: callable, args: tuple, kwargs: dict) -> None:
record_proc = RecordProc()


def settings(dark_mode: bool) -> None:
"""Display the settings dialog.
Args:
dark_mode (bool): Current dark mode setting.
"""
with ui.dialog() as settings, ui.card():
dark_switch = ui.switch(
"Dark mode", on_change=lambda: set_dark(dark_mode, dark_switch.value)
)
sync_switch(dark_switch, dark_mode)

scrub_switch = ui.switch(
"Scrubbing", on_change=lambda: set_scrub(scrub_switch.value)
)
sync_switch(scrub_switch, get_scrub())

ui.button("Close", on_click=lambda: settings.close())
settings.open()


def select_import(f: callable) -> None:
"""Display the import file selection dialog.
Args:
f (callable): Function to call when import button is clicked.
"""

async def pick_file() -> None:
result = await LocalFilePicker(".")
ui.notify(f"Selected {result[0]}" if result else "No file selected.")
selected_file.text = result[0] if result else ""
import_button.enabled = True if result else False

with ui.dialog() as import_dialog, ui.card():
with ui.column():
ui.button("Select File", on_click=pick_file).props("icon=folder")
selected_file = ui.label("")
selected_file.visible = False
import_button = ui.button(
"Import",
on_click=lambda: f(selected_file.text, delete.value),
)
import_button.enabled = False
delete = ui.checkbox("Delete file after import")

import_dialog.open()


def stop_record() -> None:
"""Stop the current recording session."""
global record_proc
Expand Down Expand Up @@ -152,60 +99,3 @@ def quick_record(
"log_memory": False,
},
)


def recording_prompt(options: list[str], record_button: ui.button) -> None:
"""Display the recording prompt dialog.
Args:
options (list): List of autocomplete options.
record_button (nicegui.widgets.Button): Record button widget.
"""
if not record_proc.is_running():
with ui.dialog() as dialog, ui.card():
ui.label("Enter a name for the recording: ")
ui.input(
label="Name",
placeholder="test",
autocomplete=options,
on_change=lambda e: result.set_text(e),
)
result = ui.label()

with ui.row():
ui.button("Close", on_click=dialog.close)
ui.button("Enter", on_click=lambda: on_record())

dialog.open()

def terminate() -> None:
global record_proc
record_proc.set_terminate_processing()

# wait for process to terminate
record_proc.wait()
ui.notify("Stopped recording")
record_button._props["name"] = "radio_button_checked"
record_button.on("click", lambda: recording_prompt(options, record_button))

record_proc.reset()

def begin() -> None:
name = result.text.__getattribute__("value")

ui.notify(
f"Recording {name}... Press CTRL + C in terminal window to cancel",
)
global record_proc
record_proc.start(
record,
(name, record_proc.terminate_processing, record_proc.terminate_recording),
)
record_button._props["name"] = "stop"
record_button.on("click", lambda: terminate())
record_button.update()

def on_record() -> None:
global record_proc
dialog.close()
begin()
100 changes: 0 additions & 100 deletions openadapt/deprecated/app/main.py

This file was deleted.

42 changes: 0 additions & 42 deletions openadapt/deprecated/app/objects/console.py

This file was deleted.

Loading

0 comments on commit 8bb6fc1

Please sign in to comment.