61 lines
1.6 KiB
Plaintext
61 lines
1.6 KiB
Plaintext
import copy
|
|
|
|
DEFAULT_BUTTON = {
|
|
"position": "absolute",
|
|
"top": "19px",
|
|
"left": "15px",
|
|
"bottom": "auto",
|
|
"right": "auto",
|
|
"zIndex": "auto",
|
|
"width": "auto",
|
|
"height": "auto",
|
|
"viewPath": "Templates/Buttons/NavButtonBanner",
|
|
"viewParams": {
|
|
#"label": "System",
|
|
"showIcons": True,
|
|
#"tagPath": "[default]SystemStatus",
|
|
#"view": "Windows/Graphics/Overview"
|
|
},
|
|
"style": {
|
|
"classes": ""
|
|
}
|
|
}
|
|
|
|
def genButtonsFromDataset(areas):
|
|
buttons = []
|
|
|
|
for i in range(areas.getRowCount()):
|
|
# Get values from row:
|
|
label = areas.getValueAt(i, "Label")
|
|
tagPath = areas.getValueAt(i, "TagPath")
|
|
view = areas.getValueAt(i, "View")
|
|
# Clone and customize button:
|
|
button = copy.deepcopy(DEFAULT_BUTTON)
|
|
button["left"] = str(15+140*i)+"px"
|
|
if label <> "":
|
|
button["viewParams"]["label"] = label
|
|
if tagPath <> "":
|
|
button["viewParams"]["tagPath"] = tagPath
|
|
else:
|
|
button["viewParams"]["showIcons"] = False
|
|
if view <> "":
|
|
button["viewParams"]["view"] = view
|
|
# Add button to list:
|
|
buttons.append(button)
|
|
|
|
return buttons
|
|
|
|
def genButtonsFromViews(areas=None):
|
|
if areas == None:
|
|
projectName = system.project.getProjectName()
|
|
path = os.path.join(os.getcwd(), "data", "projects", projectName, "com.inductiveautomation.perspective", "views", "Windows", "Graphics")
|
|
areas = [name for name in os.listdir(".") if os.path.isdir(name) and name.lower() not in ["overview", "templates"]]
|
|
|
|
buttons = []
|
|
|
|
for i, area in enumerate(areas):
|
|
button = copy.deepcopy(DEFAULT_BUTTON)
|
|
button["left"] = str(15+145*i)+"px"
|
|
button["viewParams"]["tagPath"] = area
|
|
|
|
return buttons |