started the animationpage

This commit is contained in:
2025-06-05 16:26:29 +03:00
parent 8652940879
commit 3da7a28546
5 changed files with 86 additions and 7 deletions

52
main.py
View File

@@ -465,7 +465,51 @@ class RegisterScreen(Screen):
return False
class CreateAnimationScreen(Screen):
pass
project_name = StringProperty("")
def on_pre_enter(self):
# This will be called when the screen is shown
pass
def open_rename_popup(self):
from kivy.uix.popup import Popup
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.textinput import TextInput
from kivy.uix.label import Label
layout = BoxLayout(orientation='vertical', spacing=10, padding=10)
label = Label(text="Enter new project name:")
input_field = TextInput(text=self.project_name, multiline=False)
btn_save = Button(text="Save", background_color=(0.008, 0.525, 0.290, 1))
btn_cancel = Button(text="Cancel")
layout.add_widget(label)
layout.add_widget(input_field)
layout.add_widget(btn_save)
layout.add_widget(btn_cancel)
popup = Popup(title="Rename Project", content=layout, size_hint=(None, None), size=(350, 260), auto_dismiss=False)
def do_rename(instance):
new_name = input_field.text.strip()
if new_name and new_name != self.project_name:
if self.rename_project_folder(self.project_name, new_name):
self.project_name = new_name
popup.dismiss()
btn_save.bind(on_press=do_rename)
btn_cancel.bind(on_press=lambda x: popup.dismiss())
popup.open()
def rename_project_folder(self, old_name, new_name):
import os
old_path = os.path.join(RESOURCES_FOLDER, "projects", old_name)
new_path = os.path.join(RESOURCES_FOLDER, "projects", new_name)
if os.path.exists(old_path) and not os.path.exists(new_path):
os.rename(old_path, new_path)
return True
return False
class HomeScreen(Screen):
def on_pre_enter(self):
@@ -545,10 +589,12 @@ class HomeScreen(Screen):
self.manager.current = "get_trip_from_server"
def edit_project(self, project_name):
# Navigate to the create_animation screen and pass the project name if needed
# Set the project name on the CreateAnimationScreen before switching
create_anim_screen = self.manager.get_screen("create_animation")
create_anim_screen.project_name = project_name
self.manager.current = "create_animation"
# Optionally, set a property or method to load the project in create_animation
# delete or archive project
def confirm_delete_project(self, project_name):
from kivy.uix.popup import Popup
from kivy.uix.boxlayout import BoxLayout