Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single Window Design #2

Closed
PFython opened this issue Dec 9, 2020 · 0 comments · Fixed by #32
Closed

Single Window Design #2

PFython opened this issue Dec 9, 2020 · 0 comments · Fixed by #32
Assignees
Labels
enhancement New feature or request

Comments

@PFython
Copy link
Owner

PFython commented Dec 9, 2020

I haven’t really used easypypi, but had a glimpse at it. It all looks impressive.

I was surprised to see that you had organized the UI as a linear number of lists. That has the disadvantage that you have to go through ALL questions and that you can’t go back and don’t have an overview.
Would it be much nicer to have a window with all the prompts, where you can just what you want.

In order to demonstrate what I mean, I have made a mockup:
image
image
763×397 15.9 KB

Please observe that the checkbox options are kind of special. The fields are actually Text elements that trigger another window with the checkboxes:
image
image
765×399 14.6 KB
Here’s the -not very elegant- code of the mockup:

import PySimpleGUI as sg

def prompt_with_checkboxes(group, choices, selected_choices):
"""
Creates a scrollable checkbox popup using PySimpleGui
Returns a set of selected choices, or and empty set
"""
prompt = [sg.Text(text=f"Please select any relevant classifiers in the {group.title()} group:")]
layout = [[sg.Checkbox(text=choice, key=choice, default=choice in selected_choices)] for choice in choices]
event, values = sg.Window(
"", [prompt, [sg.Column(layout)], [sg.Button("Accept"), sg.Button("Cancel")]], resizable=True, no_titlebar=True
).read(close=True)

if event == "Accept":
    selected_choices.clear()
    selected_choices.extend(k for k in choices if values[k])
    return True
if event is None or event == "Cancel":
    return False

sg.theme("DarkAmber")
prompts = {
"name": "Name for this package (all lowercase, underscores if needed)",
"version": "Latest version number",
"github_id": "Your Github or main repository ID",
"url": "Link to the package repository",
"description": "Description with escape characters for \ " ' etc.",
"author": "Full name of the author",
"email": "E-mail address for the author",
"keywords": "Some keywords separated by a comma",
"requirements": "Any packages/modules that absolutely need to be installed",
}
answer = {}
answer["name"] = "salabim"
answer["version"] = "20.0.6"
answer["github_id"] = "www.ggithub.com/salabim/salabim"
answer["url"] = "www.salabim.org"
answer["description"] = "Discrete event simulation in Python"
answer["author"] = "Ruud van der Ham"
answer["email"] = "info@salabim.org"
answer["keywords"] = "simulation,engineering,logistics"
answer["requirements"] = ""

layout = []
for key, prompt in prompts.items():

layout += [[sg.Text(prompt, size=(50, 0)), sg.Input(answer[key], key=key, size=(40, 0))]]

choices = {}
selected_choices = {}
for group in "Development Status|Intended Audience|Operating System|Programming Language :: |Topic".split("|"):
choices[group] = [option for option in "Option 1|Option 2|Option 3|Option 4|Option 5|Option 6|Option 7|Option 8".split("|")]
selected_choices[group] = []
if group == "Programming Language :: ":
selected_choices[group] = "Option 3|Option 4|Option 5|Option 7|Option 8".split("|")
layout += [
[
sg.Text(group, size=(50, 1)),
sg.Text(
", ".join(selected_choices[group]),
key=("group", group),
enable_events=True,
size=(40, 0),
background_color=sg.theme_input_background_color(),
text_color=sg.theme_text_color(),
),
]
]

window = sg.Window("easypypi", layout)
while True:
event, values = window.read()
if event is None:
break

print(event)
if isinstance(event, tuple):
    group = event[1]
    prompt_with_checkboxes(group, choices=choices[group], selected_choices=selected_choices[group])
    window[event].update(value=", ".join(selected_choices[group]))

What do you think of that?

@PFython PFython added enhancement New feature or request help wanted Extra attention is needed labels Dec 9, 2020
@PFython PFython removed the help wanted Extra attention is needed label Dec 9, 2020
@PFython PFython self-assigned this Dec 9, 2020
@PFython PFython linked a pull request Jan 4, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant