Dundee is a long way from Cheltenham Ladies' College, and not just in geographical terms.

Yet, without such an august institution commissioning playwright Sharman Macdonald to write a new work, it's unlikely that her play now known as She Town would be opening in a brand new production at Dundee Rep this week.

"It was the suggestion of my very first literary agent that I write something for them," the Glasgow-born actor turned writer says. "I said that I've only got one idea, and they're not going to want to do that."

Given that the idea involved a cast of 40 playing a community of vocal working-class women in 1930s Dundee, you can see her point. Especially as the play was set against a backdrop of social and political strife, with intimations of the Spanish Civil War en route.

"I was reading an economics book, and there was a section in it about a society of women in Dundee during the Depression. There was a sentence in the book that said something about how freedom can disappear before you even know it's there, and I thought, if I know nothing about it, then maybe no-one else does either. I was reading about Paul Robeson at the same time as well, and his role in the Spanish Civil War, and it turned out he sang at the Caird Hall, so the two things just sort of came together."

That play became Lu Lah, Lu Lah, performed at Cheltenham in 2010. "It was extraordinary," Macdonald says. "The cast not only had to conquer the Dundee accent, but they had to try to understand what was going on in this entire society and the Spanish Civil War and all of that as well."

Macdonald passed the script of Lu Lah, Lu Lah to her next door neighbour, who knew Dundee Rep's then artistic director James Brining. He immediately recognised the potential of doing such a big, community-based work set on his own doorstep, and earmarked it for a production.

"That gave me the chance to rewrite," Macdonald says. "Paul Robeson had never been present onstage, but I thought I'd put him on. But then Dundee said, no, we really like the fact that there are no men onstage. So all the men are present, but in the minds of the women."

The night before we talk, it was the red carpet premiere of the new film version of Tolstoy's Anna Karenina, starring Macdonald's superstar daughter Keira Knightley in the title role. This morning, however, Macdonald is distracted by the domestic mundanities of dealing with the dishwasher man.

"It's totally chaotic," says Macdonald, "but he says there's absolutely nothing wrong with the dishwasher, and has just disappeared. Oh, goody, but I wish there was something wrong with it."

There's an inherent girlishness about Macdonald when she talks like this. It can see her get as excited about the peccadilloes of her dishwasher as she does about her latest line of artistic inquiry. This sense of brio has sat alongside an accompanying dreaminess ever since Macdonald's first play, coming-of-age drama When I Was A Girl I Used To Scream and Shout, became a hit in 1984.That play was written out of Macdonald's desire to quit performing to have a second child with actor husband Will Knightley.

While a second child duly followed in the shape of Ms Knightley, so did other plays; When We Were Women and Sea Urchins followed in steady succession at theatres including the Bush, the Cottesloe and the Royal Court. In the mid-1990s, another play, The Winter Guest, was picked up by actor Alan Rickman, who directed the big-screen version starring real-life mother and daughter Phyllida Law and Emma Thompson.

As well as being able to see her play in the city it's set in, the Dundee Rep production of She Town will also provide Macdonald with something of a reunion with director Jemima Levick. The last new play Macdonald had produced in Scotland was The Girl With Red Hair, a co-production between Edinburgh's Royal Lyceum Theatre and the Bush produced in 2005. While the production's main director was Bush veteran Mike Bradwell, Levick assisted. Since then, of course, Levick has gone on to carve out a brilliant career of her own, and is now joint artistic director of Dundee Rep. Among her many triumphs in Dundee, Levick even directed a version of Anna Karenina.

While The Girl With Red Hair was playing in Edinburgh and London, Macdonald was working on the screenplay for what became The Edge of Love, which looked at the women who orbited around poet Dylan Thomas. Knightley played Vera Phillips, Thomas' one time teenage sweetheart who later formed an unlikely friendship with Thomas' wife, Caitlin, played in the film by Sienna Miller.

Since then, Macdonald has spent her time "writing screenplays that weren't done, but still might be."

One of these looked again at the Spanish Civil War, and is, in Macdonald's own estimation, "the best thing I've ever done."

The Spanish Civil War is a subject that clearly fascinates Macdonald. "There's something about its complexity," she says, "and the fact that those who fought thought that if they stayed they could get rid of Franco, the sheer bravery of them. There's also the tragedy of the left fragmenting, while the right stays as a cohesive whole. I suppose it's because I don't understand all those complexities that I keep on going back to it, just so I can try and understand it."

Despite such passion, Macdonald remains pragmatic about her unproduced screenplay.

"Things have their time," she says. "It was so nearly done, but it was superseded by something else that came along on the same subject.

That's the luck of the draw. But that doesn't mean I won't write about it again. It just won't be the same specific story."

Whether the subject will inform the play she's working on now, Macdonald isn't saying. In fact, in terms of what the play might be about, she won't say much at all on the subject, preferring instead to hold onto a superstitious sense of mystery that's as perfect as when she's dealing with the dishwasher man.

"Do you mind if I don't tell you?" she says. "If you talk about things you're working on, they can disappear in a puff of smoke. It's almost like you lose a part of it."

She pauses. "I'm sorry," she says. "I have to go. People are calling for me."

She Town, Dundee Rep, September 12-29. www.dundeerep.co.uk