开发者

can't call method "geometry" without a package or object reference

开发者 https://www.devze.com 2023-04-11 08:55 出处:网络
I\'m trying to centre a getSaveFile dialog on a selected(by xwininfo) window, I have the position, width and height of the selected window, but need help moving the getSaveFile dialog about (when it\'

I'm trying to centre a getSaveFile dialog on a selected(by xwininfo) window, I have the position, width and height of the selected window, but need help moving the getSaveFile dialog about (when it's up/showing maybe the key), and so to the centre of the selected window...

vars I have for the selected window are $window_width, $window_height, $abs_x, $abs_y

I believe to position the GetSaveFile dialog right, 开发者_开发问答I would need something like:

$sfile ->geometry("originalWidth"."x"."orighnalHeight+($abs_x+($window_width/2 - originalWidth/2))+($abs_y+($window_height/2 -orighnalHeight/2)");

the above is not so much the problem, but some help there too would be nice, it is what code to use to plug those numbers into that I'm after...

where and how to use the "$sfile ->geometry(widthxheight+x+y);" type bits, as I'm getting errors with the below:

# save dialog
 my $types = [
['All Files',        '*',             ],
['mpg files',        '.mpg',          ],        
['avi files',        '.avi',          ],              
['mov files',        '.mov',          ],         
];


my $sfile = $mw->getSaveFile( 
                                          -defaultextension => ".mov",
                                          -initialdir => "/home/frank/Perl/screencaps", # standardise...
                                          -initialfile => "ScreenCast01",
                                          -title => "ScreenCast Capture file",
                                          -filetypes => $types,
                                          # position/geometry
                                          ); 

 # $sfile ->geometry('100x100+100+100');   # can't call method "geometry" without a package or object reference...   
 &do_saveFileWithType($sfile) if defined $sfile;

sub do_saveFileWithType {

 my @InboundParameters = @_;
   print "This is what was passed:\t$InboundParameters[0]\n";

#   $sfile ->geometry('100x100+100+100');   # can't call method "geometry" without a package or object reference...   
 }

I now have this:

# to centre the save dialog(for when it's up): 
 my $title = "ScreenCast Capture file";
 my $x = ($abs_x+($window_width/2)-207); # 207 =  SaveDialogWidth/2
 my $y = ($abs_y+($window_height/2)-134); # 134 =  SaveDialogHeight/2

my $checking4win2move;
  $checking4win2move = "on";
  my $pid = fork(); # ??
  if ($pid == 0){ # ??

    while ($checking4win2move eq "on"){
       my  @runwmctrl = wmctrl ("-l"); 
       for( @runwmctrl ) { 
             my $linesOf_wmctrl=$_;  
             chomp ($linesOf_wmctrl);           # Get rid of the trailling \n   ??

            if($linesOf_wmctrl =~ m/ScreenCast Capture file/) { 
               #print "The \"ScreenCast Capture file\" dialog is mentioned and so is up, I can now move it to the centre of the selected window.\n";
                   my $windowMove = wmctrl ("-r $title", "-e 0,$x,$y,-1,-1"); 

                 # and stop checking:
                # $checking4win2move = "off"; # unfork?? # X Error of failed request: BadIDChoice (invalid resource ID chosen for this connection)
                exit(); #??
                  }else{ # print "The dialog is not mentioned in this line of wmctrl\'s output\n";
                   }
     }
      sleep .02; # then check again or...
    }
 } 


The getSaveFile method returns a file name (or undef, if cancelled), not a widget reference. I don't see anything its documentation about positioning the window.

0

精彩评论

暂无评论...
验证码 换一张
取 消