When I run a two instances of the same perl tk script at the same time, the second one does not pick up the X resources. How can I fix this? For example (for simplicity):
my $mw = MainWindow->new(-title => 'Menu');
$mw->Label(-text => 'hello world')->pack;
MainLoop;
My Xresources file has:
weird*font: clean
weird*foreground: steel blue
weird*background: cornsilk
Here is what the first running copy gives:
Here is what a second copy of the same script running at the same time gives:
I found this in the documentation:
Every Tk program is automatically assigned a default application name, usually the filename of the program, although the appname method can set the name programmatically. To avoid ambiguities, Tk insists that application names be unique and appends a number if needed,
To find your own application name, use the name method, and to see a list of active Tk programs, use interps:
my $name = $mw->name;
my(@interps) = $mw->interps;
So I think what this means, is that unless you know there will only ever be one copy of the program running at any one time, you must assign a class to the main window, and use that class name rather than the program name as the first qualifier in Xresorces.