Exemplo n.º 1
0
    def ui(self):
        """ Method build ui """
        grid = QGridLayout(self)
        self.setLayout(grid)

        self.userLbl = QLabel(self)
        self.timeLbl = QLabel(self)
        self.timeLbl.setAlignment(Qt.AlignRight)

        self.line_1 = QFrame(self)
        self.line_1.setFrameShape(QFrame.HLine)
        self.line_1.setFrameShadow(QFrame.Sunken)
        self.line_2 = QFrame(self)
        self.line_2.setFrameShape(QFrame.HLine)
        self.line_2.setFrameShadow(QFrame.Sunken)

        self.msgLbl = QTextBrowser(self)
        # font = QFont()
        # font.setPointSize(12)
        # self.msgLbl.setFont(font)
        self.msgLbl.setFrameShape(QFrame.NoFrame)
        self.msgLbl.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.msgLbl.setSizeAdjustPolicy(QAbstractScrollArea.AdjustToContents)
        self.msgLbl.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)

        grid.addWidget(self.userLbl, 0, 0)
        grid.addWidget(self.timeLbl, 0, 1)
        grid.addWidget(self.line_1, 1, 0, 1, 2)
        grid.addWidget(self.msgLbl, 2, 0, 1, 2)
        grid.addWidget(self.line_2, 3, 0, 1, 2)
Exemplo n.º 2
0
    def _set_common_top_ui(self):
        top_frame = QFrame()
        top_frame.setMaximumHeight(60)
        top_layout = QVBoxLayout(top_frame)
        self.layout.addWidget(top_frame)

        common_top_frame = QFrame()
        common_top_frame.setMinimumHeight(50)
        common_top_frame.setMaximumHeight(50)
        common_top_layout = QHBoxLayout(common_top_frame)
        top_layout.addWidget(common_top_frame)
        common_top_layout.addStretch(0)

        label = QLabel(i18n[self.lang]['Type'] + ':')
        self.label_type = QLabel('')
        self.label_type.setStyleSheet('''color: gray;font:bold;''')
        common_top_layout.addWidget(label)
        common_top_layout.addWidget(self.label_type)

        label = QLabel(i18n[self.lang]['Mode'] + ':')
        self.label_mode = QLabel('')
        self.label_mode.setStyleSheet('''color: gray;font:bold;''')
        common_top_layout.addWidget(label)
        common_top_layout.addWidget(self.label_mode)

        label = QLabel(i18n[self.lang]['HardwareVersion'] + ':')
        self.label_hard_version = QLabel('')
        self.label_hard_version.setStyleSheet('''color: gray;font:bold;''')
        common_top_layout.addWidget(label)
        common_top_layout.addWidget(self.label_hard_version)

        label = QLabel(i18n[self.lang]['FirmwareVersion'] + ':')
        self.label_firm_version = QLabel('')
        self.label_firm_version.setStyleSheet('''color: gray;font:bold;''')
        common_top_layout.addWidget(label)
        common_top_layout.addWidget(self.label_firm_version)

        label_1 = QLabel(i18n[self.lang]['Connected'] + ':')
        self.label_connected = QLabel()
        img = QImage()
        self.label_connected.setMaximumHeight(20)
        self.label_connected.setMaximumWidth(20)
        self.label_connected.setScaledContents(True)
        if img.load(disconnect_icon_path):
            self.label_connected.setPixmap(QPixmap.fromImage(img))

        self.lnt_addr = QLineEdit('COM12')
        self.lnt_addr.setMaximumWidth(50)
        self.lnt_addr.setMinimumWidth(30)
        self.btn_connect = QPushButton(i18n[self.lang]['Connect'])
        # self.btn_connect.setMaximumWidth(50)

        # common_top_layout.addStretch(0)
        common_top_layout.setSpacing(10)
        common_top_layout.addWidget(label_1)
        common_top_layout.addWidget(self.label_connected)
        common_top_layout.addWidget(self.lnt_addr)
        common_top_layout.addWidget(self.btn_connect)
Exemplo n.º 3
0
    def initConvertPage(self):
        f = QFrame()
        l = QGridLayout()
        f.setLayout(l)

        row = 0

        l.addWidget(QLabel('Converter :'), row, 0)
        currentPluginBox = QComboBox()
        currentPluginBox.currentTextChanged.connect(self.selectPlugin)
        l.addWidget(currentPluginBox, row, 1)
        for key in self.plugins.keys():
            currentPluginBox.addItem(key)
        row += 1

        l.addWidget(QLabel('Destination path :'), row, 0)
        self.destPathLbl = QLabel(
            self.joinSavePath(self.config[PATHS]['save_path'],
                              self.config[FILES]['save_file'],
                              self.config[FILES]['save_ext']))
        self.destPathLbl.setSizePolicy(QSizePolicy.Expanding,
                                       QSizePolicy.Fixed)
        l.addWidget(self.destPathLbl, row, 1)

        row += 1

        f2 = QFrame()
        l2 = QHBoxLayout()
        f2.setLayout(l2)

        f3 = QFrame()
        l3 = QGridLayout()
        f3.setLayout(l3)

        l3.addWidget(QLabel('Destination Files :'), 0, 0)
        self.destFilesList = QListWidget()
        self.destFilesList.setAlternatingRowColors(True)
        l3.addWidget(self.destFilesList, 1, 0)

        l2.addWidget(self.initFileFrame())
        l2.addWidget(f3)
        l.addWidget(f2, row, 0, 1, 3)

        row += 1

        l.addWidget(self.initSrcFiles(), row, 0, 1, 3)

        row += 1

        self.convertBtn = QPushButton('Convert')
        self.convertBtn.clicked.connect(self.handleConvertClicked)
        self.convertBtn.setEnabled(False)
        l.addWidget(self.convertBtn, row, 0, 1, 3)

        return f
