Пример #1
0
    def __init__(self):
        super().__init__()

        self.ui = QUiLoader().load('u3.ui')
        self.ui.pushButton.clicked.connect(self.testpopwindow)
        #生成一个widget,放在mainwindow 中间
        self._main = QtWidgets.QWidget()

        self.setCentralWidget(self._main)

        #继承自父类,_main,即删除_main layout也会删除
        #下面两幅画都是在layout下
        layout = QtWidgets.QVBoxLayout(self._main)

        static_canvas = FigureCanvas(Figure(figsize=(5, 3)))
        layout.addWidget(static_canvas)
        self.addToolBar(NavigationToolbar(static_canvas, self))

        dynamic_canvas = FigureCanvas(Figure(figsize=(5, 3)))
        layout.addWidget(dynamic_canvas)
        self.addToolBar(QtCore.Qt.BottomToolBarArea,
                        NavigationToolbar(dynamic_canvas, self))

        self._static_ax = static_canvas.figure.subplots()
        t = np.linspace(0, 10, 501)
        self._static_ax.plot(t, np.tan(t), ".")

        self._dynamic_ax = dynamic_canvas.figure.subplots()
        t = np.linspace(0, 10, 101)
        # Set up a Line2D.
        self._line, = self._dynamic_ax.plot(t, np.sin(t + time.time()))
        self._timer = dynamic_canvas.new_timer(50)
        self._timer.add_callback(self._update_canvas)
        self._timer.start()
Пример #2
0
    def __init__(self):
        super().__init__()

        # Create are maing widget that is used for the UI, set the widget 
        # As the main window, then creates a vertical layout for the widget
        self._main = QtWidgets.QWidget()
        self.setCentralWidget(self._main)
        layout = QtWidgets.QVBoxLayout(self._main)


        # Create a new figure canvas for the matplot lib graph to be drawn on then add this 
        # figure to the widget. Then add the matplot naviagation toolbar 
        static_canvas = FigureCanvas(Figure(figsize=(5, 3)))
        layout.addWidget(static_canvas)
        self.addToolBar(NavigationToolbar(static_canvas, self))

        # Next we create the second canvas
        dynamic_canvas = FigureCanvas(Figure(figsize=(5, 3)))
        layout.addWidget(dynamic_canvas)
        self.addToolBar(QtCore.Qt.BottomToolBarArea,NavigationToolbar(dynamic_canvas, self))

        # Next add the X and Y cords to the figure 
        self._static_ax = static_canvas.figure.subplots()
        t = np.linspace(0, 10, 501)
        self._static_ax.plot(t, np.tan(t), ".")

        self._dynamic_ax = dynamic_canvas.figure.subplots()
        self._timer = dynamic_canvas.new_timer(100, [(self._update_canvas, (), {})])
        self._timer.start()
Пример #3
0
    def __init__(self):
        super(ApplicationWindow, self).__init__()
        self._main = QtWidgets.QWidget()
        self.setCentralWidget(self._main)
        layout = QtWidgets.QVBoxLayout(self._main)

        static_canvas = FigureCanvas(Figure(figsize=(5, 3)))
        layout.addWidget(static_canvas)
        self.addToolBar(NavigationToolbar(static_canvas, self))

        dynamic_canvas = FigureCanvas(Figure(figsize=(5, 3)))
        layout.addWidget(dynamic_canvas)
        self.addToolBar(QtCore.Qt.BottomToolBarArea,
                        NavigationToolbar(dynamic_canvas, self))

        self._static_ax = static_canvas.figure.subplots()
        self._static_ax.grid(True)
        t = np.linspace(0, 10, 501)
        self._static_ax.plot(t, np.tan(t), ".")

        self._dynamic_ax = dynamic_canvas.figure.subplots()
        self._dynamic_ax.grid(True)
        self._timer = dynamic_canvas.new_timer(
            100, [(self._update_canvas, (), {})])
        self._timer.start()
Пример #4
0
    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.Online_Plt_checkBox.setText(_translate("MainWindow", "Plot"))
        self.Meas_pushButton.setText(_translate("MainWindow", "Measure"))
        self.Input_Lab_1.setText(_translate("MainWindow", "Start"))
        self.Input_Lab_2.setText(_translate("MainWindow", "Step"))
        self.lineEdit_3.setText(_translate("MainWindow", "End"))
        self.Step_radioButton.setText(_translate("MainWindow", "Step"))
        self.Num_radioButton.setText(_translate("MainWindow", "Num"))
        self.label.setText(_translate("MainWindow", "Avg Times"))
        self.lineEdit_AvfTime.setText(_translate("MainWindow", "16"))
        self.label_2.setText(_translate("MainWindow", "dt"))
        self.lineEdit_4.setText(_translate("MainWindow", "0.01"))
        self.data_save.setText(_translate("MainWindow", "Save"))
        self.data_clear.setText(_translate("MainWindow", "Clear"))
        self.menuFile.setTitle(_translate("MainWindow", "File"))
        self.menuEdit.setTitle(_translate("MainWindow", "Edit"))
        self.menuHelp.setTitle(_translate("MainWindow", "Help"))

        dynamic_canvas = FigureCanvas(Figure(figsize=(5, 3)))
        self.horizontalLayout_plot.addWidget(dynamic_canvas)

        self._dynamic_ax = dynamic_canvas.figure.subplots()
        self._timer = dynamic_canvas.new_timer(
            50, [(self._update_canvas, (), {})])
        self._timer.start()
Пример #5
0
    def __init__(self, pid, delay):

        self.process = psutil.Process(6704)
        self.stats = {
            'memory': [],
            'cpu_percent': []
        }
        self.ma = {k: [] for k in self.stats.keys()}

        super().__init__()
        self._main = QtWidgets.QWidget()
        self.setCentralWidget(self._main)
        layout = QtWidgets.QVBoxLayout(self._main)

        # Center window
        self.setFixedSize(800, 600)
        qtRectangle = self.frameGeometry()
        centerPoint = QDesktopWidget().availableGeometry().center()
        qtRectangle.moveCenter(centerPoint)
        self.move(qtRectangle.topLeft())

        self.setWindowTitle(f"pstrace : pid={pid} ({self.process.name()})")

        dynamic_canvas = FigureCanvas(Figure(figsize=(5, 3)))
        layout.addWidget(dynamic_canvas)
        # self.addToolBar(QtCore.Qt.BottomToolBarArea, NavigationToolbar(dynamic_canvas, self))

        self._dynamic_ax = dynamic_canvas.figure.subplots(2, sharex=True)
        self._timer = dynamic_canvas.new_timer(
            delay*1000, [(self._update_canvas, (), {})])
        self._figure = dynamic_canvas.figure
        self._timer.start()
Пример #6
0
    def __init__(self):
        super().__init__()
        self._main = QtWidgets.QWidget()
        self.setCentralWidget(self._main)
        layout = QtWidgets.QVBoxLayout(self._main)

        static_canvas = FigureCanvas(Figure(figsize=(5, 3)))
        layout.addWidget(static_canvas)
        self.addToolBar(NavigationToolbar(static_canvas, self))

        dynamic_canvas = FigureCanvas(Figure(figsize=(5, 3)))
        layout.addWidget(dynamic_canvas)
        self.addToolBar(QtCore.Qt.BottomToolBarArea,
                        NavigationToolbar(dynamic_canvas, self))

        self._static_ax = static_canvas.figure.subplots()
        t = np.linspace(0, 10, 501)
        self._static_ax.plot(t, np.tan(t), ".")

        self._dynamic_ax = dynamic_canvas.figure.subplots()
        t = np.linspace(0, 10, 101)
        # Set up a Line2D.
        self._line, = self._dynamic_ax.plot(t, np.sin(t + time.time()))
        self._timer = dynamic_canvas.new_timer(50)
        self._timer.add_callback(self._update_canvas)
        self._timer.start()
Пример #7
0
    def __init__(self):
        super().__init__()
        self._main = QtWidgets.QWidget()
        self.setCentralWidget(self._main)
        layout = QtWidgets.QVBoxLayout(self._main)
        

        
        
        
        self.setWindowTitle('DataFairy-v0.0.0-betav1')
        image = QtGui.QPixmap()
        image.load('pic/image-24.png')
        image = image.scaled(self.width(), self.height())

        self.setWindowIcon(QtGui.QIcon('pic/logo2.jpg'))

        static_canvas = FigureCanvas(Figure(figsize=(5, 3)))
        layout.addWidget(static_canvas)
        self.addToolBar(NavigationToolbar(static_canvas, self))

        dynamic_canvas = FigureCanvas(Figure(figsize=(5, 3)))
        layout.addWidget(dynamic_canvas)
        self.addToolBar(QtCore.Qt.BottomToolBarArea,
                        NavigationToolbar(dynamic_canvas, self))

        self._static_ax = static_canvas.figure.subplots()
        self._static_ax.plot(year,predict,'red')
        self._static_ax.scatter(year,popularity)

        self._dynamic_ax = dynamic_canvas.figure.subplots()
        self._timer = dynamic_canvas.new_timer(
            100, [(self._update_canvas, (), {})])
        self._timer.start()
