예제 #1
1
 def build_connection_group (self):
     
     self.connect_group = QGroupBox(parent =  self.main_widget)
     self.connect_group.setTitle('Connection')
     self.connect_group.setStyleSheet("QGroupBox { border: 1px solid gray; border-radius: 3px;  margin-top: 0.5em; } QGroupBox::title {  subcontrol-origin: margin; left: 10px; padding: 0 3px 0 3px;}")
     
     self.connect_label = QLabel("IP Address")
     self.connect_line = QLineEdit("10.0.6.65")
     self.connect_line.setFixedWidth(100)
     
     self.connect_button = QPushButton("Connect")
     self.connect_button.clicked.connect(self.connection_handler)
     
     self.port_label = QLabel("Port")
     self.port_line = QLineEdit("4000")
     self.port_line.setFixedWidth(50)
     self.led_connected = QLed(parent = self.main_widget)
     self.led_connected.turnOff()
     
     self.connect_layout = QHBoxLayout()
     
     self.connect_layout.addWidget(self.connect_label)
     self.connect_layout.addWidget(self.connect_line)
     self.connect_layout.addWidget(self.port_label)
     self.connect_layout.addWidget(self.port_line)
     self.connect_layout.addWidget(self.led_connected)
     self.connect_layout.addWidget(self.connect_button)
     
     self.connect_group.setLayout(self.connect_layout)
예제 #2
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()
    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)
예제 #4
0
    def __init__(
        self,
        parent=None,
    ):
        print repr(self), repr(parent)
        QDialog.__init__(self, parent)
        self.parent = parent
        self.setWindowTitle("{0} {1}: Rename {0}".format(
            PLUGIN_NAME, PLUGIN_VERSION, parent.key_type_name))
        layout = QVBoxLayout(self)
        self.setLayout(layout)

        data_group_box = QGroupBox('', self)
        layout.addWidget(data_group_box)
        data_group_box_layout = QVBoxLayout()
        data_group_box.setLayout(data_group_box_layout)

        data_group_box_layout.addWidget(QLabel('New Key Name:', self))
        self.key_ledit = QLineEdit(self.parent.listy.currentItem().text(),
                                   self)
        self.key_ledit.setToolTip(
            u"Enter a new name for this existing {0}.".format(
                parent.key_type_name))
        data_group_box_layout.addWidget(self.key_ledit)

        layout.addSpacing(20)

        self.button_box = QDialogButtonBox(QDialogButtonBox.Ok
                                           | QDialogButtonBox.Cancel)
        self.button_box.accepted.connect(self.accept)
        self.button_box.rejected.connect(self.reject)
        layout.addWidget(self.button_box)

        self.resize(self.sizeHint())
예제 #5
0
    def __init__(
        self,
        parent=None,
    ):
        QDialog.__init__(self, parent)
        self.parent = parent
        self.setWindowTitle(u"{0} {1}: Add New Mobipocket PID".format(
            PLUGIN_NAME, PLUGIN_VERSION))
        layout = QVBoxLayout(self)
        self.setLayout(layout)

        data_group_box = QGroupBox(u"", self)
        layout.addWidget(data_group_box)
        data_group_box_layout = QVBoxLayout()
        data_group_box.setLayout(data_group_box_layout)

        key_group = QHBoxLayout()
        data_group_box_layout.addLayout(key_group)
        key_group.addWidget(QLabel(u"PID:", self))
        self.key_ledit = QLineEdit("", self)
        self.key_ledit.setToolTip(
            u"Enter a Mobipocket PID. Mobipocket PIDs are 8 or 10 characters long. Mobipocket PIDs are case-sensitive, so be sure to enter the upper and lower case letters unchanged."
        )
        key_group.addWidget(self.key_ledit)
        key_label = QLabel(_(''), self)
        key_label.setAlignment(Qt.AlignHCenter)
        data_group_box_layout.addWidget(key_label)

        self.button_box = QDialogButtonBox(QDialogButtonBox.Ok
                                           | QDialogButtonBox.Cancel)
        self.button_box.accepted.connect(self.accept)
        self.button_box.rejected.connect(self.reject)
        layout.addWidget(self.button_box)

        self.resize(self.sizeHint())
예제 #6
0
    def __init__(self):
        QWidget.__init__(self)
        self.l = QVBoxLayout()
        self.setLayout(self.l)

        self.ll = QHBoxLayout()
        self.server_label = QLabel("Server:")
        self.ll.addWidget(self.server_label)

        self.lsb_server = QLineEdit(self)
        self.lsb_server.setText(prefs["lsb_server"])
        self.ll.addWidget(self.lsb_server)
        self.server_label.setBuddy(self.lsb_server)
        self.l.addLayout(self.ll)

        self.lll = QHBoxLayout()
        self.librarian_label = QLabel("Librarian:")
        self.lll.addWidget(self.librarian_label)

        self.librarian = QLineEdit(self)
        self.librarian.setText(prefs["librarian"])
        self.lll.addWidget(self.librarian)
        self.librarian_label.setBuddy(self.librarian)
        self.l.addLayout(self.lll)

        self.llll = QHBoxLayout()
        self.library_uuid_label = QLabel("Library ID:")
        self.llll.addWidget(self.library_uuid_label)

        self.library_uuid = QLabel(self)
        self.library_uuid.setText(prefs["library_uuid"])
        self.llll.addWidget(self.library_uuid)
        self.library_uuid_label.setBuddy(self.library_uuid)
        self.l.addLayout(self.llll)
예제 #7
0
    def setup_ui(self):
        self.l = l = QFormLayout(self)
        self.setLayout(l)

        self.title = t = QLineEdit(self)
        l.addRow(_('&Title:'), t)
        t.setFocus(Qt.OtherFocusReason)

        self.authors = a = QLineEdit(self)
        l.addRow(_('&Authors:'), a)
        a.setText(tprefs.get('previous_new_book_authors', ''))

        self.languages = la = LanguagesEdit(self)
        l.addRow(_('&Language:'), la)
        la.lang_codes = (tprefs.get('previous_new_book_lang',
                                    canonicalize_lang(get_lang())), )

        bb = self.bb
        l.addRow(bb)
        bb.clear()
        bb.addButton(bb.Cancel)
        b = bb.addButton('&EPUB', bb.AcceptRole)
        b.clicked.connect(partial(self.set_fmt, 'epub'))
        b = bb.addButton('&AZW3', bb.AcceptRole)
        b.clicked.connect(partial(self.set_fmt, 'azw3'))
예제 #8
0
    def setup_ui(self):
        self.l = l = QGridLayout()
        self.setLayout(l)

        self.la = la = QLabel(
            _('Arrange the files in this book into sub-folders based on their types.'
              ' If you leave a folder blank, the files will be placed in the root.'
              ))
        la.setWordWrap(True)
        l.addWidget(la, 0, 0, 1, -1)

        folders = tprefs['folders_for_types']
        for i, (typ, text) in enumerate(self.TYPE_MAP):
            la = QLabel('&' + text)
            setattr(self, '%s_label' % typ, la)
            le = QLineEdit(self)
            setattr(self, '%s_folder' % typ, le)
            val = folders.get(typ, '')
            if val and not val.endswith('/'):
                val += '/'
            le.setText(val)
            la.setBuddy(le)
            l.addWidget(la, i + 1, 0)
            l.addWidget(le, i + 1, 1)
        self.la2 = la = QLabel(
            _('Note that this will only arrange files inside the book,'
              ' it will not affect how they are displayed in the Files Browser'
              ))
        la.setWordWrap(True)
        l.addWidget(la, i + 2, 0, 1, -1)
        l.addWidget(self.bb, i + 3, 0, 1, -1)
예제 #9
0
class AddKindleDialog(QDialog):
    def __init__(self, parent=None,):
        QDialog.__init__(self, parent)
        self.parent = parent
        self.setWindowTitle(u"{0} {1}: Getting Default Kindle for Mac/PC Key".format(PLUGIN_NAME, PLUGIN_VERSION))
        layout = QVBoxLayout(self)
        self.setLayout(layout)

        try:
            self.default_key = retrieve_kindle_keys()[0]
        except:
            self.default_key = u""

        self.button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)

        if len(self.default_key)>0:
            data_group_box = QGroupBox(u"", self)
            layout.addWidget(data_group_box)
            data_group_box_layout = QVBoxLayout()
            data_group_box.setLayout(data_group_box_layout)

            key_group = QHBoxLayout()
            data_group_box_layout.addLayout(key_group)
            key_group.addWidget(QLabel(u"Unique Key Name:", self))
            self.key_ledit = QLineEdit("", self)
            self.key_ledit.setToolTip(u"<p>Enter an identifying name for the current default Kindle for Mac/PC key.")
            key_group.addWidget(self.key_ledit)
            key_label = QLabel(_(''), self)
            key_label.setAlignment(Qt.AlignHCenter)
            data_group_box_layout.addWidget(key_label)
            self.button_box.accepted.connect(self.accept)
        else:
            default_key_error = QLabel(u"The default encryption key for Kindle for Mac/PC could not be found.", self)
            default_key_error.setAlignment(Qt.AlignHCenter)
            layout.addWidget(default_key_error)
            # if no default, bot buttons do the same
            self.button_box.accepted.connect(self.reject)

        self.button_box.rejected.connect(self.reject)
        layout.addWidget(self.button_box)

        self.resize(self.sizeHint())

    @property
    def key_name(self):
        return unicode(self.key_ledit.text().toUtf8(), 'utf8').strip()

    @property
    def key_value(self):
        return self.default_key


    def accept(self):
        if len(self.key_name) == 0 or self.key_name.isspace():
            errmsg = u"All fields are required!"
            return error_dialog(None, "{0} {1}".format(PLUGIN_NAME, PLUGIN_VERSION), errmsg, show=True, show_copy_button=False)
        if len(self.key_name) < 4:
            errmsg = u"Key name must be at <i>least</i> 4 characters long!"
            return error_dialog(None, "{0} {1}".format(PLUGIN_NAME, PLUGIN_VERSION), errmsg, show=True, show_copy_button=False)
        QDialog.accept(self)
