Python Forum

Full Version: [PySimpleGUI] Tutorial - Name, Address, Phone GUI
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4
MODERATORS - Please review this post meant for the GUI section.

Here's a very basic form using the package PySimpleGUI

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)

print(name, address, phone)
[Image: 43615477-c8b3f4e2-9685-11e8-83a9-88ecb44965b4.jpg]

To get PySimpleGUI:
pip install PySimpleGUI
I'm going to have to take a look at this package.
Maybe I can get to it today. I'll post my opinion afterwards.
It looks like an input forms module like easygui, easygui_qt, guidata or psidialogs. I often use pythondialog in a linux terminal, which works easily over ssh...
(Aug-03-2018, 10:58 AM)Gribouillis Wrote: [ -> ]It looks like an input forms module like easygui, easygui_qt, guidata or psidialogs. I often use pythondialog in a linux terminal, which works easily over ssh...

Thank you so much for the extended list of similar packages. I went through as many as I could find prior to writing PySimpleGUI. I found nothing close to what I needed for my projects, so I wrote a new package. I honestly have not found anything that uses the language to create a natural feeling GUI framework, without all of the need to understand what a GUI is and how it works.

I'm highly interested in feedback.... I want to push this design as far as I take it into the world of Python to see if I can get it to catch on.

I'm searching for a middle ground between super-easy for beginners and flexible enough for professionals to use for their needs too..... for example, IT professionals looking for a front-end to their daily tools.

I appreciate your time looking this over!
I would like my post of the tutorial to appear in the "tutorials" forum under "GUI" if possible.
WOW... I just realized all that code can be compacted down to a SINGLE LINE of Python code! Not that I would, just saying it's possible. Not sure how many other Python GUIs can do this in 1 line of code. The design is even more Python-like than I thought.

button, (name, address, phone) = sg.FlexForm('Simple data entry form').\
                                 LayoutAndRead([[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()]])
Can you add a "focus" option for some elements? just like some widgets the tkinter has.
Added to list of enhancements.

Thank you for the feedback!
(Aug-04-2018, 12:18 AM)PySimpleGUI Wrote: [ -> ]Not sure how many other Python GUIs can do this in 1 line of code. The design is even more Python-like than I thought.
Python's goal is not to make it into one line. It is more readable in your first example.

The zen of python states:
Quote:Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.

(Aug-03-2018, 04:48 PM)PySimpleGUI Wrote: [ -> ]to push this design as far as I take it into the world of Python to see if I can get it to catch on.
Time will tell. Are you going to be here 5 years from now, or even 10 years from now maintaining the same package? We only put common GUI frameworks in tutorials. A lot of people will make GUI frameworks and then abandon them within a year.
Quote:Time will tell. Are you going to be here 5 years from now, or even 10 years from now maintaining the same package? We only put common GUI frameworks in tutorials. A lot of people will make GUI frameworks and then abandon them within a year.

You're absolutely right.

I looked through packages that are both active and abandoned before writing this. I wrote it with the immediate idea of trying to get it adopted down the road. I have every intention of sticking with this project. I've been at this for 4 decades. The implementation isn't the best at the moment, but it's solid. I was still learning Python at that time.

I appreciate you taking the time to bring up stuff like this. Comments only make it a better package in the end, right?

Just finished posting the documentation here:
http://pysimplegui.readthedocs.io

This provides an hotlinked outline of the same content as the readme file.
Pages: 1 2 3 4