не может вызвать метод "geometry" без ссылки на пакет или объект - PullRequest
0 голосов
/ 06 октября 2011

Я пытаюсь центрировать диалог getSaveFile в выбранном (по xwininfo) окне, у меня есть положение, ширина и высота выбранного окна, но мне нужна помощь в перемещении диалога getSaveFile (когда он вверх / показывает, может быть, ключ), и так до центра выбранного окна ...

переменные, которые у меня есть для выбранного окна: $ window_width, $ window_height, $ abs_x, $ abs_y

Я считаю, что для правильного позиционирования диалога GetSaveFile мне нужно что-то вроде:

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

вышеизложенное - не столько проблема, но некоторая помощь там тоже была бы неплоха, это какой код использовать, чтобы подключить эти цифры к тому, что я ищу ...

где и как использовать "$ sfile -> geometry (widthxheight + x + y);" введите биты, так как я получаю сообщения об ошибках ниже:

# 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...   
 }

Теперь у меня есть это:

# 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...
    }
 } 

1 Ответ

2 голосов
/ 06 октября 2011

Метод getSaveFile возвращает имя файла (или undef, если отменено), а не ссылку на виджет. Я не вижу ничего в документации о расположении окна.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...