Base Dialog

This is intended to be used as a base class for custom dialogs, as well as a provider for use in YAML config files. This allows loading custom dialogs from .ui files without needing to write any python code.

You can launch dialogs using a Dialog Button or from a window menu item.

Example

YAML config for loading a custom dialog called my_dialog from a .ui file named my_diloag.ui located in the same dir as the .yml file:

dialogs:
  my_dialog:
    provider: qtpyvcp.widgets.dialogs.base_dialog:BaseDialog
    kwargs:
      ui_file: {{ file.dir }}/my_dialog.ui
      title: My Dialog Title    # optional, set the dialog title
      modal: false              # optional, whether the dialog is modal
      popup: false              # optional, whether the dialog is a popup
      frameless: false          # optional, whether the dialog is frameless
      stay_on_top: true         # optional, whether the dialog stays on top
class qtpyvcp.widgets.dialogs.base_dialog.BaseDialog(parent=None, ui_file=None, title=None, modal=None, popup=None, frameless=None, stay_on_top=None)[source]

Base QtPyVCP dialog class.

Parameters:
  • parent (QWidget, optional) – The dialog’s parent window, or None.
  • ui_file (str, optional) – The path of a .ui file to load the dialog from. The ui base widget should be a QDialog.
  • title (str, optional) – The title to use for the dialog. This will override any title property set in QtDesigner.
  • modal (bool, optional) – Whether the dialog should be application modal. This will override any modality hints set in QtDesigner.
  • frameless (bool, optional) – Whether the window has a frame or not. If the window does not have a frame you will need some way to close it, like an Ok or Cancel button.
  • popup – (bool, optional) : Makes the dialog use a frame less window that automatically hides when it looses focus.
  • stay_on_top (bool, optional) – Sets the stay on top hint window flag. This overrides any window flags set in QtDesiger.
loadUiFile(ui_file)[source]

Load dialog from a .ui file.

The .ui file base class should be a QDialog.

Parameters:ui_file (str) – path to the .ui file to load.
setWindowFlag(flag, on)[source]

BackPort QWidget.setWindowFlag() implementation from Qt 5.9

This method was introduced in Qt 5.9 so is not present in Qt 5.7.1 which is standard on Debian 9 (stretch), so add our own implementation.