![]() SetSizer( sizer) 39 40 #- 41 42 def OnTakeScreenShot( self, event): 43 """ 44 Takes a screenshot of the screen at give pos & size (rect). OnTakeScreenShot) 33 34 #- 35 36 sizer = wx. ID_ANY, " Take Screenshot ") 32 screenshotBtn. icons/wxwin.ico ')) 26 27 #- 28 29 # Add a panel so it looks the correct on all platforms 30 panel = wx. MainLoop()ġ # sample_one_c.py 2 3 """ 4 5 Author : Mike Driscoll 6 Link : 7 8 """ 9 10 import sys 11 import wx 12 13 #- 14 15 class MyForm( wx. App() 144 frame = MyFrame( None, title= " wxPython screenshot ") 145 frame. ![]() SaveFile( ' screenshot_for_working.png ', wx. Blit( 0, 0, width, height, screen, 0, 0) 121 del mem 122 bmp. MemoryDC( bmp) 118 # Tell mem to use the actual bitmap. 113 print( width, height) 114 115 # Use Bitmap here instead of wx.Bitmap. DisplaySize()) 108 109 width = size 110 height = size 111 112 # Compare with above values. GetSize() 105 106 # Debugging : see if pixel values are okay. panel) 96 97 98 def OnScreenshot( self, event): 99 """ 100 Thank to Andrea Gavana. ALL, 10) 90 91 # Finally, tell the panel to use the sizer for layout. 87 # wx.BoxSizer(sizer, proportion, flag, border). VERTICAL) 85 86 # wx.BoxSizer(window, proportion, flag, border). 81 """ 82 83 # MainSizer is the top-level one that manages everything. 70 """ 71 72 # Bind events to an events handler. panel, - 1, 64 " &Close ") 65 66 67 def BindEvents( self): 68 """ 69 Bind some events to an event handler. panel, - 1, 61 " Take a screenshot ") 62 63 self. _init_( self, * args, ** kwargs) 20 21 #- 22 23 # Simplified init method. Now, click the button "Take ScreenShot" and it will capture the screen of size 700px wide and 300 px height, starting from the coordinates (x=500, y=500).1 # sample_one_b.py 2 3 """ 4 5 Author : Thank to Andrea Gavana. When we run the code, it will display a window with a button to take a screenshot. Im1 = pyautogui.screenshot(region=(x, y, 700, 300))īutton(win, text='Take ScreenShot', command=take_screenshot).pack(padx=10, pady=10) # Take the screenshot in the given corrds ![]() # Define a function to take the screenshot # Create an instance of tknter frame or window Pack the widget and display the output image. In the given function, define the coords and region through which we want to take the screenshot.Ĭreate a Toplevel window and define a label image in it. To achieve this, we can follow the steps given below −Ĭreate a universal button to take the screenshot.ĭefine a function to take the screenshot. Let us suppose that we want to create an application that will take a screenshot of the window and display the captured image in another window. To display an image, we use the PIL or Pillow library. Tkinter is a standard Python library that is used to create and develop GUI-based applications.
0 Comments
Leave a Reply. |