From 1bdc0eadd70e1e83bdb8ff194630fdb0331310f1 Mon Sep 17 00:00:00 2001 From: Eugenio Parodi Date: Wed, 7 Apr 2021 12:09:10 +0100 Subject: [PATCH] Moved first tutorial to rst --- Makefile | 3 +- tutorial/001-helloworld.rst | 76 +++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 tutorial/001-helloworld.rst diff --git a/Makefile b/Makefile index 2b79991f..4ac79aea 100644 --- a/Makefile +++ b/Makefile @@ -42,8 +42,7 @@ buildTest: .venv deployDoc: git checkout gh-pages - find index.html TTk* libbpytop -name "*.html" | rm -rf - # cp -a docs/html/TermTk/* . + rm -rf *.inv *.html *.js _* autogen.* cp -a docs/build/html/* . find *.html *.inv *.js autogen.TermTk _* | xargs git add git commit -m "Doc Updated" diff --git a/tutorial/001-helloworld.rst b/tutorial/001-helloworld.rst new file mode 100644 index 00000000..e413f1ee --- /dev/null +++ b/tutorial/001-helloworld.rst @@ -0,0 +1,76 @@ +.. _pyTermTk: https://github.com/ceccopierangiolieugenio/pyTermTk +.. _TTk: https://ceccopierangiolieugenio.github.io/pyTermTk/TTkCore/ttk.html +.. _TTkLabel: https://ceccopierangiolieugenio.github.io/pyTermTk/TTkWidgets/label.html +.. _mainloop(): https://ceccopierangiolieugenio.github.io/pyTermTk/TTkCore/ttk.html#TermTk.TTkCore.ttk.TTk.mainloop + +============================================================================= +pyTermTk_ - Hello World +============================================================================= + +Intro +===== + +Creating a simple GUI application using pyTermTk_ involves the following steps: + +* Import TermTk package. +* Create an TTk_ object. +* Add a TTkLabel_ object in it with the caption "**hello world**" in the position (x=5,y=2). +* Enter the mainloop of application by `mainloop()`_ method. +* pippo :class:`~TermTk.TTkCore.constant.TTkConstant.Alignment` + +Example 1 +========= + +Following is the code to execute [Hello World program](helloworld/helloworld.001.py) in [pyTermTk](https://github.com/ceccopierangiolieugenio/pyTermTk) − + +.. code:: python + + 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 +:: + + Hello World + + +Example 2 - Your first Window +============================= + +Following is the code to execute [Hello World program](helloworld/helloworld.002.py) in [pyTermTk](https://github.com/ceccopierangiolieugenio/pyTermTk) − + +.. code:: python + + import TermTk as ttk + + # Create a root object (it is a widget that represent the terminal) + root = ttk.TTk() + + # Create a window and attach it to the root (parent=root) + helloWin = ttk.TTkWindow(parent=root,pos = (1,1), size=(30,10), title="Hello Window", border=True) + + # Define the Label and attach it to the window (parent=helloWin) + ttk.TTkLabel(parent=helloWin, pos=(5,5), text="Hello World") + + # Start the Main loop + root.mainloop() + + +The above code produces the following output (yuhuuuuu!!!) +:: + + ╔════════════════════════════╗ + ║ Hello Window ║ + ╟────────────────────────────╢ + ║ ║ + ║ ║ + ║ Hello World ║ + ║ ║ + ║ ║ + ║ ║ + ╚════════════════════════════╝ +