Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Tk window location Win 7

by Anonymous Monk
on Mar 09, 2020 at 11:36 UTC ( [id://11114006]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have a main window using pack & another top level window using place, but this second window opens half off-screen. ->geometry(size x size + position + position) sets the size OK but ignores the position. It is also a fixed size window using ->minsize & ->maxsize because ->resize(0,0) didn't work. What am I doing wrong?

Replies are listed 'Best First'.
Re: Tk window location Win 7
by tybalt89 (Monsignor) on Mar 09, 2020 at 18:33 UTC

    pack and place are for positioning subwindows inside a window, they should not matter.

    Lacking code from you, here's a small example that puts up a main window and a top level window exactly where they are supposed to be.

    #!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11114006 use warnings; use Tk; my $mw = MainWindow->new; $mw->geometry( '300x300+100+300' ); my $top = $mw->Toplevel(); $top->geometry( '300x300+500+300' ); MainLoop;
Re: Tk window location Win 7
by Marshall (Canon) on Mar 09, 2020 at 22:14 UTC
    Please show some short example code of the problem. Without that, this is kind of like a "UFO report" - very hard to reproduce. It has been years since I did a complex Tk GUI, but it worked surprisingly well on XP,Win2K and Win7. I remember having to tweak a bit to get a nice display on all platforms, but I did succeed with the exception that there wasn't a nice "open directory" widget. I remember there being some issues with things like whether the user had "large fonts" enabled and interaction with custom display resolution. If you are using something aside from the defaults, please mention that.

    Update: As I think about this, I haven't had the need to place a secondary window on the screen at particular x,y screen coordinates. If this window has to be at particular coordinates relative to the main window, why isn't it in the main window? Or why doesn't simple pack() work? The user can move these windows around and "save windows", meaning that you ask each window where it is and save those coordinates. Lot's of possibilities here.

      Thank you for bothering to reply. The code below is just a bit of the definition of $G=$mw->DialogBox with most fields initially disabled. $G isn't displayed until requested by action in the main window.
      if(not defined $G) { $G = $mw->DialogBox(title => "List", -buttons => ["Edit/Save", "Add Picture", "Exit"], -default_button=>"Exit", -cancel_button=>'Exit', -command=>\&handle_display_button); # lots of code here my $img2 = $mv->Photo('resized'); $G->Label(-image=>'resized', -height=>400, -width=>600)->place(-x=>20, -y=>190); $lft= $G->Button(-image=>'left', -command=>[\&change_picture, 'down'], -relief=>'flat')->place(-x=>0, -y=>350); $rr = $Gems->Button(-image=>'right', -command=>[\&change_picture, 'up'], -relief=>'flat')->place(-x=>620, -y=>350); $scale = $G->Scale(-from=>0, -to=>$#Search_List, -variable=>\$sb_idx, -command=>\&Change_Record, -orient=>'horizontal', -length=>540)->place(-x=>50, -y=>600); # $G->positionfrom('program'); $G->geometry('650x680+0+0'); # $G->geometry('+0+0'); $G->minsize(650,680); $G->maxsize(650,680); } $G->Show;
      ->geometry('650x680); gave it the size I wanted, but it started opening half off screen so I added '+pos+pos', but it didn't change anything, no matter what values I used. Every time it is shown it is always in the same place and I have to move it manually to see it in its entirety.
        #!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11114006 use warnings; use Tk; use Tk::DialogBox; my $mw = MainWindow->new; $mw->geometry( '300x300+600+300' ); my $G = $mw->DialogBox( -popover => undef, -popanchor => 'nw', -overanchor => 'nw'); $G->minsize(650,680); $G->maxsize(650,680); $mw->Button(-text => 'Open Dialog Box', -command => sub { $G->Show }, )->pack; MainLoop;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-04-20 01:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found