示例#1
0
 def __init__(self, parent, modal=True, flags=Qt.WindowFlags(), caption="Select Tags", ok_button="Select"):
     QDialog.__init__(self, parent, flags)
     self.setModal(modal)
     self.setWindowTitle(caption)
     lo = QVBoxLayout(self)
     lo.setMargin(10)
     lo.setSpacing(5)
     # tag selector
     self.wtagsel = QListWidget(self)
     lo.addWidget(self.wtagsel)
     #    self.wtagsel.setColumnMode(QListBox.FitToWidth)
     self.wtagsel.setSelectionMode(QListWidget.MultiSelection)
     QObject.connect(self.wtagsel, SIGNAL("itemSelectionChanged()"), self._check_tag)
     # buttons
     lo.addSpacing(10)
     lo2 = QHBoxLayout()
     lo.addLayout(lo2)
     lo2.setContentsMargins(0, 0, 0, 0)
     lo2.setMargin(5)
     self.wokbtn = QPushButton(ok_button, self)
     self.wokbtn.setMinimumWidth(128)
     QObject.connect(self.wokbtn, SIGNAL("clicked()"), self.accept)
     self.wokbtn.setEnabled(False)
     cancelbtn = QPushButton("Cancel", self)
     cancelbtn.setMinimumWidth(128)
     QObject.connect(cancelbtn, SIGNAL("clicked()"), self.reject)
     lo2.addWidget(self.wokbtn)
     lo2.addStretch(1)
     lo2.addWidget(cancelbtn)
     self.setMinimumWidth(384)
     self._tagnames = []
示例#2
0
    def __init__(self, parent):
        super(CharacterDialog, self).__init__(parent)
        self.setWindowTitle(_("KeepKey Seed Recovery"))
        self.character_pos = 0
        self.word_pos = 0
        self.loop = QEventLoop()
        self.word_help = QLabel()
        self.char_buttons = []

        vbox = QVBoxLayout(self)
        vbox.addWidget(WWLabel(CHARACTER_RECOVERY))
        hbox = QHBoxLayout()
        hbox.addWidget(self.word_help)
        for i in range(4):
            char_button = CharacterButton('*')
            char_button.setMaximumWidth(36)
            self.char_buttons.append(char_button)
            hbox.addWidget(char_button)
        self.accept_button = CharacterButton(_("Accept Word"))
        self.accept_button.clicked.connect(partial(self.process_key, 32))
        self.rejected.connect(partial(self.loop.exit, 1))
        hbox.addWidget(self.accept_button)
        hbox.addStretch(1)
        vbox.addLayout(hbox)

        self.finished_button = QPushButton(_("Seed Entered"))
        self.cancel_button = QPushButton(_("Cancel"))
        self.finished_button.clicked.connect(
            partial(self.process_key, Qt.Key_Return))
        self.cancel_button.clicked.connect(self.rejected)
        buttons = Buttons(self.finished_button, self.cancel_button)
        vbox.addSpacing(40)
        vbox.addLayout(buttons)
        self.refresh()
        self.show()
示例#3
0
    def setup_ui(self, parent):
        cm = self.col_metadata
        self.make_widgets(parent, DateTimeEdit)
        self.widgets.append(QLabel(''))
        w = QWidget(parent)
        self.widgets.append(w)
        l = QHBoxLayout()
        l.setContentsMargins(0, 0, 0, 0)
        w.setLayout(l)
        l.addStretch(1)
        self.today_button = QPushButton(_('Set \'%s\' to today')%cm['name'], parent)
        l.addWidget(self.today_button)
        self.clear_button = QPushButton(_('Clear \'%s\'')%cm['name'], parent)
        l.addWidget(self.clear_button)
        l.addStretch(2)

        w = self.main_widget
        format = cm['display'].get('date_format','')
        if not format:
            format = 'dd MMM yyyy'
        w.setDisplayFormat(format)
        w.setCalendarPopup(True)
        w.setMinimumDateTime(UNDEFINED_QDATETIME)
        w.setSpecialValueText(_('Undefined'))
        self.today_button.clicked.connect(w.set_to_today)
        self.clear_button.clicked.connect(w.set_to_clear)
示例#4
0
 def __init__(self, parent=None):
     QWidget.__init__(self, parent)
     self._layout = l = QGridLayout()
     self.setLayout(self._layout)
     self.header = QLabel(
         _('Double click on any entry to change the'
           ' keyboard shortcuts associated with it'))
     l.addWidget(self.header, 0, 0, 1, 3)
     self.view = QTreeView(self)
     self.view.setAlternatingRowColors(True)
     self.view.setHeaderHidden(True)
     self.view.setAnimated(True)
     l.addWidget(self.view, 1, 0, 1, 3)
     self.delegate = Delegate()
     self.view.setItemDelegate(self.delegate)
     self.delegate.sizeHintChanged.connect(self.editor_opened,
                                           type=Qt.QueuedConnection)
     self.delegate.changed_signal.connect(self.changed_signal)
     self.search = SearchBox2(self)
     self.search.initialize('shortcuts_search_history',
                            help_text=_('Search for a shortcut by name'))
     self.search.search.connect(self.find)
     l.addWidget(self.search, 2, 0, 1, 1)
     self.nb = QPushButton(QIcon(I('arrow-down.png')), _('&Next'), self)
     self.pb = QPushButton(QIcon(I('arrow-up.png')), _('&Previous'), self)
     self.nb.clicked.connect(self.find_next)
     self.pb.clicked.connect(self.find_previous)
     l.addWidget(self.nb, 2, 1, 1, 1)
     l.addWidget(self.pb, 2, 2, 1, 1)
     l.setColumnStretch(0, 100)
