It is difficult, at times, to determine which events are staged for tourists and which are reflections of a deeply ingrained local culture. Eating at the Irma Hotel buffet, you wonder if you are underdressed without a Stetson. It is not for mere effect that the entrance to the Buffalo Bill Historical Center specifies “Firearms Prohibited.”

Cody, you see, is cowboy country. For real. And cowboy country, too, for show. The town is surrounded by landscapes that could have been used as movie backdrops by John Ford. A stunning drive of just over 50 miles takes you to the eastern entrance of Yellowstone National Park.

The town was named after — and founded by — William F. Cody, who imagined that tourists would flock here because of its proximity to the park entrance. It was one of his few schemes that eventually succeeded. But even at its incorporation in 1902, Cody (the town) had a fighting chance only because Cody (the man) was Buffalo Bill — perhaps the most renowned celebrity of his time. His cowboy-and-Indian variety show, “Buffalo Bill’s Wild West,” had been seen across the country and in Europe. From 1883 to 1913, it toured (according to the history center) a quarter of a million miles, touching down in Paris, London and Brooklyn.

It is as if the show had given birth to a town. In that sense Cody is a bit like Disneyland or Las Vegas, originating from an entertainment concept. Except, of course, Cody is not just a theme park but also real: there are ranches and cattle. Moreover, because the town is not extraordinarily wealthy or (like nearby Jackson Hole) a draw for well-to-do skiers and financiers, it glitters with true grittiness. (Or is that the glitter of showmanship? )

And that brings us to this rather remarkable historical center. It traces its origins to a Buffalo Bill Memorial Association established in 1917, the year of that showman’s death. In 1959 the Whitney Gallery of Western Art opened and was later united with the Buffalo Bill Museum. The center grew.