Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions adl2pydm/output_handler.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
write the screen in the new XML protocol
Write the screen in the new XML protocol.

Only rely on packages in the standard Python distribution. (rules out lxml)
"""
Expand All @@ -21,6 +21,8 @@
ENV_PYDM_DISPLAYS_PATH = "PYDM_DISPLAYS_PATH"
SCREEN_FILE_EXTENSION = ".ui"
DEFAULT_NUMBER_OF_POINTS = 1200
# TOP_LEVEL_WIDGET = "QWidget"
TOP_LEVEL_WIDGET_CLASS = "PyDMAbsoluteGeometry"

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -67,9 +69,7 @@ def convertDynamicAttribute_to_Rules(attr):
for nm, ref in dict(chan="A", chanB="B", chanC="C", chanD="D").items():
if nm in attr:
pv = convertMacros(attr[nm])
channels[ref] = dict(
channel=f"ca://{pv}", trigger=len(pv) > 0, use_enum=False
)
channels[ref] = dict(channel=f"ca://{pv}", trigger=len(pv) > 0)

calc = attr.get("calc")
if calc is not None and len(calc) > 0:
Expand Down Expand Up @@ -284,16 +284,19 @@ def write_font_size(self, qw, block, **kwargs):
smallest = 4
largest = 10
margin = 3
pointsize = int(max(smallest, min(largest, block.geometry.height - 2 * margin)))
pointsize = int(
max(
smallest,
min(largest, block.geometry.height - 2 * margin)
)
)

propty = self.writer.writeOpenProperty(qw, "font", stdset="0")
font = self.writer.writeOpenTag(propty, "font")
self.writer.writeTaggedString(font, "pointsize", str(pointsize))

def write_ui(self, screen, output_path):
"""main entry point to write the .ui file"""
window_class = "QWidget"
# window_class = "QMainWindow"
title = (
screen.title
or os.path.split(os.path.splitext(screen.given_filename)[0])[-1]
Expand All @@ -308,7 +311,9 @@ def write_ui(self, screen, output_path):
root = self.writer.openFile(ui_filename)
logging.info("writing screen file: %s", ui_filename)
self.writer.writeTaggedString(root, "class", "Dialog")
form = self.writer.writeOpenTag(root, "widget", cls=window_class, name="screen")
form = self.writer.writeOpenTag(
root, "widget", cls=TOP_LEVEL_WIDGET_CLASS, name="screen"
)

self.write_geometry(form, screen.geometry)
self.write_stylesheet(form, screen)
Expand Down Expand Up @@ -1050,6 +1055,8 @@ def write_customwidgets(self, parent):
# example: PyDMDrawingPie extends PyDMDrawingArc
while True: # do..until
additions = []
if TOP_LEVEL_WIDGET_CLASS not in self.custom_widgets:
self.custom_widgets.append(TOP_LEVEL_WIDGET_CLASS)
for widget in self.custom_widgets:
if widget == "PyDMDrawingPie":
logger.debug("breakpoint")
Expand Down
6 changes: 5 additions & 1 deletion adl2pydm/symbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
"byte": dict(type="monitor", pydm_widget="PyDMByteIndicator"),
"cartesian plot": dict(type="monitor", pydm_widget="PyDMWaveformPlot"),
"choice button": dict(type="controller", pydm_widget="PyDMEnumButton"),
"composite": dict(type="static", pydm_widget="PyDMFrame"),
# "composite": dict(type="static", pydm_widget="PyDMFrame"),
"composite": dict(type="static", pydm_widget="PyDMAbsoluteGeometry"),
"embedded display": dict(type="static", pydm_widget="PyDMEmbeddedDisplay"),
"image": dict(type="monitor", pydm_widget="PyDMDrawingImage"),
"indicator": dict(type="monitor", pydm_widget="PyDMScaleIndicator"),
Expand Down Expand Up @@ -94,6 +95,9 @@
"""

pydm_widgets = dict(
PyDMAbsoluteGeometry=PyDM_CustomWidget(
"PyDMAbsoluteGeometry", "QWidget", "pydm.widgets.absolute_geometry"
),
PyDMTabWidget=PyDM_CustomWidget(
"PyDMTabWidget", "QTabWidget", "pydm.widgets.tab_bar"
),
Expand Down
2 changes: 1 addition & 1 deletion adl2pydm/tests/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ def assertExpectedDictInRef(ref, doc=None, **kwargs):
assert isinstance(kwargs, dict), doc
for k, v in kwargs.items():
assert k in ref, f"{doc}, k={k}, v={v}"
assert v == ref[k], f"{doc}, k={k}, v={v}"
assert v == ref[k], f"{doc}, k={k}, v={v}, ref[k]={ref[k]}"


def assertGreater(a, b, doc=None):
Expand Down
Loading