示例#1
0
    def InitWindow(self):
        self.setWindowIcon(QtGui.QIcon("icon.png"))
        self.setWindowTitle(self.title)
        self.setGeometry(self.left, self.top, self.width, self.height)

        vbox = QVBoxLayout()

        button = QPushButton("Launch")
        button.clicked.connect(self.btn_clicked)

        vbox.addWidget(button)

        self.setLayout(vbox)

        self.wizard = QWizard()
        self.wizard.setWindowTitle("Launcher Page")
        page1 = QWizardPage()
        page1.setTitle("p11111")

        page2 = QWizardPage()
        page2.setTitle("page 2")
        self.wizard.addPage(page1)
        self.wizard.addPage(page2)

        self.show()
示例#2
0
    def create_finish_page(self):
        page = QWizardPage()
        page.setTitle("That's it!")

        #self.settings = self.gridsync_link
        text = 'By clicking <b>Done</b> below, Gridsync will begin synchronizing your selected folder with your storage grid and will continue to keep your files in sync so long as it is running.'
        label = QLabel(text)
        label.setWordWrap(True)

        img = QLabel()
        pixmap = QPixmap(":sync-complete.png")
        img.setPixmap(pixmap)

        warning_label = QLabel(
            '\n\n\n\nPlease note that, depending on how many files you have, your initial sync may take a while. When Gridsync is working, the system tray icon will animate and you will receive a desktop notification as soon as the process completes.'
        )
        warning_label.setWordWrap(True)

        layout = QVBoxLayout()
        layout.addWidget(label)
        layout.addWidget(img)
        layout.addWidget(warning_label)
        page.setLayout(layout)

        self.addPage(page)
示例#3
0
 def __init__(self, config: Config, on_finish: Callable,
              ui_app: QApplication):
     self._config = config
     self._config.reset_named_dirs()
     super().__init__(parent=None)
     page = QWizardPage()
     page.setTitle(texts.SETUP_HEADING)
     page.setSubTitle(texts.SETUP_TEXT)
     layout = NamedDirsForm(
         ui_app,
         self._config.named_dirs,
         on_change=self._on_named_dirs_change,
         parent=page,
         custom_names_enabled=False,
     )
     page.setLayout(layout)
     self.addPage(page)
     self.setWindowTitle(texts.SETUP_TITLE)
     self.setWizardStyle(QWizard.MacStyle)
     background = pkgutil.get_data('human_activities.qt.data',
                                   'qt_wizard_bg.png')
     pixmap = QPixmap()
     pixmap.loadFromData(background)
     self.setPixmap(QWizard.BackgroundPixmap, pixmap)
     if self.exec_():
         on_finish(self._config)
    def openfilepage(self):

        wpo = QWizardPage()
        wpo.isCommitPage()
        wpo.setTitle("Select HTML file")
        wpo_lbl = QLabel("Select an <b>HTML file</b> containing your website.<br />"
                         "Slimweb websites are meant to be one-pagers, for now - but one-pagers are fashionable, actually ;-).")
        wpo_lbl2 = QLabel("<b>Note:</b> If you want to publish the page with WebTorrent with this wizard, "
                          "it must be saved in the WebTorrent Download folder.")
        wpo_lbl.setWordWrap(True)
        wpo_lbl2.setWordWrap(True)

        insc_lbl = QLabel('<b>Inscription:</b> This is the magnet link appearing in your Slimcoin transaction.')
        self.fdl_flabel = QLabel('<em>No file selected</em>')
        self.insc_edit = QLineEdit()
        self.insc_edit.textChanged[str].connect(self.inscribe)

        fdl_btn = QPushButton("Open HTML File ...")
        fdl_btn.setToolTip('From an HTML File, a Torrent infohash can be created as an inscription.')
        fdl_btn.clicked.connect(self.openFileDialog)

        wpo_layout = QVBoxLayout()
        wpo_layout.addWidget(wpo_lbl)
        wpo_layout.addWidget(wpo_lbl2)
        wpo_layout.addWidget(self.fdl_flabel)
        wpo_layout.addWidget(fdl_btn)
        wpo_layout.addWidget(insc_lbl)
        wpo_layout.addWidget(self.insc_edit)

        wpo.setLayout(wpo_layout)

        return wpo
