Skip to content

Commit

Permalink
New version: now shows CWD + sys.path.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmontes committed Sep 24, 2020
1 parent a2ffa05 commit 2314f48
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/puppy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
65 changes: 55 additions & 10 deletions src/puppy/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
Puppy's entry point and single module.
"""

import os
import pprint
import sys
import tkinter

import importlib_metadata as ilr
Expand All @@ -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}')
Expand All @@ -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()


Expand Down

0 comments on commit 2314f48

Please sign in to comment.