Exemplo n.º 4
0
Arquivo: align.py Projeto: ligm74/LiGM
    def __init__(self, color_caption):
        TestableWidget.__init__(self)
        self.setWindowFlags(Qt.Popup)
        self._text = self.tr("Alignment text")

        main_layout = QVBoxLayout()
        main_layout.setContentsMargins(0, 0, 0, 0)

        b = "border: 1px solid #9b9b9b;"
        self._styles = {
            "border": b,
            "border_blue": "border: 0px solid blue;",
            "frame": 'QFrame[frameShape="4"]{color: #9b9b9b;}'
        }

        self.setStyleSheet(self._styles["frame"])

        # -- CAPTION ----------------------------------
        caption = QFrame(self, flags=Qt.WindowFlags())
        caption_layout = QHBoxLayout()
        self._lbl_caption = QLabel(self._text)
        self._lbl_caption.setStyleSheet(self._styles["border_blue"])
        caption_layout.addWidget(self._lbl_caption, alignment=Qt.Alignment())
        caption.setLayout(caption_layout)
        caption_layout.setContentsMargins(9, 5, 9, 5)
        caption.setStyleSheet(
            f"background-color: {color_caption}; {self._styles['border']}")

        # -- CELLS GRID -------------------------------
        cellsbox = QFrame(self, flags=Qt.WindowFlags())
        cells = QGridLayout()
        cellsbox.setLayout(cells)
        cells.setContentsMargins(9, 0, 9, 9)
        self._clrbtn = []
        for i in range(1, 4):
            for j in range(1, 5):
                self._clrbtn.append(QToolButton())
                self._clrbtn[-1].clicked.connect(
                    lambda z, y=i, x=j: self.select_align_(x, y))
                self._clrbtn[-1].setAutoRaise(True)

                sz = 48
                self._clrbtn[-1].setFixedSize(sz, sz)
                self._clrbtn[-1].setIconSize(QSize(sz, sz))

                self._clrbtn[-1].setIcon(QIcon(img(f"editor/a{i}{j}.png")))
                # noinspection PyArgumentList
                cells.addWidget(self._clrbtn[-1], i - 1, j - 1)

        # ---------------------------------------------
        main_layout.addWidget(caption, alignment=Qt.Alignment())
        main_layout.addWidget(cellsbox, alignment=Qt.Alignment())

        self.setLayout(main_layout)
Exemplo n.º 5
0
    def __init__(self, parent=None, show=True):
        QMainWindow.__init__(self, parent)

        self.frame = QFrame()
        vlayout = QVBoxLayout()
        self.vtk_widget = QtInteractor(self.frame)
        vlayout.addWidget(self.vtk_widget)

        self.frame.setLayout(vlayout)
        self.setCentralWidget(self.frame)

        mainMenu = self.menuBar()
        fileMenu = mainMenu.addMenu('File')

        exitButton = QAction('Exit', self)
        exitButton.setShortcut('Ctrl+Q')
        exitButton.triggered.connect(self.close)

        fileMenu.addAction(exitButton)

        meshMenu = mainMenu.addMenu('Mesh')
        self.add_sphere_action = QAction('Add Sphere', self)

        self.add_sphere_action.triggered.connect(self.add_sphere)
        meshMenu.addAction(self.add_sphere_action)

        if show:
            self.show()
Exemplo n.º 6
0
 def __init__(self, parent, label, extra_widgets=[], style=QFrame.HLine + QFrame.Raised, offset=16):
     QWidget.__init__(self, parent)
     lo = QHBoxLayout(self)
     lo.setContentsMargins(0, 0, 0, 0)
     lo.setSpacing(4)
     if offset:
         frame = QFrame(self)
         frame.setFrameStyle(style)
         frame.setMinimumWidth(offset)
         lo.addWidget(frame, 0)
     lo.addWidget(QLabel(label, self), 0)
     frame = QFrame(self)
     frame.setFrameStyle(style)
     lo.addWidget(frame, 1)
     for w in extra_widgets:
         lo.addWidget(w, 0)
Exemplo n.º 7
0
 def __init__(self, name, is_checked=False, path='', restriction='', parent=None, is_first=False, enable_on_checked=True):
     QWidget.__init__(self, parent)
     self.name = name
     self.enable_on_checked = enable_on_checked
     self.l = l = QVBoxLayout(self)
     l.setSizeConstraint(l.SetMinAndMaxSize)
     if not is_first:
         self.border = b = QFrame(self)
         b.setFrameStyle(b.HLine)
         l.addWidget(b)
     self.cw = cw = QCheckBox(name.replace('&', '&&'))
     cw.setStyleSheet('QCheckBox { font-weight: bold }')
     cw.setChecked(is_checked)
     cw.stateChanged.connect(self.state_changed)
     if path:
         cw.setToolTip(path)
     l.addWidget(cw)
     self.la = la = QLabel(_('Further &restrict access to books in this library that match:'))
     l.addWidget(la)
     self.rw = rw = QLineEdit(self)
     rw.setPlaceholderText(_('A search expression'))
     rw.setToolTip(textwrap.fill(_(
         'A search expression. If specified, access will be further restricted'
         ' to only those books that match this expression. For example:'
         ' tags:"=Share"')))
     rw.setText(restriction or '')
     rw.textChanged.connect(self.on_rchange)
     la.setBuddy(rw)
     l.addWidget(rw)
     self.state_changed()
Exemplo n.º 8
0
    def __init__(self, plugin, parent):
        QWidget.__init__(self, parent)

        self.plugin = plugin

        self.l = l = QVBoxLayout()
        self.setLayout(l)
        self.c = c = QLabel(
            _('<b>Configure %(name)s</b><br>%(desc)s') %
            dict(name=plugin.name, desc=plugin.description))
        c.setAlignment(Qt.AlignHCenter)
        l.addWidget(c)

        self.config_widget = plugin.config_widget()
        self.l.addWidget(self.config_widget)

        self.bb = QDialogButtonBox(QDialogButtonBox.Save
                                   | QDialogButtonBox.Cancel,
                                   parent=self)
        self.bb.accepted.connect(self.finished)
        self.bb.rejected.connect(self.finished)
        self.bb.accepted.connect(self.commit)
        l.addWidget(self.bb)

        self.f = QFrame(self)
        self.f.setFrameShape(QFrame.HLine)
        l.addWidget(self.f)
Exemplo n.º 9
0
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)
        self.l = l = QGridLayout(self)

        def add_row(*args):
            r = l.rowCount()
            if len(args) == 1:
                l.addWidget(args[0], r, 0, 1, 2)
            else:
                la = QLabel(args[0])
                l.addWidget(la, r, 0, Qt.AlignmentFlag.AlignRight), l.addWidget(args[1], r, 1)
                la.setBuddy(args[1])

        self.heading = la = QLabel('<h2>\xa0')
        add_row(la)
        self.helpl = la = QLabel(_('For help with snippets, see the <a href="%s">User Manual</a>') %
                                 localize_user_manual_link('https://manual.calibre-ebook.com/snippets.html'))
        la.setOpenExternalLinks(True)
        add_row(la)

        self.name = n = QLineEdit(self)
        n.setPlaceholderText(_('The name of this snippet'))
        add_row(_('&Name:'), n)

        self.trig = t = QLineEdit(self)
        t.setPlaceholderText(_('The text used to trigger this snippet'))
        add_row(_('Tri&gger:'), t)

        self.template = t = QPlainTextEdit(self)
        la.setBuddy(t)
        add_row(_('&Template:'), t)

        self.types = t = QListWidget(self)
        t.setFlow(QListView.Flow.LeftToRight)
        t.setWrapping(True), t.setResizeMode(QListView.ResizeMode.Adjust), t.setSpacing(5)
        fm = t.fontMetrics()
        t.setMaximumHeight(2*(fm.ascent() + fm.descent()) + 25)
        add_row(_('&File types:'), t)
        t.setToolTip(_('Which file types this snippet should be active in'))

        self.frame = f = QFrame(self)
        f.setFrameShape(f.HLine)
        add_row(f)
        self.test = d = SnippetTextEdit('', self)
        d.snippet_manager.snip_func = self.snip_func
        d.setToolTip(_('You can test your snippet here'))
        d.setMaximumHeight(t.maximumHeight() + 15)
        add_row(_('T&est:'), d)

        i = QListWidgetItem(_('All'), t)
        i.setData(Qt.ItemDataRole.UserRole, '*')
        i.setCheckState(Qt.CheckState.Checked)
        i.setFlags(i.flags() | Qt.ItemFlag.ItemIsUserCheckable)
        for ftype in sorted(all_text_syntaxes):
            i = QListWidgetItem(ftype, t)
            i.setData(Qt.ItemDataRole.UserRole, ftype)
            i.setCheckState(Qt.CheckState.Checked)
            i.setFlags(i.flags() | Qt.ItemFlag.ItemIsUserCheckable)

        self.creating_snippet = False
Exemplo n.º 10
0
    def _set_down_frame_ui(self):
        self.down_frame = QFrame()
        self.down_layout = QHBoxLayout(self.down_frame)
        self.layout.addWidget(self.down_frame)

        self.textEdit = QTextEdit()
        self.down_layout.addWidget(self.textEdit)
Exemplo n.º 11
0
    def __init__(self, parent=None, show=True, off_screen=True):
        MainWindow.__init__(self, parent)

        self.frame = QFrame()
        vlayout = QVBoxLayout()
        self.vtk_widget = QtInteractor(parent=self.frame,
                                       off_screen=off_screen)
        vlayout.addWidget(self.vtk_widget.interactor)

        self.frame.setLayout(vlayout)
        self.setCentralWidget(self.frame)

        mainMenu = _create_menu_bar(parent=self)

        fileMenu = mainMenu.addMenu('File')
        self.exit_action = QAction('Exit', self)
        self.exit_action.setShortcut('Ctrl+Q')
        self.exit_action.triggered.connect(self.close)
        fileMenu.addAction(self.exit_action)

        meshMenu = mainMenu.addMenu('Mesh')
        self.add_sphere_action = QAction('Add Sphere', self)
        self.exit_action.setShortcut('Ctrl+A')
        self.add_sphere_action.triggered.connect(self.add_sphere)
        meshMenu.addAction(self.add_sphere_action)

        self.signal_close.connect(self.vtk_widget.close)

        if show:
            self.show()
