I've been to both cities and will be returning to Budapest in May for a week, it had a huge impact on me and I have been unable to stop thinking about it and longing for more--my original 4 days were just a small taste. Prague is quite beautiful but has such a hectic vibe, even when I was there in May, so I can scarcely imagine what it's like in summer. If you really want to see a bit of both then 3 days Prague and the rest in Budapest would be adequate, but I think 7 days in Budapest and the immediate environs would be more satisfying.
Others will be along with more detailed suggestions, but for day trips there's a lovely little artist's colony called Szentendre, easily reached on the suburban HEV train, also the towns of Vac, Visegrad and Esztergom. This trip I will be visiting Godollo to see the summer palace of Franz Joseph and the infamous Sissi, and to a small town called Tata, birthplace of my great-grandparents and it also has a castle and lake that draw visitors, and another as yet undecided town.
You can also take the train for a long day trip to Vienna, 3 hours, catching an early train and arriving by 10, leaving around 6, would give you a bit of time to explore quite a bit since Vienna is fairly compact and easy to get around. Bratislava is about 2 1/2 hours away, also worth a day trip.