Exemplo n.º 1
0
def pick_file(parent=None, message="", directory="", what=FILE):
    if NATIVE_DIALOGS:
        if what == DIRECTORY:
            result = QFileDialog.getExistingDirectory(QParent(parent), message,
                                                      directory)
        elif what == FILES:
            # return value is filenames, selected_filter
            result = QFileDialog.getOpenFileNames(QParent(parent), message,
                                                  directory)
        else:
            # return value is filename, selected_filter
            result = QFileDialog.getOpenFileName(QParent(parent), message,
                                                 directory)
        if isinstance(result, tuple):
            # PySide returns a tuple, path is first param
            result = result[0]
    else:
        dialog = QFileDialog(parent, message)
        if directory:
            dialog.setDirectory(directory)
        if what == DIRECTORY:
            dialog.setFileMode(QFileDialog.Directory)
        elif what == FILES:
            dialog.setFileMode(QFileDialog.ExistingFiles)
        modal_result = dialog.exec_()
        if not modal_result:
            result = None
        elif what == FILES:
            result = dialog.selectedFiles()
        else:
            result = dialog.selectedFiles()[0]
        dialog.destroy()
    print("return file/dir dialog result:", result)
    return result
Exemplo n.º 2
0
 def __init__(self, parent, min_value, max_value, initial_value):
     super().__init__()
     self.set_widget(QSpinBox(QParent(parent)))
     self._widget.setRange(min_value, max_value)
     self._widget.setValue(initial_value)
     self._widget.valueChanged.connect(self.__value_changed)
     self.changed = SignalWrapper(self, "changed")
Exemplo n.º 3
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)
Exemplo n.º 4
0
    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 = []
Exemplo n.º 5
0
 def __init__(self,
              parent=None,
              message="",
              directory="",
              file="",
              pattern="*.*",
              multiple=False,
              dir_mode=False):
     QFileDialog.__init__(self, QParent(parent), message)
     if directory:
         self.setDirectory(directory)
     if dir_mode:
         self.setFileMode(QFileDialog.Directory)
     if multiple:
         self.setFileMode(QFileDialog.ExistingFiles)
Exemplo n.º 6
0
    def __init__(self, parent, paintable=False):
        unused(paintable)
        super().__init__(parent)
        self.set_widget(WidgetWithEventHandlers(QParent(parent), self))
        self._widget.move(0, 2000)
        self._widget.setAutoFillBackground(True)

        self._parent = weakref.ref(parent)
        # QWidget.__init__(self, QParent(parent))
        # self.init_widget(parent)
        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
Exemplo n.º 7
0
 def __init__(self, parent, image, stretch=False):
     super().__init__()
     self.set_widget(QLabel(QParent(parent)))
     self._widget.setPixmap(image.qpixmap)
     if stretch:
         self._widget.setScaledContents(True)
Exemplo n.º 8
0
 def __init__(self, parent, widget):
     super().__init__()
     self._widget = widget
     self._widget.setParent(QParent(parent))
Exemplo n.º 9
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)
Exemplo n.º 10
0
def show_warning(message, title=None, parent=None):
    if not title:
        title = gettext("Warning")
    QMessageBox.warning(QParent(parent), title, message)
Exemplo n.º 11
0
 def __init__(self, parent=None, title=""):
     super().__init__(QParent(parent), title=title)
Exemplo n.º 12
0
 def __init__(self, parent):
     super().__init__()
     self.set_widget(QWebView(QParent(parent)))