示例#5
0
文件: undo.py 项目: siebert/calibre
    def __init__(self, model, parent=None):
        QWidget.__init__(self, parent)
        self.l = l = QGridLayout(self)
        self.setLayout(l)
        self.setContentsMargins(0, 0, 0, 0)

        self.view = v = QListView(self)
        self.d = SpacedDelegate(v)
        v.doubleClicked.connect(self.double_clicked)
        v.setItemDelegate(self.d)
        v.setModel(model)
        l.addWidget(v, 0, 0, 1, -1)
        model.dataChanged.connect(self.data_changed)

        self.rb = b = QPushButton(QIcon(I('edit-undo.png')), _('&Revert to'),
                                  self)
        b.setToolTip(_('Revert the book to the selected checkpoint'))
        b.clicked.connect(self.revert_clicked)
        l.addWidget(b, 1, 1)

        self.cb = b = QPushButton(QIcon(I('diff.png')), _('&Compare'), self)
        b.setToolTip(
            _('Compare the state of the book at the selected checkpoint with the current state'
              ))
        b.clicked.connect(self.compare_clicked)
        l.addWidget(b, 1, 0)
示例#6
0
 def __init__(self, movie):
     self.movie = movie
     QDialog.__init__(self, None)
     self.setObjectName("movie_warning")
     self.text_browser = QTextBrowser(self)
     self.text_browser.setObjectName("movie_warning_textbrowser")
     self.text_browser.setMinimumSize(400, 40)
     self.setWindowTitle('Rewind your movie?')
     self.text_browser.setPlainText(
         "You may want to rewind the movie now. If you save the part without "
         +
         "rewinding the movie, the movie file will become invalid because it "
         +
         "depends upon the initial atom positions. The atoms move as the movie "
         +
         "progresses, and saving the part now will save the final positions, "
         + "which are incorrect for the movie you just watched.")
     self.ok_button = QPushButton(self)
     self.ok_button.setObjectName("ok_button")
     self.ok_button.setText("Rewind movie")
     self.cancel_button = QPushButton(self)
     self.cancel_button.setObjectName("cancel_button")
     self.cancel_button.setText("No thanks")
     layout = QGridLayout(self)
     layout.addWidget(self.text_browser, 0, 0, 0, 1)
     layout.addWidget(self.ok_button, 1, 0)
     layout.addWidget(self.cancel_button, 1, 1)
     self.connect(self.ok_button, SIGNAL("clicked()"), self.rewindMovie)
     self.connect(self.cancel_button, SIGNAL("clicked()"), self.noThanks)
    def __init__(self):
        QtGui.QMainWindow.__init__(self)

        ##Creating and new window
        self.win1 = QtGui.QWidget()
        self.win1.setGeometry(10, 20, 300, 100)
        self.win1.setWindowTitle("Data_LOG Plotter")
        self.win1.setFixedWidth(300)

        ## Setting for the vertical layout##
        layout1 = QVBoxLayout()

        ## Adding buttons and stuffs##     ## In Layout format button.resize and button.move won't work
        self.line_edit = QLineEdit()
        button = QPushButton("Browse")
        button2 = QPushButton("Read")
        button3 = QPushButton("Exit Application")

        ##Adding widgets in layout structure##
        layout1.addWidget(self.line_edit)
        layout1.addWidget(button)
        layout1.addWidget(button2)
        layout1.addWidget(button3)
        ##Showing layout items
        self.win1.setLayout(layout1)

        ##Showing the the current window
        self.win1.show()

        button.clicked.connect(self.browse)
        button2.clicked.connect(self.read_file)
        button3.clicked.connect(self.win1.close)
示例#8
0
    def setupCommandAllGUI(self):
        # start all
        row = self.ui.gridLayout.rowCount() + 1

        label = QLabel(self.ui.groupBox)
        label.setText("All Components")
        label.setObjectName('lableCommand_all')

        buttonStart = QPushButton(self.ui.groupBox)
        buttonStart.setText('Start All')
        buttonStart.setObjectName('pushButtonCommand_all_start')
        buttonStart.clicked.connect(partial(self.onStartAll, self.commands))

        buttonStop = QPushButton(self.ui.groupBox)
        buttonStop.setText('Stop All')
        buttonStop.setObjectName('pushButtonCommand_all_stop')
        buttonStop.clicked.connect(partial(self.onStopAll, self.commands))

        buttonRestart = QPushButton(self.ui.groupBox)
        buttonRestart.setText('Restart All')
        buttonRestart.setObjectName('pushButtonCommand_all_restart')
        buttonRestart.clicked.connect(partial(self.onRestartAll,
                                              self.commands))

        self.ui.gridLayout.addWidget(label, row, 0)
        self.ui.gridLayout.addWidget(buttonStart, row, 1)
        self.ui.gridLayout.addWidget(buttonStop, row, 2)
        self.ui.gridLayout.addWidget(buttonRestart, row, 3)
示例#9
0
    def setupCommandGUI(self, commands):
        for name, node in sorted(commands.items(), key=natural_keys):
            row = self.ui.gridLayout.rowCount() + 1

            label = QLabel(self.ui.groupBox)

            if not node.category:
                label.setText(('      ' * node.level) +
                              node.name.replace('___', ' '))
            else:
                label.setText(('      ' *
                               node.level) + '<b>' +
                              node.name.replace('___', ' ') + '</b>')
            label.setObjectName('lableCommand_' + node.name)

            if not node.category:
                buttonStart = QPushButton(self.ui.groupBox)
                buttonStart.setText('Start')
                buttonStart.setObjectName('pushButtonCommand_' + node.name +
                                          '_start')
                buttonStart.clicked.connect(partial(self.onStart, name))

                buttonStop = QPushButton(self.ui.groupBox)
                buttonStop.setText('Stop')
                buttonStop.setObjectName('pushButtonCommand_' + node.name +
                                         '_stop')
                buttonStop.clicked.connect(partial(self.onStop, name))

                buttonRestart = QPushButton(self.ui.groupBox)
                buttonRestart.setText('Restart')
                buttonRestart.setObjectName('pushButtonCommand_' + node.name +
                                            '_restart')
                buttonRestart.clicked.connect(partial(self.onRestart, name))

                progressBar = None
                if node.name in self.progressTopics:
                    progressBar = QProgressBar(self.ui.groupBox)
                    progressBar.setObjectName('progressBarCommand_' +
                                              node.name)
                    progressBar.setValue(0)
                    progressBar.setMaximum(100)
                    progressBar.setMaximumWidth(300)

