diff --git a/TermTk/TTkCore/log.py b/TermTk/TTkCore/log.py index f3ec36c2..0db6bcb1 100644 --- a/TermTk/TTkCore/log.py +++ b/TermTk/TTkCore/log.py @@ -61,7 +61,7 @@ class TTkLog: log(f"{context.file}:{context.line} {message}") @staticmethod - def use_default_file_logging(): + def use_default_file_logging(file="session.log"): logging.basicConfig(level=logging.DEBUG, filename='session.log', format='%(levelname)s:(%(threadName)-9s) %(message)s',) diff --git a/tutorial/001-helloworld.md b/tutorial/001-helloworld.md index 24269104..3f979142 100644 --- a/tutorial/001-helloworld.md +++ b/tutorial/001-helloworld.md @@ -11,7 +11,6 @@ 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() @@ -32,7 +31,6 @@ The above code produces the following output Following is the code to execute [Hello World program](helloworld/helloworld.002.py) in [pyTermTk](https://github.com/ceccopierangiolieugenio/pyTermTk) − ```python -import sys, os import TermTk as ttk # Create a root object (it is a widget that represent the terminal) diff --git a/tutorial/002-layout.md b/tutorial/002-layout.md index 3640cec9..41ce0b83 100644 --- a/tutorial/002-layout.md +++ b/tutorial/002-layout.md @@ -69,11 +69,42 @@ TTkGridLayout ┌┐ columnMinWidth -## Example 1 - Simple [TTkVBoxLayout](https://ceccopierangiolieugenio.github.io/pyTermTk/TTkLayouts/boxlayout.html#TermTk.TTkLayouts.boxlayout.TTkVBoxLayout) -Following is the code to execute [VBox Example](layout/example1.simple.vbox.py) in [pyTermTk](https://github.com/ceccopierangiolieugenio/pyTermTk) +## Example 1 - Simple [TTkLayout](https://ceccopierangiolieugenio.github.io/pyTermTk/TTkLayouts/layout.html#TermTk.TTkLayouts.layout.TTkLayout) +Following is the code to execute [VBox Example](layout/example1.simple.layout.py) in [pyTermTk](https://github.com/ceccopierangiolieugenio/pyTermTk) + +```python +import TermTk as ttk + + # TTkLayout is used by default +root = ttk.TTk() + + # Attach 4 buttons to the root widget +ttk.TTkButton(parent=root, pos=(0,0), size=(15,5), border=True, text="Button1") +ttk.TTkButton(parent=root, pos=(0,5), size=(10,4), border=True, text="Button2") +ttk.TTkButton(parent=root, pos=(10,6), size=(10,3), border=True, text="Button3") +ttk.TTkButton(parent=root, pos=(13,1), size=(15,3), border=True, text="Button4") + +root.mainloop() +``` + +The above code produces the following output +```text +┌─────────────┐ +│ ┌─────────────┐ +│ Button1 │ Button4 │ +│ ╘═════════════╛ +╘═════════════╛ +┌────────┐ +│Button2 │┌────────┐ +│ ││Button3 │ +╘════════╛╘════════╛ + +``` + +## Example 2 - Simple [TTkVBoxLayout](https://ceccopierangiolieugenio.github.io/pyTermTk/TTkLayouts/boxlayout.html#TermTk.TTkLayouts.boxlayout.TTkVBoxLayout) +Following is the code to execute [VBox Example](layout/example2.simple.vbox.py) in [pyTermTk](https://github.com/ceccopierangiolieugenio/pyTermTk) ```python -import sys, os import TermTk as ttk # Set the VBoxLayout as defaut in the terminal widget @@ -112,11 +143,10 @@ The above code produces the following output ╘═══════════════════════════════════════════════════════════╛ ``` -## Example 2 - Simple [TTkHBoxLayout](https://ceccopierangiolieugenio.github.io/pyTermTk/TTkLayouts/boxlayout.html#TermTk.TTkLayouts.boxlayout.TTkHBoxLayout) -Following is the code to execute [HBox Example](layout/example2.simple.hbox.py) in [pyTermTk](https://github.com/ceccopierangiolieugenio/pyTermTk) +## Example 3 - Simple [TTkHBoxLayout](https://ceccopierangiolieugenio.github.io/pyTermTk/TTkLayouts/boxlayout.html#TermTk.TTkLayouts.boxlayout.TTkHBoxLayout) +Following is the code to execute [HBox Example](layout/example3.simple.hbox.py) in [pyTermTk](https://github.com/ceccopierangiolieugenio/pyTermTk) ```python -import sys, os import TermTk as ttk # Set the HBoxLayout as defaut in the terminal widget @@ -156,11 +186,10 @@ The above code produces the following output ``` -## Example 3 - Simple [TTkGridLayout](https://ceccopierangiolieugenio.github.io/pyTermTk/TTkLayouts/boxlayout.html#TermTk.TTkLayouts.gridlayout.TTkGridLayout) -Following is the code to execute [HBox Example](layout/example3.simple.grid.py) in [pyTermTk](https://github.com/ceccopierangiolieugenio/pyTermTk) +## Example 4 - Simple [TTkGridLayout](https://ceccopierangiolieugenio.github.io/pyTermTk/TTkLayouts/gridlayout.html#TermTk.TTkLayouts.gridlayout.TTkGridLayout) +Following is the code to execute [HBox Example](layout/example4.simple.grid.py) in [pyTermTk](https://github.com/ceccopierangiolieugenio/pyTermTk) ```python -import sys, os import TermTk as ttk # Set the GridLayout as defaut in the terminal widget @@ -204,11 +233,10 @@ root.mainloop() ╘═════════════════╛ ``` -## Example 4 - Nested Layouts -Following is the code to execute [Nested Layouts Example](layout/example4.nested.layouts.py) in [pyTermTk](https://github.com/ceccopierangiolieugenio/pyTermTk) +## Example 5 - Nested Layouts +Following is the code to execute [Nested Layouts Example](layout/example5.nested.layouts.py) in [pyTermTk](https://github.com/ceccopierangiolieugenio/pyTermTk) ```python -import sys, os import TermTk as ttk # Set the GridLayout as defaut in the terminal widget diff --git a/tutorial/004-logging.md b/tutorial/004-logging.md new file mode 100644 index 00000000..c401417e --- /dev/null +++ b/tutorial/004-logging.md @@ -0,0 +1,111 @@ +# [pyTermTk](https://github.com/ceccopierangiolieugenio/pyTermTk) - Logging + +## Intro +The [TTkLog](https://ceccopierangiolieugenio.github.io/pyTermTk/TTkCore/log.html) class provide a set of api to allow and configure the logging. + + +## Example 1 - Log to file +From [example1.logtofile.py](logging/example1.logtofile.py) + +```python +import TermTk as ttk + + # session.log is used by default +ttk.TTkLog.use_default_file_logging() + +ttk.TTkLog.info( "Test Info Messgae") +ttk.TTkLog.debug( "Test Debug Messgae") +ttk.TTkLog.error( "Test Error Messgae") +ttk.TTkLog.warn( "Test Warning Messgae") +ttk.TTkLog.critical("Test Critical Messgae") +ttk.TTkLog.fatal( "Test Fatal Messgae") +``` + +## Example 2 - Log to stdout +From [example2.logtostdout.py ](logging/example2.logtostdout.py ) +```python +import TermTk as ttk + +ttk.TTkLog.use_default_stdout_logging() + +ttk.TTkLog.info( "Test Info Messgae") +ttk.TTkLog.debug( "Test Debug Messgae") +ttk.TTkLog.error( "Test Error Messgae") +ttk.TTkLog.warn( "Test Warning Messgae") +ttk.TTkLog.critical("Test Critical Messgae") +ttk.TTkLog.fatal( "Test Fatal Messgae") +``` + +## Example 3 - custom logging +From [example3.customlogging.py ](logging/example3.customlogging.py ) +```python +import TermTk as ttk + + # define the callback used to process the log message +def message_handler(mode, context, message): + msgType = "NONE" + if mode == ttk.TTkLog.InfoMsg: msgType = "[INFO]" + elif mode == ttk.TTkLog.WarningMsg: msgType = "[WARNING]" + elif mode == ttk.TTkLog.CriticalMsg: msgType = "[CRITICAL]" + elif mode == ttk.TTkLog.FatalMsg: msgType = "[FATAL]" + elif mode == ttk.TTkLog.ErrorMsg: msgType = "[ERROR]" + print(f"{msgType} {context.file} {message}") + + # Register the callback to the message handler +ttk.TTkLog.installMessageHandler(message_handler) + +ttk.TTkLog.info( "Test Info Messgae") +ttk.TTkLog.debug( "Test Debug Messgae") +ttk.TTkLog.error( "Test Error Messgae") +ttk.TTkLog.warn( "Test Warning Messgae") +ttk.TTkLog.critical("Test Critical Messgae") +ttk.TTkLog.fatal( "Test Fatal Messgae") +``` + +## Example 4 - Use [TTkLogViewer](https://ceccopierangiolieugenio.github.io/pyTermTk/TTkTestWidgets/logviewer.html) widget +From [example4.ttklogviewer.py](logging/example4.ttklogviewer.py) +```python +import TermTk as ttk + +root = ttk.TTk() + + # Create a window and attach it to the root (parent=root) +logWin = ttk.TTkWindow(parent=root,pos = (1,1), size=(80,20), title="LogViewer Window", border=True, layout=ttk.TTkVBoxLayout()) + + # Define the Label and attach it to the window (parent=helloWin) +ttk.TTkLogViewer(parent=logWin) + +ttk.TTkLog.info( "Test Info Messgae") +ttk.TTkLog.debug( "Test Debug Messgae") +ttk.TTkLog.error( "Test Error Messgae") +ttk.TTkLog.warn( "Test Warning Messgae") +ttk.TTkLog.critical("Test Critical Messgae") +ttk.TTkLog.fatal( "Test Fatal Messgae") + + # Start the Main loop +root.mainloop() +``` +The above code produces the following output + +```text +╔══════════════════════════════════════════════════════════════════════════════╗ +║ LogViewer Window ║ +╟──────────────────────────────────────────────────────────────────────────────╢ +║ ║ +║INFO : tutorial/logging/example4.ttklogviewer.py:36 Test Info Messgae ║ +║DEBUG: tutorial/logging/example4.ttklogviewer.py:37 Test Debug Messgae ║ +║ERROR: tutorial/logging/example4.ttklogviewer.py:38 Test Error Messgae ║ +║WARNING : tutorial/logging/example4.ttklogviewer.py:39 Test Warning Messgae ║ +║CRITICAL: tutorial/logging/example4.ttklogviewer.py:40 Test Critical Messgae ║ +║FATAL: tutorial/logging/example4.ttklogviewer.py:41 Test Fatal Messgae ║ +║DEBUG: _/.venv/lib/python3.8/site-packages/TermTk/TTkCore/ttk.py:70 Starting M║ +║DEBUG: _/.venv/lib/python3.8/site-packages/TermTk/TTkCore/ttk.py:80 Signal Eve║ +║DEBUG: _/.venv/lib/python3.8/site-packages/TermTk/TTkCore/ttk.py:65 fps: 33 ║ +║DEBUG: _/.venv/lib/python3.8/site-packages/TermTk/TTkCore/ttk.py:65 fps: 34 ║ +║DEBUG: _/.venv/lib/python3.8/site-packages/TermTk/TTkCore/ttk.py:65 fps: 34 ║ +║ ║ +║ ║ +║ ║ +║◀▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓┄┄┄┄┄┄┄┄┄┄┄▶║ +╚══════════════════════════════════════════════════════════════════════════════╝ +``` \ No newline at end of file diff --git a/tutorial/helloworld/helloworld.001.py b/tutorial/helloworld/helloworld.001.py index 7b67386a..035f01e3 100755 --- a/tutorial/helloworld/helloworld.001.py +++ b/tutorial/helloworld/helloworld.001.py @@ -22,7 +22,6 @@ # 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() diff --git a/tutorial/helloworld/helloworld.002.py b/tutorial/helloworld/helloworld.002.py index 440b2380..8c2c8a33 100755 --- a/tutorial/helloworld/helloworld.002.py +++ b/tutorial/helloworld/helloworld.002.py @@ -22,7 +22,6 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -import sys, os import TermTk as ttk # Create a root object (it is a widget that represent the terminal) diff --git a/tutorial/layout/example1.simple.layout.py b/tutorial/layout/example1.simple.layout.py new file mode 100755 index 00000000..8e91164c --- /dev/null +++ b/tutorial/layout/example1.simple.layout.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 + +# MIT License +# +# Copyright (c) 2021 Eugenio Parodi +# +# 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 TermTk as ttk + + # TTkLayout is used by default +root = ttk.TTk() + + # Attach 4 buttons to the root widget +ttk.TTkButton(parent=root, pos=(0,0), size=(15,5), border=True, text="Button1") +ttk.TTkButton(parent=root, pos=(0,5), size=(10,4), border=True, text="Button2") +ttk.TTkButton(parent=root, pos=(10,6), size=(10,3), border=True, text="Button3") +ttk.TTkButton(parent=root, pos=(13,1), size=(15,3), border=True, text="Button4") + +root.mainloop() \ No newline at end of file diff --git a/tutorial/layout/example1.simple.vbox.py b/tutorial/layout/example2.simple.vbox.py similarity index 99% rename from tutorial/layout/example1.simple.vbox.py rename to tutorial/layout/example2.simple.vbox.py index 59c20343..c7e00b95 100755 --- a/tutorial/layout/example1.simple.vbox.py +++ b/tutorial/layout/example2.simple.vbox.py @@ -22,7 +22,6 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -import sys, os import TermTk as ttk # Set the VBoxLayout as defaut in the terminal widget diff --git a/tutorial/layout/example2.simple.hbox.py b/tutorial/layout/example3.simple.hbox.py similarity index 99% rename from tutorial/layout/example2.simple.hbox.py rename to tutorial/layout/example3.simple.hbox.py index b33ac19a..705d2d0a 100755 --- a/tutorial/layout/example2.simple.hbox.py +++ b/tutorial/layout/example3.simple.hbox.py @@ -22,7 +22,6 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -import sys, os import TermTk as ttk # Set the HBoxLayout as defaut in the terminal widget diff --git a/tutorial/layout/example3.simple.grid.py b/tutorial/layout/example4.simple.grid.py similarity index 96% rename from tutorial/layout/example3.simple.grid.py rename to tutorial/layout/example4.simple.grid.py index 11965913..58a67863 100755 --- a/tutorial/layout/example3.simple.grid.py +++ b/tutorial/layout/example4.simple.grid.py @@ -22,7 +22,6 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -import sys, os import TermTk as ttk # Set the GridLayout as defaut in the terminal widget @@ -30,7 +29,7 @@ gridLayout = ttk.TTkGridLayout(columnMinHeight=0,columnMinWidth=2) root = ttk.TTk(layout=gridLayout) # Attach 2 buttons to the root widget using the default method - # this wil append them to the first row + # this will append them to the first row ttk.TTkButton(parent=root, border=True, text="Button1") ttk.TTkButton(parent=root, border=True, text="Button2") # Attach 2 buttons to a specific position in the grid diff --git a/tutorial/layout/example4.nested.layouts.py b/tutorial/layout/example5.nested.layouts.py similarity index 99% rename from tutorial/layout/example4.nested.layouts.py rename to tutorial/layout/example5.nested.layouts.py index 0cdff20a..a7f5d555 100755 --- a/tutorial/layout/example4.nested.layouts.py +++ b/tutorial/layout/example5.nested.layouts.py @@ -22,7 +22,6 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -import sys, os import TermTk as ttk # Set the GridLayout as defaut in the terminal widget diff --git a/tutorial/logging/example1.logtofile.py b/tutorial/logging/example1.logtofile.py new file mode 100755 index 00000000..ace9e9df --- /dev/null +++ b/tutorial/logging/example1.logtofile.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 + +# MIT License +# +# Copyright (c) 2021 Eugenio Parodi +# +# 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 TermTk as ttk + + # session.log is used by default +ttk.TTkLog.use_default_file_logging() + +ttk.TTkLog.info( "Test Info Messgae") +ttk.TTkLog.debug( "Test Debug Messgae") +ttk.TTkLog.error( "Test Error Messgae") +ttk.TTkLog.warn( "Test Warning Messgae") +ttk.TTkLog.critical("Test Critical Messgae") +ttk.TTkLog.fatal( "Test Fatal Messgae") + diff --git a/tutorial/logging/example2.logtostdout.py b/tutorial/logging/example2.logtostdout.py new file mode 100755 index 00000000..c9da164d --- /dev/null +++ b/tutorial/logging/example2.logtostdout.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 + +# MIT License +# +# Copyright (c) 2021 Eugenio Parodi +# +# 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 TermTk as ttk + +ttk.TTkLog.use_default_stdout_logging() + +ttk.TTkLog.info( "Test Info Messgae") +ttk.TTkLog.debug( "Test Debug Messgae") +ttk.TTkLog.error( "Test Error Messgae") +ttk.TTkLog.warn( "Test Warning Messgae") +ttk.TTkLog.critical("Test Critical Messgae") +ttk.TTkLog.fatal( "Test Fatal Messgae") diff --git a/tutorial/logging/example3.customlogging.py b/tutorial/logging/example3.customlogging.py new file mode 100755 index 00000000..4d434e3d --- /dev/null +++ b/tutorial/logging/example3.customlogging.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python3 + +# MIT License +# +# Copyright (c) 2021 Eugenio Parodi +# +# 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 TermTk as ttk + + # define the callback used to process the log message +def message_handler(mode, context, message): + msgType = "NONE" + if mode == ttk.TTkLog.InfoMsg: msgType = "[INFO]" + elif mode == ttk.TTkLog.WarningMsg: msgType = "[WARNING]" + elif mode == ttk.TTkLog.CriticalMsg: msgType = "[CRITICAL]" + elif mode == ttk.TTkLog.FatalMsg: msgType = "[FATAL]" + elif mode == ttk.TTkLog.ErrorMsg: msgType = "[ERROR]" + print(f"{msgType} {context.file} {message}") + + # Register the callback to the message handler +ttk.TTkLog.installMessageHandler(message_handler) + +ttk.TTkLog.info( "Test Info Messgae") +ttk.TTkLog.debug( "Test Debug Messgae") +ttk.TTkLog.error( "Test Error Messgae") +ttk.TTkLog.warn( "Test Warning Messgae") +ttk.TTkLog.critical("Test Critical Messgae") +ttk.TTkLog.fatal( "Test Fatal Messgae") diff --git a/tutorial/logging/example4.ttklogviewer.py b/tutorial/logging/example4.ttklogviewer.py new file mode 100755 index 00000000..80713fdb --- /dev/null +++ b/tutorial/logging/example4.ttklogviewer.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python3 + +# MIT License +# +# Copyright (c) 2021 Eugenio Parodi +# +# 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 TermTk as ttk + +root = ttk.TTk() + + # Create a window and attach it to the root (parent=root) +logWin = ttk.TTkWindow(parent=root,pos = (1,1), size=(80,20), title="LogViewer Window", border=True, layout=ttk.TTkVBoxLayout()) + + # Define the Label and attach it to the window (parent=helloWin) +ttk.TTkLogViewer(parent=logWin) + +ttk.TTkLog.info( "Test Info Messgae") +ttk.TTkLog.debug( "Test Debug Messgae") +ttk.TTkLog.error( "Test Error Messgae") +ttk.TTkLog.warn( "Test Warning Messgae") +ttk.TTkLog.critical("Test Critical Messgae") +ttk.TTkLog.fatal( "Test Fatal Messgae") + + # Start the Main loop +root.mainloop() \ No newline at end of file