Пример #8
0
    def __init__(self, N=100, M=100, parent=None):
        super().__init__(parent)
        layout = QVBoxLayout(self)

        dynamic_canvas = FigureCanvas(Figure(figsize=(5, 5)))
        layout.addWidget(dynamic_canvas)

        #Création bouton start stop
        startStopButton = QPushButton("Démarrer", self)
        startStopButton.clicked.connect(self.startStop)

        self.modele = modele()

        self.canvas = dynamic_canvas.figure.subplots()
        self.timer = dynamic_canvas.new_timer(1,
                                              [(self.update_matrix, (), {})])
        self.timerRunning = False
Пример #9
0
    def __init__(self):
        super().__init__()
        self.setupUi(self)
        dynamic_canvas = FigureCanvas(Figure(figsize=(5, 3)))
        self.verticalLayout.addWidget(dynamic_canvas)
        self.addToolBar(QtCore.Qt.BottomToolBarArea,
                        NavigationToolbar(dynamic_canvas, self))
        # self.textEdit.setFont(Qfont(14))#("Consolas", 14)
        self.textEdit.setFont(QFont("Consolas", 14))

        self.pushButton.clicked.connect(self.MeasureThread)
        self.pushButton_2.clicked.connect(self.output)
        self.pushButton_3.clicked.connect(self.opensetting)

        self._dynamic_ax = dynamic_canvas.figure.subplots()
        self._timer = dynamic_canvas.new_timer(100,
                                               [(self._update_canvas, (), {})])
Пример #10
0
    def __init__(self):
        super(self.__class__, self).__init__()
        self.setupUi(self)

        #variable for mumbo jumbo button mayhem in pyqt
        self.singleAqc_call = 0

        #create instance of ccd and set error code and initial values of UI
        self.ccd = AndorCCD('./Andor_420OE_CC_001/', 'Atmcd32d.dll')
        #set the update code in the UI and start timer to check every now and then for error code and temperature
        self.updateTimer = Timer(0.25, self.updateErrorCodeAndStatus).start()

        self.updateTemp()
        self.ccd.setExposureTime(self.integrationTime_ctrl.value(),
                                 self.avg_ctrl.value())
        #set up a timer for continous measurement
        self._timerAqc = Timer(self.ccd.actualKinetic + 0.021,
                               self.startAqcuisition)

        #event handler definitions
        #file save
        self.actionSave.triggered.connect(self.saveFile)
        #cooler on and off button
        self.startCooling_btn.clicked.connect(
            lambda: self.ccd.coolerOn(self.temperature_ctrl.value()))
        self.stopCooling_btn.clicked.connect(self.ccd.coolerOff)
        #single aqcuisition button
        self.singleAqc_btn.clicked.connect(self.singleAqcd)
        #start and stop continous aqcuisition
        self.stop_btn.clicked.connect(self.stopAqcuisition)
        self.start_btn.clicked.connect(self.startAqcuisition)

        #change of integration time and averaging
        self.integrationTime_ctrl.valueChanged.connect(self.integrationChanged)
        self.avg_ctrl.valueChanged.connect(self.integrationChanged)

        #        code for matplotlib implementation to add a figure in drawLayout
        dynamic_canvas = FigureCanvas(Figure(figsize=(500, 300)))
        self.drawLayout.addWidget(dynamic_canvas)
        self.addToolBar(QtCore.Qt.BottomToolBarArea,
                        NavigationToolbar(dynamic_canvas, self))
        self._dynamic_ax = dynamic_canvas.figure.subplots()
        self._timer = dynamic_canvas.new_timer(21,
                                               [(self._update_canvas, (), {})])
        self._timer.start()
Пример #11
0
    def __init__(self):
        super(ApplicationWindow, self).__init__()
        self._main = QtWidgets.QWidget()
        self.setCentralWidget(self._main)
        layout = QtWidgets.QVBoxLayout(self._main)

        static_canvas = FigureCanvas(Figure(figsize=(5, 3)))
        layout.addWidget(static_canvas)
        self.addToolBar(NavigationToolbar(static_canvas, self))

        dynamic_canvas = FigureCanvas(Figure(figsize=(5, 3)))
        layout.addWidget(dynamic_canvas)
        self.addToolBar(QtCore.Qt.BottomToolBarArea,
                        NavigationToolbar(dynamic_canvas, self))

        self._static_ax = static_canvas.figure.subplots()
        t = np.linspace(0, 10, 501)
        self._static_ax.plot(t, np.tan(t), ".")

        self._dynamic_ax = dynamic_canvas.figure.subplots()
        self._timer = dynamic_canvas.new_timer(100,
                                               [(self._update_canvas, (), {})])
        self._timer.start()

        self.statusBar().showMessage('Ready')

        exitAct = QAction(QIcon('Resources/images/Exit.png'), '&Exit', self)
        exitAct.setShortcut('Ctrl+Q')
        exitAct.setStatusTip('Exit application')
        exitAct.triggered.connect(qapp.quit)

        menubar = self.menuBar()
        fileMenu = menubar.addMenu('&File')
        fileMenu.addAction(exitAct)

        self.toolbar = self.addToolBar('Exit')
        self.toolbar.addAction(exitAct)

        openFile = QAction(QIcon('open.png'), 'Open', self)
        openFile.setShortcut('Ctrl+O')
        openFile.setStatusTip('Open new File')
        openFile.triggered.connect(self.showDialog)

        # self.toolbar = self.addToolBar('Open')
        self.toolbar.addAction(openFile)
Пример #12
0
    def __init__(self):
        super().__init__()
        self._main = QtWidgets.QWidget()
        self.setCentralWidget(self._main)
        layout = QtWidgets.QVBoxLayout(self._main)

        static_canvas = FigureCanvas(Figure(figsize=(5, 3)))
        layout.addWidget(static_canvas)
        self._static_ax = static_canvas.figure.subplots()
        t = np.linspace(0, 10, 501)
        self._static_ax.plot(t, np.tan(t), ".")

        dynamic_canvas = FigureCanvas(Figure(figsize=(5, 3)))
        layout.addWidget(dynamic_canvas)
        self._dynamic_ax = dynamic_canvas.figure.subplots()
        self._timer = dynamic_canvas.new_timer(100,
                                               [(self._update_canvas, (), {})])
        self._timer.start()
Пример #13
0
    def __init__(self):
        super().__init__()
        self._main = QtWidgets.QWidget()
        self.setCentralWidget(self._main)
        layout = QtWidgets.QVBoxLayout(self._main)

        dynamic_canvas = FigureCanvas(Figure(figsize=(8, 5)))
        layout.addWidget(dynamic_canvas)
        #self.addToolBar(QtCore.Qt.BottomToolBarArea, NavigationToolbar(dynamic_canvas, self))

        self._dynamic_ax = dynamic_canvas.figure.subplots()
        self._timer = dynamic_canvas.new_timer(1,
                                               [(self._update_canvas, (), {})])
        self._timer.start()

        self.data = []
        self.data_new = []
        self.andor_ctrl = None
Пример #14
0
    def __init__(self):
        super().__init__()
        self._main = QtWidgets.QWidget()
        self.setCentralWidget(self._main)
        layout = QtWidgets.QVBoxLayout(self._main)
        #        button1 = QtWidgets.QPushButton(self._main)
        #        button2 = QtWidgets.QPushButton(self._main) # work in progress
        #        button1.clicked.connect(self.clear_canvas)
        #        button2.clicked.connect(self.start_canvas)

        # canvas setup
        fig = plt.figure()
        ax = fig.gca(projection='3d')
        dynamic_canvas = FigureCanvas(Figure(figsize=(20, 12)))
        layout.addWidget(dynamic_canvas)
        self.addToolBar(QtCore.Qt.BottomToolBarArea,
                        NavigationToolbar(dynamic_canvas, self))

        n = 50
        # тут сколько по оси х в графике делений

        #data setup
        self.time1 = 0
        self.x = [0 for i in range(n)]
        self.y = [0 for i in range(n)]
        self.z = [0 for i in range(n)]

        self.vx = [0 for i in range(n)]
        self.vy = [0 for i in range(n)]
        self.vz = [0 for i in range(n)]

        self.gx = [0 for i in range(n)]
        self.gy = [0 for i in range(n)]
        self.gz = [0 for i in range(n)]

        self.ax = [0 for i in range(n)]
        self.ay = [0 for i in range(n)]
        self.az = [0 for i in range(n)]

        # timer setup
        self._dynamic_ax = dynamic_canvas.figure.gca(projection='3d')
        self._timer = dynamic_canvas.new_timer(30,
                                               [(self._update_canvas, (), {})])
        self._timer.start()
    def __init__(self):
        super().__init__()
        self._main = QtWidgets.QWidget()
        self.setCentralWidget(self._main)
        layout = QtWidgets.QVBoxLayout(self._main)

        dynamic_canvas = FigureCanvas(Figure(figsize=(5, 3)))
        layout.addWidget(dynamic_canvas)
        self.addToolBar(QtCore.Qt.BottomToolBarArea,
                        NavigationToolbar(dynamic_canvas, self))

        # 建立空的x轴数组和y轴数组
        self.x = []
        self.y = []
        self.n = 0

        self._dynamic_ax = dynamic_canvas.figure.subplots()
        self._timer = dynamic_canvas.new_timer(100,
                                               [(self._update_canvas, (), {})])
        self._timer.start()
