Skip to content

Commit

Permalink
ENH #90 add PyDMAbsoluteGeometry widget
Browse files Browse the repository at this point in the history
  • Loading branch information
prjemian committed May 14, 2022
1 parent 706f0f7 commit cb567d0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
15 changes: 8 additions & 7 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 @@ -292,8 +292,7 @@ def write_font_size(self, qw, block, **kwargs):

def write_ui(self, screen, output_path):
"""main entry point to write the .ui file"""
window_class = "QWidget"
# window_class = "QMainWindow"
window_class = TOP_LEVEL_WIDGET_CLASS
title = (
screen.title
or os.path.split(os.path.splitext(screen.given_filename)[0])[-1]
Expand All @@ -308,7 +307,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
3 changes: 3 additions & 0 deletions adl2pydm/symbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@
"""

pydm_widgets = dict(
PyDMAbsoluteGeometry=PyDM_CustomWidget(
"PyDMAbsoluteGeometry", "QWidget", "pydm.widgets.absolute_geometry"
),
PyDMTabWidget=PyDM_CustomWidget(
"PyDMTabWidget", "QTabWidget", "pydm.widgets.tab_bar"
),
Expand Down

0 comments on commit cb567d0

Please sign in to comment.