You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There should be other break condition(s) in _draw_text (other than the if...break below, which is the only break implemented). In my first attempt at running example code, the first create_marker call hangs.
How much of the timeline is visible is what should stop the loop according to the current implementation of _draw_text
Even if I use root.after to call my create_markers function (to ensure Tk has finished the initial window layout) the hang still occurs.
There are only 3 markers in my example.
The following patch to _draw_text in timeline.py reveals the issue is an infinite loop, and the output of my raise is "RuntimeError: Too many (1000) bounding boxes. (7 - -7) >= (15.0 - 5.0) :: 14 >= 10.0":
I am not suggesting this is a solution, or the proper break condition. The limit conditional code merely reveals that the loop should have ended earlier (through some better conditional)
The patch is also useful during testing to reveal the state of the variables in the infinite loop condition.
However, adding this (with 9999 or something) could be useful such as if you add a unit test based on my example code below in order to ensure there is not a regression once the root cause can be determined and fixed.
Example code (If there is nonsense in the code, it is because it is ChatGPT...regardless, the library should have some kind of way to exit the loop above better, even if there is some nonsense input):
importtkinterastkfromttkwidgets.timelineimportTimeLinefromcollectionsimportOrderedDicttimeline=Nonedefcreate_markers():
print("create marker...")
# Add markers to the timeline using create_marker()timeline.create_marker(
category="Development",
start=5.0, # Start time for the markerfinish=15.0, # Finish time for the markertext="Requirement Analysis",
foreground="white",
background="blue",
outline="darkblue",
border=2,
)
print("create marker...")
timeline.create_marker(
category="Testing",
start=20.0, # Start time for the markerfinish=30.0, # Finish time for the markertext="Unit Testing",
foreground="black",
background="green",
outline="darkgreen",
border=2,
)
print("create marker...")
timeline.create_marker(
category="Deployment",
start=40.0, # Start time for the markerfinish=50.0, # Finish time for the markertext="Initial Deployment",
foreground="white",
background="red",
outline="darkred",
border=2,
)
defcreate_timeline():
globaltimeline# Create the main windowroot=tk.Tk()
root.title("TimeLine Widget Example")
root.geometry("1200x800")
# Define categories with valid ttk.Label optionscategories=OrderedDict({
"Development": {
"text": "Development",
"foreground": "white",
"background": "blue",
},
"Testing": {
"text": "Testing",
"foreground": "black",
"background": "green",
},
"Deployment": {
"text": "Deployment",
"foreground": "white",
"background": "red",
},
})
# Create the TimeLine widgettimeline=TimeLine(
root,
width=1000, # Width of the timeline in pixelsheight=300, # Height of the timeline in pixelsextend=True, # Allow extending timeline when neededstart=0.0, # Start value for the timeline (float)finish=100.0, # Finish value for the timeline (float)resolution=1.0, # Seconds per pixel (float)tick_resolution=10.0, # Ticks every 10 seconds (float)unit="s", # Seconds as the unitzoom_enabled=True, # Enable zoomingcategories=categories, # Add categories to the timelinebackground="white", # Background colorstyle="TFrame", # Apply a style to the framezoom_factors=(1.0, 2.0, 5.0), # Allowed zoom levelszoom_default=1.0, # Default zoom levelsnap_margin=5, # Snap to ticks within 5 pixelsautohidescrollbars=True# Use AutoHideScrollbars
)
print("pack...")
timeline.pack(fill=tk.BOTH, expand=True, padx=10, pady=10)
# root.after(500, create_markers) # attempted solve of issue #110, but doesn't solvecreate_markers()
print("mainloop...")
# Run the Tkinter main looproot.mainloop()
if__name__=="__main__":
create_timeline()
The text was updated successfully, but these errors were encountered:
There should be other
break
condition(s) in_draw_text
(other than theif...break
below, which is the onlybreak
implemented). In my first attempt at running example code, the firstcreate_marker
call hangs._draw_text
create_markers
function (to ensure Tk has finished the initial window layout) the hang still occurs.The following patch to
_draw_text
in timeline.py reveals the issue is an infinite loop, and the output of myraise
is "RuntimeError: Too many (1000) bounding boxes. (7 - -7) >= (15.0 - 5.0) :: 14 >= 10.0":Example code (If there is nonsense in the code, it is because it is ChatGPT...regardless, the library should have some kind of way to exit the loop above better, even if there is some nonsense input):
The text was updated successfully, but these errors were encountered: