Ejemplo n.º 1
0
    def __init__(self):
        super(mainwind, self).__init__()
        QMainWindow.__init__(self)
        self.setupUi(self)
        self.setGeometry(0, 0, 1350, 690)
        self.create_MenuBar()
        self.sc = pg.PlotWidget()
        self.sc2 = pg.PlotWidget()
        self.timer = QtCore.QTimer()
        # self.timer2 = QtCore.QTimer()
        self.init_UI()
        self.x = []
        self.x2 = []
        self.y = []
        self.y2 = []

        self.l = QVBoxLayout(self.graphicsView)
        self.l.setGeometry(QtCore.QRect(10, 5, 571, 150))
        self.l2 = QVBoxLayout(self.graphicsView_3)
        self.l2.setGeometry(QtCore.QRect(10, 440, 571, 150))

        self.l.addWidget(self.sc)
        self.l2.addWidget(self.sc2)

        self.label = QLabel(self.centralwidget)
        self.label.setGeometry(QtCore.QRect(660, 8, 600, 191))
        self.label.setText("")
        self.label.setStyleSheet("background-color: white")

        self.label2 = QLabel(self.centralwidget)
        self.label2.setGeometry(QtCore.QRect(660, 420, 600, 191))
        self.label2.setText("")
        self.label2.setStyleSheet("background-color: white")
Ejemplo n.º 2
0
    def __init__(self):
        super(mainwind, self).__init__()
        QMainWindow.__init__(self)
        self.setupUi(self)
        self.setGeometry(0, 0, 1350, 690)
        self.create_MenuBar()
        self.sc = pg.PlotWidget()
        self.sc2 = pg.PlotWidget()
        self.timer = QtCore.QTimer()
        # self.timer2 = QtCore.QTimer()
        self.init_UI()
        self.x = []
        self.x2 = []
        self.y = []
        self.y2 = []
        self.cmap = None
        self.speed = 100
        self.signal = np.array([])

        self.l = QVBoxLayout(self.graphicsView)
        self.l.setGeometry(QtCore.QRect(10, 5, 571, 150))
        self.l2 = QVBoxLayout(self.graphicsView_3)
        self.l2.setGeometry(QtCore.QRect(10, 500, 571, 150))

        self.l.addWidget(self.sc)
        self.l2.addWidget(self.sc2)

        self.label = QLabel(self.centralwidget)
        self.label.setGeometry(QtCore.QRect(660, 120, 600, 280))
        self.label.setText("")

        self.slider_band1 = self.verticalSlider
        self.slider_band2 = self.verticalSlider_2
        self.slider_band3 = self.verticalSlider_3
        self.slider_band4 = self.verticalSlider_4
        self.slider_band5 = self.verticalSlider_5
        self.slider_band6 = self.verticalSlider_6
        self.slider_band7 = self.verticalSlider_7
        self.slider_band8 = self.verticalSlider_8
        self.slider_band9 = self.verticalSlider_9
        self.slider_band10 = self.verticalSlider_10

        self.min_freq_slider = self.verticalSlider_11
        self.max_freq_slider = self.verticalSlider_12
        self.min_freq_slider.valueChanged.connect(self.changefreq)
        self.max_freq_slider.valueChanged.connect(self.changefreq)

        self.slider_band1.valueChanged.connect(self.valuechange)
        self.slider_band2.valueChanged.connect(self.valuechange)
        self.slider_band3.valueChanged.connect(self.valuechange)
        self.slider_band4.valueChanged.connect(self.valuechange)
        self.slider_band5.valueChanged.connect(self.valuechange)
        self.slider_band6.valueChanged.connect(self.valuechange)
        self.slider_band7.valueChanged.connect(self.valuechange)
        self.slider_band8.valueChanged.connect(self.valuechange)
        self.slider_band9.valueChanged.connect(self.valuechange)
        self.slider_band10.valueChanged.connect(self.valuechange)
Ejemplo n.º 3
0
 def savepdf(self):
     self.combbox()
     fig = plot.figure()
     # plot.subplot(2,1,1)
     # plot.plot(self.audio2[0:],color='black',linewidth=0.005,scalex=True)
     # plot.title("before")
     plot.subplot(2, 1, 2)
     max = self.max_freq_slider.value()
     min = self.min_freq_slider.value()
     self.powerSpectrum, self.freqenciesFound, self.time, self.imageAxis = plot.specgram(
         self.signal.real,
         Fs=self.samplingrate,
         cmap=self.cmap,
         vmin=min,
         vmax=max)
     plot.colorbar()
     plot.xlabel('Time')
     plot.ylabel('Frequency')
     plot.subplot(2, 1, 1)
     plot.plot(self.signal[0:].real,
               color='blue',
               linewidth=0.003,
               scalex=True)
     plot.title("after")
     fn, _ = QtWidgets.QFileDialog.getSaveFileName(
         self, "Export PDF", None, "PDF files (.pdf);;All Files()")
     if fn:
         if QtCore.QFileInfo(fn).suffix() == "": fn += ".pdf"
         fig.savefig(fn)
     plot.close()
Ejemplo n.º 4
0
class OutputWrapper(QtCore.QObject):
    """ to show all output in ui text edit"""
    outputWritten = QtCore.pyqtSignal(object, object)

    def __init__(self, parent, stdout=True):
        QtCore.QObject.__init__(self, parent)
        if stdout:
            self._stream = sys.stdout
            sys.stdout = self
        else:
            self._stream = sys.stderr
            sys.stderr = self
        self._stdout = stdout

    def write(self, text):
        self._stream.write(text)
        self.outputWritten.emit(text, self._stdout)

    def __getattr__(self, name):
        return getattr(self._stream, name)

    def __del__(self):
        try:
            if self._stdout:
                sys.stdout = self._stream
            else:
                sys.stderr = self._stream
        except AttributeError:
            pass
Ejemplo n.º 5
0
 def dynamicSig(self):
     # self.clear()
     self.timer = QtCore.QTimer()
     self.timer.setInterval(5)
     self.timer.timeout.connect(self.dynamicSig)
     self.timer.start()
     xrange, yrange = self.sc.viewRange()
     scrollvalue = (xrange[1] - xrange[0])/500
     self.sc.setXRange(xrange[0]+scrollvalue, xrange[1]+scrollvalue, padding=0)
Ejemplo n.º 6
0
 def __init__(self):
     super(mainwind, self).__init__()
     QMainWindow.__init__(self)
     self.setupUi(self)
     self.ToolBar()
     self.create_MenuBar()
     self.sc = pg.PlotWidget()
     self.timer = QtCore.QTimer()
     self.l = QVBoxLayout(self.graphicsView)
     self.l.addWidget(self.sc)
Ejemplo n.º 7
0
    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(748, 371)
        self.tableWidget = QTableWidget(Form)
        self.tableWidget.setGeometry(QtCore.QRect(20, 60, 711, 291))
        self.tableWidget.setObjectName("tableWidget")
        self.tableWidget.setColumnCount(0)
        self.tableWidget.setRowCount(0)

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)
Ejemplo n.º 8
0
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(956, 631)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.tableWidget = QtWidgets.QTableWidget(self.centralwidget)
        self.tableWidget.setGeometry(QtCore.QRect(10, 10, 941, 561))
        self.tableWidget.setObjectName("tableWidget")
        self.tableWidget.setColumnCount(0)
        self.tableWidget.setRowCount(0)
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 956, 26))
        self.menubar.setObjectName("menubar")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
Ejemplo n.º 9
0
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(800, 600)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.label = QtWidgets.QLabel(self.centralwidget)
        self.label.setGeometry(QtCore.QRect(20, 0, 55, 16))
        self.label.setObjectName("label")
        self.textEdit = QtWidgets.QTextEdit(self.centralwidget)
        self.textEdit.setGeometry(QtCore.QRect(20, 20, 611, 141))
        self.textEdit.setObjectName("textEdit")
        self.pushButton = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton.setGeometry(QtCore.QRect(640, 20, 151, 141))
        self.pushButton.setObjectName("pushButton")
        self.tableWidget = QtWidgets.QTableWidget(self.centralwidget)
        self.tableWidget.setGeometry(QtCore.QRect(20, 220, 761, 311))
        self.tableWidget.setObjectName("tableWidget")
        self.tableWidget.setColumnCount(0)
        self.tableWidget.setRowCount(0)
        self.label_2 = QtWidgets.QLabel(self.centralwidget)
        self.label_2.setGeometry(QtCore.QRect(20, 180, 241, 16))
        self.label_2.setObjectName("label_2")
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 26))
        self.menubar.setObjectName("menubar")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
Ejemplo n.º 10
0
 def dynamicSig(self):
     self.timer = QtCore.QTimer()
     self.timer.setInterval(2)
     self.timer.timeout.connect(self.dynamicSig)
     self.timer.start()
     xrange, yrange = self.sc.viewRange()
     scrollvalue = (xrange[1] - xrange[0]) / 500
     if xrange[1] < self.max:
         self.sc.setXRange(xrange[0] + scrollvalue,
                           xrange[1] + scrollvalue,
                           padding=0)
     else:
         pass
Ejemplo n.º 11
0
 def dynamicSig2(self):
     # self.clear()
     self.timer2 = QtCore.QTimer()
     self.timer2.setInterval(100)
     self.timer2.timeout.connect(self.dynamicSig2)
     self.timer2.start()
     xrange, yrange = self.sc2.viewRange()
     scrollvalue = (xrange[1] - xrange[0]) / 500
     if xrange[1] < self.max2:
         self.sc2.setXRange(xrange[0] + scrollvalue,
                            xrange[1] + scrollvalue,
                            padding=0)
     else:
         pass
Ejemplo n.º 12
0
                    def dynamicSig(self):
                        self.clear()
                        self.timer = QtCore.QTimer()
                        self.timer.setInterval(5)
                        self.timer.timeout.connect(self.dynamicSig)
                        self.timer.start()
                        self.x1 = self.x1[1:] 
                        self.x1.append(self.x1[-1] + 1)

                        self.y2 = self.y2[1:]
                    
                        self.y2.append(self.y[self.i]) 
                        self.i = self.i + 1 
                        self.sc.plot(self.x1[0:self.i], self.y2[0:self.i])
Ejemplo n.º 13
0
def restore(settings):
    finfo = QtCore.QFileInfo(settings.fileName())
    if finfo.exists() and finfo.isFile():
        for w in QtWidgets.qApp.allWidgets():
            mo = w.metaObject()
            if w.objectName() and not w.objectName().startswith("qt_"):
                settings.beginGroup(w.objectName())
                for i in range(mo.propertyCount(),
                               mo.propertyOffset() - 1, -1):
                    prop = mo.property(i)
                    if prop.isWritable():
                        name = prop.name()
                        val = settings.value(name, w.property(name))
                        if str(val).isdigit():
                            val = int(val)
                        w.setProperty(name, val)
                settings.endGroup()
Ejemplo n.º 14
0
    def init_UI(self):

        self.createpdf = QtWidgets.QPushButton(self.centralwidget)
        self.createpdf.setGeometry(QtCore.QRect(1270, 23, 75, 591))
        self.createpdf.setText(" Create PDF")
        self.createpdf.setObjectName("pdf")
        self.createpdf.setShortcut("Ctrl+F")
        self.createpdf.clicked.connect(lambda: self.savepdf())

        #  channel 1
        self.open3 = QtWidgets.QPushButton(self.centralwidget)
        self.open3.setGeometry(QtCore.QRect(20, 170, 41, 23))
        self.open3.setText("")
        icon1 = QtGui.QIcon()
        icon1.addPixmap(QtGui.QPixmap("images.png"), QtGui.QIcon.Normal,
                        QtGui.QIcon.Off)
        self.open3.setIcon(icon1)
        self.open3.setObjectName("open")
        self.open3.setShortcut("Ctrl+O")
        self.open3.clicked.connect(lambda: self.OpenBrowse())

        self.play3 = QtWidgets.QPushButton(self.centralwidget)
        self.play3.setGeometry(QtCore.QRect(80, 170, 41, 23))
        self.play3.setText("")
        icon2 = QtGui.QIcon()
        icon2.addPixmap(QtGui.QPixmap("play.png"), QtGui.QIcon.Normal,
                        QtGui.QIcon.Off)
        self.play3.setIcon(icon2)
        self.play3.setObjectName("play")
        self.play3.setShortcut("Ctrl+P")
        self.play3.clicked.connect(lambda: self.dynamicSig())

        self.pause3 = QtWidgets.QPushButton(self.centralwidget)
        self.pause3.setGeometry(QtCore.QRect(140, 170, 41, 23))
        self.pause3.setText("")
        icon3 = QtGui.QIcon()
        icon3.addPixmap(QtGui.QPixmap("pause.png"), QtGui.QIcon.Normal,
                        QtGui.QIcon.Off)
        self.pause3.setIcon(icon3)
        self.pause3.setObjectName("pause")
        self.pause3.setShortcut("Ctrl+T")
        self.pause3.clicked.connect(lambda: self.pauseSignal())

        self.clear3 = QtWidgets.QPushButton(self.centralwidget)
        self.clear3.setGeometry(QtCore.QRect(200, 170, 41, 23))
        self.clear3.setText("")
        icon4 = QtGui.QIcon()
        icon4.addPixmap(QtGui.QPixmap("clear.png"), QtGui.QIcon.Normal,
                        QtGui.QIcon.Off)
        self.clear3.setIcon(icon4)
        self.clear3.setObjectName("clear")
        self.clear3.setShortcut("Ctrl+L")
        self.clear3.clicked.connect(lambda: self.clear())

        self.zoom_in3 = QtWidgets.QPushButton(self.centralwidget)
        self.zoom_in3.setGeometry(QtCore.QRect(260, 170, 41, 23))
        self.zoom_in3.setText("")
        icon5 = QtGui.QIcon()
        icon5.addPixmap(QtGui.QPixmap("zoomin.png"), QtGui.QIcon.Normal,
                        QtGui.QIcon.Off)
        self.zoom_in3.setIcon(icon5)
        self.zoom_in3.setObjectName("Zoom In")
        self.zoom_in3.setShortcut("Ctrl+Num++")
        self.zoom_in3.clicked.connect(lambda: self.zoomin())

        self.zoom_out3 = QtWidgets.QPushButton(self.centralwidget)
        self.zoom_out3.setGeometry(QtCore.QRect(320, 170, 41, 23))
        self.zoom_out3.setText("")
        icon6 = QtGui.QIcon()
        icon6.addPixmap(QtGui.QPixmap("zoomout.png"), QtGui.QIcon.Normal,
                        QtGui.QIcon.Off)
        self.zoom_out3.setIcon(icon6)
        self.zoom_out3.setObjectName("Zoom Out")
        self.zoom_out3.setShortcut("Ctrl+-")
        self.zoom_out3.clicked.connect(lambda: self.zoomout())

        self.scroll_right3 = QtWidgets.QPushButton(self.centralwidget)
        self.scroll_right3.setGeometry(QtCore.QRect(380, 170, 41, 23))
        self.scroll_right3.setText("")
        icon7 = QtGui.QIcon()
        icon7.addPixmap(QtGui.QPixmap("arrowr.png"), QtGui.QIcon.Normal,
                        QtGui.QIcon.Off)
        self.scroll_right3.setIcon(icon7)
        self.scroll_right3.setObjectName("scroll right")
        self.scroll_right3.setShortcut("Ctrl+Right")
        self.scroll_right3.clicked.connect(lambda: self.scrollR())

        self.scroll_left3 = QtWidgets.QPushButton(self.centralwidget)
        self.scroll_left3.setGeometry(QtCore.QRect(440, 170, 41, 23))
        self.scroll_left3.setText("")
        icon8 = QtGui.QIcon()
        icon8.addPixmap(QtGui.QPixmap("arrowl.png"), QtGui.QIcon.Normal,
                        QtGui.QIcon.Off)
        self.scroll_left3.setIcon(icon8)
        self.scroll_left3.setObjectName("scroll left")
        self.scroll_left3.setShortcut("Ctrl+Left")
        self.scroll_left3.clicked.connect(lambda: self.scrollL())

        self.spectrogram3 = QtWidgets.QPushButton(self.centralwidget)
        self.spectrogram3.setGeometry(QtCore.QRect(500, 170, 41, 23))
        self.spectrogram3.setText("")
        icon9 = QtGui.QIcon()
        icon9.addPixmap(QtGui.QPixmap("spectro.png"), QtGui.QIcon.Normal,
                        QtGui.QIcon.Off)
        self.spectrogram3.setIcon(icon9)
        self.spectrogram3.setObjectName("spectrogram")
        self.spectrogram3.setShortcut("Ctrl+M")
        self.spectrogram3.clicked.connect(lambda: self.spectrogram())

        self.channel1box = QCheckBox("", self)
        self.channel1box.move(560, 190)
        self.channel1box.resize(16, 17)
        self.channel1box.setChecked(True)
        self.channel1box.setShortcut("Ctrl+H")
        self.channel1box.stateChanged.connect(self.show1)

        # channel 3
        self.channel3box = QCheckBox("", self)
        self.channel3box.move(560, 610)
        self.channel3box.resize(16, 17)
        self.channel3box.setChecked(True)
        self.channel3box.setShortcut("Alt+H")
        self.channel3box.stateChanged.connect(self.show3)
