Does anyone know how make this (saving a scrollview stitched together as a series of images about the height of the screen) a reality?
There is the save_to_png method for every widget, but this only saves the currently visible portion of the screen. I'm not sure how to scroll down automatically by the height of the screen, and of course it would be better if there was a simple method for saving all of a widget to image, even if not currently rendered on the screen.
Any pointers on how to go about this?
Related
When using a BoxLayout in kivy and adding some button widgets using BoxLayout.add_widget() my buttons strech accordingly to the size of the boxes and the numebr of buttons. If my BoxLayout has an horizzontal orientation, the more buttons I add, the more they get shorter along the horizontal axis.
Since my buttons have an image, I would like the buttons to lengthen or shorten the more I add or remove widgets but keep a certain shape, perhaps square. So if the length is reduced, the width will do the same
If I'm not mistaken, using images instead they keep their shape without having to modify parameters (putting only the path to the image). The problem is that I don't know how to activate a certain function by clicking on the images.
Looking at the official documentation I can't find a solution to my problem. Thank you very much for your help.
I am working on tiny program to capture screen print, I want to do it in a similar fashion that Win Snipping Tool is working. First I need to overlay all screens with a 50% opacity layer and then, using the mouse, draw a rectangle and read vertices coordinates. Honestly, I have no idea how to bite this. I tried with win32api / gui and it is great to get mouse coordinates, but still was unable to draw a rectangle. My idea (one of many) is to (using PIL / ImageGrab) take shots of both displays, put an overlay and print them as a full screen on all windows, but I failed while doing this. Other idea is to take img grab and create two new windows using BeeWare / Toga (that is GUI framework I am using) in full screen, but I was unable to find any method to open window on second display. Any ideas and hints will be greatly appreciated, I am really counting on you, as I feel I reached dead end.
Well,It is very easy to use tkinter.
Ok,It is the principle when I make my screenshot application:
User presses the button to start.
Make a new window whose width and height should full cover all the screens,and hide the title bar(If it is had to achieve,maybe use width=9999 and height=9999).
Take a screenshot of all the desktop(You can use ImageGrab.grab((),all_screens=True)) to do that.
Make the screenshot showed in a Canvas(I know that toga have this widget).
Start your mouse listener thread and save the position of pressed.
When user moves his mouse,create a rectangle(toga's Canvas have a function rect()).Maybe use this rect(pressed_x,pressed_y,move_x,move_y).And delete the last rectangle(Then it will always show only one rectangle).
When user released his mouse,save the position of released.And use ImageGrab.grab((pressed_x,pressed_y,released_x,released_y),all_screens=True) to crop the selected area.
If you want to show it in application interface.toga has a widget called ImageView.You can put the image in it.
How can I get the size of the actual display, without using event.dict['size']?
Suppose I have a game with two screens, 'Menu' and 'Game', both of them resizable.
To make all images scale, I use in the beginning in the main file:
window = pygame.display.set_mode(reso,pygame.RESIZABLE)
window_fake = window.copy()
and inside the loops of the two screens I blit all images on the fake window and blit that to scale on the display window:
window.blit(pygame.transform.scale(window_fake, reso_act),(0,0))
pygame.display.flip()
for event in pygame.event.get():
if event.type==pygame.VIDEORESIZE:
reso_act = event.dict['size']
Now all images scale along when resizing the display. However, when I go from 'Menu' to 'Game' after resizing it, I need the size of the actual display to use as my variable reso_act, because I again blit everything onto my fake window and scale that to the display window, however there is no VIDEORESIZEevent.
So now if I make the display smaller in 'Menu', then click start and draw 'Game', it will have the original resolution and half of the images are outside of the display.
I have tried the following, but they all give me the value of reso, the original unresized resolution:
window.get_size()
window_fake.get_size()
pygame.display.get_surface().get_size()
window.get_rect()
window_fake.get_rect()
Is there a way to get the real size of the display?
Or otherwise a smarter way to achieve what I want to do?
I now solved it by returning reso_act every time from all the functions for the different screens and also passing it as input for all those functions, so it remembers the setting.
It is not so elegant, but it works.
If someone knows how to get the actual size of the display I would still be interested to know though.
I was wondering if it is possible to save a canvas that had several textures painted on it as an image file.
I know I can save regular Image's (kivy.core.image) or Texture's (kivy.graphics.texture) as an image file with the save() function, so if I am able to convert the canvas to an Image or a Texture it should be easy, but so far I wasn't able to do this.
Widgets have an export_to_png method. Call this from the Widget whose canvas you have drawn on.
The problem is that your MyPainter widget has its default size of (100,100) and its default position (0,0). So it is actually behind your Save Button. So all your drawing is actually outside the MyPainter widget, and saving the widget to an image is blank.
The fix is to change the pos and size of MyPainter, and perhaps use collide_point() in your on_touch_down() and on_touch_move() methods to ensure that you are actually drawing on the MyPainter widget.
I have been making a small program with the Tkinter module in python, and I was wondering whether it was possible or not to resize a frame in my program with the mouse. As in, the user can drag the frame border and it will resize itself.
Your use of terminology makes the question unclear. Windows which may be resized by the user are called Toplevel windows. These are what appear as rectangular windows on the display, with a frame around them, typically a title bar, and edges or corners that can be grabbed and resized.
The term Frame refers to a container widget that must be inside a Toplevel or one of its descendents. A Frame has the ability to be resized but you have to write the code to let you interactively resize them. For example, you could place a little grip widget in one or more corners, and writing bindings to the press, motion and release of a mouse button.
Depending on the effect you are looking for, you might want a PanedWindow which is a container that includes a sash that lets you adjust the proportion of space between two other widgets.