示例#5
0
    def create_configuration2_page(self):
        page = QWizardPage()
        page.setTitle("Gridsync configuration... in two easy steps")

        label = QLabel('<b>Step 2.</b> Select a local folder:\n\n ')
        label.setWordWrap(True)

        hbox = QWidget(self)
        hlayout = QHBoxLayout(hbox)
        self.folder_text = QLineEdit(hbox)
        button = QPushButton('Select Folder', self)
        button.clicked.connect(self.get_folder)
        hlayout.addWidget(self.folder_text)
        hlayout.addWidget(button)
        #self.folder_label = QLabel()

        warning_label = QLabel(
            '\n\n\n\nGridsync works by pairing directories on your computer with directories located on a storage grid. The folder you select here will be automatically synchronized with the address provided on the previous page.'
        )
        warning_label.setWordWrap(True)

        layout = QVBoxLayout()
        layout.addWidget(label)
        #layout.addWidget(button)
        layout.addWidget(hbox)
        layout.addWidget(warning_label)

        page.setLayout(layout)
        self.addPage(page)
    def publishpage(self):
        wpp = QWizardPage()
        wpp.setFinalPage(True)
        #wpp.isCommitPage()
        wpp.setTitle("Publish your page!")
        wpp_lbl = QLabel("You can publish your page now with WebTorrent.<br /> \
                          As long as you seed it, or any of your readers is seeding it, it is available on Slimweb.<br/> \
                          If there are no seeders left, you can seed it again at any time. Simply start WebTorrent.")
        wpp_lbl2 = QLabel("First, save your website as a torrent file, so WebTorrent can access it.")
        wpp_lbl.setWordWrap(True)
        wpp_lbl2.setWordWrap(True)
        save_btn = QPushButton("Save torrent file ...")
        save_btn.setToolTip("You can save the torrent file and share it now or later with a WebTorrent-compatible client.")

        save_btn.clicked.connect(self.saveTorrentFileDialog)



        wpp_layout = QVBoxLayout()
        wpp_layout.addWidget(wpp_lbl)
        wpp_layout.addWidget(wpp_lbl2)
        wpp_layout.addWidget(save_btn)
        wpp_layout.addWidget(self.aftersave_lbl)

        wpp.setLayout(wpp_layout)

        return wpp
示例#7
0
    def runConfigWizard(self):
        try:
            api = InstagramAPI(
                client_id=self.options_string['hidden_client_id'],
                client_secret=self.options_string['hidden_client_secret'],
                redirect_uri=self.options_string['redirect_uri'])
            url = api.get_authorize_login_url()

            self.wizard.setWindowTitle('Instagram plugin configuration wizard')
            page1 = QWizardPage()
            layout1 = QVBoxLayout()
            txtArea = QLabel()
            txtArea.setText(
                'Please copy the following link to your browser window. \n ' +
                'Once you authenticate with Instagram you will be redirected to '
                +
                'www.geocreepy.com and get your token. Copy the token to the input field below:'
            )
            urlArea = QLineEdit()
            urlArea.setObjectName('urlArea')
            urlArea.setText(url)
            inputLink = QLineEdit()
            inputLink.setObjectName('inputLink')
            labelLink = QLabel('Your token value:')
            openInBrowserButton = QPushButton('Open in browser')
            openInBrowserButton.clicked.connect(
                functools.partial(self.openLinkInBrowser, url))
            layout1.addWidget(txtArea)
            layout1.addWidget(urlArea)
            layout1.addWidget(openInBrowserButton)
            layout1.addWidget(labelLink)
            layout1.addWidget(inputLink)
            page1.setLayout(layout1)
            self.wizard.addPage(page1)
            self.wizard.resize(600, 400)
            if self.wizard.exec_():
                c = str(inputLink.text())
                if c:
                    try:
                        access_token = api.exchange_code_for_access_token(
                            code=c)
                        self.options_string[
                            'hidden_access_token'] = access_token[0]
                        self.saveConfiguration(self.config)
                    except Exception as err:
                        logger.error(err)
                        self.showWarning(
                            'Error Getting Access Token',
                            'Please verify that the link you pasted was correct. '
                            'Try running the wizard again.')
                else:
                    self.showWarning(
                        'Error Getting Access Token',
                        'Please verify that the link you pasted was correct. Try running the wizard again.'
                    )

        except Exception as err:
            logger.error(err)
            self.showWarning('Error', 'Error was {0}'.format(err))
    def endpage(self):
        wpx = QWizardPage()
        wpx.setTitle("Your website has been published!")

        wpx_layout = QVBoxLayout()
        wpx_layout.addWidget(self.webt_lbl)

        wpx.setLayout(wpx_layout)
        
        return wpx
