def __init__(self):
        box = gui.widgetBox(self.controlArea,
                            'Yahoo Finance Stock Data',
                            orientation='horizontal')
        lbox = gui.widgetBox(box, orientation='vertical')
        hbox = gui.widgetBox(lbox, orientation='horizontal')
        gui.label(hbox, self, 'Ticker:')
        self.combo = combo = QComboBox(editable=True,
                                       insertPolicy=QComboBox.InsertAtTop)
        combo.addItems(self.symbols)
        hbox.layout().addWidget(combo)
        # combo = gui.comboBox(
        #     lbox, self, 'symbol',#, items=self.symbols,
        #     label='Ticker:', orientation='horizontal',
        #     editable=True, maximumContentsLength=-1)
        gui.rubber(combo.parentWidget())
        minDate = QDate.fromString(self.MIN_DATE.strftime(self.PY_DATE_FORMAT),
                                   self.QT_DATE_FORMAT)
        date_from = QDateEdit(QDate.fromString(self.date_from,
                                               self.QT_DATE_FORMAT),
                              displayFormat=self.QT_DATE_FORMAT,
                              minimumDate=minDate,
                              calendarPopup=True)
        date_to = QDateEdit(QDate.fromString(self.date_to,
                                             self.QT_DATE_FORMAT),
                            displayFormat=self.QT_DATE_FORMAT,
                            minimumDate=minDate,
                            calendarPopup=True)
        date_from.dateChanged.connect(lambda date: setattr(
            self, 'date_from', date.toString(self.QT_DATE_FORMAT)))
        date_to.dateChanged.connect(lambda date: setattr(
            self, 'date_to', date.toString(self.QT_DATE_FORMAT)))
        hbox = gui.hBox(lbox)
        gui.label(hbox, self, "From:")
        hbox.layout().addWidget(date_from)
        hbox = gui.hBox(lbox)
        gui.label(hbox, self, "To:")
        hbox.layout().addWidget(date_to)

        gui.radioButtons(box,
                         self,
                         'data_granularity',
                         btnLabels=[
                             i.name.capitalize().replace('_', ' ')
                             for i in DataGranularity
                         ],
                         box='Resolution')
        self.button = gui.button(self.controlArea,
                                 self,
                                 'Download',
                                 callback=self.download)
Esempio n. 2
0
        def showDate(date):
            clearLayout(self.shotsLayout)

            getDate = date.toString("dd/MM/yy")
            workedShots = getShots(getDate)
            buildUI(workedShots)
            return workedShots
Esempio n. 3
0
 def showTime(self):
     time = QTime.currentTime()
     date = QDate.currentDate()
     showdate = date.toString('dddd,MMM-dd-yyyy')
     showtime = time.toString('hh:mm:ss')
     self.timebox.setText(showtime)
     self.datebox.setText(showdate)
    def __init__(self):
        box = gui.widgetBox(self.controlArea, 'Yahoo Finance Stock Data',
                            orientation='horizontal')
        lbox = gui.widgetBox(box, orientation='vertical')
        hbox = gui.widgetBox(lbox, orientation='horizontal')
        gui.label(hbox, self, 'Ticker:')
        self.combo = combo = QComboBox(editable=True,
                                       insertPolicy=QComboBox.InsertAtTop)
        combo.addItems(self.symbols)
        hbox.layout().addWidget(combo)
        # combo = gui.comboBox(
        #     lbox, self, 'symbol',#, items=self.symbols,
        #     label='Ticker:', orientation='horizontal',
        #     editable=True, maximumContentsLength=-1)
        gui.rubber(combo.parentWidget())
        minDate = QDate.fromString(self.MIN_DATE.strftime(self.PY_DATE_FORMAT),
                                   self.QT_DATE_FORMAT)
        date_from = QDateEdit(
            QDate.fromString(self.date_from, self.QT_DATE_FORMAT),
            displayFormat=self.QT_DATE_FORMAT,
            minimumDate=minDate,
            calendarPopup=True)
        date_to = QDateEdit(
            QDate.fromString(self.date_to, self.QT_DATE_FORMAT),
            displayFormat=self.QT_DATE_FORMAT,
            minimumDate=minDate,
            calendarPopup=True)
        date_from.dateChanged.connect(
            lambda date: setattr(self, 'date_from',
                                 date.toString(self.QT_DATE_FORMAT)))
        date_to.dateChanged.connect(
            lambda date: setattr(self, 'date_to',
                                 date.toString(self.QT_DATE_FORMAT)))
        hbox = gui.hBox(lbox)
        gui.label(hbox, self, "From:")
        hbox.layout().addWidget(date_from)
        hbox = gui.hBox(lbox)
        gui.label(hbox, self, "To:")
        hbox.layout().addWidget(date_to)

        gui.radioButtons(box, self, 'data_granularity',
                         btnLabels=[i.name.capitalize().replace('_', ' ')
                                    for i in DataGranularity],
                         box='Resolution')
        self.button = gui.button(self.controlArea, self, 'Download',
                                 callback=self.download)
Esempio n. 5
0
 def accept(self):
     self.cur = self.database.cursor
     date = self.date_edit.date()
     due_date = date.addMonths(1)
     student_id = self.student_id
     book_id = self.book_box.text()
     self.cur.execute(
         "INSERT INTO borrows (date, due_date, student_id, book_id, status) VALUES(?,?,?,?,?)",
         (date.toString('yyyy-MM-dd'), due_date.toString('yyyy-MM-dd'),
          int(student_id), int(book_id), 0))
     borrow_id = self.cur.lastrowid
     self.cur.execute("UPDATE books SET status = ? WHERE book_id = ?",
                      (borrow_id, book_id))
     self.con.commit()
     self.close()
Esempio n. 6
0
    def reciveDateTime(self):
        Date = ""
        Time = ""

        date = self.calendarWidget.selectedDate()
        Date += date.toString("yyyy MM dd")

        time = self.timeEdit.time()
        Time += time.toString("HH mm")

        self.year = Date[:4]
        self.month = Date[5:7]
        self.day = Date[8:10]

        self.hour = Time[:2]
        self.minute = Time[3:6]

        self.result += self.day + "." + self.month + "." + self.year + " в " + self.hour + ":" + self.minute
    def __init__(self, name=None, parent=None):
        super().__init__(parent)
        self.name = name
        self.cal = QCalendarWidget(self)
        initial_date = QDate.currentDate().addDays(-1)
        self.cal.setSelectedDate(initial_date)
        self.cal.setGridVisible(True)
        self.cal.clicked[QDate].connect(self.show_date)
        self.text_area = QLabel(self)
        date = self.cal.selectedDate()
        self.text_area.setText(date.toString())

        hbox_layout = QHBoxLayout()
        hbox_layout.addWidget(self.cal)
        vbox_layout = QVBoxLayout()
        vbox_layout.addLayout(hbox_layout)
        vbox_layout.addWidget(self.text_area)
        self.setLayout(vbox_layout)
Esempio n. 8
0
 def pre_upload(self):
     firstSemesterDay = [" "] * 2
     date = self.dateEdit.date()
     now = datetime.now()
     if QtCore.QDate(now.year, 8, 25) < date < QtCore.QDate(
             now.year, 9, 25) or QtCore.QDate(
                 now.year, 1, 25) < date < QtCore.QDate(now.year, 2, 25):
         Date = date.toString("MM dd")
         firstSemesterDay[0] = Date[:2]
         firstSemesterDay[1] = Date[3:5]
         fout = open('JSON\FirstDay.json', 'w', encoding='utf8')
         json.dump(firstSemesterDay, fout, ensure_ascii=False)
         fout.close()
         #self.textBrowser_2.setText("Обновление...")
         self.upload()
         print("!")
     else:
         self.textBrowser_2.setText(
             "Введенная вами дата не может быть началом семестра.")
Esempio n. 9
0
    def accept(self):
        self.cur = self.database.cursor
        date = self.date_edit.date()
        due_date = date.addMonths(1)
        student_id = self.student_id
        book_id = self.book_box.text()
        self.cur.execute(
            "INSERT INTO borrows (date, due_date, student_id, book_id, status) VALUES(?,?,?,?,?)",
            (date.toString('yyyy-MM-dd'), due_date.toString('yyyy-MM-dd'),
             int(student_id), int(book_id), 0))
        borrow_id = self.cur.lastrowid
        self.cur.execute("UPDATE books SET status = ? WHERE book_id = ?",
                         (borrow_id, book_id))
        self.con.commit()
        self.close()

        self.cur = self.database.cursor

        index = self.status_box.currentIndex()
        if index == 0:
            status = 0
        if index == 1:
            status = 1
        if index == 2:
            status = -1

        borrow_id = str(self.id_label.text())
        book_id = self.book_box.value()
        old_book_id = self.book_id
        student_id = self.student_box.value()
        date = self.date_edit.date().toString('yyyy-MM-dd')
        data = (date, student_id, book_id, status, borrow_id)
        self.cur.execute(
            "UPDATE borrows SET date = ?, student_id = ?, book_id = ?, status = ? WHERE borrow_id = ?",
            data)  # update borrow
        self.cur.execute("UPDATE books SET status = ? WHERE book_id = ?",
                         ("libera", old_book_id))  # update old book
        self.cur.execute("UPDATE books SET status = ? WHERE book_id = ?",
                         (borrow_id, book_id))  # update new book

        self.con.commit()
        self.close()
Esempio n. 10
0
    def __init__(self):
        super().__init__()

        self.output_corpus = None
        self.pubmed_api = None
        self.progress = None
        self.email_is_valid = False
        self.record_count = 0
        self.download_running = False

        # To hold all the controls. Makes access easier.
        self.pubmed_controls = []

        h_box = gui.hBox(self.controlArea)
        label = gui.label(h_box, self, 'Email:')
        label.setMaximumSize(label.sizeHint())
        # Drop-down for recent emails.
        self.email_combo = QComboBox(h_box)
        self.email_combo.setMinimumWidth(150)
        self.email_combo.setEditable(True)
        self.email_combo.lineEdit().textChanged.connect(self.sync_email)
        h_box.layout().addWidget(self.email_combo)
        self.email_combo.activated[int].connect(self.select_email)

        # RECORD SEARCH
        self.search_tabs = gui.tabWidget(self.controlArea)
        # --- Regular search ---
        regular_search_box = gui.widgetBox(self.controlArea, addSpace=True)

        # Author
        self.author_input = gui.lineEdit(regular_search_box,
                                         self,
                                         'author',
                                         'Author:',
                                         orientation=Qt.Horizontal)
        self.pubmed_controls.append(self.author_input)

        h_box = gui.hBox(regular_search_box)
        year_box = gui.widgetBox(h_box, orientation=Qt.Horizontal)
        min_date = QDate.fromString(
            self.MIN_DATE.strftime(self.PY_DATE_FORMAT), self.QT_DATE_FORMAT)

        if not self.pub_date_from:
            self.pub_date_from = self.MIN_DATE.strftime(self.PY_DATE_FORMAT)
        if not self.pub_date_to:
            self.pub_date_to = date.today().strftime(self.PY_DATE_FORMAT)

        self.date_from = QDateEdit(QDate.fromString(self.pub_date_from,
                                                    self.QT_DATE_FORMAT),
                                   displayFormat=self.QT_DATE_FORMAT,
                                   minimumDate=min_date,
                                   calendarPopup=True)
        self.date_to = QDateEdit(QDate.fromString(self.pub_date_to,
                                                  self.QT_DATE_FORMAT),
                                 displayFormat=self.QT_DATE_FORMAT,
                                 minimumDate=min_date,
                                 calendarPopup=True)

        self.date_from.dateChanged.connect(lambda date: setattr(
            self, 'pub_date_from', date.toString(self.QT_DATE_FORMAT)))
        self.date_to.dateChanged.connect(lambda date: setattr(
            self, 'pub_date_to', date.toString(self.QT_DATE_FORMAT)))
        self.pubmed_controls.append(self.date_from)
        self.pubmed_controls.append(self.date_to)

        gui.label(year_box, self, 'From:')
        year_box.layout().addWidget(self.date_from)
        gui.label(year_box, self, 'to:')
        year_box.layout().addWidget(self.date_to)

        # Keywords.
        h_box = gui.hBox(regular_search_box)
        label = gui.label(h_box, self, 'Query:')
        label.setMaximumSize(label.sizeHint())
        self.keyword_combo = QComboBox(h_box)
        self.keyword_combo.setMinimumWidth(150)
        self.keyword_combo.setEditable(True)
        h_box.layout().addWidget(self.keyword_combo)
        self.keyword_combo.activated[int].connect(self.select_keywords)
        self.pubmed_controls.append(self.keyword_combo)

        tab_height = regular_search_box.sizeHint()
        regular_search_box.setMaximumSize(tab_height)

        # --- Advanced search ---
        advanced_search_box = gui.widgetBox(self.controlArea, addSpace=True)
        # Advanced search query.
        h_box = gui.hBox(advanced_search_box)
        self.advanced_query_input = QTextEdit(h_box)
        h_box.layout().addWidget(self.advanced_query_input)
        self.advanced_query_input.setMaximumSize(tab_height)
        self.pubmed_controls.append(self.advanced_query_input)

        gui.createTabPage(self.search_tabs, 'Regular search',
                          regular_search_box)
        gui.createTabPage(self.search_tabs, 'Advanced search',
                          advanced_search_box)

        # Search info label.
        self.search_info_label = gui.label(self.controlArea, self,
                                           'Number of records found: /')

        # Search for records button.
        self.run_search_button = gui.button(
            self.controlArea,
            self,
            'Find records',
            callback=self.run_search,
            tooltip='Performs a search for articles that fit the '
            'specified parameters.')
        self.pubmed_controls.append(self.run_search_button)

        h_line = QFrame()
        h_line.setFrameShape(QFrame.HLine)
        h_line.setFrameShadow(QFrame.Sunken)
        self.controlArea.layout().addWidget(h_line)

        # RECORD RETRIEVAL
        # Text includes box.
        text_includes_box = gui.widgetBox(self.controlArea,
                                          'Text includes',
                                          addSpace=True)
        self.authors_checkbox = gui.checkBox(text_includes_box, self,
                                             'includes_authors', 'Authors')
        self.title_checkbox = gui.checkBox(text_includes_box, self,
                                           'includes_title', 'Article title')
        self.mesh_checkbox = gui.checkBox(text_includes_box, self,
                                          'includes_mesh', 'Mesh headings')
        self.abstract_checkbox = gui.checkBox(text_includes_box, self,
                                              'includes_abstract', 'Abstract')
        self.url_checkbox = gui.checkBox(text_includes_box, self,
                                         'includes_url', 'URL')
        self.pubmed_controls.append(self.authors_checkbox)
        self.pubmed_controls.append(self.title_checkbox)
        self.pubmed_controls.append(self.mesh_checkbox)
        self.pubmed_controls.append(self.abstract_checkbox)
        self.pubmed_controls.append(self.url_checkbox)

        # Num. records.
        h_box = gui.hBox(self.controlArea)
        label = gui.label(h_box, self, 'Retrieve')
        label.setMaximumSize(label.sizeHint())
        self.num_records_input = gui.spin(h_box,
                                          self,
                                          'num_records',
                                          minv=1,
                                          maxv=10000)
        self.max_records_label = gui.label(h_box, self, 'records from /.')
        self.max_records_label.setMaximumSize(
            self.max_records_label.sizeHint())
        self.pubmed_controls.append(self.num_records_input)

        # Download articles.
        # Search for records button.
        self.retrieve_records_button = gui.button(
            self.controlArea,
            self,
            'Retrieve records',
            callback=self.retrieve_records,
            tooltip='Retrieves the specified documents.')
        self.pubmed_controls.append(self.retrieve_records_button)

        # Num. retrieved records info label.
        self.retrieval_info_label = gui.label(
            self.controlArea, self, 'Number of records retrieved: /')

        # Load the most recent emails.
        self.set_email_list()

        # Load the most recent queries.
        self.set_keyword_list()

        # Check the email and enable controls accordingly.
        if self.recent_emails:
            email = self.recent_emails[0]
            self.email_is_valid = validate_email(email)

        self.enable_controls()
Esempio n. 11
0
 def set_date(self, date):
     self.picked_date = date.toString('yyyy/MM/dd')
Esempio n. 12
0
    def __init__(self):
        super().__init__()

        self.output_corpus = None
        self.all_hits = 0
        self.num_retrieved = 0
        self.nyt_api = None
        self.api_key = ""
        self.api_key_is_valid = False
        self.query_running = False

        # To hold all the controls. Makes access easier.
        self.nyt_controls = []

        # Root box.
        parameter_box = gui.widgetBox(self.controlArea, addSpace=True)

        # API key box.
        api_key_box = gui.widgetBox(parameter_box, orientation=0)
        # Valid API key feedback.
        self.api_key_valid_label = gui.label(api_key_box, self, "")
        self.update_validity_icon()
        self.api_key_valid_label.setMaximumSize(
            self.api_key_valid_label.sizeHint())
        # Set API key button.
        self.open_set_api_key_dialog_button = gui.button(
            api_key_box,
            self,
            'Article API key',
            callback=self.open_set_api_key_dialog,
            tooltip="Set the API key for this widget.")
        self.open_set_api_key_dialog_button.setFocusPolicy(QtCore.Qt.NoFocus)

        # Query box.
        query_box = gui.widgetBox(parameter_box, orientation=0)
        q_label = gui.label(query_box, self, "Query:")
        q_label.setMaximumSize(q_label.sizeHint())
        # Drop-down for recent queries.
        self.query_combo = QComboBox(query_box)
        self.query_combo.setMinimumWidth(150)
        self.query_combo.setEditable(True)
        query_box.layout().addWidget(self.query_combo)
        self.query_combo.activated[int].connect(self.select_query)
        self.query_combo.lineEdit().returnPressed.connect(
            self.run_initial_query)
        self.nyt_controls.append(self.query_combo)

        # Year box.
        year_box = gui.widgetBox(parameter_box, orientation=0)

        minDate = QDate.fromString(self.MIN_DATE.strftime(self.PY_DATE_FORMAT),
                                   self.QT_DATE_FORMAT)
        date_from = QDateEdit(QDate.fromString(self.date_from,
                                               self.QT_DATE_FORMAT),
                              displayFormat=self.QT_DATE_FORMAT,
                              minimumDate=minDate,
                              calendarPopup=True)
        date_to = QDateEdit(QDate.fromString(self.date_to,
                                             self.QT_DATE_FORMAT),
                            displayFormat=self.QT_DATE_FORMAT,
                            minimumDate=minDate,
                            calendarPopup=True)
        date_from.dateChanged.connect(lambda date: setattr(
            self, 'date_from', date.toString(self.QT_DATE_FORMAT)))
        date_to.dateChanged.connect(lambda date: setattr(
            self, 'date_to', date.toString(self.QT_DATE_FORMAT)))

        gui.label(year_box, self, "From:")
        year_box.layout().addWidget(date_from)
        gui.label(year_box, self, "to:")
        year_box.layout().addWidget(date_to)

        self.nyt_controls.append(date_from)
        self.nyt_controls.append(date_to)

        # Text includes box.
        self.text_includes_box = gui.widgetBox(self.controlArea,
                                               "Text includes",
                                               addSpace=True)
        self.headline_chbox = gui.checkBox(self.text_includes_box, self,
                                           "includes_headline", "Headline")
        self.lead_paragraph_chbox = gui.checkBox(self.text_includes_box, self,
                                                 "includes_lead_paragraph",
                                                 "Lead paragraph")
        self.snippet_chbox = gui.checkBox(self.text_includes_box, self,
                                          "includes_snippet", "Snippet")
        self.abstract_chbox = gui.checkBox(self.text_includes_box, self,
                                           "includes_abstract", "Abstract")
        self.keywords_chbox = gui.checkBox(self.text_includes_box, self,
                                           "includes_keywords", "Keywords")
        self.type_of_material_chbox = gui.checkBox(
            self.text_includes_box, self, "includes_type_of_material",
            "Article type")
        self.web_url_chbox = gui.checkBox(self.text_includes_box, self,
                                          "includes_web_url", "URL")
        self.word_count_chbox = gui.checkBox(self.text_includes_box, self,
                                             "includes_word_count",
                                             "Word count")
        self.nyt_controls.append(self.headline_chbox)
        self.nyt_controls.append(self.lead_paragraph_chbox)
        self.nyt_controls.append(self.snippet_chbox)
        self.nyt_controls.append(self.abstract_chbox)
        self.nyt_controls.append(self.keywords_chbox)
        self.nyt_controls.append(self.type_of_material_chbox)
        self.nyt_controls.append(self.web_url_chbox)
        self.nyt_controls.append(self.word_count_chbox)

        # Run query button.
        self.run_query_button = gui.button(
            self.controlArea,
            self,
            'Run query',
            callback=self.run_initial_query,
            tooltip="Run the chosen NYT article query.")
        self.run_query_button.setFocusPolicy(QtCore.Qt.NoFocus)
        self.nyt_controls.append(self.run_query_button)
        h_line = QFrame()
        h_line.setFrameShape(QFrame.HLine)
        h_line.setFrameShadow(QFrame.Sunken)
        self.controlArea.layout().addWidget(h_line)

        # Query info.
        query_info_box = gui.widgetBox(self.controlArea, addSpace=True)
        self.query_info_label = gui.label(query_info_box, self,
                                          "Records: /\nRetrieved: /")

        # Retrieve other records.
        self.retrieve_other_button = gui.button(
            self.controlArea,
            self,
            'Retrieve remaining records',
            callback=self.retrieve_remaining_records,
            tooltip="Retrieve the remaining records obtained in the query.")
        self.retrieve_other_button.setFocusPolicy(QtCore.Qt.NoFocus)
        self.retrieve_other_button.setEnabled(False)

        # Load the most recent queries.
        self.set_query_list()

        # Check the API key and enable controls accordingly.
        if self.recent_api_keys:
            self.api_key = self.recent_api_keys[0]
            self.check_api_key(self.api_key)

        self.enable_controls()
 def show_date(self, date):
     self.updated_date.emit(date.toPyDate())
     self.text_area.setText(date.toString())
