


# Python at GlobalSino:
# https://www.globalsino.com/ICs/page4853.html
# pop-up input windows at the center of the screen


from tkinter import *
import tkinter as tk
import tkinter.messagebox
  
MainWindow = tkinter.Tk()
  
MainWindow.title("Window at center")
window_width = 300
window_height = 200

# get the screen dimension
screen_width = MainWindow.winfo_screenwidth()
screen_height = MainWindow.winfo_screenheight()

# find the center point
center_x = int(screen_width/2 - window_width / 2)
center_y = int(screen_height/2 - window_height / 2)

# set the position of the window to the center of the screen
MainWindow.geometry(f'{window_width}x{window_height}+{center_x}+{center_y}')

def MyScreenShot():
        img = pyautogui.screenshot("C:\GlobalSino\images\TestScreenshot.png",
                               region = (200,300,400,400))    
   
button1=tk.Button(MainWindow, text="Take Screenshot", command=MyScreenShot)
button1.place(x=10, y=10)

MainWindow.mainloop()

