# cpy Thonny - guizero shuttle simulation - train at A
# provided by Anthony Vogelaar, Perth Scotland
# rev 0.10  2025-01-03  initial release

# tools |  manage packages | guizero : search on pypi | install
# drawing: https://lawsie.github.io/guizero/drawing/

from guizero import App, Drawing

# ==================== GUI setup =========================

app = App('Shuttle simulation', width=800, height=200)
ctx = Drawing(app, width='fill', height='fill')

# ======================= Widgets ========================

# draw track, center @ x=400, y=100
def track():
    ctx.line(10,  90, 790,  90, width=4)
    ctx.line(10, 110, 790, 110, width=4)


# draw train at position x
def train(x=0):
    x0 = 60; y0 = 100
    ctx.rectangle(x0+x-40, y0-20, x0+x+40, y0+20, color='blue')


# draw layout,  signals, track and train
def layout():
    ctx.clear()					# clear context
    track()
    train()
    
# ======================= Timer =========================

# application sequencer
def onTimer():
    ...
    
# ========================= main =========================

layout()							# initial layout
# ctx.repeat(50, onTimer)			# sequencer
app.display()						# start GUI loop
    
# ========================== end =========================    
