Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8cceb7a

Browse files
Create One_Shot_Window.py
A simple login screen with button interactions. A window layout which consists of a username label, input text box, a password label and a password textbox where the input characters are masked.
1 parent 49aa75c commit 8cceb7a

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

‎One_Shot_Window.py‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import PySimpleGUI as sg
2+
3+
# Define the window layout which consists of a username label,
4+
# input text box, a password label and a password textbox where the
5+
# input characters are masked.
6+
layout = [[sg.Text("Name:")],
7+
[sg.Input(key='-INPUT-')],
8+
[sg.Text('Password:')],
9+
[sg.InputText('', key='Password', password_char='*')],
10+
[sg.Button('OK'), sg.Button('Cancel')]]
11+
12+
# Create the window
13+
window = sg.Window('Login', layout)
14+
15+
# Display and interact with the Window using an Event Loop
16+
while True:
17+
event, values = window.read()
18+
# See if user wants to quit or window was closed
19+
if event == sg.WINDOW_CLOSED or event == 'Cancel':
20+
break
21+
22+
# if the usre clicks OK, display a message with login success.
23+
# No validation is added at this point as this is purely to
24+
# introduce the GUI concepts.
25+
if event == 'OK':
26+
sg.Popup('Login Result', 'SUCCESS!', modal = True)
27+
28+
# Finish up by removing from the screen
29+
window.close()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /