load shapes
This commit is contained in:
parent
8c30ad6af5
commit
c82453b981
1 changed files with 61 additions and 42 deletions
|
@ -7,12 +7,12 @@ import os
|
|||
import time
|
||||
|
||||
from core.api.grpc import client, core_pb2
|
||||
from coretk import appconfig, parsedata
|
||||
from coretk import appconfig
|
||||
from coretk.dialogs.mobilityplayer import MobilityPlayer
|
||||
from coretk.dialogs.sessions import SessionsDialog
|
||||
from coretk.interface import InterfaceManager
|
||||
from coretk.nodeutils import NodeDraw, NodeUtils
|
||||
from coretk.shape import Shape, ShapeData
|
||||
from coretk.shape import ShapeData
|
||||
|
||||
OBSERVERS = {
|
||||
"processes": "ps",
|
||||
|
@ -282,47 +282,48 @@ class CoreClient:
|
|||
return self.state == core_pb2.SessionState.RUNTIME
|
||||
|
||||
def parse_metadata(self, config):
|
||||
for key, value in config.items():
|
||||
if "global_options" != key:
|
||||
canvas_config = parsedata.parse(value)
|
||||
print(canvas_config)
|
||||
if canvas_config.get("type"):
|
||||
config_type = canvas_config["type"]
|
||||
if config_type == "rectangle" or config_type == "oval":
|
||||
data = ShapeData(
|
||||
False,
|
||||
canvas_config["label"],
|
||||
canvas_config["fontfamily"],
|
||||
canvas_config["fontsize"],
|
||||
canvas_config["labelcolor"],
|
||||
canvas_config["color"],
|
||||
canvas_config["border"],
|
||||
canvas_config["width"],
|
||||
)
|
||||
coords = tuple(
|
||||
[float(x) for x in canvas_config["iconcoords"].split()]
|
||||
)
|
||||
shape = Shape(
|
||||
self.app,
|
||||
self.app.canvas,
|
||||
None,
|
||||
None,
|
||||
coords,
|
||||
data,
|
||||
config_type,
|
||||
)
|
||||
self.app.canvas.shapes[shape.id] = shape
|
||||
elif canvas_config["type"] == "text":
|
||||
print("not implemented")
|
||||
else:
|
||||
if "wallpaper" in canvas_config:
|
||||
logging.info("canvas metadata: %s", canvas_config)
|
||||
wallpaper_style = canvas_config["wallpaper-style"]
|
||||
self.app.canvas.scale_option.set(wallpaper_style)
|
||||
wallpaper = canvas_config["wallpaper"]
|
||||
wallpaper = str(appconfig.BACKGROUNDS_PATH.joinpath(wallpaper))
|
||||
self.app.canvas.set_wallpaper(wallpaper)
|
||||
# for key, value in config.items():
|
||||
# if "global_options" != key:
|
||||
# canvas_config = parsedata.parse(value)
|
||||
# print(canvas_config)
|
||||
# if canvas_config.get("type"):
|
||||
# config_type = canvas_config["type"]
|
||||
# if config_type == "rectangle" or config_type == "oval":
|
||||
# data = ShapeData(
|
||||
# False,
|
||||
# canvas_config["label"],
|
||||
# canvas_config["fontfamily"],
|
||||
# canvas_config["fontsize"],
|
||||
# canvas_config["labelcolor"],
|
||||
# canvas_config["color"],
|
||||
# canvas_config["border"],
|
||||
# canvas_config["width"],
|
||||
# )
|
||||
# coords = tuple(
|
||||
# [float(x) for x in canvas_config["iconcoords"].split()]
|
||||
# )
|
||||
# shape = Shape(
|
||||
# self.app,
|
||||
# self.app.canvas,
|
||||
# None,
|
||||
# None,
|
||||
# coords,
|
||||
# data,
|
||||
# config_type,
|
||||
# )
|
||||
# self.app.canvas.shapes[shape.id] = shape
|
||||
# elif canvas_config["type"] == "text":
|
||||
# print("not implemented")
|
||||
# else:
|
||||
# if "wallpaper" in canvas_config:
|
||||
# logging.info("canvas metadata: %s", canvas_config)
|
||||
# wallpaper_style = canvas_config["wallpaper-style"]
|
||||
# self.app.canvas.scale_option.set(wallpaper_style)
|
||||
# wallpaper = canvas_config["wallpaper"]
|
||||
# wallpaper = str(appconfig.BACKGROUNDS_PATH.joinpath(wallpaper))
|
||||
# self.app.canvas.set_wallpaper(wallpaper)
|
||||
# canvas settings
|
||||
print(config)
|
||||
canvas_config = config.get("canvas")
|
||||
if canvas_config:
|
||||
logging.info("canvas metadata: %s", canvas_config)
|
||||
|
@ -332,6 +333,24 @@ class CoreClient:
|
|||
wallpaper = canvas_config["wallpaper"]
|
||||
wallpaper = str(appconfig.BACKGROUNDS_PATH.joinpath(wallpaper))
|
||||
self.app.canvas.set_wallpaper(wallpaper)
|
||||
for key, annotation_config in config.items():
|
||||
if "annotation" in key:
|
||||
annotation_config = json.loads(annotation_config)
|
||||
print(annotation_config)
|
||||
config_type = annotation_config["type"]
|
||||
if config_type in ["rectangle", "oval"]:
|
||||
coords = tuple(annotation_config["iconcoords"])
|
||||
data = ShapeData(
|
||||
False,
|
||||
annotation_config["label"],
|
||||
annotation_config["fontfamily"],
|
||||
annotation_config["fontsize"],
|
||||
annotation_config["labelcolor"],
|
||||
annotation_config["color"],
|
||||
annotation_config["border"],
|
||||
annotation_config["width"],
|
||||
)
|
||||
print(data, coords)
|
||||
|
||||
def create_new_session(self):
|
||||
"""
|
||||
|
|
Loading…
Add table
Reference in a new issue