How to find current window size in pysimplegui - windows

I want ask about code I can use to get my current pysimplegui window height and width.
I want use this code to adjust the text size of elements inside my window with increasing the window size.

Refer Call reference - PySimpleGUI
You can get the window size in pixel, (width, height), by window.size.
size
property: size
Return the current size of the window in pixels
Type
Name
Meaning
Tuple[(int), (int)] or Tuple[None, None]
return
(width, height) of the window

Related

How is the size of a surface determined in Vulkan?

I'm following the Vulkan Tutorial and the section Window Surface says that on Windows a VkSurfaceKHR object is created using the following code:
VkWin32SurfaceCreateInfoKHR createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
createInfo.hwnd = glfwGetWin32Window(window);
createInfo.hinstance = GetModuleHandle(nullptr);
if (vkCreateWin32SurfaceKHR(instance, &createInfo, nullptr, &surface) != VK_SUCCESS) {
throw std::runtime_error("failed to create window surface!");
}
But we never specify the extents of the surface in the createInfo object.
However calling the vkGetPhysicalDeviceSurfaceCapabilitiesKHR function returns a VkSurfaceCapabilitiesKHR object which has a currentExtent field which according to the documentation is
the current width and height of the surface, or the special value (0xFFFFFFFF, 0xFFFFFFFF) indicating that the surface size will be determined by the extent of a swapchain targeting the surface.
So in the special case that currentExtent equals (0xFFFFFFFF, 0xFFFFFFFF) we know that the size of the surface is determined by the swapchain targeting the surface, but in all other cases it seems that the surface already has a size originating from somewhere else and we are expected to match the extents of the swapchain to that size.
So where does the size of the surface come from when it's not being determined by the swapchain?
On Windows, the initial extents of the surface are equal to the width and height values you set when creating the window (minus window borders, menus, etc.).
The extents value returned by vkGetPhysicalDeviceSurfaceCapabilitiesKHR also updates automatically when the window is resized by the user (on Windows).
It is also important to note that on different platforms, max, min, and current extents behave differently. On Windows, the output surface must always be equal to the paintable window size, so they will all be equal.

GWT - Getting the current size of an image

I use the GWT image class with a ClickHandler to trigger actions when specific areas of the image are clicked. In order to specify these areas, I use the image's dimensions. The problem occurs when you change the size of your browser window. While the image rescales nicely, the getWidth() and getHeight() methods still return the image's original size, not the size after rescaling.
Do you know a way to retrieve the current size of the image?
.getElement().getOffsetWidgth() ? and .getOffsetHeight().
I think thats what you need.
That will return the current size of the element in the Dom, including any decorations like borders in the CSS.

How to retrieve actual window dimensions of a pop-up in IE8 ONLY? (NOT VIEWPORT)

I have a script that positions the popup at the bottom right corner of the users screen every time. However, IE8 could care less about the fact that there is more to the window than the viewport. How do I get the size of that in IE8?
var popUpWidth = window.outerWidth; // does not work in IE8!
var popUpHeight = window.outerHeight; // does not work in IE8!
IE8 doesn't have the outerWidth / outerHeight property, try instead:
document.documentElement.clientHeight;
document.documentElement.clientWidth;
Here's an example http://james.padolsey.com/javascript/get-document-height-cross-browser/
Set the window to a given size. Obtain the size of the client window. This will be smaller by the amount of window chrome. Use the difference to calculate the window size for any client size.
The initial size is completely arbitrary but the current client size plus an optional fudge factor will cause the least change on screen.

Screenshot of form whose dimensions are greater than screen dimensions

I have a TForm object whose height is greater than the required vertical resolution of my screen.
For some reason, Windows doesn't allow the visible (client?) area of the form to exceed the screen resolution, so vertical scrollbars appear on my form.
How would I get a TBitmap image or screenshot of the entire form (no scrollbars, all form components visible) so that all content of the form is visible?
At first you have to make sure the form has no scrollbars. For that you can write an event handler for FormConstrainedResize and adjust MaxWidth and MaxHeight to your needs. If the form size is restricted during design, set the required Width and Height in the FormCreate event to the desired values.
Now you can use GetFormImage to get the screenshot.

Zooming an image inside a picture box

I'm have a picture box control and 2 Command Buttons. I have an image displayed inside the picture box.
Is it possible to zoom the image when the Zoom-in and Zoom out buttons are clicked?
Or I can even put a scroll bar. Is it possible to zoom the image according to the scroll bar movements?
I'm using VB 6.
I assume here that you are using BMP or JPG files here.
The simple scratch method is to place an Image control in the PictureBox, initially with the property Stretch = False. Initially, it would be in the top left hand corner. After setting the Picture property to your picture object, the Image control will be resized to fit the image. Save the original width and height of the control in variables. Now set Stretch = True. You can zoom in by resizing the image using
img.Move 0, 0, sngWidth * sngMagFactor, sngHeight * sngMagFactor
Where sngMaxFactor = 4! or however much you want to zoom by.
Restore back to original size by:
img.Move 0, 0, sngWidth, sngHeight
You can also pan the zoomed image by altering the Left and Top arguments in the Move() method.
It might be easiest to use two pic boxes, one inside the other. The 'outer' box can be thought of as a viewport into the 'inner' box, which you resize and position as needed. The effect will be the same but the coding is much simpler.

Resources