Пример #16
0
    def __init__(self, parent):
        super(QWidget, self).__init__(parent)
        self.styleSheet = open('style.css').read()

        ### Add menu bar to widget ###
        self.hlayout = QHBoxLayout()
        self.vlayout = QVBoxLayout(self)

        ## Make buttons ##
        # Tuner tab
        self.tunerButton = QPushButton("Tune", self)
        self.tunerButton.setToolTip("Interactive Guitar Tuner")
        self.tunerButton.setObjectName("header")
        self.hlayout.addWidget(self.tunerButton)

        # Graphing tab
        self.graphButton = QPushButton("Plots", self)
        self.graphButton.setToolTip("Live Waveform Plotting")
        self.graphButton.setObjectName("header")
        self.hlayout.addWidget(self.graphButton)

        # Make buttons appear at the top
        self.vlayout.addLayout(self.hlayout)
        ### End menu bar ###

        # Add tuning label (says which tuning we're listening for)
        self.tuning_label = QLabel("Standard2", self)
        self.tuning_label.setObjectName("tuning")
        self.tuning_label.setGeometry(10, 30, 200, 100)

        ### Live Audio Plots ###
        dynamic_canvas = FigureCanvas(Figure(figsize=(5, 3)))
        self.vlayout.addWidget(dynamic_canvas)

        self._dynamic_ax = dynamic_canvas.figure.subplots()
        self._timer = dynamic_canvas.new_timer(100,
                                               [(self._update_canvas, (), {})])
        self._timer.start()
Пример #17
0
    def __init__(self):
        super(ApplicationWindow, self).__init__()
        self._main = QtWidgets.QWidget()
        self.setCentralWidget(self._main)
        layout = QtWidgets.QVBoxLayout(self._main)

        static_canvas = FigureCanvas(Figure(figsize=(5, 3)))
        layout.addWidget(static_canvas)
        self.addToolBar(NavigationToolbar(static_canvas, self))

        dynamic_canvas = FigureCanvas(Figure(figsize=(5, 3)))
        layout.addWidget(dynamic_canvas)
        self.addToolBar(QtCore.Qt.BottomToolBarArea,
                        NavigationToolbar(dynamic_canvas, self))

        self._static_ax = static_canvas.figure.subplots()
        t = np.linspace(0, 10, 501)
        self._static_ax.plot(t, np.tan(t), ".")

        self._dynamic_ax = dynamic_canvas.figure.subplots()
        self._timer = dynamic_canvas.new_timer(
            100, [(self._update_canvas, (), {})])
        self._timer.start()
    def __init__(self):
        super(mywindow, self).__init__()

        #GUI 动态载入
        self.ui = QUiLoader().load('u1.ui')


        """
        layout = self.ui.HLayout_showpic

        static_canvas = FigureCanvas(Figure(figsize=(5, 3)))

        layout.addWidget(static_canvas)

        self._static_ax = static_canvas.figure.subplots()
        t = np.linspace(0, 10, 501)
        self._static_ax.plot(t, np.tan(t), ".")
        """
        layout = self.ui.HLayout_showpic
        dynamic_canvas = FigureCanvas(Figure(figsize=(5, 3)))
        layout.addWidget(dynamic_canvas)

        self.addToolBar(NavigationToolbar(dynamic_canvas, self))

        self._dynamic_ax = dynamic_canvas.figure.subplots()
        t = np.linspace(0, 10, 101)
        # Set up a Line2D.
        self._line, = self._dynamic_ax.plot(t, np.sin(t + time.time()))
        self._timer = dynamic_canvas.new_timer(50)
        self._timer.add_callback(self._update_canvas)
        self._timer.start()
        #self.ui.addToolBar(NavigationToolbar(static_canvas, self))
        #Lin通讯有关参数初始化
        self.hardwareInit()

        #部件逻辑初始化
        self.widgetsInit()
Пример #19
0
class ApplicationWindow(QtWidgets.QMainWindow):
    def __init__(self):

        self.running: bool = False
        self.beta: float = 0
        self.range_alpha: List = []
        self.hide_alpha_zero: bool = False
        self.need_to_remake: bool = True
        self.ready_to_go = False
        self.logarithmic = False
        self.simulations_per_tick: int = 0

        super().__init__()
        self._main = QtWidgets.QWidget()
        self.setCentralWidget(self._main)
        # layout = QtWidgets.QVBoxLayout(self._main)
        layout = QtWidgets.QGridLayout(self._main)

        self.setWindowTitle("Caching Algorithm Simulation")

        self.static_canvas = FigureCanvas(Figure(figsize=(6, 4)))
        layout.addWidget(self.static_canvas, 0, 0)
        # self.addToolBar(NavigationToolbar(static_canvas, self))

        self.dynamic_canvas = FigureCanvas(Figure(figsize=(6, 4)))
        layout.addWidget(self.dynamic_canvas, 1, 0)
        # self.addToolBar(QtCore.Qt.BottomToolBarArea,
        #                 NavigationToolbar(dynamic_canvas, self))

        self.file_distribution = FigureCanvas(Figure(figsize=(6, 4)))
        layout.addWidget(self.file_distribution, 0, 1)

        self._file_dist = self.file_distribution.figure.subplots()

        # mini UI layout for button input
        entry_corner = QtWidgets.QGridLayout(self._main)
        layout.addLayout(entry_corner, 1, 1)
        miniui = QtWidgets.QGridLayout(self._main)
        entry_corner.addLayout(miniui, 0, 0)

        start_stop = QtWidgets.QGridLayout(self._main)
        miniui.addLayout(start_stop, 0, 0)

        entry_text = QtWidgets.QGridLayout(self._main)
        entry_corner.addLayout(entry_text, 0, 1)

        self.toggle_button = QtWidgets.QPushButton("Run")
        self.toggle_button.setCheckable(True)
        self.toggle_button.setFixedWidth(80)
        self.toggle_button.toggled.connect(self.toggle_run)

        self.restart_button = QtWidgets.QPushButton("Restart")
        self.restart_button.setFixedWidth(80)
        self.restart_button.clicked.connect(self._flag_for_restart)

        start_stop.addWidget(self.toggle_button, 0, 0)
        start_stop.addWidget(self.restart_button, 1, 0)

        # checkboxes
        self.toggle_buttons = QtWidgets.QGridLayout(self._main)
        miniui.addLayout(self.toggle_buttons, 1, 0)

        self.box_hide_alpha_zero = QtWidgets.QCheckBox(
            "Hide \\alpha=0/Show \\alpha=1", self
        )
        self.box_hide_alpha_zero.stateChanged.connect(self.clicked_hide_a)
        self.toggle_buttons.addWidget(self.box_hide_alpha_zero, 0, 0)

        # needs_restart_label = QtWidgets.QLabel("Requires Restart")
        # self.toggle_buttons.addWidget(needs_restart_label, 1, 0)
        self.is_logarithmic = QtWidgets.QCheckBox("Logarithmic \\alpha")
        self.is_logarithmic.stateChanged.connect(self.clicked_logarithmic)
        self.toggle_buttons.addWidget(self.is_logarithmic, 2, 0)

        # entries
        user_num_label = QtWidgets.QLabel("Number of Users")
        entry_text.addWidget(user_num_label, 0, 0)
        self.user_num_entry = QtWidgets.QLineEdit(self)
        self.user_num_entry.setFixedWidth(80)
        entry_text.addWidget(self.user_num_entry, 1, 0)

        file_num_label = QtWidgets.QLabel("Number of Files")
        entry_text.addWidget(file_num_label, 2, 0)
        self.file_num_entry = QtWidgets.QLineEdit(self)
        self.file_num_entry.setFixedWidth(80)
        entry_text.addWidget(self.file_num_entry, 3, 0)

        cache_size_label = QtWidgets.QLabel("Cached Files / User")
        entry_text.addWidget(cache_size_label, 4, 0)
        self.cache_size_entry = QtWidgets.QLineEdit(self)
        self.cache_size_entry.setFixedWidth(80)
        entry_text.addWidget(self.cache_size_entry, 5, 0)

        requested_size_label = QtWidgets.QLabel("Requested Files / User")
        entry_text.addWidget(requested_size_label, 6, 0)
        self.requested_size_entry = QtWidgets.QLineEdit(self)
        self.requested_size_entry.setFixedWidth(80)
        entry_text.addWidget(self.requested_size_entry, 7, 0)

        alpha_start_label = QtWidgets.QLabel("\\alpha Start")
        entry_text.addWidget(alpha_start_label, 0, 1)
        self.alpha_start_entry = QtWidgets.QLineEdit(self)
        self.alpha_start_entry.setFixedWidth(80)
        entry_text.addWidget(self.alpha_start_entry, 1, 1)

        alpha_end_label = QtWidgets.QLabel("\\alpha End")
        entry_text.addWidget(alpha_end_label, 2, 1)
        self.alpha_end_entry = QtWidgets.QLineEdit(self)
        self.alpha_end_entry.setFixedWidth(80)
        entry_text.addWidget(self.alpha_end_entry, 3, 1)

        num_of_alpha_label = QtWidgets.QLabel("# d\\alpha Simulations")
        entry_text.addWidget(num_of_alpha_label, 4, 1)
        self.num_of_alpha_entry = QtWidgets.QLineEdit(self)
        self.num_of_alpha_entry.setFixedWidth(80)
        entry_text.addWidget(self.num_of_alpha_entry, 5, 1)

        zipf_label = QtWidgets.QLabel("Zipf constant a")
        entry_text.addWidget(zipf_label, 6, 1)
        self.zipf_entry = QtWidgets.QLineEdit(self)
        self.zipf_entry.setFixedWidth(80)
        entry_text.addWidget(self.zipf_entry, 7, 1)

        simulation_ptick_label = QtWidgets.QLabel("Simulations per tick")
        entry_text.addWidget(simulation_ptick_label, 8, 0)
        self.simulation_ptick_entry = QtWidgets.QLineEdit(self)
        self.simulation_ptick_entry.setFixedWidth(80)
        entry_text.addWidget(self.simulation_ptick_entry, 9, 0)

        self._static_ax = self.static_canvas.figure.subplots()

        self._dynamic_ax = self.dynamic_canvas.figure.subplots()
        self._timer = self.dynamic_canvas.new_timer(
            100, [(self._update_canvas, (), {})]
        )

        # set box data manually
        self.user_num_entry.setText(str(DEFAULT_USER_NUM))
        self.file_num_entry.setText(str(DEFAULT_NUM_OF_FILES))
        self.cache_size_entry.setText(str(DEFAULT_CACHE_SIZE))
        self.requested_size_entry.setText(str(DEFAULT_REQUEST_NUM))
        self.alpha_start_entry.setText(str(DEFAULT_ALPHA_START))
        self.alpha_end_entry.setText(str(DEFAULT_ALPHA_END))
        self.num_of_alpha_entry.setText(str(DEFAULT_NUMBER_OF_ALPHA))
        self.zipf_entry.setText(str(DEFAULT_ZIPF))
        self.simulation_ptick_entry.setText(str(DEFAULT_SIMULATIONS_PER_TICK))

    def initialize_simulation(self):

        # pull data from boxes to determine initialization
        need_to_bail: bool = False

        entries_dict = {
            "user_num": [self.user_num_entry, int],
            "file_num": [self.file_num_entry, int],
            "cache_size": [self.cache_size_entry, int],
            "request_size": [self.requested_size_entry, int],
            "alpha_start": [self.alpha_start_entry, float],
            "alpha_end": [self.alpha_end_entry, float],
            "num_alpha": [self.num_of_alpha_entry, int],
            "file_zipf_scalar": [self.zipf_entry, float],
            "sim_per_tick": [self.simulation_ptick_entry, int],
        }

        result_dict: Dict[str, Union[int, float]] = dict()

        for key, value in entries_dict.items():
            try:
                intermediate = value[0].text()
                finished = value[1](intermediate)
                result_dict[key] = finished
            except Exception as e:
                need_to_bail = True
                value[0].setText("")
        if need_to_bail:
            self.ready_to_go = False
            return

        if self.logarithmic:
            self.range_alpha = np.linspace(
                log10(result_dict["alpha_start"]),
                log10(result_dict["alpha_end"]),
                result_dict["num_alpha"],
            )
            self.range_alpha = np.power(10, self.range_alpha)
        else:
            self.range_alpha = np.linspace(
                result_dict["alpha_start"],
                result_dict["alpha_end"],
                result_dict["num_alpha"],
            )

        self.simulations_per_tick = result_dict["sim_per_tick"]

        self.range_alpha = list(self.range_alpha)

        # setup evaluation driver
        self.evaluators = []
        for alpha in self.range_alpha:
            evaluator = EvaluationDriver(
                num_of_files=result_dict["file_num"],
                cache_size=result_dict["cache_size"],
                num_of_users=result_dict["user_num"],
                num_of_requests=result_dict["request_size"],
                alpha=alpha,
                zipf_constant=result_dict["file_zipf_scalar"],
            )
            evaluator.setup()
            self.evaluators.append(evaluator)

        self.x_axis = self.evaluators[0].index_files()
        self.draw_dist()
        self._timer.start()
        self.ready_to_go = True

    def _flag_for_restart(self):
        self._timer.stop()
        self.running = False
        self.toggle_button.setChecked(False)
        qapp.processEvents()
        self.need_to_remake = True
        self._dynamic_ax.clear()
        self._dynamic_ax.figure.canvas.draw()
        self._static_ax.clear()
        self._static_ax.figure.canvas.draw()

    def _update_canvas(self):

        if self.running:
            import time

            t1 = time.time()
            self._dynamic_ax.clear()
            [
                evaluator.drive_multiple(self.simulations_per_tick)
                for evaluator in self.evaluators
            ]
            t2 = time.time()

            print(f"Differential: {t2-t1}")

            avgs = [
                sum(evaluator.trials) / len(evaluator.trials)
                for evaluator in self.evaluators
            ]
            maxs = [
                max(evaluator.trials) / evaluator.num_of_users
                for evaluator in self.evaluators
            ]
            mins = [
                min(evaluator.trials) / evaluator.num_of_users
                for evaluator in self.evaluators
            ]
            adjusted_average = [
                sum(evaluator.trials) / len(evaluator.trials) / evaluator.num_of_users
                for evaluator in self.evaluators
            ]

            self._dynamic_ax.plot(self.range_alpha, avgs)
            self._dynamic_ax.figure.tight_layout()
            self._dynamic_ax.set_ylim(ymin=0, ymax=1.5 * (max(avgs)))
            self._dynamic_ax.set_ylabel("Transaction Cost")
            if self.logarithmic:
                self._dynamic_ax.set_xlabel("\\alpha (log)")
                self._dynamic_ax.set_xscale("log")
            else:
                self._dynamic_ax.set_xlabel("\\alpha (log)")
                self._dynamic_ax.set_xscale("linear")
            self._dynamic_ax.figure.tight_layout()
            self._dynamic_ax.figure.canvas.draw()

            # now deal with min/max
            self._static_ax.clear()
            self._static_ax.plot(self.range_alpha, maxs)
            self._static_ax.plot(self.range_alpha, mins)
            self._static_ax.plot(self.range_alpha, adjusted_average)
            self._static_ax.set_ylabel("Transaction Cost per User")
            if self.logarithmic:
                self._static_ax.set_xlabel("\\alpha (log)")
                self._static_ax.set_xscale("log")
            else:
                self._static_ax.set_xlabel("\\alpha (log)")
                self._static_ax.set_xscale("linear")
            self._static_ax.figure.tight_layout()
            self._static_ax.figure.canvas.draw()

    def toggle_run(self) -> None:
        self.running = self.toggle_button.isChecked()
        if self.running:
            if self.need_to_remake:
                self.initialize_simulation()
            if self.ready_to_go:
                self._timer.start()
            else:
                self._flag_for_restart()
        else:
            self._timer.stop()
        qapp.processEvents()

    def clicked_hide_a(self, state):
        self.hide_alpha_zero = state == QtCore.Qt.Checked
        self.draw_dist()

    def clicked_logarithmic(self, state):
        self.logarithmic = state == QtCore.Qt.Checked
        self.need_to_remake = True

    def draw_dist(self):
        self._file_dist.clear()
        self._file_dist.plot(self.x_axis, self.evaluators[0].pm.file_distribution)

        if self.hide_alpha_zero:
            if 0 in self.range_alpha:
                for index in range(len(self.range_alpha)):
                    if 1 in self.range_alpha:
                        if (
                            self.range_alpha.index(0) != index
                            and self.range_alpha.index(1) != index
                        ):
                            self._file_dist.plot(
                                self.x_axis, self.evaluators[index].cm.cache_p_choice
                            )
                    else:
                        if self.range_alpha.index(0) != index:
                            self._file_dist.plot(
                                self.x_axis, self.evaluators[index].cm.cache_p_choice
                            )
        else:
            if 1 in self.range_alpha:
                for index in range(len(self.range_alpha)):
                    if self.range_alpha.index(1) != index:
                        self._file_dist.plot(
                            self.x_axis, self.evaluators[index].cm.cache_p_choice
                        )
            else:
                for index in range(len(self.range_alpha)):
                    self._file_dist.plot(
                        self.x_axis, self.evaluators[index].cm.cache_p_choice
                    )

        self._file_dist.legend(["Original P_r(m)"])
        self._file_dist.set_xlabel("File Index (m)")
        self._file_dist.set_ylabel("Probability")
        self._file_dist.set_ylim(ymin=0)
        self._file_dist.figure.tight_layout()
        self._file_dist.figure.canvas.draw()
Пример #20
0
class ApplicationWindow(QtWidgets.QMainWindow):
    def __init__(self):
        super().__init__()
        self.evaluating = False
        self.polynomial = []

        self._main = QtWidgets.QWidget()
        self.setCentralWidget(self._main)
        # Initialize QT layout
        layout = QtWidgets.QVBoxLayout(self._main)

        # Create the dynamic canvas and add it as a widget to the layout
        self.dynamic_canvas = FigureCanvas(Figure(figsize=(5, 3), dpi=100))
        layout.addWidget(self.dynamic_canvas)
        self.addToolBar(QtCore.Qt.BottomToolBarArea,
                        NavigationToolbar(self.dynamic_canvas, self))
        self._dynamic_ax = self.dynamic_canvas.figure.subplots()

        self.dataPoints, = self._dynamic_ax.plot([], [],
                                                 color="k",
                                                 linestyle="--",
                                                 antialiased=True)
        self.dynamic_canvas.mpl_connect('motion_notify_event',
                                        self.moved_and_pressed)
        resetButton = QtWidgets.QPushButton("Reset Drawed Curve")
        resetButton.clicked.connect(self.clearData)
        layout.addWidget(resetButton)

        evaluateButton = QtWidgets.QPushButton("Find Curve")
        evaluateButton.clicked.connect(self.findCurve)
        layout.addWidget(evaluateButton)
        self.configAxis()

        self._dynamic_ax = self.dynamic_canvas.figure.subplots()
        self._timer = self.dynamic_canvas.new_timer(50, [(self._update_canvas,
                                                          (), {})])
        self._timer.start()

    def clearData(self):
        self.dataPoints.set_xdata([])
        self.dataPoints.set_ydata([])
        self.evaluating = False
        self.polynomial.clear()
        self._dynamic_ax.clear()
        self.dataPoints, = self._dynamic_ax.plot([], [],
                                                 color="k",
                                                 linestyle="--",
                                                 antialiased=True)
        self.configAxis()

        self._dynamic_ax.figure.canvas.draw()

    def configAxis(self):

        self._dynamic_ax.set_xlim(-1, 1)
        self._dynamic_ax.set_ylim(-1, 1)
        # Center the axes
        self._dynamic_ax.spines['left'].set_position('center')
        self._dynamic_ax.spines['bottom'].set_position('center')
        # Eliminate upper and right axes
        self._dynamic_ax.spines['right'].set_color('none')
        self._dynamic_ax.spines['top'].set_color('none')

        # Show ticks in the left and lower axes only
        self._dynamic_ax.xaxis.set_ticks_position('bottom')
        self._dynamic_ax.yaxis.set_ticks_position('left')
        self._dynamic_ax.figure.canvas.draw()

    def _update_canvas(self):
        if (self.evaluating):
            self._dynamic_ax.clear()
            # Use fixed vertical limits to prevent autoscaling changing the scale
            # of the axis.
            #self._dynamic_ax.set_xlim(-1, 1)
            #self._dynamic_ax.set_ylim(-1, 1)

            # Center the axes
            self._dynamic_ax.spines['left'].set_position('center')
            self._dynamic_ax.spines['bottom'].set_position('center')
            # Eliminate upper and right axes
            self._dynamic_ax.spines['right'].set_color('none')
            self._dynamic_ax.spines['top'].set_color('none')

            # Show ticks in the left and lower axes only
            self._dynamic_ax.xaxis.set_ticks_position('bottom')
            self._dynamic_ax.yaxis.set_ticks_position('left')

            self._dynamic_ax.plot(self.dataPoints.get_xdata(),
                                  self.dataPoints.get_ydata())

        self._dynamic_ax.figure.canvas.draw()

    def moved_and_pressed(self, event):

        if event.button == 1 and not self.evaluating:
            x = np.append(self.dataPoints.get_xdata(), event.xdata)
            y = np.append(self.dataPoints.get_ydata(), event.ydata)
            self.dataPoints.set_data(x, y)
            self.dynamic_canvas.draw()

    def errorFunction(self):
        pass

    def findCurve(self):
        #self.evaluating = True

        gradient = self.getGradient()
        C0 = self.getC0()

        self._dynamic_ax.plot(gradient.get_xdata(), gradient.get_ydata())
        roots = self.getRoots(gradient)

        self._dynamic_ax.scatter(roots[0, :], roots[1, :])
        curveDegree = len(roots[0, :]) + 1
        start_Coefficients = np.ones(curveDegree)
        start_Coefficients[0] = C0
        polynom = Poly(start_Coefficients)

        prediction = polynom(self.dataPoints.get_xdata())

        print(gradient.get_ydata())
        print(self.dataPoints.get_ydata())
        #print(C0)
        self._dynamic_ax.plot(gradient.get_xdata(), prediction)

        self.dynamic_canvas.draw()

    def getGradient(self, data=None):
        if (data == None):
            gradient = copy.copy(self.dataPoints)
        else:
            gradient = copy.copy(data)
        gradient.set_ydata(np.gradient(np.array(gradient.get_ydata())))

        return gradient

    def getC0(self):

        dataPoints = np.array(self.dataPoints.get_data())

        print(dataPoints)
        for index in range(len(dataPoints) - 1):
            if (dataPoints[0, index] < 0 and dataPoints[0, index + 1] >= 0):
                #print(dataPoints[1,index+1])
                return dataPoints[1, index + 1]
        return 0

    def getRoots(self, grad, grad2=None):
        roots = list()
        gradData = np.array(grad.get_data())

        for index in range(1, len(gradData[1]) - 1):
            if np.sign(gradData[1, index]) != np.sign(gradData[1, index + 1]):
                root = [gradData[0, index], gradData[1, index]]
                roots.append(root)
        roots = np.transpose(np.array(roots))

        if (grad2 != None):
            terraces = list()

            grad2Data = np.array(grad2.get_data())
            for index in range(1, len(grad2Data[1]) - 1):
                if np.sign(grad2Data[1, index]) != np.sign(
                        grad2Data[1, index + 1]):
                    terrace = [grad2Data[0, index], grad2Data[1, index]]
                    terraces.append(terrace)
            terraces = np.transpose(np.array(terraces))

            return roots, terraces

        return roots
Пример #21
0
class Ui_Dialog(object):
    def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(995, 767)

        self.comecar_button = QtWidgets.QPushButton(Dialog)
        self.comecar_button.setGeometry(QtCore.QRect(240, 670, 151, 61))
        self.comecar_button.setObjectName("comecar_button")

        self.fire_slider = QtWidgets.QSlider(Dialog)
        self.fire_slider.setGeometry(QtCore.QRect(42, 20, 20, 571))
        self.fire_slider.setMinimum(40)
        self.fire_slider.setMaximum(100)
        self.fire_slider.setPageStep(10)
        self.fire_slider.setOrientation(QtCore.Qt.Vertical)
        self.fire_slider.setInvertedControls(False)
        self.fire_slider.setObjectName("fire_slider")

        self.wind_slider = QtWidgets.QSlider(Dialog)
        self.wind_slider.setGeometry(QtCore.QRect(100, 620, 851, 20))
        self.wind_slider.setMinimum(2)
        self.wind_slider.setMaximum(10)
        self.wind_slider.setPageStep(2)
        self.wind_slider.setProperty("value", 0)
        self.wind_slider.setOrientation(QtCore.Qt.Horizontal)
        self.wind_slider.setObjectName("wind_slider")

        self.verticalLayoutWidget = QtWidgets.QWidget(Dialog)
        self.verticalLayoutWidget.setGeometry(QtCore.QRect(100, 10, 851, 581))
        self.verticalLayoutWidget.setObjectName("verticalLayoutWidget")
        self.layout = QtWidgets.QVBoxLayout(self.verticalLayoutWidget)
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.layout.setObjectName("layout")
        self.parar_button = QtWidgets.QPushButton(Dialog)
        self.parar_button.setGeometry(QtCore.QRect(610, 670, 151, 61))
        self.parar_button.setObjectName("parar_button")
        self.groupBox = QtWidgets.QGroupBox(Dialog)
        self.groupBox.setGeometry(QtCore.QRect(820, 660, 120, 80))
        self.groupBox.setObjectName("groupBox")
        self.esquerda_button = QtWidgets.QRadioButton(self.groupBox)
        self.esquerda_button.setGeometry(QtCore.QRect(10, 20, 95, 20))
        self.esquerda_button.setChecked(True)
        self.esquerda_button.setObjectName("esquerda_button")
        self.direita_button = QtWidgets.QRadioButton(self.groupBox)
        self.direita_button.setGeometry(QtCore.QRect(10, 50, 95, 20))
        self.direita_button.setObjectName("direita_button")

        self.decay_factor = 1.5
        self.wind_factor = 2
        self.fire = np.zeros([70, 100], dtype='uint8')

        self.img_canvas = FigureCanvas(Figure())
        self.layout.addWidget(self.img_canvas)
        self.img_ax = self.img_canvas.figure.subplots()
        self.img_ax.imshow(self.fire,
                           cmap='hot',
                           vmin=0,
                           vmax=36,
                           aspect='auto')
        self.img_ax.axis('off')

        self.timer = self.img_canvas.new_timer(100,
                                               [(self.createFire, (), {})])

        self.retranslateUi(Dialog)
        QtCore.QMetaObject.connectSlotsByName(Dialog)

    def retranslateUi(self, Dialog):
        _translate = QtCore.QCoreApplication.translate
        Dialog.setWindowTitle(_translate("Dialog", "Fire_Doom"))
        self.comecar_button.setText(_translate("Dialog", "Começar"))
        self.parar_button.setText(_translate("Dialog", "Parar"))
        self.esquerda_button.setText(_translate("Dialog", "Esquerda"))
        self.direita_button.setText(_translate("Dialog", "Direita"))

        self.fire_slider.valueChanged.connect(self.getFire)
        self.wind_slider.valueChanged.connect(self.getWind)

        self.comecar_button.clicked.connect(self.startFire)
        self.parar_button.clicked.connect(self.stopFire)

    def startFire(self):
        self.timer.start()

    def stopFire(self):
        self.timer.stop()

    def getFire(self):
        self.decay_factor = 11.5 - (self.fire_slider.value() / 10)
        # print(self.decay_factor)

    def getWind(self):
        self.wind_factor = self.wind_slider.value()
        # print(self.wind_factor)

    def createFire(self):
        heigth = 70
        width = 100
        self.fire[heigth - 1, :] = 36

        for row in range(heigth - 1):
            for col in range(width):

                decay_factor = self.decay_factor
                decay = np.int_(np.floor(np.random.rand() * decay_factor))

                if self.direita_button.isChecked():
                    col = width - 1 - col
                    col_index = (col + decay) % 100
                    col2 = np.abs(col + 1 -
                                  np.random.randint(1, self.wind_factor))
                    # col2 = col
                else:
                    col_index = col - decay
                    col2 = (col - 1 +
                            np.random.randint(1, self.wind_factor)) % 100

                self.fire[heigth - 2 - row, col_index] = np.clip(
                    self.fire[heigth - 1 - row, col2] - decay, 0, 36)

        self.img_ax.clear()
        self.img_ax.imshow(self.fire,
                           cmap='hot',
                           vmin=0,
                           vmax=36,
                           aspect='auto')
        self.img_ax.axis('off')
        self.img_ax.figure.canvas.draw()
