当前位置: 首页>>代码示例>>Python>>正文


Python ProgressBar.setValue方法代码示例

本文整理汇总了Python中ProgressBar.ProgressBar.setValue方法的典型用法代码示例。如果您正苦于以下问题:Python ProgressBar.setValue方法的具体用法?Python ProgressBar.setValue怎么用?Python ProgressBar.setValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProgressBar.ProgressBar的用法示例。


在下文中一共展示了ProgressBar.setValue方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: RawDataManager

# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import setValue [as 别名]
class RawDataManager(QtGui.QWidget):
    def __init__(self, user_id, password, *args, **kwargs):
        super(RawDataManager, self).__init__(*args, **kwargs)
        self.user_id, self.password = user_id, password
        self.raw_data_thread = RawDataUploaderThread(self.user_id, self.password)
        self.createUI()
        self.mapEvents()

    def createUI(self):
        #self.raw_data_filter_form = FilterForm()
        self.fsn_entry_field = FSNTextEdit()
        self.raw_data_table = CopiableQTableWidget(0,0)
        self.upload_raw_data_button = QtGui.QPushButton("Upload Raw Data from File")
        self.progress_bar = ProgressBar()
        self.progress_log = QtGui.QTextEdit()
        layout = QtGui.QVBoxLayout()
        layout.addWidget(self.upload_raw_data_button)
        layout.addWidget(self.progress_bar)
        layout.addWidget(self.progress_log)
        self.setLayout(layout)
        self.setWindowTitle("Raw Data Uploader")
        self.setWindowIcon(QtGui.QIcon(os.path.join(MOSES.getPathToImages(),"PORK_Icon.png")))
        self.show()

    def mapEvents(self):
        self.upload_raw_data_button.clicked.connect(self.uploadRawData)
        self.raw_data_thread.sendActivity.connect(self.displayActivity)
        self.raw_data_thread.sendMessage.connect(self.displayMessage)

    def displayActivity(self, progress, eta, accepted, rejected, failed, pending):
        self.progress_bar.setValue(progress)
        message = "%d Accepted, %d Rejected, %d Failed, %d Pending. ETA: %s"%(accepted, rejected, failed, pending, eta)
        self.displayMessage(message)
        if progress == 100:
            self.upload_raw_data_button.setEnabled(True)
            self.alertMessage("Completed uploading raw data!", "%s"%message)

    def displayMessage(self, message):
        self.progress_log.append("%s: <b>%s</b>"%(datetime.datetime.now(),message))
        self.progress_log.moveCursor(QtGui.QTextCursor.End)


    def uploadRawData(self):
        self.upload_raw_data_button.setEnabled(False)
        data_file_name = str(QtGui.QFileDialog.getOpenFileName(self,"Open Data File",os.getcwd(),("MS Excel Spreadsheet (*.xlsx)")))
        if data_file_name is not None:
            if os.path.exists(data_file_name):
                xl_file = pd.ExcelFile(data_file_name)
                if "Raw Data" in xl_file.sheet_names:
                    raw_data = xl_file.parse("Raw Data")
                    self.raw_data_thread.setDataFrame(raw_data)
                else:
                    self.alertMessage("Invalid raw data file.","""The given raw data file doesn't seem to have any sheet named "Raw Data".""")
                    
    def alertMessage(self, title, message):
        QtGui.QMessageBox.about(self, title, message)
开发者ID:vinay87,项目名称:oink,代码行数:58,代码来源:RawDataManager.py

示例2: DataSelector

# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import setValue [as 别名]
class DataSelector(QtGui.QWidget):
    def __init__(self, repo_path):
        super(DataSelector,self).__init__()
        self.repo_path = repo_path
        self.data_from_fk = None
        self.createUI()
        self.fk_retriever = FKRetriever(self.repo_path)
        self.mapEvents()
        self.data_is_ready = False
        self.data = None
        self.validate_button.setEnabled(False)

    def createUI(self):
        self.group_box = QtGui.QGroupBox("Data Selector")
        self.page_selector = IconListBox()
        page_control_list = [
                    {
                    "Name": "From Flipkart Using FSNs",
                    "Icon": os.path.join("essentials","download.png")
                    },
                    {
                    "Name": "From CSV Data File",
                    "Icon": os.path.join("essentials","csv_file.png")
                    }
                ]
        self.page_selector.addElements(page_control_list)
        self.page_selector.setFixedSize(302,110)
        #FSN Mode Widget
        self.fsn_mode_widget = QtGui.QGroupBox("Data By FSN")
        self.fsn_text_edit = FSNTextEdit()
        self.fsn_text_edit.setFixedSize(450,400)
        self.category_label = QtGui.QLabel("Category:")
        self.category_combo_box = QtGui.QComboBox()
        self.category_combo_box.addItems(getCategoryFolderNames()) #Later, add this data from OINK's server.        
        self.category_combo_box.setToolTip("Select the default category for the given FSNs.\nNote that mixing various types of FSNs isn't recommended.\nThe icons won't load.")
        self.attributes_list_box = QtGui.QListWidget()
        self.attributes_list_box.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
        self.attributes_list_box.setToolTip("Displays all product attributes, obtained from the FK server.")
        self.primary_attributes_list_box = QtGui.QListWidget()
        self.primary_attributes_list_box.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
        self.primary_attributes_list_box.setToolTip("Displays primary product attributes that you have selected.")
        self.secondary_attributes_list_box = QtGui.QListWidget()
        self.secondary_attributes_list_box.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
        self.secondary_attributes_list_box.setToolTip("Displays secondary product attributes that you have selected.")
        self.push_to_primary_button = QtGui.QPushButton("Add to\nPrimary List")
        self.push_to_primary_button.setToolTip("Click to move the chosen attribute into the list of primary attributes.")
        self.remove_from_primary_button = QtGui.QPushButton("Remove from\nPrimary List")
        self.remove_from_primary_button.setToolTip("Click to move the chosen attribute out of the list of primary attributes.")
        self.push_to_secondary_button = QtGui.QPushButton("Add to\nSecondary List")
        self.push_to_secondary_button.setToolTip("Click to move the chosen attribute into the list of secondary attributes.")
        self.remove_from_secondary_button = QtGui.QPushButton("Remove from\nSecondary List")
        self.remove_from_secondary_button.setToolTip("Click to move the chosen attribute out of the list of secondary attributes.")
        #downloader
        self.fetch_images_attributes_button = QtGui.QPushButton("Download")
        self.fetch_images_attributes_button.setToolTip("This will check if parent images are available for all the FSNs and download them if necessary from the FK site. It will also load the spec table.")
        self.export_scraped_data_button = QtGui.QPushButton("Export Data")
        self.fetching_progress = ProgressBar()
        self.fetching_progress.setRange(0,100)
        self.fetching_progress.setValue(0)
        self.fetching_activity = QtGui.QLabel("All that is gold does not glitter!")
        self.fetching_activity.setStyleSheet("QLabel{font: 10px black; border: 1px solid black;}")
        self.fetching_activity.setToolTip("This indicates the current downloader's activity, or some random quote that Vinay thinks is funny.")
        self.completed_fsns_count_label = QtGui.QLabel("Completed:")
        self.completed_fsns_count_spinbox = QtGui.QSpinBox()
        self.completed_fsns_count_spinbox.setEnabled(False)
        self.eta_label = QtGui.QLabel("ETA:")
        self.eta_datetimeedit = QtGui.QDateTimeEdit()
        self.eta_datetimeedit.setEnabled(False)
        self.eta_datetimeedit.setMinimumDateTime(QtCore.QDateTime(datetime.datetime.now()))
        self.activity_log_textedit = QtGui.QTextEdit()
        self.activity_log_textedit.setReadOnly(True)
        self.pending_fsns_count_label = QtGui.QLabel("Pending:")
        self.pending_fsns_count_spinbox = QtGui.QSpinBox()
        self.pending_fsns_count_spinbox.setEnabled(False)
        self.failed_fsns_label = QtGui.QLabel("Failed:")
        self.failed_fsns_count_spinbox = QtGui.QSpinBox()
        self.failed_fsns_count_spinbox.setEnabled(False)

        self.completed_fsns_count_spinbox.setRange(0,99999999)
        self.pending_fsns_count_spinbox.setRange(0,99999999)
        self.failed_fsns_count_spinbox.setRange(0,99999999)

        self.pending_fsns_list_text_edit = QtGui.QTextEdit()
        self.pending_fsns_list_text_edit.setReadOnly(True)
        self.completed_fsns_list_text_edit = QtGui.QTextEdit()
        self.completed_fsns_list_text_edit.setReadOnly(True)
        self.failed_fsns_list_text_edit = QtGui.QTextEdit()
        self.failed_fsns_list_text_edit.setReadOnly(True)

        buttons_and_progress_bar = QtGui.QHBoxLayout()
        buttons_and_progress_bar.addWidget(self.fetch_images_attributes_button, 2)
        buttons_and_progress_bar.addWidget(self.export_scraped_data_button, 1)
        buttons_and_progress_bar.addWidget(self.fetching_progress, 4)

        completed_tracking = QtGui.QVBoxLayout()
        completed_tracking.addWidget(self.completed_fsns_count_label)
        completed_tracking.addWidget(self.completed_fsns_count_spinbox)
        completed_tracking.addWidget(self.completed_fsns_list_text_edit)
        
        eta_layout = QtGui.QHBoxLayout()
#.........这里部分代码省略.........
开发者ID:vinay87,项目名称:leonardo,代码行数:103,代码来源:DataSelector.py

示例3: DailyPorker

# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import setValue [as 别名]

#.........这里部分代码省略.........
    def buildDBR(self):
        self.build_dbr_button.setEnabled(False)
        self.alertMessage("Please Wait","This could take a while.")
        dbr = MOSES.getDBR(self.user_id, self.password, self.start_date_edit.date().toPyDate(), self.category_tree)
        self.dbr_report.showDataFrame(dbr)
        self.dbr_report.adjustToColumns()
        self.build_dbr_button.setEnabled(True)
        self.alertMessage("Success","Successfully Pulled the DBR")

    def buildWBR(self):
        self.build_wbr_button.setEnabled(False)
        self.alertMessage("Please Wait","This could take a while.")
        wbr = MOSES.getWBR(self.user_id, self.password, self.start_date_edit.date().toPyDate(), self.category_tree)
        self.wbr_report.showDataFrame(wbr)
        self.wbr_report.adjustToColumns()
        self.build_wbr_button.setEnabled(True)
        self.alertMessage("Success","Successfully Pulled the WBR")


    def getWritersList(self):
        self.writers_data_frame = MOSES.getWritersList(self.user_id, self.password, self.start_date_edit.date().toPyDate())
        writer_names_list = list(set(self.writers_data_frame["Name"]))
        writer_names_list.sort()
        return writer_names_list

    def displayGraphs(self,handle):
        if handle:
            self.graphs.graph_date = self.pork_lane.start_date
            self.graphs.enable_plotting = True
            self.graphs.plotGraph()
            self.progress_bar.setRange(0,100)
            self.progress_bar.setFormat("Completed at %s." %(datetime.datetime.strftime(datetime.datetime.now(),"%H:%M:%S")))
            self.status.setText("Beware the alien, the mutant, the heretic.")  
            self.progress_bar.setValue(100)
            #self.export_graphs_button.setEnabled(True)
        else:
            self.export_graphs_button.setEnabled(False)
            self.status.setText("Creating Graphs...")        
            self.progress_bar.setValue(0)
            self.progress_bar.setRange(0,0)


    def refreshSortFilter(self):
        report_types = self.getRequiredReportTypes()
        self.sorting_filter_combobox.clear()
        if len(report_types) > 0:
            self.sorting_filter_combobox.setEnabled(True)
            self.sorting_filter_combobox.addItems(report_types)
        else:
            self.sorting_filter_combobox.setEnabled(False)
        self.sorting_filter_combobox.setCurrentIndex(-1)

    def buildReport(self):
        self.build_button.setEnabled(False)
        report_types = self.getRequiredReportTypes()
        if len(report_types) > 0:
            self.build = True
            self.pork_lane.writers_data_frame = self.writers_data_frame
            self.pork_lane.parameter_list = self.parameters_combobox.getCheckedItems() #set pork lane report types.]
            self.pork_lane.time_frame_list = self.report_time_frames_combobox.getCheckedItems()
            selected_writers_list = self.writers_combobox.getCheckedItems()
            if len(selected_writers_list)>0:
                self.pork_lane.writers_list = selected_writers_list
            else:
                self.writers_combobox.selectAll()
                selected_writers_list = self.writers_combobox.getCheckedItems()
开发者ID:vinay87,项目名称:oink,代码行数:70,代码来源:DailyPorker.py

示例4: Seeker

# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import setValue [as 别名]

#.........这里部分代码省略.........
        self.type_selector.setCurrentIndex(0)
        self.output_table = CopiableQTableWidget(0, 0)
        self.progress_bar = ProgressBar()
        self.fetch_data_button = ImageButton(os.path.join("Images","find.png"),64,64,os.path.join("Images","find_mouseover.png"))
        self.fetch_data_button.setFlat(True)
        form_searcher_layout = QtGui.QVBoxLayout()
        form_searcher_layout.addWidget(self.fsns_label, 0)
        form_searcher_layout.addWidget(self.fsns_text_edit, 2)

        self.seeker_button = ImageButton(os.path.join("Images","seeker.png"),100,100,os.path.join("Images","seeker_mouseover.png"))
        self.seeker_button.setFlat(True)
        self.seeker_button.setToolTip("You're a Wizard, Harry.")
        
        form_options_layout = QtGui.QVBoxLayout()
        form_options_layout.addStretch(1)
        form_options_layout.addWidget(self.seeker_button,1, QtCore.Qt.AlignHCenter | QtCore.Qt.AlignBottom)
        form_options_layout.addStretch(2)
        form_options_layout.addWidget(self.type_selector, 0)
        form_options_layout.addWidget(self.fetch_data_button, 0, QtCore.Qt.AlignHCenter | QtCore.Qt.AlignBottom)

        form_layout = QtGui.QHBoxLayout()
        form_layout.addLayout(form_searcher_layout, 3)
        form_layout.addLayout(form_options_layout, 0)

        layout = QtGui.QVBoxLayout()
        layout.addLayout(form_layout, 0)
        layout.addWidget(self.output_table, 3)
        layout.addWidget(self.progress_bar, 0)

        self.setLayout(layout)
        self.setWindowTitle("Seeker: The FSN Finding Tool")
        self.setWindowIcon(QtGui.QIcon(os.path.join('Images','PORK_Icon.png')))
        self.show()

    def createEvents(self):
        """"""
        self.fetch_data_button.clicked.connect(self.fetchData)
        self.peeves.sendProgress.connect(self.displayProgress)
        #self.peeves.sendRow.connect(self.displayFSNs)
        self.peeves.sendData.connect(self.populateTable)
    
    def fetchData(self):
        text_edit_contents = str(self.fsns_text_edit.toPlainText()).strip()
        if '"' in text_edit_contents:
            text_edit_contents.replace('"',"")
        if " " in text_edit_contents:
            text_edit_contents.replace(' ', "")
        search_items = list(set(text_edit_contents.split("\n")))
        self.search_type = self.type_selector.currentIndex()
        self.peeves.fetchData(search_items, self.search_type)

    def populateTable(self, fsn_data):
        #print "Populating the table!"
        self.output_table.setSortingEnabled(False)

        table_headers = [
            "FSN",
            "Status",
            "Item ID",
            "Description Type",
            "Writer ID",
            "Writer Name",
            "Article Date",
            "Database table",
            "BU",
            "Super-Category",
            "Category",
            "Sub-Category",
            "Vertical",
            "Brand"
            ]
        #print table_headers
        rows = len(fsn_data)
        columns = len(table_headers)
        self.output_table.setRowCount(rows)
        self.output_table.setColumnCount(columns)
        row_counter = 0
        for each_fsn in fsn_data:
            column_counter = 0