Esempio n. 14
0
    def __init__(self):
        super().__init__()

        self.output_corpus = None
        self.all_hits = 0
        self.num_retrieved = 0
        self.nyt_api = None
        self.api_key = ""
        self.api_key_is_valid = False
        self.query_running = False

        # To hold all the controls. Makes access easier.
        self.nyt_controls = []

        # Root box.
        parameter_box = gui.widgetBox(self.controlArea, addSpace=True)

        # API key box.
        api_key_box = gui.widgetBox(parameter_box, orientation=0)
        # Valid API key feedback.
        self.api_key_valid_label = gui.label(api_key_box, self, "")
        self.update_validity_icon()
        self.api_key_valid_label.setMaximumSize(self.api_key_valid_label.sizeHint())
        # Set API key button.
        self.open_set_api_key_dialog_button = gui.button(api_key_box, self, 'Article API key',
                                                         callback=self.open_set_api_key_dialog,
                                                         tooltip="Set the API key for this widget.")
        self.open_set_api_key_dialog_button.setFocusPolicy(QtCore.Qt.NoFocus)

        # Query box.
        query_box = gui.widgetBox(parameter_box, orientation=0)
        q_label = gui.label(query_box, self, "Query:")
        q_label.setMaximumSize(q_label.sizeHint())
        # Drop-down for recent queries.
        self.query_combo = QComboBox(query_box)
        self.query_combo.setMinimumWidth(150)
        self.query_combo.setEditable(True)
        query_box.layout().addWidget(self.query_combo)
        self.query_combo.activated[int].connect(self.select_query)
        self.query_combo.lineEdit().returnPressed.connect(self.run_initial_query)
        self.nyt_controls.append(self.query_combo)

        # Year box.
        year_box = gui.widgetBox(parameter_box, orientation=0)

        minDate = QDate.fromString(self.MIN_DATE.strftime(self.PY_DATE_FORMAT),
                                   self.QT_DATE_FORMAT)
        date_from = QDateEdit(QDate.fromString(self.date_from, self.QT_DATE_FORMAT),
                              displayFormat=self.QT_DATE_FORMAT,
                              minimumDate=minDate,
                              calendarPopup=True)
        date_to = QDateEdit(QDate.fromString(self.date_to, self.QT_DATE_FORMAT),
                            displayFormat=self.QT_DATE_FORMAT,
                            minimumDate=minDate,
                            calendarPopup=True)
        date_from.dateChanged.connect(
            lambda date: setattr(self, 'date_from', date.toString(self.QT_DATE_FORMAT)))
        date_to.dateChanged.connect(
            lambda date: setattr(self, 'date_to', date.toString(self.QT_DATE_FORMAT)))

        gui.label(year_box, self, "From:")
        year_box.layout().addWidget(date_from)
        gui.label(year_box, self, "to:")
        year_box.layout().addWidget(date_to)

        self.nyt_controls.append(date_from)
        self.nyt_controls.append(date_to)

        # Text includes box.
        self.text_includes_box = gui.widgetBox(self.controlArea,
                                               "Text includes", addSpace=True)
        self.headline_chbox = gui.checkBox(self.text_includes_box, self,
                                           "includes_headline", "Headline")
        self.lead_paragraph_chbox = gui.checkBox(self.text_includes_box, self,
                                                 "includes_lead_paragraph",
                                                 "Lead paragraph")
        self.snippet_chbox = gui.checkBox(self.text_includes_box, self,
                                          "includes_snippet", "Snippet")
        self.abstract_chbox = gui.checkBox(self.text_includes_box, self,
                                           "includes_abstract", "Abstract")
        self.keywords_chbox = gui.checkBox(self.text_includes_box, self,
                                           "includes_keywords", "Keywords")
        self.type_of_material_chbox = gui.checkBox(self.text_includes_box, self,
                                                   "includes_type_of_material",
                                                   "Article type")
        self.web_url_chbox = gui.checkBox(self.text_includes_box, self,
                                          "includes_web_url", "URL")
        self.word_count_chbox = gui.checkBox(self.text_includes_box, self,
                                             "includes_word_count",
                                             "Word count")
        self.nyt_controls.append(self.headline_chbox)
        self.nyt_controls.append(self.lead_paragraph_chbox)
        self.nyt_controls.append(self.snippet_chbox)
        self.nyt_controls.append(self.abstract_chbox)
        self.nyt_controls.append(self.keywords_chbox)
        self.nyt_controls.append(self.type_of_material_chbox)
        self.nyt_controls.append(self.web_url_chbox)
        self.nyt_controls.append(self.word_count_chbox)

        # Run query button.
        self.run_query_button = gui.button(self.controlArea, self, 'Run query',
                                           callback=self.run_initial_query,
                                           tooltip="Run the chosen NYT article query.")
        self.run_query_button.setFocusPolicy(QtCore.Qt.NoFocus)
        self.nyt_controls.append(self.run_query_button)
        h_line = QFrame()
        h_line.setFrameShape(QFrame.HLine)
        h_line.setFrameShadow(QFrame.Sunken)
        self.controlArea.layout().addWidget(h_line)

        # Query info.
        query_info_box = gui.widgetBox(self.controlArea, addSpace=True)
        self.query_info_label = gui.label(query_info_box, self, "Records: /\nRetrieved: /")

        # Retrieve other records.
        self.retrieve_other_button = gui.button(self.controlArea, self, 'Retrieve remaining records',
                                                callback=self.retrieve_remaining_records,
                                                tooltip="Retrieve the remaining records obtained in the query.")
        self.retrieve_other_button.setFocusPolicy(QtCore.Qt.NoFocus)
        self.retrieve_other_button.setEnabled(False)

        # Load the most recent queries.
        self.set_query_list()

        # Check the API key and enable controls accordingly.
        if self.recent_api_keys:
            self.api_key = self.recent_api_keys[0]
            self.check_api_key(self.api_key)

        self.enable_controls()
    def showDate(self, date):

        self.lbl.setText(date.toString())