Exemplo n.º 12
0
Arquivo: main.py Projeto: yws/calibre
    def __init__(self, name, plugins, gui_name, parent=None):
        QWidget.__init__(self, parent)
        self._layout = QVBoxLayout()
        self.setLayout(self._layout)
        self.label = QLabel(gui_name)
        self.sep = QFrame(self)
        self.bf = QFont()
        self.bf.setBold(True)
        self.label.setFont(self.bf)
        self.sep.setFrameShape(QFrame.HLine)
        self._layout.addWidget(self.label)
        self._layout.addWidget(self.sep)

        self.plugins = plugins

        self.bar = QToolBar(self)
        self.bar.setStyleSheet('QToolBar { border: none; background: none }')
        lh = QApplication.instance().line_height
        self.bar.setIconSize(QSize(2 * lh, 2 * lh))
        self.bar.setMovable(False)
        self.bar.setFloatable(False)
        self.bar.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
        self._layout.addWidget(self.bar)
        self.actions = []
        for p in plugins:
            target = partial(self.triggered, p)
            ac = self.bar.addAction(QIcon(p.icon), p.gui_name, target)
            ac.setToolTip(textwrap.fill(p.description))
            ac.setWhatsThis(textwrap.fill(p.description))
            ac.setStatusTip(p.description)
            self.actions.append(ac)
            w = self.bar.widgetForAction(ac)
            w.setCursor(Qt.PointingHandCursor)
            w.setAutoRaise(True)
            w.setMinimumWidth(100)
Exemplo n.º 13
0
    def __init__(self, parent=None):
        """
        Create menu object.

        `UndoMenu` class shows list of child items in the plain list,
        suitable for undo / redo operations.

        Items are inserted to menu with `setItems()` method.

        Methods `setMaxWidth()` and `setLength()` allow to limit the
        width (in pixels) and height (as a number of shown items) of
        menu.

        To customize summary label (shown in the bottom area of menu),
        use `setComment()` method.

        Top-most item can be obtained with `lastItem()` method.

        Arguments:
            parent (Optional[QWidget]): Parent widget. Defaults to None.
        """
        QMenu.__init__(self, parent)
        v_layout = QVBoxLayout(self)
        v_layout.setContentsMargins(0, 0, 0, 0)

        frame = QFrame(self)
        frame.setFrameStyle(QFrame.Panel | QFrame.Plain)
        v_layout.addWidget(frame)

        v_layout = QVBoxLayout(frame)
        v_layout.setContentsMargins(0, 0, 0, 0)
        v_layout.setSpacing(1)

        self._list = QListWidget(frame)
        self._list.setFrameStyle(QListWidget.NoFrame)
        self._list.setSelectionMode(QListWidget.MultiSelection)
        self._list.setVerticalScrollMode(QListWidget.ScrollPerItem)
        self._list.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        self._list.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self._list.setResizeMode(QListWidget.Adjust)
        self._list.setFocusPolicy(Qt.NoFocus)
        self._list.viewport().installEventFilter(self)
        self._list.installEventFilter(self)
        self._list.viewport().setMouseTracking(True)

        self._label = QLabel(frame)
        self._label.setAlignment(Qt.AlignCenter)

        v_layout.addWidget(self._list)
        v_layout.addWidget(HLine(frame))
        v_layout.addWidget(self._label)

        self._comment = "%d"
        self._length = 10
        self._max_width = 0

        self._updateComment()
Exemplo n.º 14
0
def make_split_line(vertical=False):
    line = QFrame()

    if vertical:
        line.setFrameShape(QFrame.VLine)
    else:
        line.setFrameShape(QFrame.HLine)

    return line
Exemplo n.º 15
0
    def initConfigPage(self):
        row = 0

        f = QFrame()
        l = QGridLayout()
        f.setLayout(l)

        srcLbl = QLabel('Source directory :')
        srcLbl.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        l.addWidget(srcLbl, row, 0)

        self.srcDirBox = QLineEdit()
        self.srcDirBox.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
        self.srcDirBox.setText(self.config[PATHS]['download_path'])
        l.addWidget(self.srcDirBox, row, 1)

        srcDirSelectBtn = QPushButton('Select')
        srcDirSelectBtn.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        srcDirSelectBtn.clicked.connect(self.handleSelectSrcDirectory)
        l.addWidget(srcDirSelectBtn, row, 2)

        row += 1

        destLbl = QLabel('Destination directory :')
        destLbl.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        l.addWidget(destLbl, row, 0)

        self.destDirBox = QLineEdit()
        self.destDirBox.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
        self.destDirBox.setText(self.config[PATHS]['save_path'])
        l.addWidget(self.destDirBox, row, 1)

        destDirSelectBtn = QPushButton('Select')
        destDirSelectBtn.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        destDirSelectBtn.clicked.connect(self.handleSelectDestDirectory)
        l.addWidget(destDirSelectBtn, row, 2)

        row += 1

        l.addWidget(QFrame(), row, 0, 1, 3)

        return f