Пример #22
0
class Page4(QtWidgets.QWizardPage):
    #page for the presentation of the dynamic map/graph
    def __init__(self, parent=None):
        super(Page4, self).__init__(parent)
        self.setTitle('Graph')
        self.figure = Figure(figsize=(6, 3), tight_layout=True)
        self.canvas = FigureCanvas(self.figure)
        self.ax = self.figure.add_subplot(111)
        self.setFinalPage(True)
        vbox = QtWidgets.QVBoxLayout()
        self._timer = None
        vbox.addWidget(self.canvas)
        self.setLayout(vbox)
        self.patchesX = []
        self.patchesY = []
        self.minLat = 0
        self.minLong = 0
        self.maxLat = 0
        self.maxLong = 0
        self.radiuses = []
        self.columnsWeight = []
        self.files = []
        self.lineCount = 0
        self.patches = 0
        self.currentLine = 0

    def plots(self):
        #timed callback that graphs the evolution of the allele counts, stops when we reach to the last line of the experiment (last allele count)
        if self.currentLine < (self.lineCount - 2):
            ax = self.ax
            ax.clear()
            #generates the map
            m = Basemap(projection='merc',
                        llcrnrlat=self.minLat - 1,
                        urcrnrlat=self.maxLat + 1,
                        llcrnrlon=self.minLong - 1,
                        urcrnrlon=self.maxLong + 1,
                        lat_ts=20,
                        resolution='l',
                        ax=ax)
            m.drawcoastlines(color="black")
            #reads each of the files and creates a pie char for each one
            for patch in range(0, self.patches):
                line = next(self.files[patch]).split(',')
                sizes = [float(elem) for elem in line]
                sizes = sizes[2:]
                ratios = aux.getRatios(sizes, self.columnsWeight)
                px, py = m(self.patchesX[patch], self.patchesY[patch])
                aux.draw_pie(ax, ratios, px, py, self.radiuses[patch])
                next(self.files[patch])
                next(self.files[patch])
            self.canvas.draw()
            fname = "./video/" + str(currentLine).zfill(5) + ".png"
            self.canvas.print_figure(fname,
                                     dpi=1024,
                                     facecolor='w',
                                     edgecolor='w',
                                     orientation='portrait',
                                     papertype=None,
                                     format="png",
                                     transparent=False,
                                     bbox_inches='tight',
                                     pad_inches=0.05,
                                     frameon=None)
            self.currentLine += 3
        else:
            #cleanup stops the callback and closes all of the files
            if self._timer:
                self._timer.stop()
                self._timer = None
            for f in self.files:
                f.close()

    def initializePage(self):
        #setup of the information required for the graphs
        self._timer = self.canvas.new_timer(40, [(self.plots, (), {})])
        coordFile = str(self.field('coordFile'))
        popFile = str(self.field('popFile'))
        dataFile = str(self.field('dataDir')) + "/AF1_Aggregate_Run1_*.csv"
        self.patchesX, self.patchesY = aux.getCoordinates(coordFile)
        self.minLat = min(self.patchesY)
        self.minLong = min(self.patchesX)
        self.maxLat = max(self.patchesY)
        self.maxLong = max(self.patchesX)
        self.radiuses = aux.getSizes(popFile)
        groups = int(self.field('groupCount'))
        alleles = int(self.field('alleleCount'))
        for i in range(groups):
            groupWeights = []
            for j in range(alleles):
                weight = int(self.field(str(i) + '-' + str(j)))
                groupWeights.append(weight)
            self.columnsWeight.append(groupWeights)
        fileNames = sorted(glob.glob(dataFile))
        self.files = []
        self.lineCount = len(open(fileNames[0]).readlines()) - 1
        for fileName in fileNames:
            self.files.append(open(fileName, 'r'))
        self.patches = len(self.files)
        for f in self.files:
            next(f)
        self._timer.start()

    def clearLayout(self, layout):
        if layout is not None:
            while layout.count():
                item = layout.takeAt(0)
                widget = item.widget()
                if widget is not None:
                    widget.deleteLater()
                else:
                    self.clearLayout(item.layout())

    def cleanupPage(self):
        if self._timer:
            self._timer.stop()
            self._timer = None
        for f in self.files:
            f.close()
        self.clearLayout(self.layout())

    def closeEvent(self, event):
        if self._timer:
            self._timer.stop()
            self._timer = None
        for f in self.files:
            f.close()
        self.clearLayout(self.layout())
        event.accept()
Пример #23
0
    def __init__(self, pdb_file, colors=False, debug=False):
        super(ApplicationWindow, self).__init__()
        self.debug = debug

        # Create a particle object
        self.particle = sk.Particle()
        self.particle.read_pdb(pdb_file, ff='WK')

        # Load beam
        beam = sk.Beam('../input/beam/amo86615.beam')

        # Load and initialize the detector
        self.det = sk.PnccdDetector(
            geom='../input/lcls/amo86615/PNCCD::CalibV1/'
            'Camp.0:pnCCD.1/geometry/0-end.data',
            beam=beam)

        mesh_length = 151 if not debug else 31
        mesh, self.voxel_length = self.det.get_reciprocal_mesh(
            voxel_number_1d=mesh_length)

        self.volume = sg.calculate_diffraction_pattern_gpu(
            mesh, self.particle, return_type='intensity')

        self.pixel_momentum = self.det.pixel_position_reciprocal

        if colors:
            color_map = collections.defaultdict(lambda: "#000000", {
                "C": "#ff0000",
                "N": "#00ff00",
                "O": "#0000ff",
            })
            colors = [color_map[s] for s in self.particle.atomic_symbol]
        else:
            colors = None

        self._azim = None
        self._elev = None
        self._time = 0.
        self._uptodate = False

        self._main = QtWidgets.QWidget()
        self.setCentralWidget(self._main)
        layout = QtWidgets.QHBoxLayout(self._main)

        real3d_canvas = FigureCanvas(Figure(figsize=(4, 4)))
        layout.addWidget(real3d_canvas)
        self.addToolBar(NavigationToolbar(real3d_canvas, self))

        self._real3d_ax = real3d_canvas.figure.subplots(
            subplot_kw={"projection": '3d'})
        self._real3d_ax.scatter(
            -self.particle.atom_pos[:, 2],
            self.particle.atom_pos[:, 1],
            self.particle.atom_pos[:, 0],
            s=1,
            c=colors,
        )
        self._real3d_ax.set_title("3D Protein")
        self._real3d_ax.set_xlabel('-Z')
        self._real3d_ax.set_ylabel('Y')
        self._real3d_ax.set_zlabel('X')

        if self.debug:
            real2d_canvas = FigureCanvas(Figure(figsize=(4, 4)))
            layout.addWidget(real2d_canvas)
            self.addToolBar(NavigationToolbar(real2d_canvas, self))

            self._real2d_ax = real2d_canvas.figure.subplots()

        recip_canvas = FigureCanvas(Figure(figsize=(4, 4)))
        layout.addWidget(recip_canvas)
        self.addToolBar(NavigationToolbar(recip_canvas, self))

        self._recip_ax = recip_canvas.figure.subplots()

        self._timer = recip_canvas.new_timer(100,
                                             [(self._update_canvas, (), {})])
        self._timer.start()
