1 >>> import pyautogui
2 >>> screenWidth, screenHeight = pyautogui.size() # Returns two integers, the width and height of the screen. (The primary monitor, in multi-monitor setups.)
3 >>> currentMouseX, currentMouseY = pyautogui.position() # Returns two integers, the x and y of the mouse cursor's current position.
4 >>> pyautogui.moveTo(100, 150) # Move the mouse to the x, y coordinates 100, 150.
5 >>> pyautogui.click() # Click the mouse at its current location.
6 >>> pyautogui.click(200, 220) # Click the mouse at the x, y coordinates 200, 220.
7 >>> pyautogui.move(None, 10) # Move mouse 10 pixels down, that is, move the mouse relative to its current position.
8 >>> pyautogui.doubleClick() # Double click the mouse at the
9 >>> pyautogui.moveTo(500, 500, duration=2, tween=pyautogui.easeInOutQuad) # Use tweening/easing function to move mouse over 2 seconds.
10 >>> pyautogui.write('Hello world!', interval=0.25) # Type with quarter-second pause in between each key.
11 >>> pyautogui.press('esc') # Simulate pressing the Escape key.
12 >>> pyautogui.keyDown('shift')
13 >>> pyautogui.write(['left', 'left', 'left', 'left', 'left', 'left'])
14 >>> pyautogui.keyUp('shift')
15 >>> pyautogui.hotkey('ctrl', 'c')
16
1import PySimpleGUI as sg
2
3sg.theme('DarkAmber') # Add a touch of color
4# All the stuff inside your window.
5layout = [ [sg.Text('Some text on Row 1')],
6 [sg.Text('Enter something on Row 2'), sg.InputText()],
7 [sg.Button('Ok'), sg.Button('Cancel')] ]
8
9# Create the Window
10window = sg.Window('Window Title', layout)
11# Event Loop to process "events" and get the "values" of the inputs
12while True:
13 event, values = window.read()
14 if event == sg.WIN_CLOSED or event == 'Cancel': # if user closes window or clicks cancel
15 break
16 print('You entered ', values[0])
17
18window.close()
19
1import PySimpleGUI as sg
2
3# Define the window's contents
4layout = [[sg.Text("What's your name?")],
5 [sg.Input(key='-INPUT-')],
6 [sg.Text(size=(40,1), key='-OUTPUT-')],
7 [sg.Button('Ok'), sg.Button('Quit')]]
8
9# Create the window
10window = sg.Window('Window Title', layout)
11
12# Display and interact with the Window using an Event Loop
13while True:
14 event, values = window.read()
15 # See if user wants to quit or window was closed
16 if event == sg.WINDOW_CLOSED or event == 'Quit':
17 break
18 # Output a message to the window
19 window['-OUTPUT-'].update('Hello ' + values['-INPUT-'] + "! Thanks for trying PySimpleGUI")
20
21# Finish up by removing from the screen
22window.close()
23
1Button(button_text = "",
2 button_type = 7,
3 target = (None, None),
4 tooltip = None,
5 file_types = (('ALL Files', '*.*'),),
6 initial_folder = None,
7 default_extension = "",
8 disabled = False,
9 change_submits = False,
10 enable_events = False,
11 image_filename = None,
12 image_data = None,
13 image_size = (None, None),
14 image_subsample = None,
15 border_width = None,
16 size = (None, None),
17 s = (None, None),
18 auto_size_button = None,
19 button_color = None,
20 disabled_button_color = None,
21 highlight_colors = None,
22 mouseover_colors = (None, None),
23 use_ttk_buttons = None,
24 font = None,
25 bind_return_key = False,
26 focus = False,
27 pad = None,
28 p = None,
29 key = None,
30 k = None,
31 right_click_menu = None,
32 expand_x = False,
33 expand_y = False,
34 visible = True,
35 metadata = None)