#!/usr/bin/env pythonimport PySimpleGUI as sg# Demonstrates a number of PySimpleGUI features including:# Default element size# auto_size_buttons# Button# Dictionary return values# update of elements in form (Text, Input)layout = [[sg.Text('Enter Your Passcode')],[sg.Input('', size=(10, 1), key='input')],[sg.Button('1'), sg.Button('2'), sg.Button('3')],[sg.Button('4'), sg.Button('5'), sg.Button('6')],[sg.Button('7'), sg.Button('8'), sg.Button('9')],[sg.Button('Submit'), sg.Button('0'), sg.Button('Clear')],[sg.Text('', size=(15, 1), font=('Helvetica', 18),text_color='red', key='out')],]window = sg.Window('Keypad', layout,default_button_element_size=(5, 2),auto_size_buttons=False,grab_anywhere=False)# Loop forever reading the form's values, updating the Input fieldkeys_entered = ''while True:event, values = window.read() # read the formif event is None: # if the X button clicked, just exitbreakif event == 'Clear': # clear keys if clear buttonkeys_entered = ''elif event in '1234567890':keys_entered = values['input'] # get what's been entered so farkeys_entered += event # add the new digitelif event == 'Submit':keys_entered = values['input']window['out'].update(keys_entered) # output the final string# change the form to reflect current key stringwindow['input'].update(keys_entered)window.close()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。