Пример #24
0
    def __init__(self, serialConnection):
        super(PadMainWindow, self).__init__()
        self.experiment_running = False
        self.prompting = False
        self.serialConnection = serialConnection
        uic.loadUi('c:/dev/pad/ui/designer/mainwindow.ui', self)

        # get the gridlayout for the plots
        layout = self.findChild(QGridLayout, "gridGraphs")

        raw_canvas = FigureCanvas(Figure(figsize=(5, 3)))
        layout.addWidget(raw_canvas, 0, 0)

        raw_ax = raw_canvas.figure.subplots()
        t = [np.nan] * 100
        self.i_x, = raw_ax.plot(t, [np.nan] * len(t),
                                label='$I_x = I_{\parallel }$')
        self.i_y, = raw_ax.plot(t, [np.nan] * len(t),
                                label='$I_y = I_{\perp }$')
        raw_ax.set_title(
            'Raw Intensities $(I_x, I_y) = (I_{\parallel }, I_{\perp })$')
        raw_ax.set_xlabel("Time (s)")
        raw_ax.relim()
        raw_ax.autoscale_view(True, True, True)
        raw_ax.set_xlim(0, 15)
        raw_ax.set_ylabel("Fluorescence (a.u.)")
        raw_ax.legend()
        self._raw_ax = raw_ax

        temp_canvas = FigureCanvas(Figure(figsize=(5, 3)))
        layout.addWidget(temp_canvas, 0, 2)
        temp_ax = temp_canvas.figure.subplots()
        pid_ax = temp_ax.twinx()
        self.hls_cmp = ListedColormap(sns.hls_palette(8).as_hex())
        self.default_cmp = plt.get_cmap("tab10")
        self.temp = temp_ax.plot(t, [np.nan] * len(t),
                                 label='Temp °C',
                                 color=self.hls_cmp(0))[0]
        self.pid_ctrl = pid_ax.plot(t, [np.nan] * len(t),
                                    label='PID Control',
                                    color=self.hls_cmp(1))[0]
        temp_ax.set_xlabel('Time(s)')
        temp_ax.set_ylabel('Temp (°C)')
        pid_ax.set_ylabel('PID Control')
        pid_ax.grid(False)
        temp_ax.set_title('Temperature Monitor (°C)')
        temp_ax.set_xlim(0, 15)
        temp_ax.set_ylim(10, 85)
        pid_ax.set_ylim(-20, 350)
        temp_ax.legend(loc='upper left')
        pid_ax.legend(loc='upper right')
        self._temp_ax = temp_ax

        pa_canvas = FigureCanvas(Figure(figsize=(5, 3)))
        layout.addWidget(pa_canvas, 1, 0)

        pa_ax = pa_canvas.figure.subplots()
        self.pa_r0, = pa_ax.plot(t, [np.nan] * len(t),
                                 label='$r_0$',
                                 linestyle='--')
        self.pa_r, = pa_ax.plot(t, [np.nan] * len(t), label='$r$')
        self.pa_delta_r, = pa_ax.plot(t, [np.nan] * len(t), label='$\Delta r$')
        pa_ax.set_title('Anisotropy (\Delta r$ = {1})')
        pa_ax.set_xlabel("Time (s)")
        pa_ax.relim()
        pa_ax.autoscale_view(True, True, True)
        pa_ax.set_xlim(0, 15)
        pa_ax.set_ylabel("$r, r_o, \Delta r$")
        pa_ax.legend()
        self._pa_ax = pa_ax

        buttonAutoReference = self.findChild(QPushButton,
                                             "buttonAutoReference")
        buttonAutoReference.clicked.connect(self.on_auto_reference)
        self.toolBar = self.findChild(QToolBar, "toolBar")
        widgetSpacer = QWidget()
        widgetSpacer.setSizePolicy(
            QSizePolicy.Expanding,
            QSizePolicy.Expanding,
        )
        self.progressBar = QProgressBar(self)
        self.progressBar.setValue(0)
        self.progressBar.setFixedWidth(150)
        self.progressBar.setDisabled(True)
        self.toolBar.addWidget(widgetSpacer)
        self.labelEstimatedTime = QLabel("Estimated Time To Run Experiment: ")
        self.labelExperimentTime = QLabel()
        self.toolBar.addWidget(self.labelEstimatedTime)
        self.toolBar.addWidget(self.labelExperimentTime)
        widgetSpacer2 = QWidget()
        widgetSpacer2.setFixedWidth(15)
        self.toolBar.addWidget(widgetSpacer2)
        self.toolBar.addWidget(self.progressBar)
        self.styleTemplate = '<html><head/><body><p><span style=" font-size:12pt; font-weight:600; color:#666666">{0}</span></p></body></html>'
        self.summaryStyleTemplate = '<html><head/><body><p><span style=" font-style:italic;">[{0} Samplings Per Measurement]</span></p></body></html>'
        self.actionHeater = self.findChild(QAction, "actionHeater")
        self.actionHeater.triggered.connect(self.on_heating)
        self.actionLED = self.findChild(QAction, "actionLED")
        self.actionLED.triggered.connect(self.on_led)
        self.actionResetMCUClock = self.findChild(QAction,
                                                  "actionResetMCUClock")
        self.actionResetMCUClock.triggered.connect(self.on_mcu_reset)

        self.buttonStartDiscrete = self.findChild(QPushButton,
                                                  "buttonStartDiscrete")
        self.buttonStartDiscrete.clicked.connect(self.on_start_discrete)

        for name, obj in inspect.getmembers(self):
            if isinstance(obj, QSlider):
                setattr(self, name, obj)
                obj.valueChanged.connect(self._update_estimated_time)
        self._update_estimated_time()
        self.labelSamplingSummary = self.findChild(QLabel,
                                                   "labelSamplingSummary")

        self.textRefX = self.findChild(QSpinBox, "textRefX")
        self.textRefY = self.findChild(QSpinBox, "textRefY")

        self.textExpName = self.findChild(QLineEdit, "textExpName")

        noise_canvas = FigureCanvas(Figure(figsize=(5, 3)))
        layout.addWidget(noise_canvas, 0, 1)

        noise_ax = noise_canvas.figure.subplots()
        # noise_ax2 = noise_ax.twinx()
        self.x_noise = sns.distplot([],
                                    vertical=True,
                                    ax=noise_ax,
                                    color=self.hls_cmp(0),
                                    bins=50,
                                    axlabel=False)
        self.y_noise = sns.distplot([],
                                    vertical=True,
                                    ax=noise_ax,
                                    color=self.hls_cmp(1),
                                    bins=50,
                                    axlabel=False)
        self._noise_ax = noise_ax
        noise_ax.set_title('Noise $(\mu, \sigma)$')

        pa_noise_canvas = FigureCanvas(Figure(figsize=(5, 3)))
        layout.addWidget(pa_noise_canvas, 1, 1)

        pa_noise_ax = pa_noise_canvas.figure.subplots()
        self.pa_noise = sns.distplot([],
                                     vertical=True,
                                     ax=pa_noise_ax,
                                     color=self.hls_cmp(2),
                                     bins=50,
                                     axlabel=False)
        self._pa_noise_ax = pa_noise_ax
        pa_noise_ax.set_title('Noise $(\sigma_{\Delta r})$')

        pa_ax.set_ylabel("$r, r_o, \Delta r$")

        exp_canvas = FigureCanvas(Figure(figsize=(5, 3)))
        layout.addWidget(exp_canvas, 1, 2)
        exp_ax = exp_canvas.figure.subplots()
        placehldr_exp = np.asarray([15, 7, 3.2, 1.1, 0.4, 0.1])
        # placehldr_err = np.asarray([3.4, 1.5, 0.5,0.5,0.2,0.1])
        sns.barplot(x=list(range(placehldr_exp.shape[0])),
                    y=placehldr_exp,
                    color='lightsteelblue',
                    ax=exp_ax)
        exp_ax.set_title('Anisotropy Experiment Placeholder')
        exp_ax.set_xlabel("Measurement ID (n)")
        exp_ax.set_ylabel("$\Delta r$")
        bbox_props = dict(boxstyle="round", fc="w", ec="0.5", alpha=0.9)
        # with matplotlib.rc_context({"lines.linewidth": 0.5}):
        exp_ax.text(2.5,
                    8,
                    "Click\n'Start Experiment'\nTo Begin",
                    ha="center",
                    va="center",
                    size=20,
                    bbox=bbox_props,
                    color='steelblue')
        self._exp_ax = exp_ax
        self.exp_canvas = exp_canvas

        offsets = {'bottom': 0.2, 'left': 0.17, 'right': 0.87}
        offsets_t = {'bottom': 0.2, 'left': 0.17, 'right': 1.0}
        temp_canvas.figure.subplots_adjust(**offsets)
        raw_canvas.figure.subplots_adjust(**offsets_t)
        pa_canvas.figure.subplots_adjust(**offsets_t)
        exp_canvas.figure.subplots_adjust(**offsets_t)
        noise_canvas.figure.subplots_adjust(bottom=0.2, left=0)
        pa_noise_canvas.figure.subplots_adjust(bottom=0.2, left=0)

        layout.setColumnStretch(0, 3)
        layout.setColumnStretch(1, 1)
        layout.setColumnStretch(2, 3)

        self._timer = temp_canvas.new_timer(100,
                                            [(self._update_canvas, (), {})])
        self._timer.start()
Пример #25
0
class Page3(QtWidgets.QWizardPage):
    def __init__(self, parent=None):
        super(Page3, self).__init__(parent)
        self.setTitle('Graph')
        self.figure = Figure()
        self.canvas = FigureCanvas(self.figure)
        self.ax = self.figure.add_subplot(111)
        self.setFinalPage(True)
        vbox = QtWidgets.QVBoxLayout()
        self._timer = self.canvas.new_timer(500, [(self.plots, (), {})])
        vbox.addWidget(self.canvas)
        self.setLayout(vbox)
        self.patchesX = []
        self.patchesY = []
        self.minLat = 0
        self.minLong = 0
        self.maxLat = 0
        self.maxLong = 0
        self.radiuses = []
        self.columnsWeight = []
        self.files = []
        self.lineCount = 0
        self.patches = 0
        self.currentLine = 0

    def plots(self):
        if self.currentLine < self.lineCount:
            ax = self.ax
            ax.clear()
            m = Basemap(projection='merc',
                        llcrnrlat=self.minLat - 1,
                        urcrnrlat=self.maxLat + 1,
                        llcrnrlon=self.minLong - 1,
                        urcrnrlon=self.maxLong + 1,
                        lat_ts=20,
                        resolution='l',
                        ax=ax)
            m.drawcoastlines(color="black")
            for patch in range(0, self.patches):
                line = next(self.files[patch]).split(',')
                sizes = [float(elem) for elem in line]
                sizes = sizes[2:]
                ratios = aux.getRatios(sizes, self.columnsWeight)
                px, py = m(self.patchesX[patch], self.patchesY[patch])
                aux.draw_pie(ax, ratios, px, py, self.radiuses[patch])
            self.canvas.draw()
            self.currentLine += 1
        else:
            self._timer.stop()
            for f in self.files:
                f.close()

    def initializePage(self):
        coordFile = str(self.field('coordFile'))
        popFile = str(self.field('popFile'))
        dataFile = str(self.field('dataDir')) + "/AF1_Aggregate_Run1_*.csv"
        self.patchesX, self.patchesY = aux.getCoordinates(coordFile)
        self.minLat = min(self.patchesY)
        self.minLong = min(self.patchesX)
        self.maxLat = max(self.patchesY)
        self.maxLong = max(self.patchesX)
        self.radiuses = aux.getSizes(popFile)
        groups = int(self.field('groupCount'))
        alleles = int(self.field('alleleCount'))
        for i in range(groups):
            groupWeights = []
            for j in range(alleles):
                weight = int(self.field(str(i) + '-' + str(j)))
                groupWeights.append(weight)
            self.columnsWeight.append(groupWeights)
        fileNames = sorted(glob.glob(dataFile))
        self.files = []
        self.lineCount = len(open(fileNames[0]).readlines()) - 1
        for fileName in fileNames:
            self.files.append(open(fileName, 'r'))
        self.patches = len(self.files)
        for f in self.files:
            next(f)
        self._timer.start()