#                 if node.level == 0 or (node.level == 1 and node.parent.category):
#                     buttonStart.setEnabled(True)
#                     buttonStop.setEnabled(True)
#                     buttonRestart.setEnabled(True)
#                 else:
#                     buttonStart.setEnabled(False)
#                     buttonStop.setEnabled(False)
#                     buttonRestart.setEnabled(False)

                self.ui.gridLayout.addWidget(buttonStart, row, 1)
                self.ui.gridLayout.addWidget(buttonStop, row, 2)
                self.ui.gridLayout.addWidget(buttonRestart, row, 3)
                if not progressBar is None:
                    self.ui.gridLayout.addWidget(progressBar, row, 4)

            self.ui.gridLayout.addWidget(label, row, 0)
            self.setupCommandGUI(node.childs)
    def __init__(self, gui, icon, do_user_config):
        QDialog.__init__(self, gui)
        self.gui = gui
        self.do_user_config = do_user_config

        # The current database shown in the GUI
        self.db = gui.current_db

        self.prefs = PrefsFacade(self.db)

        self.version = Downloader.version

        # The GUI, created and layouted by hand...
        self.layout = QVBoxLayout()
        self.setLayout(self.layout)

        self.setWindowTitle('Beam EBooks Downloader')
        self.setWindowIcon(icon)

        self.log_area = QTextEdit('Log output', self)
        self.log_area.setReadOnly(True)
        self.log_area.setLineWrapMode(QTextEdit.NoWrap)
        self.log_area.setText("")
        self.layout.addWidget(self.log_area)

        self.download_button = QPushButton('Download books', self)
        self.download_button.clicked.connect(self.download)
        self.layout.addWidget(self.download_button)

        self.conf_button = QPushButton('Configure this plugin', self)
        self.conf_button.clicked.connect(self.config)
        self.layout.addWidget(self.conf_button)

        self.resize(self.sizeHint())
示例#11
0
 def __init__(self, movie):
     self.movie = movie
     QDialog.__init__(self, None)
     self.setObjectName("movie_warning")
     self.text_browser = QTextBrowser(self)
     self.text_browser.setObjectName("movie_warning_textbrowser")
     self.text_browser.setMinimumSize(400, 40)
     self.setWindowTitle('Rewind your movie?')
     self.text_browser.setPlainText(  #bruce 080827 revised text
         "You may want to rewind the movie now. The atoms move as the movie "
         "progresses, and saving the part without rewinding will save the "
         "current positions, which is sometimes useful, but will make the "
         "movie invalid, because .dpb files only store deltas relative to "
         "the initial atom positions, and don't store the initial positions "
         "themselves.")
     self.ok_button = QPushButton(self)
     self.ok_button.setObjectName("ok_button")
     self.ok_button.setText("Rewind movie")
     self.cancel_button = QPushButton(self)
     self.cancel_button.setObjectName("cancel_button")
     self.cancel_button.setText(
         "Exit command without rewinding")  #bruce 080827 revised text
     # Note: this is not, in fact, a cancel button --
     # there is no option in the caller to prevent exiting the command.
     # There is also no option to "forward to final position",
     # though for a minimize movie, that might be most useful.
     # [bruce 080827 comment]
     layout = QGridLayout(self)
     layout.addWidget(self.text_browser, 0, 0, 0, 1)
     layout.addWidget(self.ok_button, 1, 0)
     layout.addWidget(self.cancel_button, 1, 1)
     self.connect(self.ok_button, SIGNAL("clicked()"), self.rewindMovie)
     self.connect(self.cancel_button, SIGNAL("clicked()"), self.noThanks)