示例#9
0
def createConclusionPage():
    page = QWizardPage()
    page.setTitle("Conclusion")

    label = QLabel("You are now successfully registered. Have a nice day!")
    label.setWordWrap(True)

    layout = QVBoxLayout()
    layout.addWidget(label)
    page.setLayout(layout)

    return page
    def intropage(self):
        wpi = QWizardPage()
        wpi.setTitle("Create a Slimweb webpage!")
        wpi_lbl = QLabel("This wizard will help you to publish or update a website on the decentralized Slimweb.<br/>"
                          "You need a HTML file, a Slimcoin client, WebTorrent and an Slimcoin address with a"
                          "balance of more than 0.02 SLM.")

        wpi_lbl.setWordWrap(True)
        wpi_layout = QVBoxLayout()
        wpi_layout.addWidget(wpi_lbl)
        wpi.setLayout(wpi_layout)
        return wpi
示例#11
0
文件: pywiz.py 项目: xxRonaldxx/pywiz
def addPage(title, text):
    page = QWizardPage()
    page.setTitle(title)
    label = QLabel(text)
    label.setWordWrap(True)
    label.setOpenExternalLinks(True)
    #label.setFont(QtGui.QFont('SansSerif', 12,QtGui.QFont.Bold))
    label.setFont(QFont('SansSerif', 10))
    wizard.setSubTitleFormat(0)
    layout = QVBoxLayout()
    layout.addWidget(label)
    page.setLayout(layout)
    wizard.addPage(page)
示例#12
0
    def create_welcome_page(self):
        page = QWizardPage()
        page.setTitle("Welcome to Gridsync!")

        label = QLabel(
            'Gridsync is an experimental desktop client for for Tahoe-LAFS, the Least Authority File Store. Tahoe-LAFS allows you to safely store all of your important files into a storage "grid" -- a distributed cluster of servers connected to the Internet.\n\nUnlike most other traditional "Cloud" services, any data stored by Tahoe-LAFS is safe and secure by default; nobody can read or alter the files stored in your grid without your permission -- not even the owners of the servers that store them.'
        )
        label.setWordWrap(True)

        layout = QVBoxLayout()
        layout.addWidget(label)
        page.setLayout(layout)

        self.addPage(page)
示例#13
0
def createIntroPage():
    page = QWizardPage()
    page.setTitle("Introduction")

    label = QLabel(
        "This wizard will help you register your copy of Super Product "
        "Two.")
    label.setWordWrap(True)

    layout = QVBoxLayout()
    layout.addWidget(label)
    page.setLayout(layout)

    return page
示例#14
0
    def add_page(self, title, widget):
        """Adds a page to this GenericWizard

        :param page: PropertyWidget to add
        """
        self.pages.append(widget)

        page = QWizardPage(self)
        page.setTitle(title)
        layout = QVBoxLayout()
        layout.addWidget(widget)
        page.setLayout(layout)

        self.addPage(page)
示例#15
0
    def wizard_pages(csl):
        from PyQt5.QtWidgets import (
            QWizardPage, QVBoxLayout, QLineEdit, QGridLayout, QLabel,

        )
        p = QWizardPage()
        vbox = QGridLayout(p)
        vbox.addWidget(QLabel("Location:"), 0, 0)
        line = QLineEdit()
        vbox.addWidget(line, 0, 1)
        vbox.addWidget(QLabel("Interpreter:"), 1, 0)
        line_interpreter = QLineEdit()
        vbox.addWidget(line_interpreter, 1, 1)

        return [p]
示例#16
0
    def create_systray_page(self):
        page = QWizardPage()
        img = QLabel()
        pixmap = QPixmap(":osx-prefs.png")
        img.setPixmap(pixmap)

        label = QLabel(
            'Like many other popular applications, Gridsync runs in the background of your computer and works while you do. If you ever need to change your settings in the future, you can do so by clicking the Gridsync icon in your system tray.'
        )
        label.setWordWrap(True)
        layout = QVBoxLayout()
        layout.addWidget(img)
        layout.addWidget(label)
        page.setLayout(layout)
        self.addPage(page)
示例#17
0
    def createConclusionPage(self):
        '''
        Create last page of wizard
        '''
        page = QWizardPage()
        page.setTitle("Conclusion")

        label = QLabel("Your project has been created")
        label.setWordWrap(True)

        layout = QVBoxLayout()
        layout.addWidget(label)
        page.setLayout(layout)

        return page
    def selectaddrpage(self):

        wps = QWizardPage()
        wps.setTitle("Select a Slimcoin address")
        wps_lbl = QLabel("A Slimcoin address is the <b>identifier</b> for your website, like the domain in the WWW.<br />"
                         "You publish all updates on a single website from the same address.")
        wps_lbl.setWordWrap(True)
        addr_lbl = QLabel('Select an address from the list below:')

        # addresslist = self.insc.get_addresslist()
        acd = self.insc.create_addr_combodict()
        # address selector
        addr_cb = QComboBox()
        addr_tv = QTableView()
        addr_model = QStandardItemModel(len(acd), 3)
        addr_model.setHorizontalHeaderLabels(["Address", "Balance", "Label"])
        x = 0
        item_addresses = [] # is item_addresses etc. necessary? Probably not, as the items are only for the GUI view and need not to be accessed afterwards.
        item_balances = []
        item_labels = []
        for address in acd.keys():
           item_addresses.append(QStandardItem(address)) 
           item_balances.append(QStandardItem(str(acd[address]["balance"])))
           item_labels.append(QStandardItem(acd[address]["label"]))
           addr_model.setItem(x, 0, item_addresses[x])
           addr_model.setItem(x, 1, item_balances[x])
           addr_model.setItem(x, 2, item_labels[x])
           x += 1

        print(item_addresses)
        print(acd)

        addr_cb.setView(addr_tv)
        addr_cb.setModel(addr_model)



        self.insc.address = list(acd.keys())[0] # default: first address
        # addr_cb.addItems(addresslist)
        addr_cb.activated[str].connect(self.insc.set_address)

        wps_layout = QVBoxLayout()
        wps_layout.addWidget(wps_lbl)
        wps_layout.addWidget(addr_lbl)
        wps_layout.addWidget(addr_cb)

        wps.setLayout(wps_layout)
        return wps
示例#19
0
    def createIntroPage(self):
        '''
        Create first page of wizard
        '''
        page = QWizardPage()
        page.setTitle("Welcome")

        label = QLabel(
                "Follow instructions to create new Map Reader project.")
        label.setWordWrap(True)

        layout = QVBoxLayout()
        layout.addWidget(label)
        page.setLayout(layout)

        return page
示例#20
0
    def createIntroPage(self):
        page = QWizardPage()
        page.setTitle("Introduction")

        label = QLabel("This wizard will show you a simple wizard.")
        label.setWordWrap(True)

        label2 = QLabel(
            "Therefore it will create a Sine plugin, a plot and connect these two."
        )
        label2.setWordWrap(True)

        layout = QVBoxLayout()
        layout.addWidget(label)
        layout.addWidget(label2)

        page.setLayout(layout)
        return page
示例#21
0
def createRegistrationPage():
    page = QWizardPage()
    page.setTitle("Registration")
    page.setSubTitle("Please fill both fields.")

    nameLabel = QLabel("Name:")
    nameLineEdit = QLineEdit()

    emailLabel = QLabel("Email address:")
    emailLineEdit = QLineEdit()

    layout = QGridLayout()
    layout.addWidget(nameLabel, 0, 0)
    layout.addWidget(nameLineEdit, 0, 1)
    layout.addWidget(emailLabel, 1, 0)
    layout.addWidget(emailLineEdit, 1, 1)
    page.setLayout(layout)

    return page
示例#22
0
    def create_configuration1_page(self):
        page = QWizardPage()
        page.setTitle("Gridsync configuration... in two easy steps")

        label = QLabel(
            '<b>Step 1.</b> Paste a Tahoe-LAFS Introducer fURL below:\n\n ')
        label.setWordWrap(True)

        self.introducer_furl = QLineEdit("")

        info_label = QLabel(
            '\n\n\n\nAn "Introducer fURL" (in the form "<i>pb://[email protected]/introducer</i>") is a special address that points to a Tahoe-LAFS storage grid. If you do not have an Introducer fURL, you can get one from the operator of a storage grid -- or from one of your friends that uses Tahoe-LAFS.'
        )
        info_label.setWordWrap(True)

        layout = QVBoxLayout()
        layout.addWidget(label)
        layout.addWidget(self.introducer_furl)
        layout.addWidget(info_label)

        page.setLayout(layout)
        self.addPage(page)
    def sendpage(self):

        wpe = QWizardPage()

        wpe.setTitle("Inscribe your website!")
        wpe_lbl = QLabel("If you continue, you inscribe your page in the Slimcoin blockchain with"                         
                         " a special transaction. This cannot be undone!<br/>"
                         "You can check the transaction data before (recommended).")
        wpe_lbl2 = QLabel("<b>Note:</b> Every inscription transaction has a mandatory fee of 0.02 SLM.")
        wpe_lbl.setWordWrap(True)
        wpe_lbl2.setWordWrap(True)

        check_button = QPushButton("Check transaction data")
        check_button.clicked.connect(self.checkTXDialog)

        wpe_layout = QVBoxLayout()
        wpe_layout.addWidget(wpe_lbl)
        wpe_layout.addWidget(wpe_lbl2)
        wpe_layout.addWidget(check_button)



        wpe.setLayout(wpe_layout)
        return wpe
示例#24
0
    def __init__(self, parent=None):
        """Initialize the ImportWizard instance."""
        super().__init__(parent=parent)

        self.filename = None
        self.auth = None
        self.race = None

        # Create the race selection page.
        race_selection_page = QWizardPage()
        race_selection_page.setTitle('Race Selection')

        # Create the wizard and add our pages.
        self.setWindowTitle('OnTheDay.net race config import')
        self.addPage(
            IntroductionPage(
                'This wizard will authenticate with OnTheDay.net and import '
                'an existing race configuration. Optionally, a remote '
                'connection to the race will be established (or this can be '
                'done at a later time).'))
        self.addPage(AuthenticationPage())
        self.addPage(RaceSelectionPage())
        self.addPage(FileSelectionPage())
        self.addPage(ImportPage())
示例#25
0
    def __init__(self, parent: QWidget, apikey: EmApiKey = None):
        super(AddEditApikeyDialog, self).__init__(parent)

        self._logger = get_logger(__name__)
        self._apikey = EmApiKey()
        if apikey is not None:
            self._apikey = apikey  # copy reference to existing object, bound to DB
            if self._apikey.friendly_name is None:
                self._apikey.friendly_name = ''

        self.setSizeGripEnabled(True)
        self.setMinimumSize(300, 200)
        self.icon = QIcon('img/pyevemon.png')
        self.setWindowIcon(self.icon)

        if not self._apikey.is_empty():
            self.setWindowTitle(self.tr('Edit API key'))
        else:
            self.setWindowTitle(self.tr('Add API key'))

        # wizard pages.
        # Page 1: API key ID / vcode input
        self.page1 = QWizardPage(self)
        self.page1.setTitle(self.tr('API Key ID / vCode input'))
        self.page1.setSubTitle(self.tr('Edit API key ID and vCode'))
        self.page1.l = QGridLayout()
        self.page1.setLayout(self.page1.l)
        self.page1.lbl_keyID = QLabel(self.tr('API key ID:'), self.page1)
        self.page1.lbl_vcode = QLabel(self.tr('API key vCode:'), self.page1)
        self.page1.le_keyID = QLineEdit(self.page1)
        self.page1.le_vcode = QLineEdit(self.page1)
        self.page1.lbl_keyID.setBuddy(self.page1.le_keyID)
        self.page1.lbl_vcode.setBuddy(self.page1.le_vcode)
        self.page1.l.addWidget(self.page1.lbl_keyID, 0, 0)
        self.page1.l.addWidget(self.page1.le_keyID, 0, 1)
        self.page1.l.addWidget(self.page1.lbl_vcode, 1, 0)
        self.page1.l.addWidget(self.page1.le_vcode, 1, 1)
        self.page1.registerField('keyid', self.page1.le_keyID)
        self.page1.registerField('vcode', self.page1.le_vcode)

        self.page2 = QWizardPage(self)
        self.page2.setTitle(self.tr('API Key type and access mask'))
        # self.page2.setSubTitle(self.tr('Check thar API key has acceptable access rights'))
        self.page2.l = QVBoxLayout()
        self.page2.l1 = QHBoxLayout()  # key type
        self.page2.l2 = QHBoxLayout()  # access mask
        self.page2.l3 = QHBoxLayout()  # characters
        self.page2.l4 = QHBoxLayout()  # expires
        self.page2.lx = QGridLayout()  # checks grid
        self.page2.setLayout(self.page2.l)
        self.page2.l.addLayout(self.page2.l1)
        self.page2.l.addLayout(self.page2.l2)
        self.page2.l.addLayout(self.page2.l3)
        self.page2.l.addLayout(self.page2.l4)
        self.page2.l.addLayout(self.page2.lx)
        #
        self.page2.lbl_keytype = QLabel(self.tr('API Key type:'), self.page2)
        self.page2.lbl_keytype_v = QLabel('', self.page2)
        self.page2.lbl_accessmask = QLabel(self.tr('API Key access mask:'),
                                           self.page2)
        self.page2.lbl_accessmask_v = QLabel('', self.page2)
        self.page2.lbl_characters = QLabel(self.tr('Characters:'), self.page2)
        self.page2.lbl_characters_v = QLabel('', self.page2)
        self.page2.lbl_expires = QLabel(self.tr('Expires:'), self.page2)
        self.page2.lbl_expires_v = QLabel('', self.page2)
        self.page2.l1.addWidget(self.page2.lbl_keytype)
        self.page2.l1.addWidget(self.page2.lbl_keytype_v)
        self.page2.l1.addStretch()
        self.page2.l2.addWidget(self.page2.lbl_accessmask)
        self.page2.l2.addWidget(self.page2.lbl_accessmask_v)
        self.page2.l2.addStretch()
        self.page2.l3.addWidget(self.page2.lbl_characters)
        self.page2.l3.addWidget(self.page2.lbl_characters_v)
        self.page2.l3.addStretch()
        self.page2.l4.addWidget(self.page2.lbl_expires)
        self.page2.l4.addWidget(self.page2.lbl_expires_v)
        self.page2.l4.addStretch()
        #
        self.page2.w_basicfuncs = LabelWithOkCancelIcon(self.page2)
        self.page2.w_basicfuncs.set_text(self.tr('Basic character info'))
        self.page2.lx.addWidget(self.page2.w_basicfuncs, 0, 0)
        self.page2.w_skills = LabelWithOkCancelIcon(self.page2)
        self.page2.w_skills.set_text(self.tr('Skills monitoring'))
        self.page2.lx.addWidget(self.page2.w_skills, 1, 0)
        #
        self.page3 = QWizardPage(self)
        self.page3.l = QVBoxLayout()
        self.page3.l1 = QHBoxLayout()
        self.page3.l2 = QHBoxLayout()
        self.page3.lgb = QVBoxLayout()
        self.page3.setLayout(self.page3.l)
        self.page3.lbl_keyname = QLabel(self.tr('Enter key name:'), self.page3)
        self.page3.le_keyname = QLineEdit(self)
        self.page3.gb = QGroupBox(self.tr('Select characters to import:'),
                                  self.page3)
        self.page3.gb.setCheckable(False)
        self.page3.gb.setFlat(False)
        self.page3.gb.setLayout(self.page3.lgb)
        self.page3.l1.addWidget(self.page3.lbl_keyname)
        self.page3.l1.addWidget(self.page3.le_keyname)
        self.page3.l2.addWidget(self.page3.gb)
        self.page3.l.addLayout(self.page3.l1)
        self.page3.l.addLayout(self.page3.l2)
        self.page3.registerField('keyname', self.page3.le_keyname)

        self.addPage(self.page1)
        self.addPage(self.page2)
        self.addPage(self.page3)

        # wizard options
        self.setOption(QWizard.HaveHelpButton, False)
示例#26
0
 def wizard_pages(cls):
     from PyQt5.QtWidgets import QWizardPage
     p = QWizardPage()
     p.setTitle("PPPPPP")
     p.setSubTitle("Pyqslaldsald ")
     return [p]