Пример #26
0
class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(2560, 1440)
        palette = QtGui.QPalette()
        palette.setBrush(QtGui.QPalette.Background,
                         QtGui.QColor(255, 255, 255))
        MainWindow.setPalette(palette)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap("reco.ico"), QtGui.QIcon.Normal,
                       QtGui.QIcon.Off)
        MainWindow.setWindowIcon(icon)
        self.thread = GetState()
        self.thread.start()
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.gridLayout_3 = QtWidgets.QGridLayout(self.centralwidget)
        self.gridLayout_3.setObjectName("gridLayout_3")
        self.OutterGrid = QtWidgets.QGridLayout()
        self.OutterGrid.setObjectName("OutterGrid")
        self.UpperGrid = QtWidgets.QGridLayout()
        self.UpperGrid.setObjectName("UpperGrid")
        self.LowerGrid = QtWidgets.QGridLayout()
        self.LowerGrid.setObjectName("LowerGrid")
        self.Quit = QtWidgets.QPushButton(self.centralwidget)
        self.Quit.setObjectName("Quit")
        self.Start = QtWidgets.QPushButton(self.centralwidget)
        self.Start.setObjectName("Start")
        self.Stop = QtWidgets.QPushButton(self.centralwidget)
        self.Stop.setObjectName("Stop")
        spacerItem = QtWidgets.QSpacerItem(20, 40,
                                           QtWidgets.QSizePolicy.Minimum,
                                           QtWidgets.QSizePolicy.Preferred)
        self.LowerGrid.addItem(spacerItem, 3, 0, 1, 7)
        spacerItem1 = QtWidgets.QSpacerItem(20, 40,
                                            QtWidgets.QSizePolicy.Minimum,
                                            QtWidgets.QSizePolicy.Preferred)
        self.LowerGrid.addItem(spacerItem1, 0, 0, 1, 7)
        spacerItem2 = QtWidgets.QSpacerItem(40, 20,
                                            QtWidgets.QSizePolicy.Preferred,
                                            QtWidgets.QSizePolicy.Minimum)
        self.LowerGrid.addItem(spacerItem2, 2, 4, 1, 1)
        spacerItem3 = QtWidgets.QSpacerItem(40, 20,
                                            QtWidgets.QSizePolicy.Preferred,
                                            QtWidgets.QSizePolicy.Minimum)
        self.LowerGrid.addItem(spacerItem3, 2, 0, 1, 1)
        spacerItem4 = QtWidgets.QSpacerItem(40, 20,
                                            QtWidgets.QSizePolicy.Preferred,
                                            QtWidgets.QSizePolicy.Minimum)
        spacerItem5 = QtWidgets.QSpacerItem(40, 20,
                                            QtWidgets.QSizePolicy.Preferred,
                                            QtWidgets.QSizePolicy.Minimum)
        self.LowerGrid.addItem(spacerItem5, 2, 2, 1, 1)
        self.LowerGrid.addItem(spacerItem4, 2, 6, 1, 1)
        self.LowerGrid.addWidget(self.Start, 2, 1, 1, 1)
        self.LowerGrid.addWidget(self.Stop, 2, 3, 1, 1)
        self.LowerGrid.addWidget(
            self.Quit, 2, 5, 1, 1)  # int r, int c, int rowspan, int columnspan
        self.OutterGrid.addLayout(self.LowerGrid, 1, 0, 1, 1)
        self.Quit.clicked.connect(MainWindow.close)

        # face recognition
        self.face_detection_widget = FaceDetectionWidget()
        # TODO: set video port
        self.record_video = RecordVideo()
        # Connect the image data signal and slot together
        image_data_slot = self.face_detection_widget.image_data_slot
        self.record_video.image_data.connect(image_data_slot)
        # connect the run button to the start recording slot
        self.Start.clicked.connect(self.record_video.start_recording)
        self.Stop.clicked.connect(self.record_video.stop_recording)
        self.UpperGrid.addWidget(self.face_detection_widget, 1, 0, 1, 1)

        self.dynamic_canvas = FigureCanvas(Figure(figsize=(5, 3)))
        self.UpperGrid.addWidget(self.dynamic_canvas, 1, 1, 1, 1)
        self.addToolBar(NavigationToolbar(self.dynamic_canvas, self))
        self._dynamic_ax = self.dynamic_canvas.figure.subplots()
        self._timer = self.dynamic_canvas.new_timer(0, [(self._update_canvas,
                                                         (), {})])
        self._timer.start()

        # add timeframe
        self.timeLabel = QtWidgets.QLabel(self.centralwidget)
        font = QtGui.QFont()
        font.setPointSize(18)
        self.timeLabel.setFont(font)
        self.timeLabel.setAlignment(QtCore.Qt.AlignCenter)
        self.timeLabel.setObjectName("label")
        self.UpperGrid.addWidget(self.timeLabel, 0, 0, 1, 1)
        self.timlabTimer = QtCore.QTimer()
        self.timlabTimer.timeout.connect(self._update_time)
        self.timlabTimer.start()
        # add number of students
        self.numLabel = QtWidgets.QLabel(self.centralwidget)  # timeframe
        font = QtGui.QFont()
        font.setPointSize(18)
        self.numLabel.setFont(font)
        self.numLabel.setAlignment(QtCore.Qt.AlignCenter)
        self.numLabel.setObjectName("label")
        self.UpperGrid.addWidget(self.numLabel, 0, 1, 1, 1)
        self.numlabTimer = QtCore.QTimer()
        self.numlabTimer.timeout.connect(self._update_num)
        self.numlabTimer.start()

        self.OutterGrid.addLayout(self.UpperGrid, 0, 0, 1, 1)
        self.OutterGrid.setRowStretch(0, 3)
        self.OutterGrid.setRowStretch(1, 1)
        self.gridLayout_3.addLayout(self.OutterGrid, 0, 0, 1, 1)
        MainWindow.setCentralWidget(self.centralwidget)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def _update_canvas(self):
        global stateList
        self._dynamic_ax.clear()
        state = ['confused ', 'interested', 'distracted', 'normal  ']
        y_pos = range(len(state))
        ratio = np.zeros(4)
        if (stateList):
            for n in list(range(0, 4)):
                ratio[n] = (stateList.count(n) / len(stateList)) * 100
            csfont = {'fontname': 'Comic Sans MS'}
            self._dynamic_ax.barh(
                state,
                ratio,
                align='center',
                alpha=0.7,
                color=['limegreen', 'orange', 'deepskyblue', 'darkgrey'])
            self._dynamic_ax.set_xticks(np.arange(0, 101, step=10))
            self._dynamic_ax.tick_params(axis='x', which='major', labelsize=14)
            self._dynamic_ax.set_yticklabels(state,
                                             fontsize=20,
                                             fontweight="bold",
                                             **csfont)
            # self._dynamic_ax.set_yticks(y_pos,state)
            self._dynamic_ax.set_xlabel('percentage %',
                                        fontsize=18,
                                        fontweight="bold",
                                        **csfont)
            self._dynamic_ax.set_title('State of Students',
                                       fontsize=40,
                                       fontweight="bold",
                                       pad=30,
                                       **csfont)
            # handles, labels = self._dynamic_ax.get_legend_handles_labels()
            # self._dynamic_ax.legend(handles[::-1], labels[::-1])
            self._dynamic_ax.spines['bottom'].set_linewidth(2)
            self._dynamic_ax.spines['left'].set_linewidth(2)
            self._dynamic_ax.spines['right'].set_linewidth(2)
            self._dynamic_ax.spines['top'].set_linewidth(2)
            self._dynamic_ax.figure.canvas.draw()

    def _update_time(self):
        global frameTime
        self.timeLabel.setText("Frame Time: " + frameTime)

    def _update_num(self):
        global stuNum
        self.numLabel.setText(str(stuNum) + " Student(s)")

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(
            _translate("MainWindow", " Condition Recognition"))
        self.Start.setText(_translate("MainWindow", "Capture Start"))
        self.Quit.setText(_translate("MainWindow", "Quit"))
        self.Stop.setText(_translate("MainWindow", "Stop"))