I just want to put an Image on a screen given the X and Y.
Use a GtkFixed container to absolute position inside a GtkWindow
If you want to absolute position the toplevel window itself use gtk_window_move().
Related
What would be the approach with Vue.Draggable/SortableJS in order to achieve the functionality as shown in this animated gif?
The default behavior of Sortable for nesting is to drag the element up to the above element until the mouse reaches emptyInsertThreshold pixels from the drop zone of the above element but I would like to be able to nest elements by dragging them to the right. Same for un-nesting.
I have set emptyInsertThreshold to 0 to disable the default behavior and now when I drag the element to the right I get the following events fired: clone and start (in that order).
But how do I:
Can get notified when the mouse has traveled the pre-defined distance to the right?
Inform Vue.Draggable that the ghost element should be nested as a child to the element under which I am doing the horizontal movement?
You can get the mouse position given in the start event under event.originalEvent and in the onMove event using the originalEvent argument (2nd argument). I would track the % that the mouse is past the end of the list item above the dragged item, using: (clientX - aboveItemStart) / aboveItemWidth. Then when it reaches 10% or so, change the DOM directly using event.dragged. Not sure how you would modify it to work with Vue.Draggable... you might need to edit the Vue.Draggable source.
Using Cytoscape.js, how can I constrain movement of a node to a single (i.e. either the x or y) axis? I'd like to be able to make it so a node can only be dragged vertically or horizontally, but not both. In other words, I'd like to lock a node, but only on a single axis. I'm not sure if this is possible, and wasn't able to find anything in the documentation that mentioned this specifically, so I figured I'd ask.
Thanks in advance!
Use the automove extension, which lets you set whatever restrictions on node positioning that you like. Constraining the x value is as easy as passing a (x, y) => { return { xConst, y }; } function to the extension.
I ended up coming up with a way to approximate the result that I wanted by listening for each node's free event, and setting its position to what I needed it to be. This doesn't restrict dragging of nodes to a single axis, but it does restrict dropping of nodes to a single axis, if that makes sense.
Here is the Cytoscape.js description of the free event:
free : when an element is freed (i.e. let go from being grabbed)
from: http://js.cytoscape.org/#events/collection-events
I am looking for a way to retrieve the cursor position to later set the position back with CGDisplayMoveCursorToPoint. I can't find any function like CGDisplayGetCursorPosition in Quartz Display References.
Does anybody know how to retrieve the (absolute) position of the cursor in Mac OS X?
Use one of the answers at Cocoa: Getting the current mouse position on the screen to get the mouse position in global coordinates.
To call CGDisplayMoveCursorToPoint, get the display containing that position using CGGetDisplaysWithPoint, and then use the rect returned by CGDisplayBounds to convert the global point to a screen-local point.
Or just use CGWarpMouseCursorPosition instead of CGDisplayMoveCursorToPoint, since CGWarpMouseCursorPosition just takes a global point and no display.
I'm using the Selenium method mouseMoveAt(java.lang.String locator,java.lang.String coordString), which requires a coordString.
For example : coordString - x,y position (10,20). If I use 10 for x and 20 for y coordinate, what does it mean?
mouseMoveAt(E,(x,y))
This means you simulate the mouse moving to a specific (x,y) location relative to the top-left corner of element E, independent of where the element lies on screen.
Look at the org.openqa.selenium.Point class and getLocation() method of the WebElement class.
Point getLocation()
Where on the page is the top left-hand corner of the rendered element?
Returns:
A point, containing the location of the top left-hand corner of the element
Most of my GUI programming was done in Java, where you could use a .pack() method that would set the preferred size the window should have. I'm learning PyGTK now and wondering if such a thing exists in it.
You don't need a pack method. if you don't set a size, the window will adjust to its minimum size.
You can use window.set_size_request(-1,-1) to unset any previous size.
Unfortunately... not that I know of. I use the following trick that uses a variety of GTK and GDK methods to work out the screen size of the current monitor at app startup and resizes the root window to have a certain proportion of fill.
Note that root is a GtkWindow. You could, of course, have two values for SCREEN_FILL for horizontal and vertical fill.
SCREEN_FILL = 0.7
class MainApp(object):
def set_initial_size(self):
screen = self.root.get_screen()
monitor = screen.get_monitor_at_window(self.root.get_window())
geom = screen.get_monitor_geometry(monitor)
self.root.set_resize_mode(gtk.RESIZE_QUEUE)
self.root.resize(
int(geom.width * SCREEN_FILL),
int(geom.height * SCREEN_FILL))