diff --git a/src/puppy/__init__.py b/src/puppy/__init__.py index 180a47c..e32328a 100644 --- a/src/puppy/__init__.py +++ b/src/puppy/__init__.py @@ -2,7 +2,7 @@ Puppy - A minimal GUI app to test pup. """ -__version__ = '1.0.0' +__version__ = '1.1.0' __title__ = 'puppy' __description__ = 'Puppy, a minimal GUI app to test pup' diff --git a/src/puppy/__main__.py b/src/puppy/__main__.py index bc30699..ab36b72 100644 --- a/src/puppy/__main__.py +++ b/src/puppy/__main__.py @@ -2,6 +2,9 @@ Puppy's entry point and single module. """ +import os +import pprint +import sys import tkinter import importlib_metadata as ilr @@ -15,8 +18,8 @@ def _create_window(): screen_w = window.winfo_screenwidth() screen_h = window.winfo_screenheight() - w = screen_w // 6 - h = screen_h // 6 + w = screen_w // 3 + h = screen_h // 3 x = (screen_w - w) // 2 y = (screen_h - h) // 2 window.geometry(f'{w}x{h}+{x}+{y}') @@ -32,28 +35,70 @@ def _create_window(): def _add_widgets(window): - label = tkinter.Label( + tkinter.Label( window, text='Minimal GUI app to test pup.', - padx=32, - pady=32, + ).pack( + side='top', + fill='x', + padx=16, + pady=16, ) - label.pack() - button = tkinter.Button( + log_widget = tkinter.Text( + window, + highlightthickness=1, + highlightcolor='lightgray', + state=tkinter.DISABLED, + wrap='none', + height=1, + padx=8, + pady=8, + ) + log_widget.focus_set() + log_widget.pack(side='top', fill='both', expand=True, padx=16) + + tkinter.Button( window, text='Quit', - padx=32, pady=8, command=window.destroy, + ).pack( + side='bottom', + fill='both', + padx=16, + pady=16, ) - button.pack() + + return log_widget + + +def _log_lines(window, log_widget, lines): + + log_widget.configure(state=tkinter.NORMAL) + for line in lines: + log_widget.insert('end', f'{line}\n') + log_widget.yview('end') + log_widget.configure(state=tkinter.DISABLED) + + window.update() def main(): window = _create_window() - _add_widgets(window) + log_widget = _add_widgets(window) + + log_lines = lambda l: _log_lines(window, log_widget, l) + + log_lines([ + 'os.getcwd():', + f' {os.getcwd()!r}', + '', + 'sys.path:', + *map(lambda s: f' {s!r}', sys.path), + ]) + tkinter.mainloop()