monitor refreshrate animation consistency added
This commit is contained in:
parent
980c148b29
commit
dabc74f0a1
1 changed files with 13 additions and 6 deletions
|
@ -1,14 +1,19 @@
|
|||
import threading
|
||||
import time
|
||||
import math
|
||||
from tkinter import Canvas, Tk, Frame, Button
|
||||
|
||||
# Constants
|
||||
FRAME_INTERVAL = 1 # milliseconds, adjust to control the animation speed
|
||||
|
||||
# Modified code
|
||||
root = Tk()
|
||||
root.geometry("1000x600")
|
||||
|
||||
from gui_starfield import StarField # Assuming gui_starfield.py contains the StarField class
|
||||
|
||||
container_x = -320
|
||||
container_x_size = 320 # Defined size of tab/container
|
||||
container_x = -container_x_size
|
||||
col_isDark = True
|
||||
|
||||
current_container = None # To keep track of the current container
|
||||
|
@ -17,24 +22,26 @@ close_finished_event = threading.Event()
|
|||
def open_container():
|
||||
global container_x
|
||||
if container_x < 0:
|
||||
container_x += 5
|
||||
container_x += 1
|
||||
current_container.place(x=container_x, y=0)
|
||||
if container_x >= 0:
|
||||
container_x = 0 # This is stupid, but just to make sure
|
||||
pass # If you need to execute something when the container is fully open, add it here
|
||||
else:
|
||||
root.after(5, open_container)
|
||||
root.after(FRAME_INTERVAL, open_container)
|
||||
|
||||
def close_container():
|
||||
global container_x
|
||||
global close_finished_event
|
||||
if current_container:
|
||||
container_x -= 5
|
||||
container_x -= 1
|
||||
current_container.place(x=container_x, y=0)
|
||||
if container_x <= -320:
|
||||
if container_x <= -container_x_size:
|
||||
container_x = -container_x_size # This is stupid, but just to make sure
|
||||
close_finished_event.set() # Signal that the closing animation is finished
|
||||
pass # If you need to execute something when the container is fully closed, add it here
|
||||
else:
|
||||
root.after(5, close_container)
|
||||
root.after(FRAME_INTERVAL, close_container)
|
||||
|
||||
def switch_to_tab(tab_name):
|
||||
global current_container
|
||||
|
|
Reference in a new issue