Exemplo n.º 16
0
    def _set_up_frame_ui(self):
        self.up_frame = QFrame()
        self.up_frame.setMinimumHeight(300)
        self.up_frame.setMaximumHeight(500)
        self.up_layout = QHBoxLayout(self.up_frame)
        up_left_frame = QFrame()
        # up_left_frame.setMinimumWidth(self.main_ui.window.geometry().width() / 2)
        # up_left_frame.setMaximumWidth(self.geometry().width() / 2)
        up_right_frame = QFrame()
        # up_right_frame.setMinimumWidth(self.main_ui.window.geometry().width() / 2)
        # up_right_frame.setMaximumWidth(self.geometry().width() / 2)
        self.up_left_layout = QHBoxLayout(up_left_frame)
        self.up_right_layout = QHBoxLayout(up_right_frame)
        self.up_layout.addWidget(up_left_frame)
        # self.up_layout.addWidget(up_right_frame)
        self.layout.addWidget(self.up_frame)

        self.label_img = QLabel()
        # self.label_img.setMaximumHeight(320)
        # self.label_img.setMaximumWidth(480)
        # self.label_img.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
        # self.label_img.setScaledContents(True)

        img = QImage()
        if img.load(os.path.join(icon_path, 'tmp.svg')):
            self.label_img.setPixmap(QPixmap.fromImage(img))
            with open(os.path.join(icon_path, 'tmp.svg'), 'rb') as f:
                self.handler.source = f.read()

        self.up_left_layout.addWidget(self.label_img)

        self.label_img_preview = QLabel()
        # self.label_img_preview.setMaximumHeight(320)
        # self.label_img_preview.setMaximumWidth(480)
        self.label_img_preview.setDisabled(True)
        # # self.label_img_preview.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
        # # self.label_img_preview.setScaledContents(True)
        # data = np.zeros(320 * 240)
        # img = QImage(data, 320, 240, QImage.Format_RGB888)
        # pixmap = QPixmap.fromImage(img)
        # self.label_img_preview.setPixmap(pixmap)
        self.up_right_layout.addWidget(self.label_img_preview)
Exemplo n.º 17
0
    def setup_ui(self):
        self.l = l = QVBoxLayout(self)
        self.setLayout(l)

        self.tl = tl = QFormLayout()
        self.semantic_type = QComboBox(self)
        for key, val in iteritems(self.all_types):
            self.semantic_type.addItem(val, key)
        tl.addRow(_('Type of &semantics:'), self.semantic_type)
        self.target = t = QLineEdit(self)
        t.setPlaceholderText(_('The destination (href) for the link'))
        tl.addRow(_('&Target:'), t)
        l.addLayout(tl)

        self.hline = hl = QFrame(self)
        hl.setFrameStyle(hl.HLine)
        l.addWidget(hl)

        self.h = h = QHBoxLayout()
        l.addLayout(h)

        names = [n for n, linear in self.container.spine_names]
        fn, f = create_filterable_names_list(names,
                                             filter_text=_('Filter files'),
                                             parent=self)
        self.file_names, self.file_names_filter = fn, f
        fn.selectionModel().selectionChanged.connect(
            self.selected_file_changed)
        self.fnl = fnl = QVBoxLayout()
        self.la1 = la = QLabel(_('Choose a &file:'))
        la.setBuddy(fn)
        fnl.addWidget(la), fnl.addWidget(f), fnl.addWidget(fn)
        h.addLayout(fnl), h.setStretch(0, 2)

        fn, f = create_filterable_names_list([],
                                             filter_text=_('Filter locations'),
                                             parent=self)
        self.anchor_names, self.anchor_names_filter = fn, f
        fn.selectionModel().selectionChanged.connect(self.update_target)
        fn.doubleClicked.connect(self.accept,
                                 type=Qt.ConnectionType.QueuedConnection)
        self.anl = fnl = QVBoxLayout()
        self.la2 = la = QLabel(_('Choose a &location (anchor) in the file:'))
        la.setBuddy(fn)
        fnl.addWidget(la), fnl.addWidget(f), fnl.addWidget(fn)
        h.addLayout(fnl), h.setStretch(1, 1)

        self.bb.addButton(self.bb.Help)
        self.bb.helpRequested.connect(self.help_requested)
        l.addWidget(self.bb)
        self.semantic_type_changed()
        self.semantic_type.currentIndexChanged.connect(
            self.semantic_type_changed)
        self.target.textChanged.connect(self.target_text_changed)
Exemplo n.º 18
0
    def _set_left_ui(self):
        left_frame = QFrame()
        self.left_layout = QVBoxLayout(left_frame)
        self.layout.addWidget(left_frame)

        self.label_title = QLabel('untitled')
        self.textEdit = TextEdit()
        self.textEdit.dropEvent = self.dropEvent
        self.textEdit.setDisabled(False)
        self.main_ui.window.setAcceptDrops(True)
        self.left_layout.addWidget(self.label_title)
        self.left_layout.addWidget(self.textEdit)
Exemplo n.º 19
0
    def _set_log_ui(self):
        log_frame = QFrame()
        log_layout = QGridLayout(log_frame)
        self.main_layout.addWidget(log_frame)

        self.textedit_log = QTextEdit()
        self.textedit_log.setAcceptDrops(False)
        # self.textedit_log.setEnabled(False)
        log_layout.addWidget(self.textedit_log)
        btn_clear_log = QPushButton('ClearLog')
        btn_clear_log.clicked.connect(self.clear_log)
        log_layout.addWidget(btn_clear_log)
