Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

I want Tk::Splashscreen not centered.

by ric00015 (Beadle)
on Oct 23, 2013 at 23:12 UTC ( #1059369=perlquestion: print w/ replies, xml ) Need Help??
ric00015 has asked for the wisdom of the Perl Monks concerning the following question:

I have an application that I'd like to have a splash screen with a label, a progress bar, and possibly, a label that specifies where in execution the program is. This I have done, and am quite pleased. However, I have 2 screens; not a bad thing, but the splash screen appears in the middle of the viewing area, which happens to be right where the screen splits.

I am using Tk::Splashscreen, and as the documentation states, it can be treated like a toplevel widget. That widget has a -screen switch, but I can't figure out what to use for the value. 'Display 1', 'display 1', 'screen 1', '1', and ':1' don't work. I am assuming the displays are 1 and 2, as labeled in the Display options on Red Hat.

Does anyone know the format of the display for the -screen switch? Or does anyone know of a way to place the splash screen somewhere other than the middle of the viewing area?

Update! I just tried ':0' and it worked, but it was still in the middle of the 2 screens. Not what I wanted. <sigh> Leaving the value blank does the same thing, so maybe the -screen switch is not what I need.

Update 2! I just tried the suggestions below, but neither of them has worked. At least not yet. I will keep trying, and let you know if I get something working.

Update 3! I got it working properly by using geometry, as suggested below. I tinkered with it until I got the proper behavior. Actually it probably was the way I was creating it that was messing up. But now it's fixed.

Comment on I want Tk::Splashscreen not centered.
Select or Download Code
Re: I want Tk::Splashscreen not centered. (geometry)
by Anonymous Monk on Oct 24, 2013 at 02:29 UTC
    A Tk::Splashscreen is a Tk::Toplevel is a Tk::Wm and Tk::Widget ... so geometry to move it ... hey, if you UTSL you can see geometry is used

    So use geometry :)

Re: I want Tk::Splashscreen not centered.
by Khen1950fx (Canon) on Oct 24, 2013 at 07:38 UTC
    The format for display would be similar to this:
    #!/usr/bin/perl use strict; use warnings; use Tk; use Tk::Splashscreen; my $mw1 = MainWindow->new; my $mw2 = MainWindow->new( -screen => $ARGV[0] ||= $ENV{'DISPLAY'}, );

      The format for display would be similar to this:

      Well, the OP talked about format for -screen and you don't show any format for the kind of argument -screen takes

      Thanks for that suggestion, but, alas, it didn't work. Or rather, it worked, but like ':0', just leaving the value blank, or even no -screen at all. It was still firmly in the middle of my 2 screens.

Re: I want Tk::Splashscreen not centered.
by keszler (Priest) on Oct 24, 2013 at 09:47 UTC
    To move the splashscreen from the center, immediately after your $splash->Splash; command add $splash->geometry("+20+20");.

      Alas, that didn't work either. I had the $splash->geometry("+20+20"); right after $splash->Splash;, just like you said, but no dice. I even put the geometry command right after the creation code: our $splash = $parent->Splashscreen(-milliseconds => 3000); but still it was stuck in the middle.

        The example program for Tk::Splashscreen is http://cpansearch.perl.org/src/LUSOL/Tk-Splashscreen-1.0/splashscreen.pl. On my system (WinXP 64 w/ Activestate 5.12.2), adding the $splash->geometry("+20+20"); command as above succeeded in moving the splash window.

        If this isn't the case for you, please reduce your program to the minimum needed to demonstrate the problem and post it as a new question, along with details of your OS and Perl versions. (More people will see a new SoPW than will see new replies in this one.)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1059369]
Approved by Athanasius
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (11)
As of 2014-07-30 10:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (230 votes), past polls