There is an excellent train network along the coast in the South of France, train timetables readily available. Saint Tropez is accessible but I cannot remember the journey time. Plenty of other places to head to via train along the coast - Eze, Villefranche, Monaco all within an hour.
When I was in Cannes last summer there was a day trip available by boat to Saint Tropez also, info was available in the tourist office in Cannes. Looked like a nice alternative way to get there, I didn't go due as it was too late in my holiday.