예제 #10
0
파일: widgets.py 프로젝트: Hainish/calibre
    def setup_ui(self):
        self.l = l = QFormLayout(self)
        self.setLayout(l)

        la = self.la = QLabel(_(
            'You can import an HTML or DOCX file directly as an EPUB and edit it. The EPUB'
            ' will be generated with minimal changes from the source, unlike doing a full'
            ' conversion in calibre.'))
        la.setWordWrap(True)
        l.addRow(la)

        self.h1 = h1 = QHBoxLayout()
        self.src = src = QLineEdit(self)
        src.setPlaceholderText(_('Choose the file to import'))
        h1.addWidget(src)
        self.b1 = b = QToolButton(self)
        b.setIcon(QIcon(I('document_open.png')))
        b.setText(_('Choose file'))
        h1.addWidget(b)
        l.addRow(_('Source file'), h1)
        b.clicked.connect(self.choose_source)
        b.setFocus(Qt.OtherFocusReason)

        self.h2 = h1 = QHBoxLayout()
        self.dest = src = QLineEdit(self)
        src.setPlaceholderText(_('Choose the location for the newly created EPUB'))
        h1.addWidget(src)
        self.b2 = b = QToolButton(self)
        b.setIcon(QIcon(I('document_open.png')))
        b.setText(_('Choose file'))
        h1.addWidget(b)
        l.addRow(_('Destination file'), h1)
        b.clicked.connect(self.choose_destination)

        l.addRow(self.bb)
예제 #11
0
    def __init__(self, stats, location, parent=None):
        QDialog.__init__(self, parent)
        self.setWindowTitle(_('No library found'))
        self._l = l = QGridLayout(self)
        self.setLayout(l)
        self.stats, self.location = stats, location

        loc = self.oldloc = location.replace('/', os.sep)
        self.header = QLabel(
            _('No existing calibre library was found at %s. '
              'If the library was moved, select its new location below. '
              'Otherwise calibre will forget this library.') % loc)
        self.header.setWordWrap(True)
        ncols = 2
        l.addWidget(self.header, 0, 0, 1, ncols)
        self.cl = QLabel('<br><b>' + _('New location of this library:'))
        l.addWidget(self.cl, 1, 0, 1, ncols)
        self.loc = QLineEdit(loc, self)
        l.addWidget(self.loc, 2, 0, 1, 1)
        self.cd = QToolButton(self)
        self.cd.setIcon(QIcon(I('document_open.png')))
        self.cd.clicked.connect(self.choose_dir)
        l.addWidget(self.cd, 2, 1, 1, 1)
        self.bb = QDialogButtonBox(QDialogButtonBox.Abort)
        b = self.bb.addButton(_('Library moved'), self.bb.AcceptRole)
        b.setIcon(QIcon(I('ok.png')))
        b = self.bb.addButton(_('Forget library'), self.bb.RejectRole)
        b.setIcon(QIcon(I('edit-clear.png')))
        b.clicked.connect(self.forget_library)
        self.bb.accepted.connect(self.accept)
        self.bb.rejected.connect(self.reject)
        l.addWidget(self.bb, 3, 0, 1, ncols)
        self.resize(self.sizeHint() + QSize(100, 50))
예제 #12
0
파일: widgets.py 프로젝트: Kielek/calibre
    def setup_ui(self):
        self.l = l = QGridLayout()
        self.setLayout(l)

        self.la = la = QLabel(_(
            'Arrange the files in this book into sub-folders based on their types.'
            ' If you leave a folder blank, the files will be placed in the root.'))
        la.setWordWrap(True)
        l.addWidget(la, 0, 0, 1, -1)

        folders = tprefs['folders_for_types']
        for i, (typ, text) in enumerate(self.TYPE_MAP):
            la = QLabel('&' + text)
            setattr(self, '%s_label' % typ, la)
            le = QLineEdit(self)
            setattr(self, '%s_folder' % typ, le)
            val = folders.get(typ, '')
            if val and not val.endswith('/'):
                val += '/'
            le.setText(val)
            la.setBuddy(le)
            l.addWidget(la, i + 1, 0)
            l.addWidget(le, i + 1, 1)
        self.la2 = la = QLabel(_(
            'Note that this will only arrange files inside the book,'
            ' it will not affect how they are displayed in the Files Browser'))
        la.setWordWrap(True)
        l.addWidget(la, i + 2, 0, 1, -1)
        l.addWidget(self.bb, i + 3, 0, 1, -1)
예제 #13
0
 def __init__(self, *args):
     QWidget.__init__(self, *args)
     lo = QHBoxLayout(self)
     lo.setContentsMargins(0, 0, 0, 0)
     lo.setSpacing(5)
     # type selector
     self.wtypesel = QComboBox(self)
     for i, tp in enumerate(self.ValueTypes):
         self.wtypesel.addItem(tp.__name__)
     QObject.connect(self.wtypesel, SIGNAL("activated(int)"),
                     self._selectTypeNum)
     typesel_lab = QLabel("&Type:", self)
     typesel_lab.setBuddy(self.wtypesel)
     lo.addWidget(typesel_lab, 0)
     lo.addWidget(self.wtypesel, 0)
     self.wvalue = QLineEdit(self)
     self.wvalue_lab = QLabel("&Value:", self)
     self.wvalue_lab.setBuddy(self.wvalue)
     self.wbool = QComboBox(self)
     self.wbool.addItems(["false", "true"])
     self.wbool.setCurrentIndex(1)
     lo.addWidget(self.wvalue_lab, 0)
     lo.addWidget(self.wvalue, 1)
     lo.addWidget(self.wbool, 1)
     self.wvalue.hide()
     # make input validators
     self._validators = {
         int: QIntValidator(self),
         float: QDoubleValidator(self)
     }
     # select bool type initially
     self._selectTypeNum(0)
예제 #14
0
    def setup_ui(self):
        self.l = l = QFormLayout(self)
        self.setLayout(l)

        self.search_name = n = QLineEdit(self.search.get('name', ''), self)
        n.setPlaceholderText(_('The name with which to save this search'))
        l.addRow(_('&Name:'), n)

        self.find = f = QLineEdit(self.search.get('find', ''), self)
        f.setPlaceholderText(_('The expression to search for'))
        l.addRow(_('&Find:'), f)

        self.replace = r = QLineEdit(self.search.get('replace', ''), self)
        r.setPlaceholderText(_('The replace expression'))
        l.addRow(_('&Replace:'), r)

        self.case_sensitive = c = QCheckBox(_('Case sensitive'))
        c.setChecked(
            self.search.get('case_sensitive',
                            SearchWidget.DEFAULT_STATE['case_sensitive']))
        l.addRow(c)

        self.dot_all = d = QCheckBox(_('Dot matches all'))
        d.setChecked(
            self.search.get('dot_all', SearchWidget.DEFAULT_STATE['dot_all']))
        l.addRow(d)

        self.mode_box = m = ModeBox(self)
        self.mode_box.mode = self.search.get('mode', 'regex')
        l.addRow(_('&Mode:'), m)

        l.addRow(self.bb)
예제 #15
0
 def __init__(self,
              parent,
              label,
              filename=None,
              dialog_label=None,
              file_types=None,
              default_suffix=None,
              file_mode=QFileDialog.AnyFile):
     QWidget.__init__(self, parent)
     lo = QHBoxLayout(self)
     lo.setContentsMargins(0, 0, 0, 0)
     lo.setSpacing(5)
     # label
     lab = QLabel(label, self)
     lo.addWidget(lab, 0)
     # text field
     self.wfname = QLineEdit(self)
     self.wfname.setReadOnly(True)
     self.setFilename(filename)
     lo.addWidget(self.wfname, 1)
     # selector
     wsel = QToolButton(self)
     wsel.setText("Choose...")
     QObject.connect(wsel, SIGNAL("clicked()"), self._chooseFile)
     lo.addWidget(wsel, 0)
     # other init
     self._file_dialog = None
     self._dialog_label = dialog_label or label
     self._file_types = file_types or "All files (*)"
     self._file_mode = file_mode
     self._default_suffix = default_suffix
     self._dir = None
예제 #16
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()
예제 #17
0
    def __init__(self):
        QWidget.__init__(self)
        self.l = QGridLayout()
        self.setLayout(self.l)

        self.newFormatCheckboxLabel = QLabel("Generate new format data (SQLite3)")
        self.l.addWidget(self.newFormatCheckboxLabel, 0, 0, 1, 1)
        self.newFormatCheckbox = QCheckBox(self)
        self.l.addWidget(self.newFormatCheckbox, 0, 1, 1, 1)
        self.newFormatCheckbox.setChecked(prefs["newFormat"])

        # ARTTBD Maybe should be a native directory picker?  Works for now..
        self.cacheDirLabel = QLabel("Caching directory (optional, useful if re-running for a given book)")
        self.l.addWidget(self.cacheDirLabel, 1, 0, 1, 1)
        self.cacheDirEdit = QLineEdit(self)
        self.l.addWidget(self.cacheDirEdit, 1, 1, 1, 1)
        self.cacheDirEdit.setText(prefs["cacheDir"])

        self.autoExpandAliasesLabel = QLabel("Auto-generate aliases from character names")
        self.l.addWidget(self.autoExpandAliasesLabel, 2, 0, 1, 1)
        self.autoExpandAliasesCheckbox = QCheckBox(self)
        self.l.addWidget(self.autoExpandAliasesCheckbox, 2, 1, 1, 1)
        self.autoExpandAliasesCheckbox.setChecked(prefs["autoExpandAliases"])

        self.logfileLabel = QLabel("Log file (optional)")
        self.l.addWidget(self.logfileLabel, 3, 0, 1, 1)
        self.logfileEdit = QLineEdit(self)
        self.l.addWidget(self.logfileEdit, 3, 1, 1, 1)
        self.logfileEdit.setText(prefs["logfile"])
예제 #18
0
    def __init__(self):
        QWidget.__init__(self)
        self.l = QVBoxLayout()
        self.setLayout(self.l)

        self.url_label = QLabel('Casanova server:')
        self.l.addWidget(self.url_label)

        self.url_msg = QLineEdit(self)
        self.url_msg.setText(prefs['base_url'])
        self.l.addWidget(self.url_msg)

        self.url_label.setBuddy(self.url_msg)

        self.username_label = QLabel('Username:'******'username'])
        self.l.addWidget(self.username_msg)

        self.username_label.setBuddy(self.username_msg)        

        self.password_label = QLabel('password:'******'password'])
        self.l.addWidget(self.password_msg)

        self.password_label.setBuddy(self.password_msg)                
예제 #19
0
    def __init__(self):
        QWidget.__init__(self)
        self.l = QVBoxLayout()
        self.setLayout(self.l)

        self.serialLabel = QLabel('eInk Kindle Serial numbers (First character B, 16 characters, use commas if more than one)')
        self.l.addWidget(self.serialLabel)

        self.serials = QLineEdit(self)
        self.serials.setText(prefs['serials'])
        self.l.addWidget(self.serials)
        self.serialLabel.setBuddy(self.serials)

        self.pidLabel = QLabel('Mobipocket PIDs (8 or 10 characters, use commas if more than one)')
        self.l.addWidget(self.pidLabel)

        self.pids = QLineEdit(self)
        self.pids.setText(prefs['pids'])
        self.l.addWidget(self.pids)
        self.pidLabel.setBuddy(self.serials)

        self.wpLabel = QLabel('For Linux only: WINEPREFIX (enter absolute path)')
        self.l.addWidget(self.wpLabel)

        self.wineprefix = QLineEdit(self)
        wineprefix = prefs['WINEPREFIX']
        if wineprefix is not None:
            self.wineprefix.setText(wineprefix)
        else:
            self.wineprefix.setText('')

        self.l.addWidget(self.wineprefix)
        self.wpLabel.setBuddy(self.wineprefix)
예제 #20
0
    def __init__(self):
        QWidget.__init__(self)
        self.l = QGridLayout()
        self.setLayout(self.l)

        self.newFormatCheckboxLabel = QLabel('Generate new format data (SQLite3)')
        self.l.addWidget(self.newFormatCheckboxLabel, 0, 0, 1, 1)
        self.newFormatCheckbox = QCheckBox(self)
        self.l.addWidget(self.newFormatCheckbox, 0, 1, 1, 1)
        self.newFormatCheckbox.setChecked(prefs['newFormat'])

        # ARTTBD Maybe should be a native directory picker?  Works for now..
        self.cacheDirLabel = QLabel("Caching directory (optional, useful if re-running for a given book)")
        self.l.addWidget(self.cacheDirLabel, 1, 0, 1, 1)
        self.cacheDirEdit = QLineEdit(self)
        self.l.addWidget(self.cacheDirEdit, 1, 1, 1, 1)
        self.cacheDirEdit.setText(prefs['cacheDir'])
        
        self.autoExpandAliasesLabel = QLabel('Auto-generate aliases from character names')
        self.l.addWidget(self.autoExpandAliasesLabel, 2, 0, 1, 1)
        self.autoExpandAliasesCheckbox = QCheckBox(self)
        self.l.addWidget(self.autoExpandAliasesCheckbox, 2, 1, 1, 1)
        self.autoExpandAliasesCheckbox.setChecked(prefs['autoExpandAliases'])
        
        self.logfileLabel = QLabel('Log file (optional)')
        self.l.addWidget(self.logfileLabel, 3, 0, 1, 1)
        self.logfileEdit = QLineEdit(self)
        self.l.addWidget(self.logfileEdit, 3, 1, 1, 1)
        self.logfileEdit.setText(prefs['logfile'])
예제 #21
0
class FileSelector(QWidget):
    """A FileSelector is a one-line widget for selecting a file."""

    def __init__(self, parent, label, filename=None, dialog_label=None, file_types=None, default_suffix=None,
                 file_mode=QFileDialog.AnyFile):
        QWidget.__init__(self, parent)
        lo = QHBoxLayout(self)
        lo.setContentsMargins(0, 0, 0, 0)
        lo.setSpacing(5)
        # label
        lab = QLabel(label, self)
        lo.addWidget(lab, 0)
        # text field
        self.wfname = QLineEdit(self)
        self.wfname.setReadOnly(True)
        self.setFilename(filename)
        lo.addWidget(self.wfname, 1)
        # selector
        wsel = QToolButton(self)
        wsel.setText("Choose...")
        QObject.connect(wsel, SIGNAL("clicked()"), self._chooseFile)
        lo.addWidget(wsel, 0)
        # other init
        self._file_dialog = None
        self._dialog_label = dialog_label or label
        self._file_types = file_types or "All files (*)"
        self._file_mode = file_mode
        self._default_suffix = default_suffix
        self._dir = None

    def _chooseFile(self):
        if self._file_dialog is None:
            dialog = self._file_dialog = QFileDialog(self, self._dialog_label, ".", self._file_types)
            if self._default_suffix:
                dialog.setDefaultSuffix(self._default_suffix)
            dialog.setFileMode(self._file_mode)
            dialog.setModal(True)
            if self._dir is not None:
                dialog.setDirectory(self._dir)
            QObject.connect(dialog, SIGNAL("filesSelected(const QStringList &)"), self.setFilename)
        return self._file_dialog.exec_()

    def setFilename(self, filename):
        if isinstance(filename, QStringList):
            filename = filename[0]
        filename = (filename and str(filename)) or ''
        self.wfname.setText(filename)
        self.emit(SIGNAL("valid"), bool(filename))
        self.emit(SIGNAL("filenameSelected"), filename)

    def setDirectory(self, directory):
        self._dir = directory
        if self._file_dialog is not None:
            self._file_dialog.setDirectory(directory)

    def filename(self):
        return str(self.wfname.text())

    def isValid(self):
        return bool(self.filename())
예제 #22
0
파일: diff.py 프로젝트: Hainish/calibre
 def __init__(self, field, is_new, parent, metadata, extra):
     QLineEdit.__init__(self, parent)
     self.is_new = is_new
     self.field = field
     self.metadata = metadata
     if not is_new:
         self.setReadOnly(True)
     self.textChanged.connect(self.changed)
예제 #23
0
파일: diff.py 프로젝트: sss/calibre
 def __init__(self, field, is_new, parent, metadata, extra):
     QLineEdit.__init__(self, parent)
     self.is_new = is_new
     self.field = field
     self.metadata = metadata
     if not is_new:
         self.setReadOnly(True)
     self.textChanged.connect(self.changed)
예제 #24
0
class AddBookDialog(SizePersistedDialog):

    def __init__(self, parent=None, mm=None, mi = None):
        SizePersistedDialog.__init__(self, parent, 'casanova plugin:add book dialog')
        self.setWindowTitle('Add text to Casanova:')
        self.gui = parent
        self.mm = mm
        self.mi = mi
        self.one_line_description = ''

        layout = QVBoxLayout(self)
        self.setLayout(layout)

        self.one_liner_label = QLabel('Enter a short description (255 chars max) before pressing OK')
        layout.addWidget(self.one_liner_label)
        self.one_liner_str = QLineEdit(self)
        self.one_liner_str.setText('')
        layout.addWidget(self.one_liner_str)
        self.one_liner_label.setBuddy(self.one_liner_str)

        self.values_label = QLabel('Below are potential matches of texts that already exist - please make sure you are adding something new')
        layout.addWidget(self.values_label)
        self.values_list = QListWidget(self)
        self.values_list.setSelectionMode(QAbstractItemView.ExtendedSelection)
        layout.addWidget(self.values_list)
        
        self.button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        self.button_box.accepted.connect(self._accept_clicked)
        self.button_box.rejected.connect(self.reject)
        layout.addWidget(self.button_box)

        self._display_choices()

        # Cause our dialog size to be restored from prefs or created on first usage
        self.resize_dialog()

    def _display_choices(self):
        self.values_list.clear()
        choices = self.mm.search(self.mi.title)
        if choices is None or len(choices)==0:
            item = QListWidgetItem(get_icon('images/books.png'), _('there seem to be no matches'), self.values_list)
            self.values_list.addItem(item)
        for id, name in choices.items():
            item = QListWidgetItem(get_icon('images/books.png'), name, self.values_list)
            item.setData(1, (id,))
            self.values_list.addItem(item)

    def _accept_clicked(self):
        #self._save_preferences()
        one_liner = unicode(self.one_liner_str.text())
        if one_liner=='':
            self.values_list.clear()
            item = QListWidgetItem(get_icon('images/books.png'), _('you need to enter a short description'), self.values_list)
            self.values_list.addItem(item)
        else:
            self.one_line_description = one_liner
        self.accept()  
예제 #25
0
class MovedDialog(QDialog):  # {{{
    def __init__(self, stats, location, parent=None):
        QDialog.__init__(self, parent)
        self.setWindowTitle(_('No library found'))
        self._l = l = QGridLayout(self)
        self.setLayout(l)
        self.stats, self.location = stats, location

        loc = self.oldloc = location.replace('/', os.sep)
        self.header = QLabel(
            _('No existing calibre library was found at %s. '
              'If the library was moved, select its new location below. '
              'Otherwise calibre will forget this library.') % loc)
        self.header.setWordWrap(True)
        ncols = 2
        l.addWidget(self.header, 0, 0, 1, ncols)
        self.cl = QLabel('<br><b>' + _('New location of this library:'))
        l.addWidget(self.cl, 1, 0, 1, ncols)
        self.loc = QLineEdit(loc, self)
        l.addWidget(self.loc, 2, 0, 1, 1)
        self.cd = QToolButton(self)
        self.cd.setIcon(QIcon(I('document_open.png')))
        self.cd.clicked.connect(self.choose_dir)
        l.addWidget(self.cd, 2, 1, 1, 1)
        self.bb = QDialogButtonBox(QDialogButtonBox.Abort)
        b = self.bb.addButton(_('Library moved'), self.bb.AcceptRole)
        b.setIcon(QIcon(I('ok.png')))
        b = self.bb.addButton(_('Forget library'), self.bb.RejectRole)
        b.setIcon(QIcon(I('edit-clear.png')))
        b.clicked.connect(self.forget_library)
        self.bb.accepted.connect(self.accept)
        self.bb.rejected.connect(self.reject)
        l.addWidget(self.bb, 3, 0, 1, ncols)
        self.resize(self.sizeHint() + QSize(100, 50))

    def choose_dir(self):
        d = choose_dir(self,
                       'library moved choose new loc',
                       _('New library location'),
                       default_dir=self.oldloc)
        if d is not None:
            self.loc.setText(d)

    def forget_library(self):
        self.stats.remove(self.location)

    def accept(self):
        newloc = unicode(self.loc.text())
        if not db_class.exists_at(newloc):
            error_dialog(self,
                         _('No library found'),
                         _('No existing calibre library found at %s') % newloc,
                         show=True)
            return
        self.stats.rename(self.location, newloc)
        self.newloc = newloc
        QDialog.accept(self)
예제 #26
0
파일: main.py 프로젝트: kmshi/calibre
 def __init__(self, *args):
     QLineEdit.__init__(self, *args)
     self.setValidator(QRegExpValidator(QRegExp(r'\d+\.\d+'), self))
     self.setToolTip(textwrap.fill('<p>'+_(
         'Go to a reference. To get reference numbers, use the <i>reference '
         'mode</i>, by clicking the reference mode button in the toolbar.')))
     if hasattr(self, 'setPlaceholderText'):
         self.setPlaceholderText(_('Go to...'))
     self.editingFinished.connect(self.editing_finished)
예제 #27
0
    def do_user_config(self, parent=None):
        '''
        This method shows a configuration dialog for this plugin. It returns
        True if the user clicks OK, False otherwise. The changes are
        automatically applied.
        '''
        from PyQt4.Qt import (QDialog, QDialogButtonBox, QVBoxLayout, QLabel,
                              Qt, QLineEdit, QCheckBox)

        config_dialog = QDialog(parent)
        button_box = QDialogButtonBox(QDialogButtonBox.Ok
                                      | QDialogButtonBox.Cancel)
        v = QVBoxLayout(config_dialog)

        def size_dialog():
            config_dialog.resize(config_dialog.sizeHint())

        button_box.accepted.connect(config_dialog.accept)
        button_box.rejected.connect(config_dialog.reject)
        config_dialog.setWindowTitle(_('Customize') + ' ' + self.name)
        from calibre.customize.ui import (plugin_customization,
                                          customize_plugin)
        help_text = self.customization_help(gui=True)
        help_text = QLabel(help_text, config_dialog)
        help_text.setWordWrap(True)
        help_text.setTextInteractionFlags(Qt.LinksAccessibleByMouse
                                          | Qt.LinksAccessibleByKeyboard)
        help_text.setOpenExternalLinks(True)
        v.addWidget(help_text)
        bf = QCheckBox(_('Add linked files in breadth first order'))
        bf.setToolTip(
            _('Normally, when following links in HTML files'
              ' calibre does it depth first, i.e. if file A links to B and '
              ' C, but B links to D, the files are added in the order A, B, D, C. '
              ' With this option, they will instead be added as A, B, C, D'))
        sc = plugin_customization(self)
        if not sc:
            sc = ''
        sc = sc.strip()
        enc = sc.partition('|')[0]
        bfs = sc.partition('|')[-1]
        bf.setChecked(bfs == 'bf')
        sc = QLineEdit(enc, config_dialog)
        v.addWidget(sc)
        v.addWidget(bf)
        v.addWidget(button_box)
        size_dialog()
        config_dialog.exec_()

        if config_dialog.result() == QDialog.Accepted:
            sc = unicode(sc.text()).strip()
            if bf.isChecked():
                sc += '|bf'
            customize_plugin(self, sc)

        return config_dialog.result()
예제 #28
0
class SearchDialog(SizePersistedDialog):
    def __init__(self, parent=None, mm=None):
        SizePersistedDialog.__init__(self, parent,
                                     'casanova plugin:search dialog')
        self.setWindowTitle('Search Casanova:')
        self.gui = parent
        self.mm = mm

        layout = QVBoxLayout(self)
        self.setLayout(layout)

        self.search_label = QLabel('Search for:')
        layout.addWidget(self.search_label)
        self.search_str = QLineEdit(self)
        self.search_str.setText('')
        layout.addWidget(self.search_str)
        self.search_label.setBuddy(self.search_str)

        self.find_button = QPushButton("&Find")
        self.search_button_box = QDialogButtonBox(Qt.Horizontal)
        self.search_button_box.addButton(self.find_button,
                                         QDialogButtonBox.ActionRole)
        self.search_button_box.clicked.connect(self._find_clicked)
        layout.addWidget(self.search_button_box)

        self.values_list = QListWidget(self)
        self.values_list.setSelectionMode(QAbstractItemView.ExtendedSelection)
        layout.addWidget(self.values_list)

        self.button_box = QDialogButtonBox(QDialogButtonBox.Ok
                                           | QDialogButtonBox.Cancel)
        self.button_box.accepted.connect(self._accept_clicked)
        self.button_box.rejected.connect(self.reject)
        layout.addWidget(self.button_box)

        # Cause our dialog size to be restored from prefs or created on first usage
        self.resize_dialog()

    def _display_choices(self, choices):
        self.values_list.clear()
        for id, name in choices.items():
            item = QListWidgetItem(get_icon('images/books.png'), name,
                                   self.values_list)
            item.setData(1, (id, ))
            self.values_list.addItem(item)

    def _find_clicked(self):
        query = unicode(self.search_str.text())
        self._display_choices(self.mm.search(query))

    def _accept_clicked(self):
        #self._save_preferences()
        self.selected_texts = []
        for item in self.values_list.selectedItems():
            self.selected_texts.append(item.data(1).toPyObject()[0])
        self.accept()
예제 #29
0
class MovedDialog(QDialog):  # {{{
    def __init__(self, stats, location, parent=None):
        QDialog.__init__(self, parent)
        self.setWindowTitle(_("No library found"))
        self._l = l = QGridLayout(self)
        self.setLayout(l)
        self.stats, self.location = stats, location

        loc = self.oldloc = location.replace("/", os.sep)
        self.header = QLabel(
            _(
                "No existing calibre library was found at %s. "
                "If the library was moved, select its new location below. "
                "Otherwise calibre will forget this library."
            )
            % loc
        )
        self.header.setWordWrap(True)
        ncols = 2
        l.addWidget(self.header, 0, 0, 1, ncols)
        self.cl = QLabel("<br><b>" + _("New location of this library:"))
        l.addWidget(self.cl, 1, 0, 1, ncols)
        self.loc = QLineEdit(loc, self)
        l.addWidget(self.loc, 2, 0, 1, 1)
        self.cd = QToolButton(self)
        self.cd.setIcon(QIcon(I("document_open.png")))
        self.cd.clicked.connect(self.choose_dir)
        l.addWidget(self.cd, 2, 1, 1, 1)
        self.bb = QDialogButtonBox(QDialogButtonBox.Abort)
        b = self.bb.addButton(_("Library moved"), self.bb.AcceptRole)
        b.setIcon(QIcon(I("ok.png")))
        b = self.bb.addButton(_("Forget library"), self.bb.RejectRole)
        b.setIcon(QIcon(I("edit-clear.png")))
        b.clicked.connect(self.forget_library)
        self.bb.accepted.connect(self.accept)
        self.bb.rejected.connect(self.reject)
        l.addWidget(self.bb, 3, 0, 1, ncols)
        self.resize(self.sizeHint() + QSize(100, 50))

    def choose_dir(self):
        d = choose_dir(self, "library moved choose new loc", _("New library location"), default_dir=self.oldloc)
        if d is not None:
            self.loc.setText(d)

    def forget_library(self):
        self.stats.remove(self.location)

    def accept(self):
        newloc = unicode(self.loc.text())
        if not db_class.exists_at(newloc):
            error_dialog(self, _("No library found"), _("No existing calibre library found at %s") % newloc, show=True)
            return
        self.stats.rename(self.location, newloc)
        self.newloc = newloc
        QDialog.accept(self)
