-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a2ffa05
Showing
5 changed files
with
208 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
], | ||
}, | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |