gpt4 book ai didi

linux - 没有包或对象引用无法调用方法 "geometry"

转载 作者:太空宇宙 更新时间:2023-11-04 09:54:02 24 4
gpt4 key购买 nike

我正在尝试将 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...
}
}

最佳答案

getSaveFile 方法返回文件名(或 undef,如果取消),而不是小部件引用。我什么也没看到its documentation关于定位窗口。

关于linux - 没有包或对象引用无法调用方法 "geometry",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7674585/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com