示例#12
0
    def __init__(self, parent):
        ImageView.__init__(self, parent)
        self.dialog = parent
        self._cdata = None
        self.cover_changed.connect(self.set_pixmap_from_data)

        self.select_cover_button = QPushButton(QIcon(I('document_open.png')),
                                               _('&Browse'), parent)
        self.trim_cover_button = QPushButton(QIcon(I('trim.png')), _('T&rim'),
                                             parent)
        self.remove_cover_button = QPushButton(QIcon(I('trash.png')),
                                               _('&Remove'), parent)

        self.select_cover_button.clicked.connect(self.select_cover)
        self.remove_cover_button.clicked.connect(self.remove_cover)
        self.trim_cover_button.clicked.connect(self.trim_cover)

        self.download_cover_button = QPushButton(_('Download co&ver'), parent)
        self.generate_cover_button = QPushButton(_('&Generate cover'), parent)

        self.download_cover_button.clicked.connect(self.download_cover)
        self.generate_cover_button.clicked.connect(self.generate_cover)

        self.buttons = [
            self.select_cover_button, self.remove_cover_button,
            self.trim_cover_button, self.download_cover_button,
            self.generate_cover_button
        ]

        self.frame_size = (300, 400)
        self.setSizePolicy(
            QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
示例#13
0
文件: single.py 项目: siebert/calibre
    def setupUi(self, *args):  # {{{
        self.resize(990, 670)

        self.download_shortcut = QShortcut(self)
        self.download_shortcut.setKey(
            QKeySequence('Ctrl+D', QKeySequence.PortableText))
        p = self.parent()
        if hasattr(p, 'keyboard'):
            kname = u'Interface Action: Edit Metadata (Edit Metadata) : menu action : download'
            sc = p.keyboard.keys_map.get(kname, None)
            if sc:
                self.download_shortcut.setKey(sc[0])

        self.button_box = bb = QDialogButtonBox(self)
        self.button_box.accepted.connect(self.accept)
        self.button_box.rejected.connect(self.reject)
        self.next_button = QPushButton(QIcon(I('forward.png')), _('Next'),
                                       self)
        self.next_button.setShortcut(QKeySequence('Alt+Right'))
        self.next_button.clicked.connect(self.next_clicked)
        self.prev_button = QPushButton(QIcon(I('back.png')), _('Previous'),
                                       self)
        self.prev_button.setShortcut(QKeySequence('Alt+Left'))

        self.button_box.addButton(self.prev_button, bb.ActionRole)
        self.button_box.addButton(self.next_button, bb.ActionRole)
        self.prev_button.clicked.connect(self.prev_clicked)
        bb.setStandardButtons(bb.Ok | bb.Cancel)
        bb.button(bb.Ok).setDefault(True)

        self.scroll_area = QScrollArea(self)
        self.scroll_area.setFrameShape(QScrollArea.NoFrame)
        self.scroll_area.setWidgetResizable(True)
        self.central_widget = QTabWidget(self)
        self.scroll_area.setWidget(self.central_widget)

        self.l = QVBoxLayout(self)
        self.setLayout(self.l)
        self.l.addWidget(self.scroll_area)
        ll = self.button_box_layout = QHBoxLayout()
        self.l.addLayout(ll)
        ll.addSpacing(10)
        ll.addWidget(self.button_box)

        self.setWindowIcon(QIcon(I('edit_input.png')))
        self.setWindowTitle(BASE_TITLE)

        self.create_basic_metadata_widgets()

        if len(self.db.custom_column_label_map):
            self.create_custom_metadata_widgets()

        self.do_layout()
        geom = gprefs.get('metasingle_window_geometry3', None)
        if geom is not None:
            self.restoreGeometry(bytes(geom))
示例#14
0
    def __init__(self, win):
        self.xmlfile = os.path.join(_sponsordir, 'sponsors.xml')
        self.win = win

        self.needToAsk = False
        self.downloadSponsors = False
        threading.Thread.__init__(self)

        if not self.refreshWanted():
            return
        if env.prefs[sponsor_permanent_permission_prefs_key]:
            # We have a permanent answer so no need for a dialog
            if env.prefs[sponsor_download_permission_prefs_key]:
                self.downloadSponsors = True
            return

        self.needToAsk = True
        QDialog.__init__(self, None)
        self.setObjectName("Permission")
        self.setModal(True)  #This fixes bug 2296. Mitigates bug 2297
        layout = QGridLayout()
        self.setLayout(layout)
        layout.setMargin(0)
        layout.setSpacing(0)
        layout.setObjectName("PermissionLayout")
        self.text_browser = QTextBrowser(self)
        self.text_browser.setObjectName("text_browser")
        layout.addWidget(self.text_browser, 0, 0, 1, 4)
        self.text_browser.setMinimumSize(400, 80)
        self.setWindowTitle('May we use your network connection?')
        self.setWindowIcon(geticon('ui/border/MainWindow.png'))
        self.text_browser.setPlainText(self.text)
        self.accept_button = QPushButton(self)
        self.accept_button.setObjectName("accept_button")
        self.accept_button.setText("Always OK")
        self.accept_once_button = QPushButton(self)
        self.accept_once_button.setObjectName("accept_once_button")
        self.accept_once_button.setText("OK now")
        self.decline_once_button = QPushButton(self)
        self.decline_once_button.setObjectName("decline_once_button")
        self.decline_once_button.setText("Not now")
        self.decline_always_button = QPushButton(self)
        self.decline_always_button.setObjectName("decline_always_button")
        self.decline_always_button.setText("Never")
        layout.addWidget(self.accept_button, 1, 0)
        layout.addWidget(self.accept_once_button, 1, 1)
        layout.addWidget(self.decline_once_button, 1, 2)
        layout.addWidget(self.decline_always_button, 1, 3)
        self.connect(self.accept_button, SIGNAL("clicked()"),
                     self.acceptAlways)
        self.connect(self.accept_once_button, SIGNAL("clicked()"),
                     self.acceptJustOnce)
        self.connect(self.decline_once_button, SIGNAL("clicked()"),
                     self.declineJustOnce)
        self.connect(self.decline_always_button, SIGNAL("clicked()"),
                     self.declineAlways)
示例#15
0
    def setup_ui(self):
        self.setAttribute(Qt.WA_DeleteOnClose, False)
        self.l = l = QVBoxLayout(self)
        self.setLayout(l)

        self.bb.clear()
        self.bb.addButton(self.bb.Close)
        self.splitter = s = QSplitter(self)
        l.addWidget(s), l.addWidget(self.bb)

        self.fonts_view = fv = QTableView(self)
        self.model = m = AllFonts(fv)
        fv.horizontalHeader().setStretchLastSection(True)
        fv.setModel(m)
        fv.setSortingEnabled(True)
        fv.setShowGrid(False)
        fv.setAlternatingRowColors(True)
        fv.setSelectionMode(fv.ExtendedSelection)
        fv.setSelectionBehavior(fv.SelectRows)
        fv.horizontalHeader().setSortIndicator(1, Qt.AscendingOrder)
        self.container = c = QWidget()
        l = c.l = QVBoxLayout(c)
        c.setLayout(l)
        s.addWidget(fv), s.addWidget(c)

        self.cb = b = QPushButton(_('&Change selected fonts'))
        b.setIcon(QIcon(I('auto_author_sort.png')))
        b.clicked.connect(self.change_fonts)
        l.addWidget(b)
        self.rb = b = QPushButton(_('&Remove selected fonts'))
        b.clicked.connect(self.remove_fonts)
        b.setIcon(QIcon(I('trash.png')))
        l.addWidget(b)
        self.eb = b = QPushButton(_('&Embed all fonts'))
        b.setIcon(QIcon(I('embed-fonts.png')))
        b.clicked.connect(self.embed_fonts)
        l.addWidget(b)
        self.sb = b = QPushButton(_('&Subset all fonts'))
        b.setIcon(QIcon(I('subset-fonts.png')))
        b.clicked.connect(self.subset_fonts)
        l.addWidget(b)
        self.refresh_button = b = self.bb.addButton(_('&Refresh'), self.bb.ActionRole)
        b.setToolTip(_('Rescan the book for fonts in case you have made changes'))
        b.setIcon(QIcon(I('view-refresh.png')))
        b.clicked.connect(self.refresh)

        self.la = la = QLabel('<p>' + _(
        ''' All the fonts declared in this book are shown to the left, along with whether they are embedded or not.
            You can remove or replace any selected font and also embed any declared fonts that are not already embedded.'''))
        la.setWordWrap(True)
        l.addWidget(la)

        l.setAlignment(Qt.AlignTop | Qt.AlignHCenter)
示例#16
0
    def setup_ui(self):
        self.block_show = False
        self.properties = []
        self.l = l  = QVBoxLayout(self)
        self.setLayout(l)
        h = QHBoxLayout()
        l.addLayout(h)
        self.la = la = QLabel(_('&Edit theme:'))
        h.addWidget(la)
        self.theme = t = QComboBox(self)
        la.setBuddy(t)
        t.addItems(sorted(custom_theme_names()))
        t.setMinimumWidth(200)
        if t.count() > 0:
            t.setCurrentIndex(0)
        t.currentIndexChanged[int].connect(self.show_theme)
        h.addWidget(t)

        self.add_button = b = QPushButton(QIcon(I('plus.png')), _('Add &new theme'), self)
        b.clicked.connect(self.create_new_theme)
        h.addWidget(b)

        self.remove_button = b = QPushButton(QIcon(I('minus.png')), _('&Remove theme'), self)
        b.clicked.connect(self.remove_theme)
        h.addWidget(b)
        h.addStretch(1)

        self.scroll = s = QScrollArea(self)
        self.w = w = QWidget(self)
        s.setWidget(w), s.setWidgetResizable(True)
        self.cl = cl = QVBoxLayout()
        w.setLayout(cl)

        from calibre.gui2.tweak_book.editor.text import TextEdit
        self.preview = p = TextEdit(self, expected_geometry=(73, 50))
        p.load_text(HELP_TEXT.format(
                *['<b>%s</b>' % x for x in (
                    'Normal', 'Visual', 'CursorLine', 'LineNr', 'MatchParen',
                    'Function', 'Type', 'Statement', 'Constant', 'SpecialCharacter', 'Error', 'SpellError', 'Comment'
                )]
            ))
        p.setMaximumWidth(p.size_hint.width() + 5)
        s.setMinimumWidth(600)
        self.splitter = sp = QSplitter(self)
        l.addWidget(sp)
        sp.addWidget(s), sp.addWidget(p)

        self.bb.clear()
        self.bb.addButton(self.bb.Close)
        l.addWidget(self.bb)

        if self.theme.count() > 0:
            self.show_theme()
示例#17
0
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)

        self.l = l = QGridLayout(self)
        self.setLayout(l)

        self.l1 = l1 = QLabel('<p>'+_(
            'You can control the color of columns in the'
            ' book list by creating "rules" that tell calibre'
            ' what color to use. Click the Add Rule button below'
            ' to get started.<p>You can <b>change an existing rule</b> by double'
            ' clicking it.'))
        l1.setWordWrap(True)
        l.addWidget(l1, 0, 0, 1, 2)

        self.add_button = QPushButton(QIcon(I('plus.png')), _('Add Rule'),
                self)
        self.remove_button = QPushButton(QIcon(I('minus.png')),
                _('Remove Rule'), self)
        self.add_button.clicked.connect(self.add_rule)
        self.remove_button.clicked.connect(self.remove_rule)
        l.addWidget(self.add_button, 1, 0)
        l.addWidget(self.remove_button, 1, 1)

        self.g = g = QGridLayout()
        self.rules_view = QListView(self)
        self.rules_view.doubleClicked.connect(self.edit_rule)
        self.rules_view.setSelectionMode(self.rules_view.SingleSelection)
        self.rules_view.setAlternatingRowColors(True)
        self.rtfd = RichTextDelegate(parent=self.rules_view, max_width=400)
        self.rules_view.setItemDelegate(self.rtfd)
        g.addWidget(self.rules_view, 0, 0, 2, 1)

        self.up_button = b = QToolButton(self)
        b.setIcon(QIcon(I('arrow-up.png')))
        b.setToolTip(_('Move the selected rule up'))
        b.clicked.connect(self.move_up)
        g.addWidget(b, 0, 1, 1, 1, Qt.AlignTop)
        self.down_button = b = QToolButton(self)
        b.setIcon(QIcon(I('arrow-down.png')))
        b.setToolTip(_('Move the selected rule down'))
        b.clicked.connect(self.move_down)
        g.addWidget(b, 1, 1, 1, 1, Qt.AlignBottom)

        l.addLayout(g, 2, 0, 1, 2)
        l.setRowStretch(2, 10)

        self.add_advanced_button = b = QPushButton(QIcon(I('plus.png')),
                _('Add Advanced Rule'), self)
        b.clicked.connect(self.add_advanced)
        l.addWidget(b, 3, 0, 1, 2)