示例#27
0
    def showDialog(self):
        # Initialise the setup directory empty toavoid exceptions.
        self.setupDictionary = {}

        # ask for a project directory.
        self.projectDirectory = QFileDialog.getExistingDirectory(
            caption=i18n("Where should the comic project go?"),
            options=QFileDialog.ShowDirsOnly)
        if os.path.exists(self.projectDirectory) is False:
            return
        self.pagesDirectory = os.path.relpath(self.projectDirectory,
                                              self.projectDirectory)
        self.exportDirectory = os.path.relpath(self.projectDirectory,
                                               self.projectDirectory)

        wizard = QWizard()
        wizard.setWindowTitle(i18n("Comic Project Setup"))
        wizard.setOption(QWizard.IndependentPages, True)

        # Set up the UI for the wizard
        basicsPage = QWizardPage()
        basicsPage.setTitle(i18n("Basic Comic Project Settings"))
        formLayout = QFormLayout()
        basicsPage.setLayout(formLayout)
        projectLayout = QHBoxLayout()
        self.lnProjectName = QLineEdit()
        basicsPage.registerField("Project Name*", self.lnProjectName)
        self.lnProjectName.setToolTip(
            i18n(
                "A Project name. This can be different from the eventual title"
            ))
        btnRandom = QPushButton()
        btnRandom.setText(i18n("Generate"))
        btnRandom.setToolTip(
            i18n(
                "If you cannot come up with a project name, our highly sophisticated project name generator will serve to give a classy yet down to earth name."
            ))
        btnRandom.clicked.connect(self.slot_generate)
        projectLayout.addWidget(self.lnProjectName)
        projectLayout.addWidget(btnRandom)
        lnConcept = QLineEdit()
        lnConcept.setToolTip(
            i18n(
                "What is your comic about? This is mostly for your own convenience so don't worry about what it says too much."
            ))
        self.cmbLanguage = comics_metadata_dialog.language_combo_box()
        self.cmbLanguage.setToolTip(i18n("The main language the comic is in"))
        self.cmbLanguage.setEntryToCode(
            str(QLocale.system().name()).split("_")[0])
        self.lnProjectDirectory = QLabel(self.projectDirectory)
        self.chkMakeProjectDirectory = QCheckBox(
            i18n("Make a new directory with the project name."))
        self.chkMakeProjectDirectory.setToolTip(
            i18n(
                "This allows you to select a generic comics project directory, in which a new folder will be made for the project using the given project name."
            ))
        self.chkMakeProjectDirectory.setChecked(True)
        self.lnPagesDirectory = QLineEdit()
        self.lnPagesDirectory.setText(i18n("pages"))
        self.lnPagesDirectory.setToolTip(
            i18n(
                "The name for the folder where the pages are contained. If it doesn't exist, it will be created."
            ))
        self.lnExportDirectory = QLineEdit()
        self.lnExportDirectory.setText(i18n("export"))
        self.lnExportDirectory.setToolTip(
            i18n(
                "The name for the folder where the export is put. If it doesn't exist, it will be created."
            ))
        self.lnTemplateLocation = QLineEdit()
        self.lnTemplateLocation.setText(i18n("templates"))
        self.lnTemplateLocation.setToolTip(
            i18n(
                "The name for the folder where the page templates are sought in."
            ))

        self.lnTranslationLocation = QLineEdit()
        self.lnTranslationLocation.setText(i18n("translations"))
        self.lnTranslationLocation.setToolTip(
            "This is the location that POT files will be stored to and PO files will be read from."
        )
        formLayout.addRow(i18n("Comic Concept:"), lnConcept)
        formLayout.addRow(i18n("Project Name:"), projectLayout)
        formLayout.addRow(i18n("Main Language:"), self.cmbLanguage)

        buttonMetaData = QPushButton(i18n("Meta Data"))
        buttonMetaData.clicked.connect(self.slot_edit_meta_data)

        wizard.addPage(basicsPage)

        foldersPage = QWizardPage()
        foldersPage.setTitle(i18n("Folder names and other."))
        folderFormLayout = QFormLayout()
        foldersPage.setLayout(folderFormLayout)
        folderFormLayout.addRow(i18n("Project Directory:"),
                                self.lnProjectDirectory)
        folderFormLayout.addRow("", self.chkMakeProjectDirectory)
        folderFormLayout.addRow(i18n("Pages Directory"), self.lnPagesDirectory)
        folderFormLayout.addRow(i18n("Export Directory"),
                                self.lnExportDirectory)
        folderFormLayout.addRow(i18n("Template Directory"),
                                self.lnTemplateLocation)
        folderFormLayout.addRow(i18n("Translation Directory"),
                                self.lnTranslationLocation)
        folderFormLayout.addRow("", buttonMetaData)
        wizard.addPage(foldersPage)

        # Execute the wizard, and after wards...
        if (wizard.exec_()):

            # First get the directories, check if the directories exist, and otherwise make them.
            self.pagesDirectory = self.lnPagesDirectory.text()
            self.exportDirectory = self.lnExportDirectory.text()
            self.templateLocation = self.lnTemplateLocation.text()
            self.translationLocation = self.lnTranslationLocation.text()
            projectPath = Path(self.projectDirectory)
            # Only make a project directory if the checkbox for that has been checked.
            if self.chkMakeProjectDirectory.isChecked():
                projectPath = projectPath / self.lnProjectName.text()
                if projectPath.exists() is False:
                    projectPath.mkdir()
                self.projectDirectory = str(projectPath)
            if Path(projectPath / self.pagesDirectory).exists() is False:
                Path(projectPath / self.pagesDirectory).mkdir()
            if Path(projectPath / self.exportDirectory).exists() is False:
                Path(projectPath / self.exportDirectory).mkdir()
            if Path(projectPath / self.templateLocation).exists() is False:
                Path(projectPath / self.templateLocation).mkdir()
            if Path(projectPath / self.translationLocation).exists() is False:
                Path(projectPath / self.translationLocation).mkdir()

            # Then store the information into the setup diactionary.
            self.setupDictionary["projectName"] = self.lnProjectName.text()
            self.setupDictionary["concept"] = lnConcept.text()
            self.setupDictionary["language"] = str(
                self.cmbLanguage.codeForCurrentEntry())
            self.setupDictionary["pagesLocation"] = self.pagesDirectory
            self.setupDictionary["exportLocation"] = self.exportDirectory
            self.setupDictionary["templateLocation"] = self.templateLocation
            self.setupDictionary[
                "translationLocation"] = self.translationLocation

            # Finally, write the dictionary into the json file.
            self.writeConfig()
