Skip to content

Commit

Permalink
Single commit minimal GUI app.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmontes committed Sep 23, 2020
0 parents commit a2ffa05
Show file tree
Hide file tree
Showing 5 changed files with 208 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2020 Tiago Montes.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
13 changes: 13 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Puppy
=====

A minimal GUI application,
written in Python with the `tkinter` module,
used to test `pup <https://github.com/mu-editor/pup>`.


About
-----

Created by Tiago Montes.

97 changes: 97 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import io
import os
import re

import setuptools



###############################################################################

NAME = "puppy"
META_PATH = os.path.join("src", "puppy", "__init__.py")
KEYWORDS = ["gui", "applications"]
CLASSIFIERS = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Operating System :: MacOS",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
]
INSTALL_REQUIRES = [
"importlib-metadata==1.7.0;python_version<'3.8'",
]
EXTRAS_REQUIRE = {
"docs": [
],
"tests": [
],
"release": [
],
}
EXTRAS_REQUIRE["dev"] = EXTRAS_REQUIRE["tests"] + EXTRAS_REQUIRE["docs"]



###############################################################################

HERE = os.path.abspath(os.path.dirname(__file__))

def read(*parts):
"""
Build an absolute path from *parts* and and return the contents of the
resulting file. Assume UTF-8 encoding.
"""
with io.open(os.path.join(HERE, *parts), encoding="utf-8") as f:
return f.read()



META_FILE = read(META_PATH)

def find_meta(meta):
"""
Extract __*meta*__ from META_FILE.
"""
meta_match = re.search(
r"^__{meta}__ = ['\"]([^'\"]*)['\"]".format(meta=meta),
META_FILE, re.M
)
if meta_match:
return meta_match.group(1)
raise RuntimeError("Unable to find __{meta}__ string.".format(meta=meta))



if __name__ == "__main__":
setuptools.setup(
name=NAME,
description=find_meta("description"),
license=find_meta("license"),
url=find_meta("uri"),
version=find_meta("version"),
author=find_meta("author"),
author_email=find_meta("email"),
maintainer=find_meta("author"),
maintainer_email=find_meta("email"),
keywords=KEYWORDS,
long_description=read("README.rst"),
long_description_content_type='text/x-rst',
packages=setuptools.find_packages(where="src"),
package_dir={"": "src"},
zip_safe=False,
classifiers=CLASSIFIERS,
install_requires=INSTALL_REQUIRES,
extras_require=EXTRAS_REQUIRE,
entry_points={
'console_scripts': [
'puppy=puppy.__main__:main',
],
},
)

15 changes: 15 additions & 0 deletions src/puppy/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
Puppy - A minimal GUI app to test pup.
"""

__version__ = '1.0.0'

__title__ = 'puppy'
__description__ = 'Puppy, a minimal GUI app to test pup'

__license__ = 'MIT'
__uri__ = 'https://github.com/tmontes/puppy'

__author__ = 'Tiago Montes'
__email__ = 'tiago.montes@gmail.com'

62 changes: 62 additions & 0 deletions src/puppy/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
"""
Puppy's entry point and single module.
"""

import tkinter

import importlib_metadata as ilr



def _create_window():

window = tkinter.Tk()

screen_w = window.winfo_screenwidth()
screen_h = window.winfo_screenheight()

w = screen_w // 6
h = screen_h // 6
x = (screen_w - w) // 2
y = (screen_h - h) // 2
window.geometry(f'{w}x{h}+{x}+{y}')
window.minsize(w, h)

meta = ilr.metadata(__package__)
name = meta['name']
version = meta['version']
window.title(f'{name} {version}')

return window


def _add_widgets(window):

label = tkinter.Label(
window,
text='Minimal GUI app to test pup.',
padx=32,
pady=32,
)
label.pack()

button = tkinter.Button(
window,
text='Quit',
padx=32,
pady=8,
command=window.destroy,
)
button.pack()


def main():

window = _create_window()
_add_widgets(window)
tkinter.mainloop()


if __name__ == '__main__':

main()

0 comments on commit a2ffa05

Please sign in to comment.