示例#18
0
 def __init__(self, parent, modal=True, flags=Qt.WindowFlags()):
     QDialog.__init__(self, parent, flags)
     self.setModal(modal)
     self.setWindowTitle("Add FITS brick")
     lo = QVBoxLayout(self)
     lo.setMargin(10)
     lo.setSpacing(5)
     # file selector
     self.wfile = FileSelector(self,
                               label="FITS filename:",
                               dialog_label="FITS file",
                               default_suffix="fits",
                               file_types="FITS files (*.fits *.FITS)",
                               file_mode=QFileDialog.ExistingFile)
     lo.addWidget(self.wfile)
     # overwrite or add mode
     lo1 = QGridLayout()
     lo.addLayout(lo1)
     lo1.setContentsMargins(0, 0, 0, 0)
     lo1.addWidget(QLabel("Padding factor:", self), 0, 0)
     self.wpad = QLineEdit("2", self)
     self.wpad.setValidator(QDoubleValidator(self))
     lo1.addWidget(self.wpad, 0, 1)
     lo1.addWidget(QLabel("Assign source name:", self), 1, 0)
     self.wname = QLineEdit(self)
     lo1.addWidget(self.wname, 1, 1)
     # OK/cancel buttons
     lo.addSpacing(10)
     lo2 = QHBoxLayout()
     lo.addLayout(lo2)
     lo2.setContentsMargins(0, 0, 0, 0)
     lo2.setMargin(5)
     self.wokbtn = QPushButton("OK", self)
     self.wokbtn.setMinimumWidth(128)
     QObject.connect(self.wokbtn, SIGNAL("clicked()"), self.accept)
     self.wokbtn.setEnabled(False)
     cancelbtn = QPushButton("Cancel", self)
     cancelbtn.setMinimumWidth(128)
     QObject.connect(cancelbtn, SIGNAL("clicked()"), self.reject)
     lo2.addWidget(self.wokbtn)
     lo2.addStretch(1)
     lo2.addWidget(cancelbtn)
     self.setMinimumWidth(384)
     # signals
     QObject.connect(self.wfile, SIGNAL("filenameSelected"),
                     self._fileSelected)
     # internal state
     self.qerrmsg = QErrorMessage(self)
