Пример #1
0
    def __init__(
        self,
        parent,
        text="",
        read_only=False,
        placeholder="",
        clearbutton=False,
        passwordMode=False,
    ):
        super().__init__(parent, QLineEdit(text, QParent(parent)))
        # Widget.__init__(self, parent)
        # self.init_widget(parent)
        self._qwidget.setReadOnly(read_only)

        self._has_text = text != ""
        self.update_color()

        # noinspection PyUnresolvedReferences
        self._qwidget.textChanged.connect(self.__on_text_changed)
        # noinspection PyUnresolvedReferences
        self._qwidget.returnPressed.connect(self.__on_return_pressed)

        self.changed = SignalWrapper(self, "changed")
        self.activated = SignalWrapper(self, "activated")

        if passwordMode:
            self._qwidget.setEchoMode(QLineEdit.Password)
        if placeholder:
            self._qwidget.setPlaceholderText(placeholder)
        if clearbutton:
            self._qwidget.setClearButtonEnabled(True)
        self.update_style()
Пример #2
0
    def __init__(self, parent, label="", *, icon=None):
        if icon:
            qwidget = QPushButton(icon.qicon(), label, QParent(parent))
        else:
            qwidget = QPushButton(label, QParent(parent))
        super().__init__(parent, qwidget)
        self._qwidget.clicked.connect(self.__on_clicked)

        theme = get_theme(self)
        padding = theme.button_padding()
        if padding:
            fontmetrics = QFontMetrics(self._widget.font())
            fontheight = fontmetrics.height()
            border = 4
            min_height = fontheight + padding.top + padding.bottom + border
            self.set_min_height(min_height)
    def __init__(self, parent):
        super().__init__(
            parent, QScrollAreaWrapper(QParent(parent), owner=self)
        )
        self._qwidget.move(0, 2000)

        self._parent = weakref.ref(parent)
        # QWidget.__init__(self, QParent(parent))
        # self.init_widget(parent)
        self.layout = None
        self._painter = None

        # QScrollArea.__init__(self, parent.get_container())
        # self.init_widget(parent)
        self.__child = None
        # self.layout = None
        # self._painter = None

        # self._qwidget.move(0, 2000)

        # self.set_background_color(Color(0xff0000))

        # Needed to make the scroll area transparent (background shows
        # through).
        self._qwidget.viewport().setAutoFillBackground(False)

        self._qwidget.setFrameShape(QFrame.NoFrame)
        self._qwidget.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        self._qwidget.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
Пример #4
0
    def __init__(self, parent, border=True):
        # self = QListView(parent.get_container())
        super().__init__(parent, QListView(QParent(parent)))
        # Widget.__init__(self, parent)
        # self.init_widget(parent)

        # FIXME: Hmmm...?
        # self._qwidget.viewport().installEventFilter(self.get_window())
        # self._qwidget.verticalScrollBar().installEventFilter(self.get_window())

        if not border:
            self._qwidget.setFrameStyle(0)

        # self.setSelectionModel()
        self._model = QStandardItemModel(self)
        # self.setModel(self._model)
        self._qwidget.setModel(self._model)
        # self.itemSelectionChanged.connect(self._on_selection_changed)
        selection_model = self._qwidget.selectionModel()
        print("QListView selectionModel", selection_model)
        selection_model.selectionChanged.connect(self.__on_selection_changed)
        self._qwidget.setEditTriggers(QListView.NoEditTriggers)
        self._qwidget.doubleClicked.connect(self.__on_double_clicked)
        # self.returnPressed.connect(self.__double_clicked)
        # self.activated.connect(self.__double_clicked)
        self._row_height = 26
Пример #5
0
 def __init__(self, parent, min_value, max_value, initial_value):
     super().__init__(parent, QSpinBox(QParent(parent)))
     self._widget.setRange(min_value, max_value)
     self._widget.setValue(initial_value)
     self._widget.valueChanged.connect(self.__value_changed)
     # FIXME: What did this to, again?
     self.changed = SignalWrapper(self, "changed")
     self.update_style()
    def __init__(self, parent):
        super().__init__(parent, QScrollArea(QParent(parent)))
        self.__child = None
        # self.layout = None
        # self._painter = None

        self._qwidget.move(0, 2000)
        self._qwidget.setFrameShape(QFrame.NoFrame)
        self._qwidget.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
Пример #7
0
def show_error(message, title=None, parent=None):
    if not title:
        title = gettext("An Error Occurred")
    # QErrorMessage().showMessage(message)
    # message_box = QMessageBox()
    # message_box.setIcon(QMessageBox.Critical)
    # message_box.setText(message)
    # message_box.exec_()
    QMessageBox.critical(QParent(parent), title, message)
Пример #8
0
    def __init__(self, parent, text="", check=False):
        # self._widget = QCheckBox(text, parent.get_container())
        super().__init__(parent, QCheckBox(text, QParent(parent)))
        self.changed = SignalWrapper(self, "changed")

        # self.init_widget(parent)
        if check:
            self.setChecked(True)
        # self._widget.stateChanged.connect(self.__state_changed)
        self._qwidget.stateChanged.connect(self.__state_changed)
Пример #9
0
    def __init__(self, parent, label, min_width=None):
        super().__init__(parent, QLabel(label, QParent(parent)))
        self._qwidget.setWordWrap(True)
        # self._widget.setFixedWidth(200)
        # self._widget.setFixedHeight(200)
        if min_width:
            self.set_min_width(min_width)

        self._qwidget.setTextFormat(Qt.RichText)
        self._qwidget.setTextInteractionFlags(Qt.TextBrowserInteraction)
        self._qwidget.setOpenExternalLinks(True)
        self._qwidget.setAlignment(Qt.AlignLeft | Qt.AlignTop)
Пример #10
0
    def __init__(self, parent, *, border, fswidget, title):
        super().__init__(QParent(parent, window=True))
        self.setWindowTitle(title)
        self.setAttribute(Qt.WA_DeleteOnClose)

        flags = Qt.Dialog
        if not border:
            flags |= Qt.FramelessWindowHint
            # flags |= Qt.NoDropShadowWindowHint
        self.setWindowFlags(flags)

        # Maybe...
        self._fswidget_ref = weakref.ref(fswidget)
    def __init__(self, parent=None, title=""):
        QDialog.__init__(self, QParent(parent))
        self._window = weakref.ref(self)

        self.layout = None
        self.setWindowTitle(title)

        # self.container = wx.Panel(self)
        # self.container.get_window = self.get_window
        # self.Bind(wx.EVT_SIZE, self.__resize_event)
        # self.Bind(wx.EVT_WINDOW_DESTROY, self.__destroy_event)
        # self.Bind(wx.EVT_CLOSE, self.__close_event)
        self.destroy_listeners = []
        self.close_listeners = []
Пример #12
0
    def __init__(
        self,
        parent,
        # child,
        *,
        below=False,
        border=True,
        fswidget,
        minimizable=True,
        maximizable=True,
        title,
    ):
        print(f"\nWindowWrapper.__init__ parent={parent}")
        super().__init__(QParent(parent, window=True))
        # self.margins = Margins()
        self.setWindowTitle(title)
        self.setAttribute(Qt.WA_DeleteOnClose)

        flags = Qt.Window
        if System.macos:
            flags &= ~Qt.WindowFullscreenButtonHint

        if border:
            flags |= Qt.CustomizeWindowHint
            flags |= Qt.WindowCloseButtonHint
            flags |= Qt.WindowTitleHint
            if minimizable:
                flags |= Qt.WindowMinimizeButtonHint
            if maximizable:
                flags |= Qt.WindowMaximizeButtonHint
            # else:
            #     flags &= ~Qt.WindowMaximizeButtonHint
        else:
            flags |= Qt.FramelessWindowHint
            # flags |= Qt.NoDropShadowWindowHint
            if below:
                flags |= Qt.WindowStaysOnBottomHint
        self.setWindowFlags(flags)
        # self.setAttribute(Qt.WA_DeleteOnClose, True)

        # self._child = weakref.ref(child)
        # self._child = child
        # self._fake_window = child
        # self.__already_closed = False

        # self.destroyed.connect(self.__on_destroyed)

        # Maybe...
        self._fswidget_ref = weakref.ref(fswidget)
Пример #13
0
    def __init__(self, parent, items=None, cursor_keys=True):
        if items is None:
            items = []
        super().__init__(parent, QComboBox(QParent(parent)))
        self.inhibit_change_event = False
        self.cursor_keys = cursor_keys

        for i, item in enumerate(items):
            self._qwidget.insertItem(i, item)
        if len(items) > 0:
            self.set_index(0)
        self._qwidget.currentIndexChanged.connect(
            self.__on_current_index_changed)
        self.changed = SignalWrapper(self, "changed")
        self.update_style()
Пример #14
0
    def __init__(self, parent, paintable=False):
        unused(paintable)
        super().__init__(parent,
                         WidgetWithEventHandlers(QParent(parent), self))
        self._widget.move(0, 2000)

        self._parent = weakref.ref(parent)
        # QWidget.__init__(self, QParent(parent))
        # self.init_widget(parent)
        self.layout = VerticalLayout()
        # self.layout = None
        self._painter = None

        # QWidget.__init__(self)
        # self.setParent(parent.get_container())
        # super(Panel, self).__init__(parent.get_container())
        # super().__init__()
        self._ignore_next_left_down_event = False
Пример #15
0
    def __init__(self, parent, image):
        super().__init__(parent, QPushButton(QParent(parent)))
        # if image is not None:
        icon = image.qicon
        self._qwidget.setIcon(icon)
        self._qwidget.setIconSize(QSize(image.size[0], image.size[1]))
        self._qwidget.clicked.connect(self.__clicked)

        theme = get_theme(self)
        padding = theme.button_padding()
        print("THEME", theme, "PADDING", padding)
        if padding:
            fontmetrics = QFontMetrics(self._qwidget.font())
            fontheight = fontmetrics.height()
            print(fontheight)
            border = 4
            min_height = fontheight + padding.top + padding.bottom + border
            self.set_min_height(min_height)
            print("BUTTONTHEME", theme, min_height)
    def __init__(self, parent, border=True):
        super().__init__(parent, QListView(QParent(parent)))
        # FIXME: Why?
        # self._qwidget.viewport().installEventFilter(self.get_window())
        # self._qwidget.verticalScrollBar().installEventFilter(self.get_window())
        if not border:
            self._qwidget.setFrameStyle(0)

        # self.setSelectionModel()
        # self.model = QStandardItemModel(self)
        self.model = Model(self)
        self._qwidget.setModel(self.model)
        # self.itemSelectionChanged.connect(self.__selection_changed)
        selection_model = self._qwidget.selectionModel()
        print("VerticalItemView selectionModel = ", selection_model)
        selection_model.selectionChanged.connect(self.__selection_changed)
        self._qwidget.doubleClicked.connect(self.__double_clicked)
        # self.returnPressed.connect(self.__double_clicked)
        # self.activated.connect(self.__double_clicked)
        self._row_height = 26
Пример #17
0
    def __init__(
        self,
        parent,
        text="",
        read_only=False,
        font_family=None,
        border=True,
        line_wrap=True,
        text_color=None,
        background_color=None,
        padding=None,
    ):
        super().__init__(parent, QTextEdit("", QParent(parent)))
        if not border:
            self._qwidget.setFrameStyle(QFrame.NoFrame)
        self._qwidget.setReadOnly(read_only)
        if font_family:
            print("FIXME: not respecting font_family yet")
            font = QFont("Courier")
            # font.setStyleHint(QtGui.QFont.TypeWriter)
            self._qwidget.setFont(font)
        if line_wrap == False:
            self._qwidget.setLineWrapMode(QTextEdit.NoWrap)
        if text:
            self.append_text(text)

        stylesheet = []
        if text_color:
            stylesheet.append(f"color: {text_color.to_hex()};")
        if background_color:
            stylesheet.append(
                f"background-color: {background_color.to_hex()};")
        if padding:
            stylesheet.append(f"padding: {padding};")
        if stylesheet:
            nl = "\n"
            stylesheet_str = f"QTextEdit {{\n{nl.join(stylesheet)}\n}}\n"
            # print(stylesheet_str)
            self._qwidget.setStyleSheet(stylesheet_str)

        self._qwidget.textChanged.connect(self.__text_changed)
Пример #18
0
    def __init__(self, parent, items=[], read_only=False):
        super().__init__(parent, QComboBox(QParent(parent)))
        # QComboBox.__init__(self, parent.get_container())
        # self = QComboBox(parent.get_container())
        # Widget.__init__(self, parent)
        # self.init_widget(parent)
        # self.setEditable(not read_only)
        print("FIXME: ComboBox not respecting read_only"
              "(because of missing lineEdit then")
        self._qwidget.setEditable(True)

        # FIXME: Why?? Disabling until checked, remember to comment
        # self._qwidget.lineEdit().installEventFilter(self.get_window())

        self.set_items(items)

        if len(items) > 0:
            self.set_index(0)
        self._qwidget.currentIndexChanged.connect(self.__current_index_changed)

        # self.dumpObjectTree()
        # print("(dumped)")
        self.update_style()
Пример #19
0
 def __init__(self, parent):
     super().__init__(parent, QWebView(QParent(parent)))
Пример #20
0
 def __init__(self, parent):
     super().__init__(parent, ClockQWidget(QParent(parent)))
Пример #21
0
 def __init__(self, parent, image, stretch=False):
     super().__init__(parent, QLabel(QParent(parent)))
     self._qwidget.setPixmap(image.qpixmap)
     if stretch:
         self._qwidget.setScaledContents(True)
Пример #22
0
def show_warning(message, title=None, parent=None):
    if not title:
        title = gettext("Warning")
    QMessageBox.warning(QParent(parent), title, message)
Пример #23
0
    def __init__(
        self,
        parent,
        title="",
        border=True,
        minimizable=True,
        maximizable=True,
        separator=True,
        menu=False,
        native=None,
        header=True,
        below=False,
        closable=True,
        color=None,
        **_
    ):
        init_qt()
        super().__init__()

        # if parent is None and len(default_window_parent) > 0:
        #     parent = default_window_parent[-1]
        #     print("using default parent", parent)

        # FIXME
        self._window = weakref.ref(self)

        if native is None:
            if fsboot.get("fws") == "1":
                native = False
            else:
                native = not _use_fws
        if native:
            self._real_window = RealWindow(
                QParent(parent, True),
                self,
                minimizable=minimizable,
                maximizable=maximizable,
                below=below,
                border=border,
            )
        else:
            self._real_window = FwsWindow(
                QParent(parent, True), self, below=below
            )

        self._real_widget = RealWidget(self._real_window, self)

        # Widget.__init__(self, parent)
        # self.init_widget(parent)

        # MixinBase.__init__(self)

        self.set_title(title)

        self.layout = None
        self._size_specified = False
        self.close_listeners = []
        # _windows.add(self)
        self.destroyed.connect(self.__destroyed)

        self._real_window.setAttribute(Qt.WA_DeleteOnClose, True)

        # if not border:
        #     self.setWindowFlags(Qt.FramelessWindowHint |
        #                         Qt.NoDropShadowWindowHint)
        #     # self.setWindowFlags(Qt.FramelessWindowHint)

        self.center_on_show = True
        self._centered_on_initial_show = False
        if hasattr(self, "accepted"):
            self.accepted.connect(self.__accepted)
        if hasattr(self, "rejected"):
            self.rejected.connect(self.__rejected)

        # Add a keep-alive reference
        print("Adding window reference", self)
        windows.add(self)
        self.closed.connect(self.__closed)

        self.title_panel = None
        self.title_panel_visible = False
        if not native:
            self.real_window()._window = weakref.ref(self)
            from workspace.ui.theme import WorkspaceTheme
            from workspace.ui.window import WindowHeader

            if header:
                self.title_panel = WindowHeader(
                    self.real_window(),
                    menu=menu,
                    minimizable=minimizable,
                    maximizable=maximizable,
                    separator=separator,
                    closable=closable,
                    background=color,
                )
            self.title_panel_visible = True
            self.set_background_color(
                WorkspaceTheme.instance().window_background
            )
Пример #24
0
 def __init__(self, parent, label):
     super().__init__(parent, QLabel(label, QParent(parent)))