|
|
|
|
@ -1,41 +1,81 @@
|
|
|
|
|
#!/usr/bin/env python3 |
|
|
|
|
|
|
|
|
|
# MIT License |
|
|
|
|
# |
|
|
|
|
# Copyright (c) 2025 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 asyncio |
|
|
|
|
import inspect |
|
|
|
|
import sys, os |
|
|
|
|
import time |
|
|
|
|
|
|
|
|
|
sys.path.append(os.path.join(sys.path[0],'..')) |
|
|
|
|
sys.path.append(os.path.join(sys.path[0],'../..')) |
|
|
|
|
import TermTk as ttk |
|
|
|
|
|
|
|
|
|
root = ttk.TTk(layout=ttk.TTkVBoxLayout()) |
|
|
|
|
res = ttk.TTkLabel(parent=root) |
|
|
|
|
num = ttk.TTkLabel(parent=root, text=1) |
|
|
|
|
button_add = ttk.TTkButton(parent=root, text="+") |
|
|
|
|
root = ttk.TTk(layout=(rgl:=ttk.TTkGridLayout())) |
|
|
|
|
|
|
|
|
|
rgl.addWidget(button_add := ttk.TTkButton(maxSize=(8,3), border=True, text="+") , 0, 0) |
|
|
|
|
rgl.addWidget(button_call := ttk.TTkButton(maxSize=(8,3), border=True, text="Call") , 1, 0) |
|
|
|
|
rgl.addWidget(button_call2 := ttk.TTkButton(maxSize=(8,3), border=True, text="Call2", checkable=True) , 2, 0) |
|
|
|
|
button_add.clicked.connect(lambda: num.setText(int(num.text()) + 1)) |
|
|
|
|
button_call = ttk.TTkButton(parent=root, text="Call") |
|
|
|
|
ttk.TTkButton(parent=root, text="Quit").clicked.connect(ttk.TTkHelper.quit) |
|
|
|
|
|
|
|
|
|
rgl.addWidget(res := ttk.TTkLabel(test='out...'), 0 , 1) |
|
|
|
|
rgl.addWidget(num := ttk.TTkLabel(text='1') , 1 , 1) |
|
|
|
|
|
|
|
|
|
rgl.addWidget(qb := ttk.TTkButton(border=True, maxWidth=8, text="Quit"), 0,2,3,1) |
|
|
|
|
qb.clicked.connect(ttk.TTkHelper.quit) |
|
|
|
|
|
|
|
|
|
rgl.addWidget(ttk.TTkLogViewer(), 3, 0, 1, 3) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ttk.pyTTkSlot() |
|
|
|
|
def call0(): |
|
|
|
|
res.setText("0 Calling...") |
|
|
|
|
ttk.TTkLog.info("0 Calling...") |
|
|
|
|
time.sleep(1) |
|
|
|
|
res.setText("0 Calling... - DONE") |
|
|
|
|
ttk.TTkLog.info("0 Calling... - DONE") |
|
|
|
|
|
|
|
|
|
async def call1(): |
|
|
|
|
res.setText("1 Calling...") |
|
|
|
|
ttk.TTkLog.info("1 Calling...") |
|
|
|
|
await asyncio.sleep(3) |
|
|
|
|
res.setText("1 Calling... - DONE") |
|
|
|
|
ttk.TTkLog.info("1 Calling... - DONE") |
|
|
|
|
|
|
|
|
|
@ttk.pyTTkSlot() |
|
|
|
|
async def call2(): |
|
|
|
|
res.setText("2 Calling...") |
|
|
|
|
await asyncio.sleep(5) |
|
|
|
|
ttk.TTkLog.info("2 Calling...") |
|
|
|
|
await asyncio.sleep(4) |
|
|
|
|
res.setText("2 Calling... - DONE") |
|
|
|
|
ttk.TTkLog.info("2 Calling... - DONE") |
|
|
|
|
|
|
|
|
|
@ttk.pyTTkSlot(int) |
|
|
|
|
@ttk.pyTTkSlot(bool) |
|
|
|
|
async def call3(val): |
|
|
|
|
res.setText(f"3 Calling... {val}") |
|
|
|
|
ttk.TTkLog.info(f"3 Calling... {val}") |
|
|
|
|
await asyncio.sleep(5) |
|
|
|
|
res.setText(f"3 Calling... {val} - DONE") |
|
|
|
|
ttk.TTkLog.info(f"3 Calling... {val} - DONE") |
|
|
|
|
|
|
|
|
|
print(inspect.iscoroutinefunction(call0)) |
|
|
|
|
print(inspect.iscoroutinefunction(call1)) |
|
|
|
|
@ -46,4 +86,9 @@ button_call.clicked.connect(call0)
|
|
|
|
|
button_call.clicked.connect(call1) |
|
|
|
|
button_call.clicked.connect(call2) |
|
|
|
|
|
|
|
|
|
# button_call2.toggled.connect(call0) |
|
|
|
|
button_call2.toggled.connect(call1) |
|
|
|
|
button_call2.toggled.connect(call2) |
|
|
|
|
button_call2.toggled.connect(call3) |
|
|
|
|
|
|
|
|
|
root.mainloop() |