Ejemplo n.º 15
0
    def init_UI(self):

        self.createpdf = QtWidgets.QPushButton(self.centralwidget)
        self.createpdf.setGeometry(QtCore.QRect(1270, 23, 75, 591))
        self.createpdf.setText(" Create PDF")
        self.createpdf.setObjectName("pdf")
        self.createpdf.setShortcut("Ctrl+F")
        self.createpdf.clicked.connect(lambda: self.savepdf())

        #  channel 1
        self.open3 = QtWidgets.QPushButton(self.centralwidget)
        self.open3.setGeometry(QtCore.QRect(20, 220, 61, 28))
        self.open3.setText("")
        icon1 = QtGui.QIcon()
        icon1.addPixmap(QtGui.QPixmap("images.png"), QtGui.QIcon.Normal,
                        QtGui.QIcon.Off)
        self.open3.setIcon(icon1)
        self.open3.setObjectName("open")
        self.open3.setShortcut("Ctrl+O")
        self.open3.clicked.connect(lambda: self.OpenBrowse())

        self.play3 = QtWidgets.QPushButton(self.centralwidget)
        self.play3.setGeometry(QtCore.QRect(90, 220, 61, 28))
        self.play3.setText("")
        icon2 = QtGui.QIcon()
        icon2.addPixmap(QtGui.QPixmap("play.png"), QtGui.QIcon.Normal,
                        QtGui.QIcon.Off)
        self.play3.setIcon(icon2)
        self.play3.setObjectName("play")
        self.play3.setShortcut("Ctrl+P")
        self.play3.clicked.connect(lambda: self.dynamicSig())

        self.pause3 = QtWidgets.QPushButton(self.centralwidget)
        self.pause3.setGeometry(QtCore.QRect(160, 220, 61, 28))
        self.pause3.setText("")
        icon3 = QtGui.QIcon()
        icon3.addPixmap(QtGui.QPixmap("pause.png"), QtGui.QIcon.Normal,
                        QtGui.QIcon.Off)
        self.pause3.setIcon(icon3)
        self.pause3.setObjectName("pause")
        self.pause3.setShortcut("Ctrl+shift+p")
        self.pause3.clicked.connect(lambda: self.pauseSignal())

        self.zoom_in3 = QtWidgets.QPushButton(self.centralwidget)
        self.zoom_in3.setGeometry(QtCore.QRect(230, 220, 61, 28))
        self.zoom_in3.setText("")
        icon5 = QtGui.QIcon()
        icon5.addPixmap(QtGui.QPixmap("zoomin.png"), QtGui.QIcon.Normal,
                        QtGui.QIcon.Off)
        self.zoom_in3.setIcon(icon5)
        self.zoom_in3.setObjectName("Zoom In")
        self.zoom_in3.setShortcut("Ctrl++")
        self.zoom_in3.clicked.connect(lambda: self.zoomin())

        self.zoom_out3 = QtWidgets.QPushButton(self.centralwidget)
        self.zoom_out3.setGeometry(QtCore.QRect(300, 220, 61, 28))
        self.zoom_out3.setText("")
        icon6 = QtGui.QIcon()
        icon6.addPixmap(QtGui.QPixmap("zoomout.png"), QtGui.QIcon.Normal,
                        QtGui.QIcon.Off)
        self.zoom_out3.setIcon(icon6)
        self.zoom_out3.setObjectName("Zoom Out")
        self.zoom_out3.setShortcut("Ctrl+-")
        self.zoom_out3.clicked.connect(lambda: self.zoomout())

        self.scroll_left3 = QtWidgets.QPushButton(self.centralwidget)
        self.scroll_left3.setGeometry(QtCore.QRect(370, 220, 61, 28))
        self.scroll_left3.setText("")
        icon8 = QtGui.QIcon()
        icon8.addPixmap(QtGui.QPixmap("arrowl.png"), QtGui.QIcon.Normal,
                        QtGui.QIcon.Off)
        self.scroll_left3.setIcon(icon8)
        self.scroll_left3.setObjectName("scroll left")
        self.scroll_left3.setShortcut("Ctrl+Left")
        self.scroll_left3.clicked.connect(lambda: self.scrollL())

        self.scroll_right3 = QtWidgets.QPushButton(self.centralwidget)
        self.scroll_right3.setGeometry(QtCore.QRect(440, 220, 61, 28))
        self.scroll_right3.setText("")
        icon7 = QtGui.QIcon()
        icon7.addPixmap(QtGui.QPixmap("arrowr.png"), QtGui.QIcon.Normal,
                        QtGui.QIcon.Off)
        self.scroll_right3.setIcon(icon7)
        self.scroll_right3.setObjectName("scroll right")
        self.scroll_right3.setShortcut("Ctrl+Right")
        self.scroll_right3.clicked.connect(lambda: self.scrollR())

        self.colorPalette = QtWidgets.QComboBox()
        self.colorPalette.setGeometry(700, 40, 500, 28)
        self.colorPalette.addItem("viridis")
        self.colorPalette.addItem('Spectral_r')
        self.colorPalette.addItem("gnuplot2")
        self.colorPalette.addItem("Greys")
        self.colorPalette.addItem("Set2")

        self.layout().addWidget(self.colorPalette)
        self.colorPalette.currentIndexChanged.connect(self.combbox)

        self.speedup = QtWidgets.QPushButton(self.centralwidget)
        self.speedup.setGeometry(QtCore.QRect(510, 220, 61, 28))
        self.speedup.setText("")
        icon11 = QtGui.QIcon()
        icon11.addPixmap(QtGui.QPixmap("speed.jpg"), QtGui.QIcon.Normal,
                         QtGui.QIcon.Off)
        self.speedup.setIcon(icon11)
        self.speedup.setObjectName("speedup")
        self.speedup.setShortcut("Ctrl+up")
        self.speedup.clicked.connect(lambda: self.inc_speed())

        self.slow = QtWidgets.QPushButton(self.centralwidget)
        self.slow.setGeometry(QtCore.QRect(580, 220, 61, 28))
        self.slow.setText("")
        icon12 = QtGui.QIcon()
        icon12.addPixmap(QtGui.QPixmap("slow.png"), QtGui.QIcon.Normal,
                         QtGui.QIcon.Off)
        self.slow.setIcon(icon12)
        self.slow.setObjectName("slow")
        self.slow.setShortcut("Ctrl+Down")
        self.slow.clicked.connect(lambda: self.dec_speed())
Ejemplo n.º 16
0
class workThread(QtCore.QThread):
    my_signal = QtCore.pyqtSignal()

    def __init__(self,
                 groupBox_follow,
                 comboBox_follow,
                 lineEdit_follow,
                 spinBox_getfollowers,
                 spinBox_getfollowing,
                 groupBox_unfollow,
                 radioButton_nonfollowers,
                 radioButton_unfollowAll,
                 radioButton_restoreFollowing,
                 groupBox_like,
                 lineEdit_like,
                 comboBox_like,
                 spinBox_nlikes,
                 groupBox_comment,
                 comboBox_comment,
                 lineEdit_comment,
                 listWidget,
                 groupBox_combo,
                 spinBox_nlikes_combo,
                 comboBox_combo,
                 lineEdit_combo,
                 return_base_path,
                 parent=None):

        super(workThread, self).__init__(parent)
        # IMPORT UI OBJECT NAME FROM MAINWINDOW CLASS
        self.groupBox_follow = groupBox_follow
        self.comboBox_follow = comboBox_follow
        self.lineEdit_follow = lineEdit_follow
        self.spinBox_getfollowers = spinBox_getfollowers
        self.spinBox_getfollowing = spinBox_getfollowing

        self.groupBox_unfollow = groupBox_unfollow
        self.radioButton_nonfollowers = radioButton_nonfollowers
        self.radioButton_unfollowAll = radioButton_unfollowAll
        self.radioButton_restoreFollowing = radioButton_restoreFollowing

        self.groupBox_like = groupBox_like
        self.lineEdit_like = lineEdit_like
        self.comboBox_like = comboBox_like
        self.spinBox_nlikes = spinBox_nlikes

        self.groupBox_comment = groupBox_comment
        self.comboBox_comment = comboBox_comment
        self.lineEdit_comment = lineEdit_comment
        self.listWidget = listWidget

        self.groupBox_combo = groupBox_combo
        self.spinBox_nlikes_combo = spinBox_nlikes_combo
        self.comboBox_combo = comboBox_combo
        self.lineEdit_combo = lineEdit_combo

        self.return_base_path = return_base_path

    def follow(self):
        # IF THE GROUPBOX IS CHECK, FOLLOW USER WITH THAT #
        if self.groupBox_follow.isChecked():
            lineEdit = str(self.lineEdit_follow.text()).strip().split(",")

            if self.comboBox_follow.currentText() == "hashtags":
                for hashtag in lineEdit:
                    # print("Begin hahstag: " + hashtag)
                    users = bot.get_hashtag_users(hashtag)
                    bot.follow_users(users)

            if self.comboBox_follow.currentText() == "followers":
                for username in lineEdit:
                    # print("Begin followers: " + username)
                    bot.follow_followers(
                        username, nfollows=self.spinBox_getfollowers.value())

            if self.comboBox_follow.currentText() == "following":
                for username in lineEdit:
                    # print("Begin following: " + username)
                    bot.follow_following(
                        username, nfollows=self.spinBox_getfollowing.value())
        else:
            print("groupBox follow not check")
            pass

    def unfollow(self):
        if self.groupBox_unfollow.isChecked():
            if self.radioButton_nonfollowers.isChecked():
                bot.unfollow_non_followers()

            if self.radioButton_unfollowAll.isChecked():
                bot.unfollow_everyone()

            if self.radioButton_restoreFollowing.isChecked():
                friends = bot.read_list_from_file(
                    self.return_base_path +
                    "friends.txt")  # getting the list of friends
                your_following = bot.following
                unfollow = list(
                    set(your_following) - set(friends)
                )  # removing your friends from the list to unfollow
                bot.unfollow_users(unfollow)
        else:
            print("groupbox unfollow uncheck")

    def like(self):
        if self.groupBox_like.isChecked():
            lineEdit = str(self.lineEdit_like.text()).strip().split(",")

            if self.comboBox_like.currentText() == "hashtags":
                for hashtag in lineEdit:
                    # print("Begin like#: " + hashtag)
                    bot.like_hashtag(hashtag,
                                     amount=self.spinBox_nlikes.value())

            if self.comboBox_like.currentText() == "followers":
                for username in lineEdit:
                    # print("Begin likefollowers: " + username)
                    bot.like_followers(username,
                                       nlikes=self.spinBox_nlikes.value())

            if self.comboBox_like.currentText() == "following":
                for username in lineEdit:
                    # print("Begin following: " + username)
                    bot.like_following(username,
                                       nlikes=self.spinBox_nlikes.value())
        else:
            print("groupBox_like not check")
            pass

    def comment(self):
        if self.groupBox_comment.isChecked():
            comment_text = random.choice(self.comment_list())
            lineEdit = str(self.lineEdit_comment.text()).strip().split(",")

            if self.comboBox_comment.currentText() == "hashtags":
                for hashtag in lineEdit:
                    bot.comment_hashtag(hashtag, text=comment_text)

            if self.comboBox_comment.currentText() == "my timeline":
                bot.comment_medias(bot.get_timeline_medias(),
                                   text=comment_text)
        else:
            print("groupbox comment no check")

    def comment_list(self):
        list = []
        for i in range(self.listWidget.count()):
            text = self.listWidget.item(i).text()
            list.append(text)
        return list

    def like_follow(self):
        usernames = str(self.lineEdit_combo.text()).strip().split(",")
        for username in usernames:
            user_id = bot.get_user_id_from_username(username)

            if self.comboBox_combo.currentText() == "followers":
                # print("combo followers")
                followers_list_id = bot.get_user_followers(
                    user_id, nfollows=self.spinBox_getfollowers.value())
                for username_id in followers_list_id:
                    new_user_id = username_id.strip()
                    bot.like_user(new_user_id,
                                  amount=self.spinBox_nlikes_combo.value())
                    bot.follow(new_user_id)
                    time.sleep(30 + 20 * random.random())
                print("complete combo followers task")

            if self.comboBox_combo.currentText() == "following":
                # print("combo following")
                following_list_id = bot.get_user_following(
                    user_id, nfollows=self.spinBox_getfollowing.value())
                for username_id in following_list_id:
                    new_user_id = username_id.strip()
                    bot.like_user(new_user_id,
                                  amount=self.spinBox_nlikes_combo.value())
                    bot.follow(new_user_id)
                    time.sleep(30 + 20 * random.random())
                print("complete combo following task")

            if self.comboBox_combo.currentText() == "likers":
                # print("combo likers")
                for username in usernames:
                    medias = bot.get_user_medias(username, filtration=False)
                    if len(medias):
                        likers = bot.get_media_likers(medias)
                        for liker in tqdm(likers):
                            bot.like_user(
                                liker,
                                amount=self.spinBox_nlikes_combo.value())
                            bot.follow(liker)
                print("complete combo likers task")

    def run_threaded(self, job_func):
        job_thread = threading.Thread(target=job_func)
        job_thread.start()

    def jobs(self):
        self.follow()
        self.like()
        self.comment()
        self.unfollow()

    def check_job(self):
        start_time = datetime.now().strftime("%H:%M")
        if self.groupBox_combo.isChecked():
            # official
            self.run_threaded(self.like_follow)
            schedule.every().day.at(start_time).do(self.run_threaded,
                                                   self.unfollow)
        else:
            self.run_threaded(self.jobs)
            # schedule.every().day.at(start_time).do(self.run_threaded, self.jobs)

    def loop_job(self):
        try:
            self.check_job()
        except:
            self.loop_job()

    # ALL FUNCTION IN WORKTHREAD START HERE
    # if combo selected run combo
    # else run schedule


# official
#     @fuckit

    def run(self):
        # todo check expired date
        # OFFICIAl

        self.loop_job()
        while 1:
            schedule.run_pending()
            print("shchedule run pending")
            time.sleep(5 * 60)
Ejemplo n.º 17
0
    def setupUi(self, PreprocessGui):
        PreprocessGui.setObjectName(_fromUtf8("PreprocessGui"))
        PreprocessGui.resize(1906, 1088)
        self.centralwidget = QtGui.QWidget(PreprocessGui)
        self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
        self.verticalLayout_3 = QtGui.QVBoxLayout(self.centralwidget)
        self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3"))
        self.horizontalLayout_9 = QtGui.QHBoxLayout()
        self.horizontalLayout_9.setObjectName(_fromUtf8("horizontalLayout_9"))
        self.verticalLayout = QtGui.QVBoxLayout()
        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
        self.horizontalLayout_8 = QtGui.QHBoxLayout()
        self.horizontalLayout_8.setObjectName(_fromUtf8("horizontalLayout_8"))
        self.sorted_sections_gview = QtGui.QGraphicsView(self.centralwidget)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,
                                       QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.sorted_sections_gview.sizePolicy().hasHeightForWidth())
        self.sorted_sections_gview.setSizePolicy(sizePolicy)
        self.sorted_sections_gview.setMinimumSize(QtCore.QSize(600, 500))
        self.sorted_sections_gview.setObjectName(
            _fromUtf8("sorted_sections_gview"))
        self.horizontalLayout_8.addWidget(self.sorted_sections_gview)
        self.label_sorted_sections_status = QtGui.QLabel(self.centralwidget)
        self.label_sorted_sections_status.setObjectName(
            _fromUtf8("label_sorted_sections_status"))
        self.horizontalLayout_8.addWidget(self.label_sorted_sections_status)
        self.verticalLayout.addLayout(self.horizontalLayout_8)
        self.horizontalLayout_6 = QtGui.QHBoxLayout()
        self.horizontalLayout_6.setObjectName(_fromUtf8("horizontalLayout_6"))
        self.label_sorted_sections_filename = QtGui.QLabel(self.centralwidget)
        self.label_sorted_sections_filename.setObjectName(
            _fromUtf8("label_sorted_sections_filename"))
        self.horizontalLayout_6.addWidget(self.label_sorted_sections_filename)
        self.label_sorted_sections_index = QtGui.QLabel(self.centralwidget)
        self.label_sorted_sections_index.setObjectName(
            _fromUtf8("label_sorted_sections_index"))
        self.horizontalLayout_6.addWidget(self.label_sorted_sections_index)
        self.verticalLayout.addLayout(self.horizontalLayout_6)
        self.gridLayout_2 = QtGui.QGridLayout()
        self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2"))
        self.button_edit_transform = QtGui.QPushButton(self.centralwidget)
        self.button_edit_transform.setObjectName(
            _fromUtf8("button_edit_transform"))
        self.gridLayout_2.addWidget(self.button_edit_transform, 3, 4, 1, 1)
        self.button_load_crop = QtGui.QPushButton(self.centralwidget)
        self.button_load_crop.setObjectName(_fromUtf8("button_load_crop"))
        self.gridLayout_2.addWidget(self.button_load_crop, 3, 1, 1, 1)
        self.button_save_crop = QtGui.QPushButton(self.centralwidget)
        self.button_save_crop.setObjectName(_fromUtf8("button_save_crop"))
        self.gridLayout_2.addWidget(self.button_save_crop, 3, 3, 1, 1)
        self.comboBox_show = QtGui.QComboBox(self.centralwidget)
        self.comboBox_show.setObjectName(_fromUtf8("comboBox_show"))
        self.comboBox_show.addItem(_fromUtf8(""))
        self.comboBox_show.addItem(_fromUtf8(""))
        self.comboBox_show.addItem(_fromUtf8(""))
        self.comboBox_show.addItem(_fromUtf8(""))
        self.comboBox_show.addItem(_fromUtf8(""))
        self.gridLayout_2.addWidget(self.comboBox_show, 2, 1, 1, 1)
        self.button_update_order = QtGui.QPushButton(self.centralwidget)
        self.button_update_order.setObjectName(
            _fromUtf8("button_update_order"))
        self.gridLayout_2.addWidget(self.button_update_order, 2, 4, 1, 1)
        self.button_toggle_show_hide_invalid = QtGui.QPushButton(
            self.centralwidget)
        self.button_toggle_show_hide_invalid.setObjectName(
            _fromUtf8("button_toggle_show_hide_invalid"))
        self.gridLayout_2.addWidget(self.button_toggle_show_hide_invalid, 2, 3,
                                    1, 1)
        self.verticalLayout.addLayout(self.gridLayout_2)
        self.horizontalLayout_9.addLayout(self.verticalLayout)
        self.verticalLayout_3.addLayout(self.horizontalLayout_9)
        self.horizontalLayout_2 = QtGui.QHBoxLayout()
        self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2"))
        self.button_save_sorted_filenames = QtGui.QPushButton(
            self.centralwidget)
        self.button_save_sorted_filenames.setObjectName(
            _fromUtf8("button_save_sorted_filenames"))
        self.horizontalLayout_2.addWidget(self.button_save_sorted_filenames)
        self.button_load_sorted_filenames = QtGui.QPushButton(
            self.centralwidget)
        self.button_load_sorted_filenames.setObjectName(
            _fromUtf8("button_load_sorted_filenames"))
        self.horizontalLayout_2.addWidget(self.button_load_sorted_filenames)
        self.verticalLayout_3.addLayout(self.horizontalLayout_2)
        PreprocessGui.setCentralWidget(self.centralwidget)
        self.menubar = QtGui.QMenuBar(PreprocessGui)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 1906, 25))
        self.menubar.setObjectName(_fromUtf8("menubar"))
        PreprocessGui.setMenuBar(self.menubar)
        self.statusbar = QtGui.QStatusBar(PreprocessGui)
        self.statusbar.setObjectName(_fromUtf8("statusbar"))
        PreprocessGui.setStatusBar(self.statusbar)

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