Exemplo n.º 20
0
 def setup_select_libraries_panel(self):
     self.imported_lib_widgets = []
     self.frames = []
     l = self.slp.layout()
     for lpath in sorted(self.importer.metadata['libraries'], key=lambda x:numeric_sort_key(os.path.basename(x))):
         f = QFrame(self)
         self.frames.append(f)
         l.addWidget(f)
         f.setFrameShape(f.HLine)
         w = ImportLocation(lpath, self.slp)
         l.addWidget(w)
         self.imported_lib_widgets.append(w)
     l.addStretch()
Exemplo n.º 21
0
    def _set_down_ui(self):
        down_frame = QFrame()
        self.down_layout = QHBoxLayout(down_frame)
        self.layout.addWidget(down_frame)

        self.webview = QWebEngineView()
        self.webview.urlChanged.connect(self.update_url)
        self.webview.loadFinished.connect(self.load_finish)
        self.action_back.triggered.connect(self.webview.back)
        self.action_forward.triggered.connect(self.webview.forward)
        self.action_stop.triggered.connect(self.webview.stop)
        self.action_reload.triggered.connect(self.webview.reload)
        self.down_layout.addWidget(self.webview)
Exemplo n.º 22
0
    def _set_right_ui(self):
        right_frame = QFrame()
        right_frame.setMinimumWidth(330)
        self.right_layout = QVBoxLayout(right_frame)
        self.layout.addWidget(right_frame)

        img_frame = QFrame()
        img_frame.setMaximumHeight(250)
        img_layout = QVBoxLayout(img_frame)
        self.right_layout.addWidget(img_frame)

        self.label_img = QLabel()
        self.label_img.setAlignment(QtCore.Qt.AlignRight)
        self.label_img.setAlignment(QtCore.Qt.AlignTop)
        self.label_img.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
        self.label_img.setScaledContents(True)
        data = np.zeros(320 * 240)
        img = QImage(data, 320, 240, QImage.Format_RGB888)
        pixmap = QPixmap.fromImage(img)
        self.label_img.setPixmap(pixmap)
        img_layout.addWidget(self.label_img)

        ctrl_frame = QFrame()
        ctrl_layout = QGridLayout(ctrl_frame)
        self.right_layout.addWidget(ctrl_frame)

        self.btn_connect = QPushButton('Connect')
        self.btn_enable_fb = QPushButton('FB-Disable')
        self.btn_reset_openmv = QPushButton('Reset')
        self.btn_run_openmv = QPushButton('Run')
        ctrl_layout.addWidget(self.btn_connect, 0, 0)
        ctrl_layout.addWidget(self.btn_enable_fb, 1, 0)
        ctrl_layout.addWidget(self.btn_reset_openmv, 2, 0)
        ctrl_layout.addWidget(self.btn_run_openmv, 3, 0)
        self.btn_connect.clicked.connect(self.connect_openmv)
        self.btn_enable_fb.clicked.connect(self.enable_fb)
        self.btn_reset_openmv.clicked.connect(self.reset_openmv)
        self.btn_run_openmv.clicked.connect(self.run_openmv)
Exemplo n.º 23
0
    def _set_ui(self):
        frame = QFrame()
        layout = QGridLayout(frame)
        self.p_layout.addWidget(frame)

        for i, joint in enumerate(self.joints):
            setattr(self, 'checkbox_{}'.format(joint['name']),
                    QCheckBox('Axis-{}'.format(i + 1)))
            setattr(self, 'slider_{}'.format(joint['name']),
                    QSlider(Qt.Horizontal))
            setattr(self, 'spinbox_{}'.format(joint['name']), QDoubleSpinBox())
            checkbox = getattr(self, 'checkbox_{}'.format(joint['name']))
            slider = getattr(self, 'slider_{}'.format(joint['name']))
            spinbox = getattr(self, 'spinbox_{}'.format(joint['name']))
            slider.setMinimum(joint['range'][0] * 10)
            slider.setMaximum(joint['range'][1] * 10)
            slider.setValue(joint['default'] * 10)
            spinbox.setDecimals(1)
            spinbox.setSingleStep(0.1)
            spinbox.setMinimum(joint['range'][0])
            spinbox.setMaximum(joint['range'][1])
            spinbox.setValue(joint['default'])

            slider.mouseReleaseEvent = functools.partial(
                self.set_servo_angle, index=i, source=slider.mouseReleaseEvent)
            spinbox.focusOutEvent = functools.partial(
                self.set_servo_angle, index=i, source=spinbox.focusOutEvent)
            slider.mousePressEvent = functools.partial(
                self.set_flag, index=i, source=slider.mousePressEvent)
            spinbox.focusInEvent = functools.partial(
                self.set_flag, index=i, source=spinbox.focusInEvent)

            checkbox.mouseReleaseEvent = functools.partial(
                self.set_servo_state,
                servo_id=i + 1,
                source=checkbox.mouseReleaseEvent)

            # checkbox.stateChanged.connect(functools.partial(self.checkbox_state_changed, servo_id=i+1))
            slider.valueChanged.connect(
                functools.partial(self.slider_spinbox_related,
                                  slave=spinbox,
                                  scale=0.1))
            spinbox.valueChanged.connect(
                functools.partial(self.slider_spinbox_related,
                                  slave=slider,
                                  scale=10))

            layout.addWidget(checkbox, i, 0)
            layout.addWidget(slider, i, 1)
            layout.addWidget(spinbox, i, 2)