Esempio n. 16
0
 def on_date_selection(self, date):
     self.ldate.setText(date.toString())
     self.ldate.resize(self.ldate.sizeHint())
Esempio n. 17
0
    def __init__(self):
        super().__init__()

        self.output_corpus = None
        self.pubmed_api = None
        self.progress = None
        self.email_is_valid = False
        self.record_count = 0
        self.download_running = False

        # To hold all the controls. Makes access easier.
        self.pubmed_controls = []

        h_box = gui.hBox(self.controlArea)
        label = gui.label(h_box, self, 'Email:')
        label.setMaximumSize(label.sizeHint())
        # Drop-down for recent emails.
        self.email_combo = QComboBox(h_box)
        self.email_combo.setMinimumWidth(150)
        self.email_combo.setEditable(True)
        self.email_combo.lineEdit().textChanged.connect(self.sync_email)
        h_box.layout().addWidget(self.email_combo)
        self.email_combo.activated[int].connect(self.select_email)

        # RECORD SEARCH
        self.search_tabs = gui.tabWidget(self.controlArea)
        # --- Regular search ---
        regular_search_box = gui.widgetBox(self.controlArea, addSpace=True)

        # Author
        self.author_input = gui.lineEdit(regular_search_box, self, 'author',
                                         'Author:', orientation=Qt.Horizontal)
        self.pubmed_controls.append(self.author_input)

        h_box = gui.hBox(regular_search_box)
        year_box = gui.widgetBox(h_box, orientation=Qt.Horizontal)
        min_date = QDate.fromString(
                self.MIN_DATE.strftime(self.PY_DATE_FORMAT),
                self.QT_DATE_FORMAT
        )

        if not self.pub_date_from:
            self.pub_date_from = self.MIN_DATE.strftime(self.PY_DATE_FORMAT)
        if not self.pub_date_to:
            self.pub_date_to = date.today().strftime(self.PY_DATE_FORMAT)

        self.date_from = QDateEdit(
                QDate.fromString(self.pub_date_from, self.QT_DATE_FORMAT),
                displayFormat=self.QT_DATE_FORMAT,
                minimumDate=min_date,
                calendarPopup=True
        )
        self.date_to = QDateEdit(
                QDate.fromString(self.pub_date_to, self.QT_DATE_FORMAT),
                displayFormat=self.QT_DATE_FORMAT,
                minimumDate=min_date,
                calendarPopup=True
        )

        self.date_from.dateChanged.connect(
            lambda date: setattr(self, 'pub_date_from',
                                 date.toString(self.QT_DATE_FORMAT)))
        self.date_to.dateChanged.connect(
            lambda date: setattr(self, 'pub_date_to',
                                 date.toString(self.QT_DATE_FORMAT)))
        self.pubmed_controls.append(self.date_from)
        self.pubmed_controls.append(self.date_to)

        gui.label(year_box, self, 'From:')
        year_box.layout().addWidget(self.date_from)
        gui.label(year_box, self, 'to:')
        year_box.layout().addWidget(self.date_to)

        # Keywords.
        h_box = gui.hBox(regular_search_box)
        label = gui.label(h_box, self, 'Query:')
        label.setMaximumSize(label.sizeHint())
        self.keyword_combo = QComboBox(h_box)
        self.keyword_combo.setMinimumWidth(150)
        self.keyword_combo.setEditable(True)
        h_box.layout().addWidget(self.keyword_combo)
        self.keyword_combo.activated[int].connect(self.select_keywords)
        self.pubmed_controls.append(self.keyword_combo)

        tab_height = regular_search_box.sizeHint()
        regular_search_box.setMaximumSize(tab_height)

        # --- Advanced search ---
        advanced_search_box = gui.widgetBox(self.controlArea, addSpace=True)
        # Advanced search query.
        h_box = gui.hBox(advanced_search_box)
        self.advanced_query_input = QTextEdit(h_box)
        h_box.layout().addWidget(self.advanced_query_input)
        self.advanced_query_input.setMaximumSize(tab_height)
        self.pubmed_controls.append(self.advanced_query_input)

        gui.createTabPage(self.search_tabs, 'Regular search',
                          regular_search_box)
        gui.createTabPage(self.search_tabs, 'Advanced search',
                          advanced_search_box)

        # Search info label.
        self.search_info_label = gui.label(
                self.controlArea, self,
                'Number of records found: /')

        # Search for records button.
        self.run_search_button = gui.button(
                self.controlArea,
                self,
                'Find records',
                callback=self.run_search,
                tooltip='Performs a search for articles that fit the '
                        'specified parameters.')
        self.pubmed_controls.append(self.run_search_button)

        h_line = QFrame()
        h_line.setFrameShape(QFrame.HLine)
        h_line.setFrameShadow(QFrame.Sunken)
        self.controlArea.layout().addWidget(h_line)

        # RECORD RETRIEVAL
        # Text includes box.
        text_includes_box = gui.widgetBox(self.controlArea,
                                          'Text includes', addSpace=True)
        self.authors_checkbox = gui.checkBox(text_includes_box, self,
                                          'includes_authors', 'Authors')
        self.title_checkbox = gui.checkBox(text_includes_box, self,
                                        'includes_title', 'Article title')
        self.mesh_checkbox = gui.checkBox(text_includes_box, self,
                                       'includes_mesh', 'Mesh headings')
        self.abstract_checkbox = gui.checkBox(text_includes_box, self,
                                           'includes_abstract', 'Abstract')
        self.url_checkbox = gui.checkBox(text_includes_box, self,
                                         'includes_url', 'URL')
        self.pubmed_controls.append(self.authors_checkbox)
        self.pubmed_controls.append(self.title_checkbox)
        self.pubmed_controls.append(self.mesh_checkbox)
        self.pubmed_controls.append(self.abstract_checkbox)
        self.pubmed_controls.append(self.url_checkbox)

        # Num. records.
        h_box = gui.hBox(self.controlArea)
        label = gui.label(h_box, self, 'Retrieve')
        label.setMaximumSize(label.sizeHint())
        self.num_records_input = gui.spin(h_box, self, 'num_records',
                                          minv=1, maxv=100000)
        self.max_records_label = gui.label(h_box, self, 'records from /.')
        self.max_records_label.setMaximumSize(self.max_records_label
                                              .sizeHint())
        self.pubmed_controls.append(self.num_records_input)

        # Download articles.
        # Search for records button.
        self.retrieve_records_button = gui.button(
                self.controlArea,
                self,
                'Retrieve records',
                callback=self.retrieve_records,
                tooltip='Retrieves the specified documents.')
        self.pubmed_controls.append(self.retrieve_records_button)

        # Num. retrieved records info label.
        self.retrieval_info_label = gui.label(
                self.controlArea,
                self,
                'Number of records retrieved: /')

        # Load the most recent emails.
        self.set_email_list()

        # Load the most recent queries.
        self.set_keyword_list()

        # Check the email and enable controls accordingly.
        if self.recent_emails:
            email = self.recent_emails[0]
            self.email_is_valid = validate_email(email)

        self.enable_controls()
Esempio n. 18
0
 def set_date(self, date):
     self.picked_date = date.toString('yyyy/MM/dd')
Esempio n. 19
0
 def showDate(self, date):
     self.editCalendarOutput.setText(date.toString())