示例#28
0
文件: twitter.py 项目: eBeyond/creepy
    def runConfigWizard(self):
        try:
            oAuthHandler = tweepy.OAuthHandler(
                self.options_string['hidden_application_key'],
                self.options_string['hidden_application_secret'])
            authorizationURL = oAuthHandler.get_authorization_url(True)

            self.wizard.setWindowTitle('Twitter plugin configuration wizard')
            page1 = QWizardPage()
            page2 = QWizardPage()
            layout1 = QVBoxLayout()
            layout2 = QVBoxLayout()
            layoutInputPin = QHBoxLayout()

            label1a = QLabel(
                'Click next to connect to twitter.com . Please login with your account and follow the instructions in '
                'order to authorize creepy')
            label2a = QLabel(
                'Copy the PIN that you will receive once you authorize cree.py in the field below and click finish'
            )
            pinLabel = QLabel('PIN')
            inputPin = QLineEdit()
            inputPin.setObjectName('inputPin')

            analysisHtml = QWebEngineView()
            analysisHtml.load(QUrl(authorizationURL))

            layout1.addWidget(label1a)
            layout2.addWidget(analysisHtml)
            layout2.addWidget(label2a)
            layoutInputPin.addWidget(pinLabel)
            layoutInputPin.addWidget(inputPin)
            layout2.addLayout(layoutInputPin)

            page1.setLayout(layout1)
            page2.setLayout(layout2)
            page2.registerField('inputPin*', inputPin)
            self.wizard.addPage(page1)
            self.wizard.addPage(page2)
            self.wizard.resize(800, 600)

            if self.wizard.exec_():
                try:
                    oAuthHandler.get_access_token(
                        str(self.wizard.field('inputPin').toString()).strip())
                    self.options_string[
                        'hidden_access_token'] = oAuthHandler.access_token
                    self.options_string[
                        'hidden_access_token_secret'] = oAuthHandler.access_token_secret
                    self.saveConfiguration(self.config)
                except Exception as err:
                    logger.error(err)
                    self.showWarning(
                        'Error completing the wizard',
                        'We were unable to obtain the access token for your account, please try to run '
                        'the wizard again. Error was {0}'.format(err.message))

        except Exception as err:
            logger.error(err)
            self.showWarning('Error completing the wizard',
                             'Error was: {0}'.format(err.message))