Browse Source

Add Tutorial: HelloWorld

pull/5/head
Eugenio Parodi 5 years ago
parent
commit
131b524d57
  1. 8
      Makefile
  2. 28
      tutorial/001-helloworld.md
  3. 16
      tutorial/README.md
  4. 30
      tutorial/helloworld/helloworld.001.py

8
Makefile

@ -26,6 +26,14 @@ build: .venv
rm -rf dist
python3 -m build
deployDoc:
git checkout gh-pages
cp -a docs/html/TermTk/*
find index.html TTk* libbpytop -name "*.html" | xargs git add
git commit -m "Doc Updated"
git push origin gh-pages
git checkout main
testDeploy: .venv
. .venv/bin/activate
python3 -m twine upload --repository testpypi dist/* --verbose

28
tutorial/001-helloworld.md

@ -0,0 +1,28 @@
# [pyTermTk](https://github.com/ceccopierangiolieugenio/pyTermTk) - Hello World
## Intro
- Creating a simple GUI application using [pyTermTk](https://github.com/ceccopierangiolieugenio/pyTermTk) involves the following steps −
- Import TermTk package.
- Create an [TTk](https://ceccopierangiolieugenio.github.io/pyTermTk/TTkCore/ttk.html) object.
- Add a [TTkLabel](https://ceccopierangiolieugenio.github.io/pyTermTk/TTkWidgets/label.html) object in it with the caption "**hello world**" in the position (x=5,y=2).
- Enter the mainloop of application by [mainloop()](https://ceccopierangiolieugenio.github.io/pyTermTk/TTkCore/ttk.html#TermTk.TTkCore.ttk.TTk.mainloop) method.
Following is the code to execute [Hello World program](helloworld/helloworld.001.py) in [pyTermTk](https://github.com/ceccopierangiolieugenio/pyTermTk) −
```python
import sys, os
import TermTk as ttk
root = ttk.TTk()
ttk.TTkLabel(parent=root, pos=(5,2), text="Hello World")
root.mainloop()
```
The above code produces the following output (yuhuuuuu!!!)−
```text
Hello World
```

16
tutorial/README.md

@ -0,0 +1,16 @@
# [pyTermTk](https://github.com/ceccopierangiolieugenio/pyTermTk) Tutorial
## Intro
[pyTermTk](https://github.com/ceccopierangiolieugenio/pyTermTk) is a [TUI](https://en.wikipedia.org/wiki/Text-based_user_interface) widgets toolkit.The latest version of [pyTermTk](https://github.com/ceccopierangiolieugenio/pyTermTk) can be downloaded from [PypI](https://pypi.org/project/pyTermTk/) or [github](https://github.com/ceccopierangiolieugenio/pyTermTk)
[pyTermTk](https://github.com/ceccopierangiolieugenio/pyTermTk) API is a set of modules containing a large number of classes and functions.
A list of frequently used modules is given below:
- [TTkCore](https://ceccopierangiolieugenio.github.io/pyTermTk/TTkCore) − Core classes used by other modules
- [TTkGui](https://ceccopierangiolieugenio.github.io/pyTermTk/TTkGui) − Themes collection
- [TTkWidgets](https://ceccopierangiolieugenio.github.io/pyTermTk/TTkWidgets) − Classes for creating classic desktop-style UIs
- [TTkTestWidgets](https://ceccopierangiolieugenio.github.io/pyTermTk/TTkTestWidgets) − Classes with basic testing widgets
### [Hello World](001-helloworld.md)

30
tutorial/helloworld/helloworld.001.py

@ -0,0 +1,30 @@
#!/usr/bin/env python3
# MIT License
#
# Copyright (c) 2021 Eugenio Parodi <ceccopierangiolieugenio AT googlemail DOT com>
#
# 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.
import sys, os
import TermTk as ttk
root = ttk.TTk()
ttk.TTkLabel(parent=root, pos=(5,2), text="Hello World")
root.mainloop()
Loading…
Cancel
Save