예제 #30
0
class SearchDialog(SizePersistedDialog):

    def __init__(self, parent=None, func=None, title="Search"):
        SizePersistedDialog.__init__(self, parent, 'arg plugin:search dialog')
        self.setWindowTitle(title)
        self.gui = parent
        self.func = func
        
        layout = QVBoxLayout(self)
        self.setLayout(layout)

        self.search_label = QLabel(title)
        layout.addWidget(self.search_label)
        self.search_str = QLineEdit(self)
        self.search_str.setText('')
        layout.addWidget(self.search_str)
        self.search_label.setBuddy(self.search_str)

        self.find_button = QPushButton("&Find")
        self.search_button_box = QDialogButtonBox(Qt.Horizontal)
        self.search_button_box.addButton(self.find_button, QDialogButtonBox.ActionRole)
        self.search_button_box.clicked.connect(self._find_clicked)
        layout.addWidget(self.search_button_box)        

        self.values_list = QListWidget(self)
        # for multiple selection
        #self.values_list.setSelectionMode(QAbstractItemView.ExtendedSelection)
        layout.addWidget(self.values_list)
        
        self.button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        self.button_box.accepted.connect(self._accept_clicked)
        self.button_box.rejected.connect(self.reject)
        layout.addWidget(self.button_box)

        # Cause our dialog size to be restored from prefs or created on first usage
        self.resize_dialog()

    def _display_choices(self, choices):
        self.values_list.clear()
        for id, name in choices.items():
            item = QListWidgetItem(get_icon('images/books.png'), name, self.values_list)
            item.setData(1, (id,))
            self.values_list.addItem(item)

    def _find_clicked(self):
        query = unicode(self.search_str.text())
        self._display_choices(self.func(query))

    def _accept_clicked(self):
        #self._save_preferences()
        self.selected_result = None
        if self.values_list.currentItem():
            i = self.values_list.currentItem()
            self.selected_result = (i.data(1)[0], i.text())
        self.accept() 
예제 #31
0
class MovedDialog(QDialog): # {{{

    def __init__(self, stats, location, parent=None):
        QDialog.__init__(self, parent)
        self.setWindowTitle(_('No library found'))
        self._l = l = QGridLayout(self)
        self.setLayout(l)
        self.stats, self.location = stats, location

        loc = self.oldloc = location.replace('/', os.sep)
        self.header = QLabel(_('No existing calibre library was found at %s. '
            'If the library was moved, select its new location below. '
            'Otherwise calibre will forget this library.')%loc)
        self.header.setWordWrap(True)
        ncols = 2
        l.addWidget(self.header, 0, 0, 1, ncols)
        self.cl = QLabel('<br><b>'+_('New location of this library:'))
        l.addWidget(self.cl, 1, 0, 1, ncols)
        self.loc = QLineEdit(loc, self)
        l.addWidget(self.loc, 2, 0, 1, 1)
        self.cd = QToolButton(self)
        self.cd.setIcon(QIcon(I('document_open.png')))
        self.cd.clicked.connect(self.choose_dir)
        l.addWidget(self.cd, 2, 1, 1, 1)
        self.bb = QDialogButtonBox(self)
        b = self.bb.addButton(_('Library moved'), self.bb.AcceptRole)
        b.setIcon(QIcon(I('ok.png')))
        b = self.bb.addButton(_('Forget library'), self.bb.RejectRole)
        b.setIcon(QIcon(I('edit-clear.png')))
        self.bb.accepted.connect(self.accept)
        self.bb.rejected.connect(self.reject)
        l.addWidget(self.bb, 3, 0, 1, ncols)
        self.resize(self.sizeHint() + QSize(100, 50))

    def choose_dir(self):
        d = choose_dir(self, 'library moved choose new loc',
                _('New library location'), default_dir=self.oldloc)
        if d is not None:
            self.loc.setText(d)

    def reject(self):
        self.stats.remove(self.location)
        QDialog.reject(self)

    def accept(self):
        newloc = unicode(self.loc.text())
        if not LibraryDatabase2.exists_at(newloc):
            error_dialog(self, _('No library found'),
                    _('No existing calibre library found at %s')%newloc,
                    show=True)
            return
        self.stats.rename(self.location, newloc)
        self.newloc = newloc
        QDialog.accept(self)
예제 #32
0
파일: widgets.py 프로젝트: Hainish/calibre
def create_filterable_names_list(names, filter_text=None, parent=None):
    nl = QListView(parent)
    nl.m = m = NamesModel(names, parent=nl)
    m.filtered.connect(lambda all_items: nl.scrollTo(m.index(0)))
    nl.setModel(m)
    nl.d = NamesDelegate(nl)
    nl.setItemDelegate(nl.d)
    f = QLineEdit(parent)
    f.setPlaceholderText(filter_text or '')
    f.textEdited.connect(m.filter)
    return nl, f
예제 #33
0
파일: widgets.py 프로젝트: sidneijp/calibre
def create_filterable_names_list(names, filter_text=None, parent=None):
    nl = QListView(parent)
    nl.m = m = NamesModel(names, parent=nl)
    m.filtered.connect(lambda all_items: nl.scrollTo(m.index(0)))
    nl.setModel(m)
    nl.d = NamesDelegate(nl)
    nl.setItemDelegate(nl.d)
    f = QLineEdit(parent)
    f.setPlaceholderText(filter_text or '')
    f.textEdited.connect(m.filter)
    return nl, f
예제 #34
0
    def __init__(self, current_family, parent=None):
        QDialog.__init__(self, parent)
        self.setWindowTitle(_('Choose font family'))
        self.setWindowIcon(QIcon(I('font.png')))
        from calibre.utils.fonts.scanner import font_scanner
        self.font_scanner = font_scanner

        self.m = QStringListModel(self)
        self.build_font_list()
        self.l = l = QGridLayout()
        self.setLayout(l)
        self.view = FontsView(self)
        self.view.setModel(self.m)
        self.view.setCurrentIndex(self.m.index(0))
        if current_family:
            for i, val in enumerate(self.families):
                if icu_lower(val) == icu_lower(current_family):
                    self.view.setCurrentIndex(self.m.index(i))
                    break
        self.view.doubleClicked.connect(self.accept, type=Qt.QueuedConnection)
        self.view.changed.connect(self.current_changed,
                                  type=Qt.QueuedConnection)
        self.faces = Typefaces(self)
        self.bb = QDialogButtonBox(QDialogButtonBox.Ok
                                   | QDialogButtonBox.Cancel)
        self.bb.accepted.connect(self.accept)
        self.bb.rejected.connect(self.reject)
        self.add_fonts_button = afb = self.bb.addButton(
            _('Add &fonts'), self.bb.ActionRole)
        afb.setIcon(QIcon(I('plus.png')))
        afb.clicked.connect(self.add_fonts)
        self.ml = QLabel(_('Choose a font family from the list below:'))
        self.search = QLineEdit(self)
        self.search.setPlaceholderText(_('Search'))
        self.search.returnPressed.connect(self.find)
        self.nb = QToolButton(self)
        self.nb.setIcon(QIcon(I('arrow-down.png')))
        self.nb.setToolTip(_('Find Next'))
        self.pb = QToolButton(self)
        self.pb.setIcon(QIcon(I('arrow-up.png')))
        self.pb.setToolTip(_('Find Previous'))
        self.nb.clicked.connect(self.find_next)
        self.pb.clicked.connect(self.find_previous)

        l.addWidget(self.ml, 0, 0, 1, 4)
        l.addWidget(self.search, 1, 0, 1, 1)
        l.addWidget(self.nb, 1, 1, 1, 1)
        l.addWidget(self.pb, 1, 2, 1, 1)
        l.addWidget(self.view, 2, 0, 1, 3)
        l.addWidget(self.faces, 1, 3, 2, 1)
        l.addWidget(self.bb, 3, 0, 1, 4)
        l.setAlignment(self.faces, Qt.AlignTop)

        self.resize(800, 600)
예제 #35
0
파일: to_zip.py 프로젝트: 089git/calibre
    def do_user_config(self, parent=None):
        '''
        This method shows a configuration dialog for this plugin. It returns
        True if the user clicks OK, False otherwise. The changes are
        automatically applied.
        '''
        from PyQt4.Qt import (QDialog, QDialogButtonBox, QVBoxLayout,
                QLabel, Qt, QLineEdit, QCheckBox)

        config_dialog = QDialog(parent)
        button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        v = QVBoxLayout(config_dialog)

        def size_dialog():
            config_dialog.resize(config_dialog.sizeHint())

        button_box.accepted.connect(config_dialog.accept)
        button_box.rejected.connect(config_dialog.reject)
        config_dialog.setWindowTitle(_('Customize') + ' ' + self.name)
        from calibre.customize.ui import (plugin_customization,
                customize_plugin)
        help_text = self.customization_help(gui=True)
        help_text = QLabel(help_text, config_dialog)
        help_text.setWordWrap(True)
        help_text.setTextInteractionFlags(Qt.LinksAccessibleByMouse
                | Qt.LinksAccessibleByKeyboard)
        help_text.setOpenExternalLinks(True)
        v.addWidget(help_text)
        bf = QCheckBox(_('Add linked files in breadth first order'))
        bf.setToolTip(_('Normally, when following links in HTML files'
            ' calibre does it depth first, i.e. if file A links to B and '
            ' C, but B links to D, the files are added in the order A, B, D, C. '
            ' With this option, they will instead be added as A, B, C, D'))
        sc = plugin_customization(self)
        if not sc:
            sc = ''
        sc = sc.strip()
        enc = sc.partition('|')[0]
        bfs = sc.partition('|')[-1]
        bf.setChecked(bfs == 'bf')
        sc = QLineEdit(enc, config_dialog)
        v.addWidget(sc)
        v.addWidget(bf)
        v.addWidget(button_box)
        size_dialog()
        config_dialog.exec_()

        if config_dialog.result() == QDialog.Accepted:
            sc = unicode(sc.text()).strip()
            if bf.isChecked():
                sc += '|bf'
            customize_plugin(self, sc)

        return config_dialog.result()