Exemplo n.º 24
0
    def initSrcFiles(self):

        row = 0

        f = QFrame()
        l = QGridLayout()
        f.setLayout(l)

        l.addWidget(QLabel('Source Files :'), row, 0)
        self.srcFilesList = QListWidget()
        self.srcFilesList.setSelectionMode(QAbstractItemView.MultiSelection)
        self.srcFilesList.setAlternatingRowColors(True)
        self.srcFilesList.model().rowsInserted.connect(
            self.handleSrcFilesChanged)
        self.srcFilesList.model().rowsRemoved.connect(
            self.handleSrcFilesChanged)
        selectionModel = self.srcFilesList.selectionModel()
        selectionModel.selectionChanged.connect(
            self.handleSrcFilesSelectionChanged)
        l.addWidget(self.srcFilesList, row, 1, 3, 1)

        self.srcFilesBtn = QPushButton('Select Files')
        self.srcFilesBtn.clicked.connect(self.handleSelectSrcFiles)
        self.srcFilesBtn.setSizePolicy(QSizePolicy.Preferred,
                                       QSizePolicy.Expanding)
        l.addWidget(self.srcFilesBtn, row, 2)
        row += 1

        self.addFilesBtn = QPushButton('Add Files')
        self.addFilesBtn.clicked.connect(self.handleAddSrcFiles)
        self.addFilesBtn.setSizePolicy(QSizePolicy.Preferred,
                                       QSizePolicy.Expanding)
        l.addWidget(self.addFilesBtn, row, 2)
        row += 1

        self.removeFilesBtn = QPushButton('Remove Files')
        self.removeFilesBtn.setEnabled(False)
        self.removeFilesBtn.clicked.connect(self.handleRemoveSrcFiles)
        self.removeFilesBtn.setSizePolicy(QSizePolicy.Preferred,
                                          QSizePolicy.Expanding)
        l.addWidget(self.removeFilesBtn, row, 2)
        row += 1

        self.errorEdit = QPlainTextEdit()
        self.errorEdit.setReadOnly(True)
        l.addWidget(self.errorEdit, row, 1, 1, 2)
        self.comms.errorSignal.connect(self.errorEdit.appendPlainText)

        return f
Exemplo n.º 25
0
    def add_separator(self):
        """
        Add an horizontal line to layout.
        """

        separator = QFrame()
        separator.setFrameShape(QFrame.HLine)
        separator.setFrameShadow(QFrame.Sunken)
        separator.setMinimumSize(self.width(), 2)

        # Add to layout
        self.main_layout.addWidget(separator, self.row, 0, 1, 5)

        # Increment vertically position for next widget
        self.row += 1
Exemplo n.º 26
0
    def __init__(self):
        QWidget.__init__(self, ctx.mainScreen)
        self.setObjectName("InformationWindow")
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.setFixedHeight(50)
        self.setMaximumWidth(800)
        self.setStyleSheet("""
            QFrame#frame { border: 1px solid rgba(255,255,255,30);
                           /*border-radius: 4px;*/
                           background-color: rgba(0,0,0,100);}

            QLabel { border:none;
                     color:#FFFFFF;}

            QProgressBar { border: 1px solid white;}

            QProgressBar::chunk { background-color: #F1610D;
                                  width: 0.5px;}
        """)

        self.gridlayout = QGridLayout(self)
        self.frame = QFrame(self)
        self.frame.setObjectName("frame")
        self.horizontalLayout = QHBoxLayout(self.frame)
        self.horizontalLayout.setContentsMargins(10, 0, 10, 0)

        # Spinner
        self.spinner = QLabel(self.frame)
        self.spinner.setMinimumSize(QSize(16, 16))
        self.spinner.setMaximumSize(QSize(16, 16))
        self.spinner.setIndent(6)
        self.movie = QMovie(':/images/working.mng')
        self.spinner.setMovie(self.movie)
        self.movie.start()
        self.horizontalLayout.addWidget(self.spinner)

        # Message
        self.label = QLabel(self.frame)
        self.label.setAlignment(Qt.AlignCenter)
        self.label.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.icon = QLabel(self.frame)
        self.icon.setFixedWidth(16)
        self.icon.setFixedHeight(16)
        self.horizontalLayout.setSpacing(10)
        self.horizontalLayout.addWidget(self.icon)
        self.horizontalLayout.addWidget(self.label)

        self.gridlayout.addWidget(self.frame, 0, 0, 1, 1)