示例#19
0
    def __init__(self, parent):
        QDialog.__init__(self, parent)

        self.setWindowTitle(self.tr("Connect"))

        # Create inputs
        self._hostLine = QLineEdit(self)
        self._hostLine.setText(DEFAULT_HOST)
        self._portLine = QLineEdit(self)
        self._portLine.setText(DEFAULT_PORT)
        self._databaseLine = QLineEdit(self)
        self._databaseLine.setText(DEFAULT_DATABASE)
        self._userLine = QLineEdit(self)
        self._userLine.setText(DEFAULT_USER)
        self._passwordLine = QLineEdit(self)
        self._passwordLine.setText(DEFAULT_PASSWORD)
        validateButton = QPushButton(self.tr("Ok"), self)

        self.connect(validateButton, SIGNAL("clicked()"), self.validate)

        # Set a form layout
        layout = QFormLayout(self)
        layout.addRow(self.tr("Host : "), self._hostLine)
        layout.addRow(self.tr("Port : "), self._portLine)
        layout.addRow(self.tr("Database : "), self._databaseLine)
        layout.addRow(self.tr("User : "******"Password : "), self._passwordLine)
        layout.addWidget(validateButton)
        self.setLayout(layout)
        self.show()
示例#20
0
    def getTitleButton(self,
                       title,
                       parent=None,
                       showExpanded=True):  #Ninad 070206
        """ Return the groupbox title pushbutton. The pushbutton is customized
        such that  it appears as a title bar to the user. If the user clicks on
        this 'titlebar' it sends appropriate signals to open or close the
        groupboxes   'name = string -- title of the groupbox
        'showExpanded' = boolean .. NE1 uses a different background
        image in the button's  Style Sheet depending on the bool.
        (i.e. if showExpanded = True it uses a opened group image  '^')
        See also: getGroupBoxTitleCheckBox , getGroupBoxButtonStyleSheet  methods
        """

        button = QPushButton(title, parent)
        button.setFlat(False)
        button.setAutoFillBackground(True)

        button.setStyleSheet(self.getTitleButtonStyleSheet(showExpanded))
        button.setPalette(self.getTitleButtonPalette())

        #ninad 070221 set a non existant 'Ghost Icon' for this button
        #By setting such an icon, the button text left aligns!
        #(which what we want :-) )
        #So this might be a bug in Qt4.2.  If we don't use the following kludge,
        #there is no way to left align the push button text but to subclass it.
        #(could mean a lot of work for such a minor thing)  So OK for now

        button.setIcon(geticon("ui/actions/Properties Manager/GHOST_ICON"))

        return button
示例#21
0
    def settings_dialog(self):
        get_label = lambda: self.wallet.get_client().features.label
        update_label = lambda: current_label_label.setText("Label: %s" %
                                                           get_label())

        d = QDialog()
        layout = QGridLayout(d)
        layout.addWidget(QLabel("Trezor Options"), 0, 0)
        layout.addWidget(QLabel("ID:"), 1, 0)
        layout.addWidget(
            QLabel(" %s" % self.wallet.get_client().get_device_id()), 1, 1)

        def modify_label():
            response = QInputDialog().getText(
                None, "Set New Trezor Label",
                "New Trezor Label:  (upon submission confirm on Trezor)")
            if not response[1]:
                return
            new_label = str(response[0])
            twd.start("Please confirm label change on Trezor")
            status = self.wallet.get_client().apply_settings(label=new_label)
            twd.stop()
            update_label()

        current_label_label = QLabel()
        update_label()
        change_label_button = QPushButton("Modify")
        change_label_button.clicked.connect(modify_label)
        layout.addWidget(current_label_label, 3, 0)
        layout.addWidget(change_label_button, 3, 1)

        if d.exec_():
            return True
        else:
            return False