예제 #36
0
class ConfigWidget(QWidget):
    def __init__(self):
        QWidget.__init__(self)
        self.l = QVBoxLayout()
        self.setLayout(self.l)

        self.l5 = QHBoxLayout()
        self.server_prefix_label = QLabel('Server prefix:')
        self.l5.addWidget(self.server_prefix_label)

        self.server_prefix = QLineEdit(self)
        self.server_prefix.setText(prefs['server_prefix'])
        self.l5.addWidget(self.server_prefix)
        self.server_prefix_label.setBuddy(self.server_prefix)
        self.l.addLayout(self.l5)

        self.ll = QHBoxLayout()
        self.server_label = QLabel('Server:')
        self.ll.addWidget(self.server_label)

        self.lsb_server = QLineEdit(self)
        self.lsb_server.setText(prefs['lsb_server'])
        self.ll.addWidget(self.lsb_server)
        self.server_label.setBuddy(self.lsb_server)
        self.l.addLayout(self.ll)

        self.lll = QHBoxLayout()
        self.librarian_label = QLabel('Librarian:')
        self.lll.addWidget(self.librarian_label)

        self.librarian = QLineEdit(self)
        self.librarian.setText(prefs['librarian']['name'])
        self.lll.addWidget(self.librarian)
        self.librarian_label.setBuddy(self.librarian)
        self.l.addLayout(self.lll)

        self.llll = QHBoxLayout()
        self.library_uuid_label = QLabel('Library ID:')
        self.llll.addWidget(self.library_uuid_label)
        self.library_uuid_button = QPushButton("New unique Library ID")
        self.library_uuid_button.clicked.connect(self.new_library_uuid)

        self.library_uuid = QLabel(self)
        self.library_uuid.setText(prefs['library_uuid'])
        self.llll.addWidget(self.library_uuid)
        self.llll.addWidget(self.library_uuid_button)
        self.library_uuid_label.setBuddy(self.library_uuid)
        self.l.addLayout(self.llll)

    def new_library_uuid(self):
        self.library_uuid.setText(str(uuid.uuid4()))

    def save_settings(self):
        prefs['lsb_server'] = unicode(self.lsb_server.text())
        prefs['server_prefix'] = unicode(self.server_prefix.text())
        prefs['librarian'] = {'name': unicode(self.librarian.text()),
                              'saved': True}
        prefs['library_uuid'] = self.library_uuid.text()
예제 #37
0
    def __init__(self):
        QWidget.__init__(self)
        self.l = QHBoxLayout()
        self.setLayout(self.l)

        self.label = QLabel('Hello world &message:')
        self.l.addWidget(self.label)

        self.msg = QLineEdit(self)
        self.msg.setText(prefs['hello_world_msg'])
        self.l.addWidget(self.msg)
        self.label.setBuddy(self.msg)
예제 #38
0
class DaysOfMonth(Base):

    HELP = _('''\
                Download this periodical every month, on the specified days.
                The download will happen as soon after the specified time as
                possible on the specified days of each month. For example,
                if you choose the 1st and the 15th after 9:00 AM, the
                periodical will be downloaded on the 1st and 15th of every
                month, as soon after 9:00 AM as possible.
            ''')

    def __init__(self, parent=None):
        Base.__init__(self, parent)

        self.l1 = QLabel(_('&Days of the month:'))
        self.days = QLineEdit(self)
        self.days.setToolTip(
            _('Comma separated list of days of the month.'
              ' For example: 1, 15'))
        self.l1.setBuddy(self.days)

        self.l2 = QLabel(_('Download &after:'))
        self.time = QTimeEdit(self)
        self.time.setDisplayFormat('hh:mm AP')
        self.l2.setBuddy(self.time)

        self.l.addWidget(self.l1, 0, 0, 1, 1)
        self.l.addWidget(self.days, 0, 1, 1, 1)
        self.l.addWidget(self.l2, 1, 0, 1, 1)
        self.l.addWidget(self.time, 1, 1, 1, 1)

    def initialize(self, typ=None, val=None):
        if val is None:
            val = ((1, ), 6, 0)
        days_of_month, hour, minute = val
        self.days.setText(', '.join(map(str, map(int, days_of_month))))
        self.time.setTime(QTime(hour, minute))

    @property
    def schedule(self):
        parts = [
            x.strip() for x in unicode(self.days.text()).split(',')
            if x.strip()
        ]
        try:
            days_of_month = tuple(map(int, parts))
        except:
            days_of_month = (1, )
        if not days_of_month:
            days_of_month = (1, )
        t = self.time.time()
        hour, minute = t.hour(), t.minute()
        return 'days_of_month', (days_of_month, int(hour), int(minute))
예제 #39
0
    def ask_link(self):
        d = QDialog(self)
        d.setWindowTitle(_('Create link'))
        l = QFormLayout()
        d.setLayout(l)
        d.url = QLineEdit(d)
        d.name = QLineEdit(d)
        d.treat_as_image = QCheckBox(d)
        d.setMinimumWidth(600)
        d.bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        d.br = b = QPushButton(_('&Browse'))
        b.setIcon(QIcon(I('document_open.png')))

        def cf():
            files = choose_files(d,
                                 'select link file',
                                 _('Choose file'),
                                 select_only_single_file=True)
            if files:
                path = files[0]
                d.url.setText(path)
                if path and os.path.exists(path):
                    with lopen(path, 'rb') as f:
                        q = what(f)
                    is_image = q in {'jpeg', 'png', 'gif'}
                    d.treat_as_image.setChecked(is_image)

        b.clicked.connect(cf)
        d.la = la = QLabel(
            _('Enter a URL. If you check the "Treat the URL as an image" box '
              'then the URL will be added as an image reference instead of as '
              'a link. You can also choose to create a link to a file on '
              'your computer. '
              'Note that if you create a link to a file on your computer, it '
              'will stop working if the file is moved.'))
        la.setWordWrap(True)
        la.setStyleSheet('QLabel { margin-bottom: 1.5ex }')
        l.setWidget(0, l.SpanningRole, la)
        l.addRow(_('Enter &URL:'), d.url)
        l.addRow(_('Treat the URL as an &image'), d.treat_as_image)
        l.addRow(_('Enter &name (optional):'), d.name)
        l.addRow(_('Choose a file on your computer:'), d.br)
        l.addRow(d.bb)
        d.bb.accepted.connect(d.accept)
        d.bb.rejected.connect(d.reject)
        d.resize(d.sizeHint())
        link, name, is_image = None, None, False
        if d.exec_() == d.Accepted:
            link, name = unicode(d.url.text()).strip(), unicode(
                d.name.text()).strip()
            is_image = d.treat_as_image.isChecked()
        return link, name, is_image
class Window(QtGui.QMainWindow):
    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)

    def browse(self):
        self.save_file = QFileDialog.getOpenFileName(
            self,
            caption="Read File As",
            filter="Comma Separated Variable(*.csv*)")
        self.line_edit.setText(self.save_file)

    def read_file(self):
        ##Creating empty Data Array
        data_array = []
        with open(self.save_file, 'rb') as f:
            reader = csv.reader(f)
            for row in reader:
                content = row[1]
                data_array.append(content)

            plt.plot(data_array)
            plt.show()
예제 #41
0
    def ui_selectionFilter_GroupBox(self, MMKitDialog):
        #Start Selection Filter GroupBox
        self.selectionFilter_groupBox = QtGui.QGroupBox(MMKitDialog)
        self.selectionFilter_groupBox.setObjectName("selectionFilter_groupBox")

        self.selectionFilter_groupBox.setAutoFillBackground(True)
        palette = MMKitDialog.getGroupBoxPalette()
        self.selectionFilter_groupBox.setPalette(palette)

        styleSheet = MMKitDialog.getGroupBoxStyleSheet()
        self.selectionFilter_groupBox.setStyleSheet(styleSheet)

        self.hboxlayout_selfilter = QtGui.QHBoxLayout()
        self.hboxlayout_selfilter.setMargin(pmGrpBoxVboxLayoutMargin)
        self.hboxlayout_selfilter.setSpacing(6)
        self.hboxlayout_selfilter.setObjectName("hboxlayout_selfilter")

        self.vboxlayout_selfilter = QtGui.QVBoxLayout(
            self.selectionFilter_groupBox)
        self.vboxlayout_selfilter.setMargin(pmGrpBoxVboxLayoutMargin)
        self.vboxlayout_selfilter.setSpacing(6)
        self.vboxlayout_selfilter.setObjectName("vboxlayout_selfilter")

        self.filterCB = MMKitDialog.getGroupBoxTitleCheckBox(
            "Selection Filter ", self.selectionFilter_groupBox)

        self.vboxlayout_selfilter.addWidget(self.filterCB)

        self.selectionFilter_label = QtGui.QLabel(
            self.selectionFilter_groupBox)
        self.vboxlayout_selfilter.addWidget(self.selectionFilter_label)

        self.filterlistLE = QLineEdit(self.selectionFilter_groupBox)
        self.filterlistLE.setReadOnly(1)
        self.filterlistLE.setEnabled(0)

        if self.filterCB.isChecked():
            self.filterlistLE.show()
            self.selectionFilter_label.show()
        else:
            self.filterlistLE.hide()
            self.selectionFilter_label.hide()

        self.vboxlayout_selfilter.addWidget(self.filterlistLE)
        #End Selection filter GroupBox
        self.pmVBoxLayout.addWidget(self.selectionFilter_groupBox)

        # Height is fixed. Mark 2007-05-29.
        self.selectionFilter_groupBox.setSizePolicy(
            QSizePolicy(QSizePolicy.Policy(QSizePolicy.Preferred),
                        QSizePolicy.Policy(QSizePolicy.Fixed)))