Exemplo n.º 27
0
    def initFileFrame(self):
        row = 0

        f = QFrame()
        l = QGridLayout()
        f.setLayout(l)
        #         f.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding)

        l.addWidget(QLabel('Destination File :'), row, 0)
        self.destFilenameEdit = QLineEdit(self.destFilename)
        self.destFilenameEdit.setEnabled(False)
        self.destFilenameEdit.textChanged.connect(
            self.handleDestFilenameChanged)
        l.addWidget(self.destFilenameEdit, row, 1)
        row += 1

        self.combineRoutesBox = QCheckBox('combine_routes')
        if self.config[FORMS]['combine_routes']:
            self.combineRoutesBox.setChecked(True)
        else:
            self.combineRoutesBox.setChecked(False)
        self.combineRoutesBox.clicked.connect(self.handleCombineRoutesClicked)
        self.combineRoutesBox.setEnabled(False)
        l.addWidget(self.combineRoutesBox, row, 0)
        row += 1

        addDateInNameBox = QCheckBox('Add date to filename')
        addDateInNameBox.clicked.connect(self.handleAddDateClicked)
        l.addWidget(addDateInNameBox, row, 0)
        if self.config[FORMS]['prefix_date']:
            self.prefixDateInNameBox = QPushButton('prefix_date')
            self.prefixDateInNameBox.setEnabled(False)
        else:
            self.prefixDateInNameBox = QPushButton('Suffix date')
            self.prefixDateInNameBox.setEnabled(False)
        self.prefixDateInNameBox.setToolTip('Click to change to prefix date.')
        self.prefixDateInNameBox.clicked.connect(self.handlePrefixDateClicked)

        l.addWidget(self.prefixDateInNameBox, row, 1)
        row += 1

        addRouteInNameBox = QCheckBox('Add route to filename')
        addRouteInNameBox.clicked.connect(self.handleAddRouteClicked)
        l.addWidget(addRouteInNameBox, row, 0)
        #         row += 1

        return f
Exemplo n.º 28
0
    def initResultPage(self):
        f = QFrame()
        l = QHBoxLayout()
        f.setLayout(l)

        self.convertedTabs = QTabWidget()
        l.addWidget(self.convertedTabs)
        '''
        This just adds a blank page with an empty tab widget.
        Pages are added on the fly when the files are converted as
        this could involve one or many pages depending on combine_route
        flag and number of routes.

        self.convertedTabs is the empty tab widget
        '''

        return f
Exemplo n.º 29
0
    def __init__(self, app, parent=None):
        QMainWindow.__init__(self, parent)

        # Camera

        x, y, z = app.camera_position
        u, v, w = app.camera_target

        self.camera = camera = vtkCamera()
        camera.SetViewUp(0, 0, 1)
        camera.SetPosition(x, y, z)
        camera.SetFocalPoint(u, v, w)

        # Renderer

        self.renderer = renderer = vtkRenderer()
        renderer.SetBackground(1.0, 1.0, 1.0)
        renderer.SetBackground2(0.8, 0.8, 0.8)
        renderer.GradientBackgroundOn()
        renderer.SetActiveCamera(camera)
        renderer.ResetCamera()
        renderer.ResetCameraClippingRange()
        renderer.UseFXAAOn()

        self.window = window = vtkRenderWindow()
        window.AddRenderer(renderer)

        # Widget

        self.frame = frame = QFrame()
        self.widget = widget = QVTKRenderWindowInteractor(frame, rw=window)
        self.layout = layout = QVBoxLayout()
        layout.addWidget(widget)

        frame.setLayout(layout)

        # Interactor

        self.interactor = interactor = widget.GetRenderWindow().GetInteractor()
        interactor.SetInteractorStyle(InteractorStyle())
        interactor.AddObserver('KeyPressEvent', app.keypress)
        interactor.Initialize()
        interactor.Start()

        self.resize(app.width, app.height)
        self.setCentralWidget(frame)
Exemplo n.º 30
0
    def _set_ui(self):
        frame = QFrame()
        layout = QGridLayout(frame)
        self.p_layout.addWidget(frame)

        for i, cartesian in enumerate(self.cartesians):
            label = QLabel('{}:'.format(cartesian['name']))
            setattr(self, 'slider_{}'.format(cartesian['name']),
                    QSlider(Qt.Horizontal))
            setattr(self, 'spinbox_{}'.format(cartesian['name']),
                    QDoubleSpinBox())
            slider = getattr(self, 'slider_{}'.format(cartesian['name']))
            spinbox = getattr(self, 'spinbox_{}'.format(cartesian['name']))
            slider.setMinimum(cartesian['range'][0] * 10)
            slider.setMaximum(cartesian['range'][1] * 10)
            slider.setValue(cartesian['default'] * 10)
            spinbox.setDecimals(1)
            spinbox.setSingleStep(0.1)
            spinbox.setMinimum(cartesian['range'][0])
            spinbox.setMaximum(cartesian['range'][1])
            spinbox.setValue(cartesian['default'])

            if cartesian['name'] != 'radius':
                slider.mouseReleaseEvent = functools.partial(
                    self.set_position,
                    index=i,
                    source=slider.mouseReleaseEvent)
                spinbox.focusOutEvent = functools.partial(
                    self.set_position, index=i, source=spinbox.focusOutEvent)
                slider.mousePressEvent = functools.partial(
                    self.set_flag, index=i, source=slider.mousePressEvent)
                spinbox.focusInEvent = functools.partial(
                    self.set_flag, index=i, source=spinbox.focusInEvent)

            slider.valueChanged.connect(
                functools.partial(self.slider_spinbox_related,
                                  slave=spinbox,
                                  scale=0.1))
            spinbox.valueChanged.connect(
                functools.partial(self.slider_spinbox_related,
                                  slave=slider,
                                  scale=10))

            layout.addWidget(label, i, 0)
            layout.addWidget(slider, i, 1)
            layout.addWidget(spinbox, i, 2)