started the animationpage
This commit is contained in:
50
main.py
50
main.py
@@ -465,8 +465,52 @@ class RegisterScreen(Screen):
|
||||
return False
|
||||
|
||||
class CreateAnimationScreen(Screen):
|
||||
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):
|
||||
"""Load existing projects/trips when the screen is entered."""
|
||||
@@ -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
|
||||
|
||||
@@ -1 +1 @@
|
||||
gAAAAABoQZZ4y4TyP0vsqVtL5HZvQvAvpF0KWgQHpqUHSdBgQGi0l-Qo1ZOEjNzPcnoXOxbGN6Q6knPNjzqTLxiqIdnxeN6fnX4PkYjWqSLx4USUYnws3XEK99p_YQMjOO0kcrXZUThD
|
||||
gAAAAABoQZq2xnxplxk3VFNb72evhmJ-mN3KLdQxrLvjkV_j4fzn_x1Lp2wxx3lZcQ0D6VYPPX5TVlKIcSxL3TMApYdxSONz_Gjj8yx7Fbn_7z5UO8dDVjOtR7-eVnyyCCFVeb6wmz47
|
||||
39
traccar.kv
39
traccar.kv
@@ -558,21 +558,54 @@
|
||||
on_press: app.root.current = "home"
|
||||
|
||||
<CreateAnimationScreen>:
|
||||
|
||||
BoxLayout:
|
||||
orientation: "vertical"
|
||||
padding: 20
|
||||
spacing: 20
|
||||
canvas.before:
|
||||
Color:
|
||||
rgba: 0.11, 0.10, 0.15, 1 # Same background as other screens
|
||||
rgba: 0.11, 0.10, 0.15, 1
|
||||
Rectangle:
|
||||
pos: self.pos
|
||||
size: self.size
|
||||
|
||||
Label:
|
||||
text: "Create Animation Screen"
|
||||
font_size: 24
|
||||
text: root.project_name if root.project_name else "Create Animation Screen"
|
||||
font_size: 22
|
||||
color: 1, 1, 1, 1
|
||||
size_hint_y: None
|
||||
height: 36
|
||||
|
||||
BoxLayout:
|
||||
orientation: "horizontal"
|
||||
size_hint_y: None
|
||||
height: 60
|
||||
padding: [10, 10, 10, 10]
|
||||
spacing: 10
|
||||
canvas.before:
|
||||
Color:
|
||||
rgba: 0.15, 0.15, 0.18, 1
|
||||
Rectangle:
|
||||
pos: self.pos
|
||||
size: self.size
|
||||
|
||||
Label:
|
||||
text: "Edit or change the name of the project"
|
||||
font_size: 16
|
||||
color: 1, 1, 1, 1
|
||||
size_hint_x: 0.7
|
||||
|
||||
Button:
|
||||
text: "Rename"
|
||||
size_hint_x: 0.3
|
||||
font_size: 16
|
||||
background_color: 0.341, 0.235, 0.980, 1
|
||||
color: 1, 1, 1, 1
|
||||
on_press: root.open_rename_popup()
|
||||
|
||||
Widget:
|
||||
size_hint_y: 1
|
||||
|
||||
Button:
|
||||
text: "Back to Home"
|
||||
|
||||
Reference in New Issue
Block a user