예제 #42
0
    def __init__(
        self,
        parent=None,
    ):
        QDialog.__init__(self, parent)
        self.parent = parent
        self.setWindowTitle(
            u"{0} {1}: Getting Default Kindle for Mac/PC Key".format(
                PLUGIN_NAME, PLUGIN_VERSION))
        layout = QVBoxLayout(self)
        self.setLayout(layout)

        try:
            self.default_key = retrieve_kindle_keys()[0]
        except:
            self.default_key = u""

        self.button_box = QDialogButtonBox(QDialogButtonBox.Ok
                                           | QDialogButtonBox.Cancel)

        if len(self.default_key) > 0:
            data_group_box = QGroupBox(u"", self)
            layout.addWidget(data_group_box)
            data_group_box_layout = QVBoxLayout()
            data_group_box.setLayout(data_group_box_layout)

            key_group = QHBoxLayout()
            data_group_box_layout.addLayout(key_group)
            key_group.addWidget(QLabel(u"Unique Key Name:", self))
            self.key_ledit = QLineEdit("", self)
            self.key_ledit.setToolTip(
                u"<p>Enter an identifying name for the current default Kindle for Mac/PC key."
            )
            key_group.addWidget(self.key_ledit)
            key_label = QLabel(_(''), self)
            key_label.setAlignment(Qt.AlignHCenter)
            data_group_box_layout.addWidget(key_label)
            self.button_box.accepted.connect(self.accept)
        else:
            default_key_error = QLabel(
                u"The default encryption key for Kindle for Mac/PC could not be found.",
                self)
            default_key_error.setAlignment(Qt.AlignHCenter)
            layout.addWidget(default_key_error)
            # if no default, bot buttons do the same
            self.button_box.accepted.connect(self.reject)

        self.button_box.rejected.connect(self.reject)
        layout.addWidget(self.button_box)

        self.resize(self.sizeHint())
예제 #43
0
    def setup_ui(self):
        self.l = l = QFormLayout(self)
        self.setLayout(l)

        self.err_label = QLabel('')
        self.name_edit = QLineEdit(self)
        self.name_edit.textChanged.connect(self.verify)
        self.name_edit.setText(self.candidate)
        pos = self.candidate.rfind('.')
        if pos > -1:
            self.name_edit.setSelection(0, pos)
        l.addRow(_('File &name:'), self.name_edit)
        l.addRow(self.err_label)
        l.addRow(self.bb)
예제 #44
0
파일: scheduler.py 프로젝트: Eksmo/calibre
class DaysOfMonth(Base):

    HELP = _('''\
                Download this periodical every month, on the specified days.
                The download will happen as soon after the specified time as
                possible on the specified days of each month. For example,
                if you choose the 1st and the 15th after 9:00 AM, the
                periodical will be downloaded on the 1st and 15th of every
                month, as soon after 9:00 AM as possible.
            ''')

    def __init__(self, parent=None):
        Base.__init__(self, parent)

        self.l1 = QLabel(_('&Days of the month:'))
        self.days = QLineEdit(self)
        self.days.setToolTip(_('Comma separated list of days of the month.'
            ' For example: 1, 15'))
        self.l1.setBuddy(self.days)

        self.l2 = QLabel(_('Download &after:'))
        self.time = QTimeEdit(self)
        self.time.setDisplayFormat('hh:mm AP')
        self.l2.setBuddy(self.time)

        self.l.addWidget(self.l1, 0, 0, 1, 1)
        self.l.addWidget(self.days, 0, 1, 1, 1)
        self.l.addWidget(self.l2, 1, 0, 1, 1)
        self.l.addWidget(self.time, 1, 1, 1, 1)

    def initialize(self, typ=None, val=None):
        if val is None:
            val = ((1,), 6, 0)
        days_of_month, hour, minute = val
        self.days.setText(', '.join(map(str, map(int, days_of_month))))
        self.time.setTime(QTime(hour, minute))

    @property
    def schedule(self):
        parts = [x.strip() for x in unicode(self.days.text()).split(',') if
                x.strip()]
        try:
            days_of_month = tuple(map(int, parts))
        except:
            days_of_month = (1,)
        if not days_of_month:
            days_of_month = (1,)
        t = self.time.time()
        hour, minute = t.hour(), t.minute()
        return 'days_of_month', (days_of_month, int(hour), int(minute))
예제 #45
0
    def __init__(self):
        QWidget.__init__(self)
        self.l = QVBoxLayout()
        self.setLayout(self.l)

        self.ll = QHBoxLayout()
        self.server_label = QLabel('Gphoto2 server address:')
        self.ll.addWidget(self.server_label)

        self.gphoto2_server = QLineEdit(self)
        self.gphoto2_server.setText(prefs['gphoto2_server'])
        self.ll.addWidget(self.gphoto2_server)
        self.server_label.setBuddy(self.gphoto2_server)
        self.l.addLayout(self.ll)
예제 #46
0
    def __init__(self, parent=None,):
        QDialog.__init__(self, parent)
        self.parent = parent
        self.setWindowTitle(u"{0} {1}: Create New eReader Key".format(PLUGIN_NAME, PLUGIN_VERSION))
        layout = QVBoxLayout(self)
        self.setLayout(layout)

        data_group_box = QGroupBox(u"", self)
        layout.addWidget(data_group_box)
        data_group_box_layout = QVBoxLayout()
        data_group_box.setLayout(data_group_box_layout)

        key_group = QHBoxLayout()
        data_group_box_layout.addLayout(key_group)
        key_group.addWidget(QLabel(u"Unique Key Name:", self))
        self.key_ledit = QLineEdit("", self)
        self.key_ledit.setToolTip(u"<p>Enter an identifying name for this new key.\nIt should be something that will help you remember what personal information was used to create it.")
        key_group.addWidget(self.key_ledit)
        key_label = QLabel(_(''), self)
        key_label.setAlignment(Qt.AlignHCenter)
        data_group_box_layout.addWidget(key_label)

        name_group = QHBoxLayout()
        data_group_box_layout.addLayout(name_group)
        name_group.addWidget(QLabel(u"Your Name:", self))
        self.name_ledit = QLineEdit(u"", self)
        self.name_ledit.setToolTip(u"Enter the name for this eReader key, usually the name on your credit card.\nIt will only be used to generate this one-time key and won\'t be stored anywhere in calibre or on your computer.\n(ex: Mr Jonathan Q Smith)")
        name_group.addWidget(self.name_ledit)
        name_disclaimer_label = QLabel(_(u"(Will not be saved in configuration data)"), self)
        name_disclaimer_label.setAlignment(Qt.AlignHCenter)
        data_group_box_layout.addWidget(name_disclaimer_label)

        ccn_group = QHBoxLayout()
        data_group_box_layout.addLayout(ccn_group)
        ccn_group.addWidget(QLabel(u"Credit Card#:", self))
        self.cc_ledit = QLineEdit(u"", self)
        self.cc_ledit.setToolTip(u"<p>Enter the last 8 digits of credit card number for this eReader key.\nThey will only be used to generate this one-time key and won\'t be stored anywhere in calibre or on your computer.")
        ccn_group.addWidget(self.cc_ledit)
        ccn_disclaimer_label = QLabel(_('(Will not be saved in configuration data)'), self)
        ccn_disclaimer_label.setAlignment(Qt.AlignHCenter)
        data_group_box_layout.addWidget(ccn_disclaimer_label)
        layout.addSpacing(10)

        self.button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        self.button_box.accepted.connect(self.accept)
        self.button_box.rejected.connect(self.reject)
        layout.addWidget(self.button_box)

        self.resize(self.sizeHint())
예제 #47
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)
예제 #48
0
    def __init__(self, parent=None, mm=None):
        SizePersistedDialog.__init__(self, parent, 'casanova plugin:search dialog')
        self.setWindowTitle('Search Casanova:')
        self.gui = parent
        self.mm = mm
        
        layout = QVBoxLayout(self)
        self.setLayout(layout)

        self.search_label = QLabel('Search for:')
        layout.addWidget(self.search_label)
        self.search_str = QLineEdit(self)
        self.search_str.setText('')
        layout.addWidget(self.search_str)
        self.search_label.setBuddy(self.search_str)

        self.find_button = QPushButton("&Find")
        self.search_button_box = QDialogButtonBox(Qt.Horizontal)
        self.search_button_box.addButton(self.find_button, QDialogButtonBox.ActionRole)
        self.search_button_box.clicked.connect(self._find_clicked)
        layout.addWidget(self.search_button_box)        

        self.values_list = QListWidget(self)
        self.values_list.setSelectionMode(QAbstractItemView.ExtendedSelection)
        layout.addWidget(self.values_list)
        
        self.button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        self.button_box.accepted.connect(self._accept_clicked)
        self.button_box.rejected.connect(self.reject)
        layout.addWidget(self.button_box)

        # Cause our dialog size to be restored from prefs or created on first usage
        self.resize_dialog()
예제 #49
0
    def __init__(self, parent=None,):
        print repr(self), repr(parent)
        QDialog.__init__(self, parent)
        self.parent = parent
        self.setWindowTitle("{0} {1}: Rename {0}".format(PLUGIN_NAME, PLUGIN_VERSION, parent.key_type_name))
        layout = QVBoxLayout(self)
        self.setLayout(layout)

        data_group_box = QGroupBox('', self)
        layout.addWidget(data_group_box)
        data_group_box_layout = QVBoxLayout()
        data_group_box.setLayout(data_group_box_layout)

        data_group_box_layout.addWidget(QLabel('New Key Name:', self))
        self.key_ledit = QLineEdit(self.parent.listy.currentItem().text(), self)
        self.key_ledit.setToolTip(u"Enter a new name for this existing {0}.".format(parent.key_type_name))
        data_group_box_layout.addWidget(self.key_ledit)

        layout.addSpacing(20)

        self.button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        self.button_box.accepted.connect(self.accept)
        self.button_box.rejected.connect(self.reject)
        layout.addWidget(self.button_box)

        self.resize(self.sizeHint())
