Closed MikeTheWatchGuy closed 3 years ago
Looks very nice! If I wanted less bevel on the borders, could I change it without css?
You can control the "depth" of the Elements by using the BorderDepth option when creating the form. I don't have an option to control it only on the buttons; so I can't do it just to the buttons.
For narrower looking bevels,use something like this:
with g.FlexForm('Everything bagel', AutoSizeText=True, DefaultElementSize=(40,1), BorderDepth=3) as form:
It produces a form that looks like this:
Very bagel. Can't wait to try it next week. Thanks!
This is by FAR the easiest way to share images on the net! Wow, super-easy drag and drop.
Same form with system default and 3 different look and feels.
import PySimpleGUI as sg
form = sg.FlexForm('Simple data entry form') # begin with a blank form
layout = [
[sg.Text('Please enter your Name, Address, Phone')],
[sg.Text('Name', size=(15, 1)), sg.InputText()],
[sg.Text('Address', size=(15, 1)), sg.InputText()],
[sg.Text('Phone', size=(15, 1)), sg.InputText()],
[sg.Submit(), sg.Cancel()]
]
button, (name, address, phone) = form.LayoutAndRead(layout)
import easygui_qt as eq
import PySimpleGUI as sg
import easygui as eg
def codebox(msg, title, text):
return sg.FlexForm(title).LayoutAndRead([[sg.Multiline(size=(60,4), default_text=msg)],[ sg.Multiline(size=(60,14), default_text=text)], [sg.OK(), sg.Cancel()]])
eg.codebox('msg', 'title', 'test')
codebox('msg', 'title', 'test')
# SourceDestFolders()
eq.show_message('message', 'title')
import PySimpleGUI as g
layout = [[g.Text('YouTube Download Link', auto_size_text=True)],
[g.InputText()],
[g.OK(), g.Cancel()]]
button, (youtube_link, ) = g.FlexForm('Enter YouTube Link').LayoutAndRead(layout)
# insert code here to determine what options to include based on data from the link
resolution_1080p, resolution_720p, resolution_360 = None, True, False
if youtube_link is not None:
form = g.FlexForm('Download Example', auto_size_text=True)
layout = [[g.Text('YouTube Download Link', auto_size_text=True)],
[g.Text('Your link is:')],
[g.Text(youtube_link)],
[g.Text('')],
[g.Text('Video dimensions')],
[g.Checkbox('1080p', default=resolution_1080p),
g.Checkbox('720p', default=resolution_720p),
g.Checkbox('360', default=resolution_360)],
[g.OK(), g.Cancel()]]
button, (values) = form.LayoutAndRead(layout)
g.MsgBox(button, values)
import PySimpleGUI as g
form = g.FlexForm('Registration form', auto_size_text=True)
layout = [
[g.Text('Registration Form', size=(20,1), font=('Helvitica', 20))],
[g.Text('Full name', size=(15,1)), g.InputText()],
[g.Text('Email', size=(15,1)), g.InputText()],
[g.Text('Gender', size=(15,1)), g.Radio('Male', group_id=1), g.Radio('Female', group_id=1)],
[g.Text('Country', size=(15,1)), g.Combo(values=('select your country', 'USA', 'Other'))],
[g.Text('Programming', size=(15,1)), g.Checkbox('Java'), g.Checkbox('Python')],
[g.Submit(button_color=('white', 'red'))]
]
form.LayoutAndRead(layout)
import PySimpleGUI as g
output1 = g.Text('')
layout = [
[g.Text('What is your guess?')],
[g.InputText()],
[g.ReadFormButton('Submit')]
]
form = g.FlexForm('Number game')
form.Layout(layout)
number = 100
while True:
button, (value,) = form.Read()
guess = int(value)
if guess == number:
form.CloseNonBlockingForm()
g.MsgBox('You Guessed Correctly!', 'Right')
break
if guess > number:
output1.Update('Too high')
elif guess < number:
output1.Update('Too low')
import PySimpleGUI as sg
import os
def Launcher():
form = sg.FlexForm('Script launcher')
layout = [
[sg.Text('Script output....', size=(40, 1))],
[sg.Output(size=(88, 20))],
[sg.ReadFormButton('script1'), sg.ReadFormButton('script2'), sg.SimpleButton('EXIT')]
]
form.Layout(layout)
# ---===--- Loop taking in user input and using it to query HowDoI --- #
while True:
(button, value) = form.Read()
if button == 'EXIT' or button is None:
break # exit button clicked
if button == 'script1':
ExecuteCommandOS('python SimScript.py')
elif button == 'script2':
ExecuteCommandOS('python SimScript.py')
elif button == 'Enter':
ExecuteCommandOS(value[0]) # send string without carriage return on end
def ExecuteCommandOS(command):
output = os.popen(command).read()
print(output)
if __name__ == '__main__':
Launcher()
import time
import PySimpleGUI as sg
def CubeTimer():
# Show a form that's a running counter
form = sg.FlexForm('Running Timer', auto_size_text=True)
text_element = sg.Text('', size=(10, 2), font=('Helvetica', 20), justification='center')
form_rows = [[sg.Text('Rubix Cube Timer')],
[text_element],
[sg.T(' ' * 15), sg.ReadFormButton('Start/Stop', focus=True), sg.Quit()]]
form.LayoutAndRead(form_rows, non_blocking=True)
# logic for reading the form buttons, starting/stopping timer
timer_running = True
i = 0
while True:
if timer_running:
i += 1
text_element.Update('{:02d}:{:02d}.{:02d}'.format((i//100)//60, (i//100)%60, i%100))
button, values = form.ReadNonBlocking()
if values is None or button == 'Quit': # if user closed the window using X or clicked Quit button
break
elif button == 'Start/Stop':
timer_running = not timer_running
time.sleep(.01)
# if the loop finished then need to close the form for the user
form.CloseNonBlockingForm()
del(form)
CubeTimer()
These forms are in the "cookbook" document
Learned this trick for hosting screen shots within GitHub
https://app.leanboard.io/board/3efa539b-3c23-4ddb-98a6-b2cd4558565c