示例#22
0
    def __init__(self, device, rules):
        QGroupBox.__init__(self, _('Format specific sending'))
        self._device = weakref.ref(device)
        self.l = l = QVBoxLayout()
        self.setLayout(l)
        self.la = la = QLabel(
            '<p>' +
            _('''You can create rules that control where ebooks of a specific
            format are sent to on the device. These will take precedence over
            the folders specified above.'''))
        la.setWordWrap(True)
        l.addWidget(la)
        self.sa = sa = QScrollArea(self)
        sa.setWidgetResizable(True)
        self.w = w = QWidget(self)
        w.l = QVBoxLayout()
        w.setLayout(w.l)
        sa.setWidget(w)
        l.addWidget(sa)
        self.widgets = []
        for rule in rules:
            r = Rule(device, rule)
            self.widgets.append(r)
            w.l.addWidget(r)
            r.remove.connect(self.remove_rule)

        if not self.widgets:
            self.add_rule()

        self.b = b = QPushButton(QIcon(I('plus.png')), _('Add a &new rule'))
        l.addWidget(b)
        b.clicked.connect(self.add_rule)
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Ignored)
示例#23
0
    def settings_dialog(self):
        try:
            device_id = self.get_client().get_device_id()
        except BaseException as e:
            self.window.show_message(str(e))
            return
        get_label = lambda: self.get_client().features.label
        update_label = lambda: current_label_label.setText("Label: %s" %
                                                           get_label())
        d = QDialog()
        layout = QGridLayout(d)
        layout.addWidget(QLabel("KeepKey Options"), 0, 0)
        layout.addWidget(QLabel("ID:"), 1, 0)
        layout.addWidget(QLabel(" %s" % device_id), 1, 1)

        def modify_label():
            response = QInputDialog().getText(
                None, "Set New KeepKey Label",
                "New KeepKey Label:  (upon submission confirm on KeepKey)")
            if not response[1]:
                return
            new_label = str(response[0])
            self.handler.show_message("Please confirm label change on KeepKey")
            status = self.get_client().apply_settings(label=new_label)
            self.handler.stop()
            update_label()

        current_label_label = QLabel()
        update_label()
        change_label_button = QPushButton("Modify")
        change_label_button.clicked.connect(modify_label)
        layout.addWidget(current_label_label, 3, 0)
        layout.addWidget(change_label_button, 3, 1)
        d.exec_()
示例#24
0
    def __init__(self, main):

        self.main = main

        def updateLogDisplay():
            self.pyLogTextDisplay.setText(getLastBytesOfFile(ARMORY_LOG_FILE))
            self.pyLogTextDisplay.moveCursor(QtGui.QTextCursor.End)
            self.cppLogTextDisplay.setText(getLastBytesOfFile(ARMCPP_LOG_FILE))
            self.cppLogTextDisplay.moveCursor(QtGui.QTextCursor.End)

        lblHeader = QRichLabel(tr("""<b>Log File Display</b>"""), doWrap=False)
        self.updateButton = QPushButton("Update")
        self.main.connect(self.updateButton, SIGNAL('clicked()'),
                          updateLogDisplay)
        topRow = makeHorizFrame([lblHeader, self.updateButton, 'stretch'])

        self.pyLogTextDisplay = self.createLogDisplay()
        self.cppLogTextDisplay = self.createLogDisplay()
        logTabPanel = QTabWidget()
        logTabPanel.addTab(self.pyLogTextDisplay, "Python Log")
        logTabPanel.addTab(self.cppLogTextDisplay, "C++ Log")

        self.logFrame = makeVertFrame([topRow, logTabPanel])

        # Now set the scrollarea widget to the layout
        self.tabToDisplay = QScrollArea()
        self.tabToDisplay.setWidgetResizable(True)
        self.tabToDisplay.setWidget(self.logFrame)
        updateLogDisplay()
示例#25
0
 def _getTitleButton(self, 
                     parentWidget = None,
                     title        = '', 
                     showExpanded = True ):
     """
     Return the group box title push button. The push button is customized 
     such that it appears as a title bar at the top of the group box. 
     If the user clicks on this 'title bar' it sends a signal to open or 
     close the group box.
     
     @param parentWidget: The parent dialog or group box containing this 
                          widget.
     @type  parentWidget: PM_Dialog or PM_GroupBox
     
     @param title: The button title.
     @type  title: str 
     
     @param showExpanded: dDetermines whether the expand or collapse image is 
                          displayed on the title button.
     @type  showExpanded: bool
                          
     @see: L{_getTitleButtonStyleSheet()}
     
     @Note: Including a title button should only be legal if the parentWidget
            is a PM_Dialog.
     """
     
     button  = QPushButton(title, parentWidget)
     button.setFlat(False)
     button.setAutoFillBackground(True)
     
     button.setStyleSheet(self._getTitleButtonStyleSheet(showExpanded))     
     
     return button
示例#26
0
    def __init__(self, parent):
        QDialog.__init__(self, parent)

        self.setWindowTitle("Import data from database")
        layout = QFormLayout(self)

        layout.addRow(
            QLabel("Database : " + self.parent().controller().databaseName()))
        layout.addRow(QLabel("Tables : "))
        self._tables = self.parent().controller().databaseTables()
        self._tablesItem = []
        for t in self._tables:
            cb = QCheckBox(t)
            self._tablesItem.append(cb)
            layout.addRow(cb)

        self._subset = QLineEdit(self)
        layout.addRow("Subset : ", self._subset)

        # TODO add More option (geom column, ...)
        validateButton = QPushButton("Ok", self)
        self.connect(validateButton, SIGNAL("clicked()"), self.validate)
        layout.addRow(validateButton)
        self.setLayout(layout)
        self.show()
示例#27
0
    def __init__(self, process, calculation):
        """
        """
        QDialog.__init__(self, None, None, True)

        self.process = process

        self.setCaption("Please Wait")

        pbVBLayout = QVBoxLayout(self, 11, 6, "ProgressBarDialogLayout")

        msgLabel = QLabel(self, "msgLabel")
        msgLabel.setAlignment(QLabel.AlignCenter)

        if calculation == 'Energy':
            msgLabel.setText("Calculating Energy ...")
        else:
            msgLabel.setText("Optimizing ...")

        pbVBLayout.addWidget(msgLabel)

        self.msgLabel2 = QLabel(self, "msgLabel2")
        self.msgLabel2.setAlignment(QLabel.AlignCenter)
        self.msgLabel2.setText('')

        pbVBLayout.addWidget(self.msgLabel2)

        cancelButton = QPushButton(self, "canel")
        cancelButton.setText("Cancel")

        pbVBLayout.addWidget(cancelButton)

        self.resize(QSize(248, 146).expandedTo(self.minimumSizeHint()))
        self.connect(cancelButton, SIGNAL("clicked()"), self.reject)
        return
示例#28
0
 def addIconButton(self, icon, func):
     button = QPushButton()
     button.setIcon(icon)
     setattr(self, "button%d" % self.buttonNum, button)
     self.buttonNum += 1
     self.buttonLayout.addWidget(button)
     self.connect(button, SIGNAL('clicked()'), func)
示例#29
0
    def __init__(self, parent=None, name=None, modal=0, fl=None):
        if fl is None:
            fl = Qt.Dialog | Qt.WindowTitleHint
        QDialog.__init__(self, parent, Qt.Dialog | Qt.WindowTitleHint)
        self.setModal(modal)

        image0 = pixmaps.tigger_logo.pm()

        # self.setSizeGripEnabled(0)
        LayoutWidget = QWidget(self)
        LayoutWidget.setSizePolicy(QSizePolicy.MinimumExpanding,
                                   QSizePolicy.MinimumExpanding)

        lo_top = QVBoxLayout(LayoutWidget)

        lo_title = QHBoxLayout(None)

        self.title_icon = QLabel(LayoutWidget)
        self.title_icon.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        self.title_icon.setPixmap(image0)
        self.title_icon.setAlignment(Qt.AlignCenter)
        lo_title.addWidget(self.title_icon)

        self.title_label = QLabel(LayoutWidget)
        self.title_label.setWordWrap(True)
        lo_title.addWidget(self.title_label)
        lo_top.addLayout(lo_title)

        lo_logos = QHBoxLayout(None)
        lo_top.addLayout(lo_logos)
        # for logo in ("astron",):
        #   icon = QLabel(LayoutWidget)
        #   icon.setSizePolicy(QSizePolicy.Fixed,QSizePolicy.Fixed)
        #   icon.setPixmap(getattr(pixmaps,logo+"_logo").pm())
        #   icon.setAlignment(Qt.AlignCenter)
        #   lo_logos.addWidget(icon)

        lo_mainbtn = QHBoxLayout(None)
        lo_mainbtn.addItem(
            QSpacerItem(20, 20, QSizePolicy.Expanding, QSizePolicy.Minimum))
        lo_top.addLayout(lo_mainbtn)

        self.btn_ok = QPushButton(LayoutWidget)
        self.btn_ok.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        self.btn_ok.setMinimumSize(QSize(60, 0))
        self.btn_ok.setAutoDefault(1)
        self.btn_ok.setDefault(1)
        lo_mainbtn.addWidget(self.btn_ok)
        lo_mainbtn.addItem(
            QSpacerItem(20, 20, QSizePolicy.Expanding, QSizePolicy.Minimum))

        self.languageChange()

        LayoutWidget.adjustSize()

        # LayoutWidget.resize(QSize(489,330).expandedTo(LayoutWidget.minimumSizeHint()))
        # self.resize(QSize(489,330).expandedTo(self.minimumSizeHint()))
        # self.clearWState(Qt.WState_Polished)

        self.connect(self.btn_ok, SIGNAL("clicked()"), self.accept)
示例#30
0
    def __init__(self, parent=None, name=None, modal=1, fl=0):
        #QDialog.__init__(self,parent,name,modal,fl)
        QDialog.__init__(self, parent)
        self.setModal(modal)
        qt4todo("handle flags in TextMessageBox.__init__")

        if name is None: name = "TextMessageBox"
        self.setObjectName(name)
        self.setWindowTitle(name)

        TextMessageLayout = QVBoxLayout(self)
        TextMessageLayout.setMargin(5)
        TextMessageLayout.setSpacing(1)

        self.text_edit = QTextEdit(self)

        TextMessageLayout.addWidget(self.text_edit)

        self.close_button = QPushButton(self)
        self.close_button.setText("Close")
        TextMessageLayout.addWidget(self.close_button)

        self.resize(QSize(350, 300).expandedTo(self.minimumSizeHint()))
        # Width changed from 300 to 350. Now hscrollbar doesn't appear in
        # Help > Graphics Info textbox. mark 060322
        qt4todo('self.clearWState(Qt.WState_Polished)')  # what is this?

        self.connect(self.close_button, SIGNAL("clicked()"), self.close)