예제 #50
0
class MaxArticles(QWidget):

    def __init__(self, parent):
        QWidget.__init__(self, parent)
        self.ll = ll = QGridLayout()
        self.setLayout(self.ll)

        self.labell = QLabel('Max articles:')
        ll.addWidget(self.labell, 0, 0, 1, 1)
        self.max_articles_edit = QLineEdit(self)
        self.max_articles_edit.setPlaceholderText(prefs['max_articles'])
        ll.addWidget(self.max_articles_edit, 0, 1, 1, 1)
        
    @property
    def max_articles(self):
        return int(self.max_articles_edit.text() or prefs['max_articles'])       
예제 #51
0
class ConfigWidget(QWidget):
    def __init__(self):
        QWidget.__init__(self)
        self.l = QHBoxLayout()
        self.setLayout(self.l)

        self.label = QLabel("Server:")
        self.l.addWidget(self.label)

        self.msg = QLineEdit(self)
        self.msg.setText(prefs["lsb_server"])
        self.l.addWidget(self.msg)
        self.label.setBuddy(self.msg)

    def save_settings(self):
        prefs["lsb_server"] = unicode(self.msg.text())
예제 #52
0
class ConfigWidget(QWidget):
    def __init__(self):
        QWidget.__init__(self)
        self.l = QHBoxLayout()
        self.setLayout(self.l)

        self.label = QLabel("Hello world &message:")
        self.l.addWidget(self.label)

        self.msg = QLineEdit(self)
        self.msg.setText(prefs["hello_world_msg"])
        self.l.addWidget(self.msg)
        self.label.setBuddy(self.msg)

    def save_settings(self):
        None
예제 #53
0
파일: Widgets.py 프로젝트: ska-sa/tigger
 def __init__(self, parent, label, filename=None, dialog_label=None, file_types=None, default_suffix=None,
              file_mode=QFileDialog.AnyFile):
     QWidget.__init__(self, parent)
     lo = QHBoxLayout(self)
     lo.setContentsMargins(0, 0, 0, 0)
     lo.setSpacing(5)
     # label
     lab = QLabel(label, self)
     lo.addWidget(lab, 0)
     # text field
     self.wfname = QLineEdit(self)
     self.wfname.setReadOnly(True)
     self.setFilename(filename)
     lo.addWidget(self.wfname, 1)
     # selector
     wsel = QToolButton(self)
     wsel.setText("Choose...")
     QObject.connect(wsel, SIGNAL("clicked()"), self._chooseFile)
     lo.addWidget(wsel, 0)
     # other init
     self._file_dialog = None
     self._dialog_label = dialog_label or label
     self._file_types = file_types or "All files (*)"
     self._file_mode = file_mode
     self._default_suffix = default_suffix
     self._dir = None
예제 #54
0
파일: Widgets.py 프로젝트: ska-sa/tigger
 def __init__(self, *args):
     QWidget.__init__(self, *args)
     lo = QHBoxLayout(self)
     lo.setContentsMargins(0, 0, 0, 0)
     lo.setSpacing(5)
     # type selector
     self.wtypesel = QComboBox(self)
     for i, tp in enumerate(self.ValueTypes):
         self.wtypesel.addItem(tp.__name__)
     QObject.connect(self.wtypesel, SIGNAL("activated(int)"), self._selectTypeNum)
     typesel_lab = QLabel("&Type:", self)
     typesel_lab.setBuddy(self.wtypesel)
     lo.addWidget(typesel_lab, 0)
     lo.addWidget(self.wtypesel, 0)
     self.wvalue = QLineEdit(self)
     self.wvalue_lab = QLabel("&Value:", self)
     self.wvalue_lab.setBuddy(self.wvalue)
     self.wbool = QComboBox(self)
     self.wbool.addItems(["false", "true"])
     self.wbool.setCurrentIndex(1)
     lo.addWidget(self.wvalue_lab, 0)
     lo.addWidget(self.wvalue, 1)
     lo.addWidget(self.wbool, 1)
     self.wvalue.hide()
     # make input validators
     self._validators = {int: QIntValidator(self), float: QDoubleValidator(self)}
     # select bool type initially
     self._selectTypeNum(0)
예제 #55
0
    def __init__(self, parent=None,):
        QDialog.__init__(self, parent)
        self.parent = parent
        self.setWindowTitle(u"{0} {1}: Add New EInk Kindle Serial Number".format(PLUGIN_NAME, PLUGIN_VERSION))
        layout = QVBoxLayout(self)
        self.setLayout(layout)

        data_group_box = QGroupBox(u"", self)
        layout.addWidget(data_group_box)
        data_group_box_layout = QVBoxLayout()
        data_group_box.setLayout(data_group_box_layout)

        key_group = QHBoxLayout()
        data_group_box_layout.addLayout(key_group)
        key_group.addWidget(QLabel(u"EInk Kindle Serial Number:", self))
        self.key_ledit = QLineEdit("", self)
        self.key_ledit.setToolTip(u"Enter an eInk Kindle serial number. EInk Kindle serial numbers are 16 characters long and usually start with a 'B' or a '9'. Kindle Serial Numbers are case-sensitive, so be sure to enter the upper and lower case letters unchanged.")
        key_group.addWidget(self.key_ledit)
        key_label = QLabel(_(''), self)
        key_label.setAlignment(Qt.AlignHCenter)
        data_group_box_layout.addWidget(key_label)

        self.button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        self.button_box.accepted.connect(self.accept)
        self.button_box.rejected.connect(self.reject)
        layout.addWidget(self.button_box)

        self.resize(self.sizeHint())
예제 #56
0
    def __init__(self, parent=None, mm=None, mi = None):
        SizePersistedDialog.__init__(self, parent, 'casanova plugin:add book dialog')
        self.setWindowTitle('Add text to Casanova:')
        self.gui = parent
        self.mm = mm
        self.mi = mi
        self.one_line_description = ''

        layout = QVBoxLayout(self)
        self.setLayout(layout)

        self.one_liner_label = QLabel('Enter a short description (255 chars max) before pressing OK')
        layout.addWidget(self.one_liner_label)
        self.one_liner_str = QLineEdit(self)
        self.one_liner_str.setText('')
        layout.addWidget(self.one_liner_str)
        self.one_liner_label.setBuddy(self.one_liner_str)

        self.values_label = QLabel('Below are potential matches of texts that already exist - please make sure you are adding something new')
        layout.addWidget(self.values_label)
        self.values_list = QListWidget(self)
        self.values_list.setSelectionMode(QAbstractItemView.ExtendedSelection)
        layout.addWidget(self.values_list)
        
        self.button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        self.button_box.accepted.connect(self._accept_clicked)
        self.button_box.rejected.connect(self.reject)
        layout.addWidget(self.button_box)

        self._display_choices()

        # Cause our dialog size to be restored from prefs or created on first usage
        self.resize_dialog()
예제 #57
0
    def __init__(self, stats, location, parent=None):
        QDialog.__init__(self, parent)
        self.setWindowTitle(_('No library found'))
        self._l = l = QGridLayout(self)
        self.setLayout(l)
        self.stats, self.location = stats, location

        loc = self.oldloc = location.replace('/', os.sep)
        self.header = QLabel(_('No existing calibre library was found at %s. '
            'If the library was moved, select its new location below. '
            'Otherwise calibre will forget this library.')%loc)
        self.header.setWordWrap(True)
        ncols = 2
        l.addWidget(self.header, 0, 0, 1, ncols)
        self.cl = QLabel('<br><b>'+_('New location of this library:'))
        l.addWidget(self.cl, 1, 0, 1, ncols)
        self.loc = QLineEdit(loc, self)
        l.addWidget(self.loc, 2, 0, 1, 1)
        self.cd = QToolButton(self)
        self.cd.setIcon(QIcon(I('document_open.png')))
        self.cd.clicked.connect(self.choose_dir)
        l.addWidget(self.cd, 2, 1, 1, 1)
        self.bb = QDialogButtonBox(QDialogButtonBox.Abort)
        b = self.bb.addButton(_('Library moved'), self.bb.AcceptRole)
        b.setIcon(QIcon(I('ok.png')))
        b = self.bb.addButton(_('Forget library'), self.bb.RejectRole)
        b.setIcon(QIcon(I('edit-clear.png')))
        b.clicked.connect(self.forget_library)
        self.bb.accepted.connect(self.accept)
        self.bb.rejected.connect(self.reject)
        l.addWidget(self.bb, 3, 0, 1, ncols)
        self.resize(self.sizeHint() + QSize(100, 50))
예제 #58
0
    def __init__(self, parent=None,):
        QDialog.__init__(self, parent)
        self.parent = parent
        self.setWindowTitle(u"{0} {1}: Add New Mobipocket PID".format(PLUGIN_NAME, PLUGIN_VERSION))
        layout = QVBoxLayout(self)
        self.setLayout(layout)

        data_group_box = QGroupBox(u"", self)
        layout.addWidget(data_group_box)
        data_group_box_layout = QVBoxLayout()
        data_group_box.setLayout(data_group_box_layout)

        key_group = QHBoxLayout()
        data_group_box_layout.addLayout(key_group)
        key_group.addWidget(QLabel(u"PID:", self))
        self.key_ledit = QLineEdit("", self)
        self.key_ledit.setToolTip(u"Enter a Mobipocket PID. Mobipocket PIDs are 8 or 10 characters long. Mobipocket PIDs are case-sensitive, so be sure to enter the upper and lower case letters unchanged.")
        key_group.addWidget(self.key_ledit)
        key_label = QLabel(_(''), self)
        key_label.setAlignment(Qt.AlignHCenter)
        data_group_box_layout.addWidget(key_label)

        self.button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        self.button_box.accepted.connect(self.accept)
        self.button_box.rejected.connect(self.reject)
        layout.addWidget(self.button_box)

        self.resize(self.sizeHint())