#            self.output_table.addRow(row_counter)
            for key in table_headers:
                item = QtGui.QTableWidgetItem(str(each_fsn[key]))
                self.output_table.setItem(row_counter, column_counter, item)
                column_counter += 1
            row_counter += 1
        self.output_table.setHorizontalHeaderLabels(table_headers)
        self.output_table.setSortingEnabled(True)
        self.output_table.sortItems(1)
        self.output_table.resizeColumnsToContents()
        self.output_table.resizeRowsToContents()
        #print fsn_data
    
    def displayProgress(self, done, total, eta):
        progress = float(done)/float(total)
        if done < total:
            time_string = datetime.datetime.strftime(eta, "%d %B, %H:%M:%S")
            self.progress_bar.setFormat("Getting FSN Data. Finished %d of %d. ETA: %s" %(done, total, time_string))
        else:
            self.progress_bar.setFormat("Completed fetching FSN Data")
        self.progress_bar.setValue(int(progress*100))
开发者ID:vinay87,项目名称:oink,代码行数:104,代码来源:Seeker.py

示例5: PreviewRunWidget

# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import setValue [as 别名]
class PreviewRunWidget(QtGui.QGroupBox):
    def __init__(self, title, thread_count, repo_path):
        super(PreviewRunWidget, self).__init__()
        self.repo_path = repo_path
        self.setTitle(title)
        self.createUI()
    
    def createUI(self):
        self.process_one_button = QtGui.QPushButton("Process Random FSN\nfrom Queue")
    	self.start_progress_button = QtGui.QPushButton("Start Processing All!")
        self.start_progress_button.setFixedSize(200,50)
        buttons_stylesheet = """QPushButton{background-color: #66CD00; color: white}; QPushButton::hover{background-color:#cccce5; color: black}"""
        self.start_progress_button.setStyleSheet(buttons_stylesheet)

    	self.image_viewer_widget = ImageViewerWidget()
    	self.progress_bar = ProgressBar()
    	self.live_progress = QtGui.QWidget()
        self.status_message = QtGui.QLabel("The Cake is a Lie.")
        buttons_layout = QtGui.QHBoxLayout()
        buttons_layout.addWidget(self.process_one_button,0, QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
        buttons_layout.addWidget(self.start_progress_button,0, QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
    	live_progress_layout = QtGui.QVBoxLayout()
    	live_progress_layout.addLayout(buttons_layout, 0)
    	live_progress_layout.addWidget(self.image_viewer_widget,2,QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)
        live_progress_layout.addSpacing(10)
    	live_progress_layout.addWidget(self.progress_bar,0)
        live_progress_layout.addWidget(self.status_message,0,QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
    	self.live_progress.setLayout(live_progress_layout)
    	self.tabs = QtGui.QTabWidget()
    	self.tabs.addTab(self.live_progress,"Live Progress")
    	self.log = QtGui.QTextEdit()
        self.log.setReadOnly(True)
    	self.tabs.addTab(self.log,"Log")
    	layout = QtGui.QHBoxLayout()
    	layout.addWidget(self.tabs)
    	self.setLayout(layout)
    	self.show()

    def displayProgress(self,status, progress_value, eta, completion_status, images_list, thread_index):
        """This gets the data from the Splinter Thread."""
        self.image_viewer_widget.setImages(images_list)
        self.image_viewer_widget.moveRight()
        eta_string = eta.strftime("%H:%M:%S")
        log_time_stamp = datetime.datetime.now().strftime("[%a (%d-%m)] %H:%M")
        eta_time_stamp = eta.strftime("[%a (%d-%m)] %H:%M:%S")
        log_message = "[%s]:[Thread %d]: <b>%s</b> - <i>Probable ETA: %s</i>."%(log_time_stamp, thread_index+1, status, eta_time_stamp)
        self.log.append(log_message)
        self.log.moveCursor(QtGui.QTextCursor.End)
        if not completion_status:
            self.progress_bar.setValue(progress_value)
            self.status_message.setText("%s"%(log_message))
        else:
            self.progress_bar.setValue(100)
            self.status_message.setText("Completed at %s."%datetime.datetime.now().strftime("%H:%M:%S"))

    def displayActivity(self, status, eta, thread_index):
        log_time_stamp = datetime.datetime.now().strftime("[%a (%d-%m)] %H:%M")
        eta_time_stamp = eta.strftime("[%a (%d-%m)] %H:%M:%S")
        log_message = "[%s]:[Thread %d]: <b>%s</b> - <i>Probable ETA: %s</i>."%(log_time_stamp, thread_index+1, status, eta_time_stamp)
        self.log.append(log_message)
        self.log.moveCursor(QtGui.QTextCursor.End)
        self.status_message.setText(log_message)
开发者ID:vinay87,项目名称:leonardo,代码行数:64,代码来源:PreviewRunWidget.py

示例6: OINKChooser

# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import setValue [as 别名]
class OINKChooser(QtGui.QWidget):
    def __init__(self, user_id, password, oink_widget_list, category_tree, employees_list, brands_list):
        super(OINKChooser, self).__init__()
        self.user_id, self.password = user_id, password
        self.category_tree = category_tree
        self.employees_list = employees_list
        self.brands_list = brands_list
        self.createUI(oink_widget_list)
        self.mapEvents()
        self.center()

    def center(self):
        frameGm = self.frameGeometry()
        screen = QtGui.QApplication.desktop().screenNumber(QtGui.QApplication.desktop().cursor().pos())
        centerPoint = QtGui.QApplication.desktop().screenGeometry(screen).center()
        frameGm.moveCenter(centerPoint)
        self.move(frameGm.topLeft())

    def createUI(self, oink_widget_list):
        self.label = QtGui.QLabel("Choose A Widget:")
        self.combo_box_widgets = QtGui.QComboBox()
        self.combo_box_widgets.addItems(oink_widget_list)
        self.button = QtGui.QPushButton("Launch")


        final_layout = QtGui.QHBoxLayout()
        final_layout.addWidget(self.label)
        final_layout.addWidget(self.combo_box_widgets)
        final_layout.addWidget(self.button)
        final_page = QtGui.QWidget()
        final_page.setLayout(final_layout)

        self.progress_bar = ProgressBar()
        self.message = QtGui.QLabel("Loading.....")
        loading_layout = QtGui.QVBoxLayout()
        loading_layout.addWidget(self.progress_bar)
        loading_layout.addWidget(self.message)
        loading_page = QtGui.QWidget()
        loading_page.setLayout(loading_layout)

        self.stacked_widget = QtGui.QStackedWidget()
        self.stacked_widget.addWidget(final_page)
        self.stacked_widget.addWidget(loading_page)

        layout = QtGui.QVBoxLayout()
        layout.addWidget(self.stacked_widget)
        layout.addWidget(Taunter())

        self.setLayout(layout)
        self.setWindowTitle("OINK Widget Chooser")
        icon_file_name_path = os.path.join(MOSES.getPathToImages(),'PORK_Icon.png')
        self.setWindowIcon(QtGui.QIcon(icon_file_name_path))
        self.show()

    def mapEvents(self):
        self.button.clicked.connect(self.launchChosenWidget)

    def launchChosenWidget(self):
        chosen_widget = str(self.combo_box_widgets.currentText())
        if chosen_widget.upper() == "PORK":
            self.pork_window = Pork(self.user_id, self.password, self.category_tree, self.employees_list, self.brands_list)
        elif chosen_widget.upper() == "VINDALOO":
            self.vindaloo_window = Vindaloo(self.user_id, self.password, self.category_tree, self.employees_list, self.brands_list)
        elif chosen_widget.upper() == "BACON":
            self.bacon_window = Bacon(self.user_id, self.password, self.category_tree, self.employees_list, self.brands_list)
        else:
            self.alertMessage("Error","%s is not a valid option."%chosen_widget)

    def alertMessage(self, title, message):
        QtGui.QMessageBox.about(title, message)

    def showProgress(self, progress, message):
        self.progress_bar.setValue(progress)
        self.message.setText(message)

    def turnPage(self, category_tree):
        self.category_tree = category_tree
        self.stacked_widget.setCurrentIndex(1)
开发者ID:vinay87,项目名称:oink,代码行数:80,代码来源:OINKChooser.py

示例7: OINKLoader

# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import setValue [as 别名]
class OINKLoader(QtGui.QWidget):
    def __init__(self, user_id, password):
        super(OINKLoader, self).__init__()
        self.user_id, self.password = user_id, password
        self.category_tree = None
        self.brand_list = None
        self.employees_list = None
        self.createUI()
        self.mapEvents()
        self.center()

    def center(self):
        frameGm = self.frameGeometry()
        screen = QtGui.QApplication.desktop().screenNumber(QtGui.QApplication.desktop().cursor().pos())
        centerPoint = QtGui.QApplication.desktop().screenGeometry(screen).center()
        frameGm.moveCenter(centerPoint)
        self.move(frameGm.topLeft())

    def createUI(self):
        path_to_image = os.path.join(MOSES.getPathToImages(), "OINK.png")
        self.image = ImageLabel(path_to_image, 800, 566)
        #self.sharingan = SharinganButton()
        self.progress_bar = ProgressBar()
        self.message = QtGui.QLabel("Not all those who wander are lost....")

        layout = QtGui.QVBoxLayout()
        layout.addWidget(self.image)
        layout.addWidget(self.progress_bar)
        layout.addWidget(self.message)
        layout.addWidget(Taunter())
        self.setLayout(layout)
        self.setWindowTitle("Bulk Buster: The OINK Preloader Screen")
        icon_file_name_path = os.path.join(MOSES.getPathToImages(),'PORK_Icon.png')
        self.setWindowIcon(QtGui.QIcon(icon_file_name_path))
        self.show()

    def mapEvents(self):
        self.incredible_bulk = IncredibleBulk(self.user_id, self.password)
        self.incredible_bulk.sendActivity.connect(self.showProgress)
        self.incredible_bulk.sendCategoryTree.connect(self.useCategoryTree)
        self.incredible_bulk.sendBrandList.connect(self.useBrandList)
        self.incredible_bulk.sendEmployeesList.connect(self.useEmployeesList)

    def showProgress(self, progress, message):
        self.progress_bar.setValue(progress)
        self.message.setText(message)
        if progress == 100:
            self.initiate()
            self.close()

    def useCategoryTree(self, category_tree):
        self.category_tree = category_tree

    def useBrandList(self, brand_list):
        self.brand_list = brand_list

    def useEmployeesList(self, employees_list):
        self.employees_list = employees_list

    def alertMessage(self, title, message):
        QtGui.QMessageBox.about(self, title, message)

    def initiate(self):
        if self.user_id == "bigbrother":
            user_role = "Admin"
            access_list = ["Pork","Bacon","Vindaloo"]
            allow = True
        else:
            matching_entries = list(self.employees_list[self.employees_list["Employee ID"] == self.user_id]["Name"])
            if len(matching_entries) == 0:
                allow = False
            else:
                allow = True
                user_role = list(self.employees_list[self.employees_list["Employee ID"] == self.user_id]["Role"])[0]
                access_list = list(self.employees_list[self.employees_list["Employee ID"] == self.user_id]["OINK Access Level"])[0].split(",")
        
        if not allow:
            self.alertMessage("User Error","This User either doesn't exist or he or she has been marked as an ex-employee. Unable to load OINK.")
            self.close()
        else:
            userDict = {
                "Copy Editor": Bacon, 
                "Team Lead": Vindaloo,
                "Big Brother": Vindaloo,
                "Product Specialist": Bacon,
                "Manager": Vindaloo, 
                "Assistant Manager": Vindaloo,
                "Admin": Pork,
                "Content Writer": Pork
                }

            if user_role not in userDict.keys():
                self.alertMessage("Unauthorized User","This version of OINK is not coded for use by a %s. If you encounter this message, you're probably trying to use the compiled version of OINK that doesn't need Python. That version was developed for use by writers because it's easier to set up. If you'd like to use the source version instead, follow the initial setup chapter in the documentation."%user_role)
            else:
                if len(access_list)>1:
                    self.window = OINKChooser(self.user_id, self.password, access_list, self.category_tree, self.employees_list, self.brand_list)
                    self.window.show()
                elif len(access_list) == 1:
                    if access_list[0].upper() == "PORK":
                        self.window = Pork(self.user_id, self.password, self.category_tree, self.employees_list, self.brand_list)
#.........这里部分代码省略.........
开发者ID:vinay87,项目名称:oink,代码行数:103,代码来源:OINKLoader.py


注:本文中的ProgressBar.ProgressBar.setValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。