Skip to content
Snippets Groups Projects
Commit fe1876a0 authored by Oscar Gustafsson's avatar Oscar Gustafsson :bicyclist:
Browse files

Return new schedule after editing

parent 44fefc39
No related branches found
No related tags found
1 merge request!299Return new schedule after editing
Pipeline #95055 passed
......@@ -314,11 +314,21 @@ class Schedule:
"""If the current schedule is cyclic."""
return self._cyclic
def edit(self) -> None:
"""Edit schedule in GUI."""
def edit(self, inplace=False) -> "Schedule":
"""
Edit schedule in GUI and return new schedule.
Parameters
----------
inplace : bool, default: False
If True, replace the current schedule.
"""
from b_asic.scheduler_gui.main_window import start_scheduler
start_scheduler(self)
new_schedule = start_scheduler(self)
if inplace:
self = new_schedule
return new_schedule
def increase_time_resolution(self, factor: int) -> "Schedule":
"""
......
......@@ -705,13 +705,14 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
self._update_recent_file_list()
def start_scheduler(schedule: Optional[Schedule] = None) -> None:
def start_scheduler(schedule: Optional[Schedule] = None) -> Schedule:
app = QApplication(sys.argv)
window = ScheduleMainWindow()
if schedule:
window.open(schedule)
window.show()
sys.exit(app.exec_())
app.exec_()
return window.schedule
if __name__ == "__main__":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment