A quick and simple GUI in Python
Python is an easy-to-learn but powerful language, and comes with a wealth of libraries. It is often used to create simple scripts. You run these on the command line, giving it any parameters it needs.
Remembering the parameters can be tricky. A single library and a few lines of code turn the manual parameter entry into a graphical user interface. The app shown above took just 10 lines of code.
import random
import gooey
@gooey.Gooey(default_size=(300, 300), show_success_modal=False)
def main():
parser = gooey.GooeyParser(description='Role some dice')
parser.add_argument('number_of_rolls', type=int,
metavar='How many rolls?', choices=range(1, 10))
args = parser.parse_args()
for i in range(args.number_of_rolls):
print(f'Roll {i + 1}: {random.randint(1, 6)}')
main()
For more information, including a line by line explanation of the code below, see the accompanying blog post