Can you determine the x and y size of a window in script?
Sure, just get a handle to the window like this:
win = fpmi.gui.getWindow('MyWindow')
and then get the size params like this:
x = win.location.x
y = win.location.y
width = win.size.width
height = win.size.height
The code:
x = win.location.x
y = win.location.y
bombs out for me but the rest of it works.
I have found itās easier to work with window sizing by selecting the window then use CTRL-P to see and adjust size.
I think nathan was talking about accessing the window size at runtime. How exactly did it ābomb outā? Did you include the snippet of code from the first code section too?
Iāll preface this reply by saying I donāt have much clue what Iām doing here, but checking in the Java documentation shows that location should be followed by brackets. The following code seems to work:
win = fpmi.gui.getWindow('MyWindow')
x = win.location().x
y = win.location().y
width = win.size.width
height = win.size.height
print x,y
print width,height
I also noticed that ālocation()ā is in the deprecated list and has been replaced by āgetLocation()ā - does this matter here, Carl?
Al
So, whats going on here is that the location() function is interfering with Pythonās automatic JavaBean property access support. Here is an example: If I have a Java class with functions like getFoo() and setFoo(String foo), then in Python I can say:
objectInstance.foo, referencing āfooā as if it were a variable, not a pair of getter/setter functions. This is part of the JavaBean spec.
So, normally when you access the variable āwin.locationā Python is really going to call the function win.getLocation(). But, the presence of a ālocation()ā function on Window is throwing off the JavaBean stuff, and so you are accessing that function directly, which is why you need the parens to make it work.
More than you wanted to know, eh?
I stand informed. Iām assuming then that you should really be directly calling the getLocation() function here.
Oh ya, that works now, thanks.
Where do you to look at Java documentation?
Hi harryting,
You could look at http://java.sun.com/javase/reference/api.jsp under Core API Docs version 6, but I warn you, there is a ton of stuff in there! (and if you know as little about Java as I do it may only confuse things more!)
Al
Somewhat related, do I have access to the Move Forward, Move Backward, Move to Front, Move to Back properties programatically? I found that it could be useful while using the paint component.
Step7,
Iām in so far over my head here that I canāt see the light anymore, but for what itās worth, Iāve been able to read the z-order of components on the screen using code like
root = event.source.parent
z1 = root.getComponentZOrder(event.source.parent.getComponent('Button'))
z2 = root.getComponentZOrder(event.source.parent.getComponent('Text Field'))
print "Button z-order = %d" % (z1)
print "Text Field z-order = %d" % (z2)
I then superimposed the 2 objects and tried to swap their z-order using the following code:
root.setComponentZOrder(event.source.parent.getComponent('Button'),z2)
root.setComponentZOrder(event.source.parent.getComponent('Text Field'),z1)
However, the controls only refreshed when I moved the mouse over them.
Thatās as far as Iāve got!
Al
Hey, thanks Al. Iāll be able to get that working somehow. Thatās just what I was looking for.
You probably just need to call .repaint() on the container after changing its childrenās Z-order.
Carl,
Addingroot.repaint()
at the end of the previous code did the trick