class GameHub(QMainWindow):
    def __init__(self):
        super(GameHub, self).__init__()
        self.setGeometry(90, 50, 524, 186)
        self.setMinimumSize(524, 186)
        self.setMaximumSize(524, 186)
        self.setWindowIcon(QIcon('arti.PNG'))
        self.setWindowTitle('GameHub')

        palette = QPalette()
        palette.setColor(palette.Window, QColor('#000000'))
        palette.setColor(palette.WindowText, QColor('#FFFFFF'))
        palette.setColor(palette.Button, QColor("#00FF00"))
        palette.setColor(palette.ButtonText, QColor("#000000"))
        self.setPalette(palette)

        self.menubar = QMenuBar(self)
        self.menubar.setGeometry(0, 0, 682, 21)
        self.menubar.setFont(QFont('Roboto', 10))

        self.date_menu = QMenu(self.menubar)
        self.date_menu.setTitle(str(datetime.now().strftime('%d-%m-%Y')))

        self.setMenuBar(self.menubar)
        self.menubar.addAction(self.date_menu.menuAction())

        self.label = QLabel(self)
        self.label.setGeometry(QRect(10, 30, 501, 51))
        self.label.setText(
            "Hello, I am your host, Artigence. Welcome to GameHub. Please click on below buttons to "
            "choose a game of your choice.")
        self.label.setWordWrap(True)
        self.label.setAlignment(Qt.AlignHCenter)
        self.label.setFont(QFont('Roboto', 12))

        self.pong = QPushButton(self)
        self.pong.setGeometry(QRect(20, 130, 95, 33))
        self.pong.setCursor(QCursor(Qt.PointingHandCursor))
        self.pong.setText('Pong')

        self.tictactoe = QPushButton(self)
        self.tictactoe.setGeometry(150, 130, 95, 33)
        self.tictactoe.setCursor(QCursor(Qt.PointingHandCursor))
        self.tictactoe.setText('Tic-Tac-Toe')

        self.connect_four = QPushButton(self)
        self.connect_four.setGeometry(290, 130, 95, 33)
        self.connect_four.setCursor(QCursor(Qt.PointingHandCursor))
        self.connect_four.setText('Connect-4')

        self.snake = QPushButton(self)
        self.snake.setGeometry(420, 130, 95, 33)
        self.snake.setCursor(QCursor(Qt.PointingHandCursor))
        self.snake.setText('Snake')

        self.pong.clicked.connect(lambda: pong())
        self.tictactoe.clicked.connect(lambda: tictactoe())
        self.connect_four.clicked.connect(lambda: connect_four())
        self.snake.clicked.connect(lambda: snake())
Esempio n. 2
0
    def add_menu_entry(self,
                       menu: QMenuBar,
                       name: str,
                       trigger: Callable,
                       shortcut: str = ''):
        action = QAction(name, self)

        if len(shortcut) > 0:
            action.setShortcut(shortcut)

        action.triggered.connect(trigger)

        menu.addAction(action)
class News(QMainWindow):
    def __init__(self):
        super(News, self).__init__()

        self.setWindowTitle('News')
        self.setWindowIcon(QIcon('arti.PNG'))
        self.setGeometry(120, 100, 800, 600)
        self.setMaximumSize(800, 600)
        self.setMinimumSize(800, 600)
        self.setFont(QFont('Roboto', 12))

        palette = QPalette()
        palette.setColor(palette.Window, QColor('#000000'))
        palette.setColor(palette.WindowText, QColor('#FFFFFF'))
        self.setPalette(palette)

        self.menubar = QMenuBar(self)
        self.menubar.setGeometry(0, 0, 682, 21)
        self.menubar.setFont(QFont('Roboto', 10))

        self.date_menu = QMenu(self.menubar)
        self.date_menu.setTitle(str(datetime.now().strftime('%d-%m-%Y')))

        self.setMenuBar(self.menubar)
        self.menubar.addAction(self.date_menu.menuAction())

        text = 'Welcome to News.\nThese are the latest international headlines according to BBC News Network.'

        heading = QLabel(self)
        heading.setText(text)
        heading.setGeometry(10, 30, 761, 81)
        heading.setAlignment(Qt.AlignHCenter)

        main_news = QLabel(self)
        main_news.setText(f'{str(results[0])}\n{str(results[1])}\n{str(results[2])}\n{str(results[3])}'
                          f'\n{str(results[4])}\n{str(results[5])}\n{str(results[6])}\n{str(results[7])}'
                          f'\n{str(results[8])}\n{str(results[9])}')
        main_news.setGeometry(10, 150, 761, 251)

        read = QLabel(self, text='Should I read it for you?')
        read.setGeometry(240, 490, 251, 41)

        button = QPushButton(self, text='Yes')
        button.setGeometry(500, 500, 131, 31)

        button.clicked.connect(lambda: self.on_click())

    def on_click(self):
        speak(f'{str(results[0])}\n{str(results[1])}\n{str(results[2])}\n{str(results[3])}'
              f'\n{str(results[4])}\n{str(results[5])}\n{str(results[6])}\n{str(results[7])}'
              f'\n{str(results[8])}\n{str(results[9])}')
Esempio n. 4
0
class MainWindow(QMainWindow):

    def __init__(self,application,parent=None):
        super(MainWindow,self).__init__(parent)

        #private attributes
        self.menuBar_ = QMenuBar()
        self.fileMenu_ = FileMenu(self)
        self.editMenu_ = EditMenu(self)
        self.toolbarDoc_ = QDockWidget(self)
        self.toolbarWidget_ = Toolbar(self)

        self.setGeometry(0,0,1280,720)

        #public attributes
        self.application = application
        self.contentTab = ContentTab()
        self.statusBar = QStatusBar()

        #menuBar
        self.menuBar_.addMenu(self.fileMenu_)
        self.menuBar_.addMenu(self.editMenu_)
        self.menuBar_.addAction("Help",self.helpFunc)
        self.setMenuBar(self.menuBar_)
        #statusBar
        self.statusBar.showMessage("status bar")
        self.setStatusBar(self.statusBar)
        #toolBar
        self.toolbarDoc_.setFeatures(QDockWidget.NoDockWidgetFeatures )
        self.addDockWidget(Qt.LeftDockWidgetArea,self.toolbarDoc_)
        self.toolbarDoc_.setWidget(self.toolbarWidget_)
        #contentab
        self.setCentralWidget(self.contentTab)



    def helpFunc(self):
        """
        Call the help tab
        To be added
        """
        print("called helpFunc")



    def quit(self):
        """
        Quit the application
        """
        self.application.quit()
Esempio n. 5
0
 def __init__(self):
     QMainWindow.__init__(self, MaxPlus.GetQMaxMainWindow())
     self.resize(800, 600)
     self.setWindowTitle("Max Tools Updater")
     self.mainWidget = QWidget(self)
     self.central_layout = QVBoxLayout()
     menu_bar = QMenuBar()
     settingAct = QAction("&Settings", self)
     settingAct.setStatusTip("Open setting window")
     settingAct.connect(SIGNAL("triggered()"), self, SLOT("open()"))
     menu_bar.addAction(settingAct)
     self.mainWidget.setLayout(self.central_layout)
     self.central_layout.addWidget(menu_bar)
     self.tabs = QTabWidget()
     self.setCentralWidget(self.mainWidget)
     self.activePackageWidgets = list()
Esempio n. 6
0
 def testWithCppSlot(self):
     '''QMenuBar.addAction(id, object, slot)'''
     menubar = QMenuBar()
     widget = QPushButton()
     widget.setCheckable(True)
     widget.setChecked(False)
     action = menubar.addAction("Accounts", widget, SLOT("toggle()"))
     action.activate(QAction.Trigger)
     self.assertTrue(widget.isChecked())
Esempio n. 7
0
 def testWithCppSlot(self):
     '''QMenuBar.addAction(id, object, slot)'''
     menubar = QMenuBar()
     widget = QPushButton()
     widget.setCheckable(True)
     widget.setChecked(False)
     action = menubar.addAction("Accounts", widget, SLOT("toggle()"))
     action.activate(QAction.Trigger)
     self.assert_(widget.isChecked())
Esempio n. 8
0
 def testMenuBar(self):
     self._actionDestroyed = False
     w = QWidget()
     menuBar = QMenuBar(w)
     act = menuBar.addAction("MENU")
     _ref = weakref.ref(act, self.actionDestroyed)
     act = None
     self.assertFalse(self._actionDestroyed)
     menuBar.clear()
     self.assertTrue(self._actionDestroyed)
Esempio n. 9
0
 def testMenuBar(self):
     self._actionDestroyed = False
     w = QWidget()
     menuBar = QMenuBar(w)
     act = menuBar.addAction("MENU")
     _ref = weakref.ref(act, self.actionDestroyed)
     act = None
     self.assertFalse(self._actionDestroyed)
     menuBar.clear()
     self.assertTrue(self._actionDestroyed)
Esempio n. 10
0
class MainWindow(QMainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()
        self.widget = QWidget(self)
        self.verticalLayout = QVBoxLayout(self.widget)
        self.graphicsView = GraphicsView(self.widget)
        self.verticalLayout.addWidget(self.graphicsView)
        self.setCentralWidget(self.widget)
        self.setStatusBar(QStatusBar())

        self.menubar = QMenuBar(self)
        self.file_menu = QMenu(self.menubar)
        self.draw_menu = QMenu(self.menubar)
        self.select_menu = QMenu(self.menubar)
        self.setMenuBar(self.menubar)

        self.action_close = QAction(self)
        self.action_draw_line = QAction(self)
        self.action_select_item = QAction(self)

        self.menubar.addAction(self.file_menu.menuAction())
        self.menubar.addAction(self.draw_menu.menuAction())
        self.menubar.addAction(self.select_menu.menuAction())
        self.file_menu.addAction(self.action_close)
        self.draw_menu.addAction(self.action_draw_line)
        self.select_menu.addAction(self.action_select_item)

        self.file_menu.setTitle('Dosya')
        self.action_close.setText('Kapat')
        self.action_close.setShortcut('Ctrl+Q')

        self.draw_menu.setTitle('Çizim')
        self.action_draw_line.setText('Doğru Çiz')
        self.action_draw_line.setShortcut('Ctrl+L')

        self.select_menu.setTitle('Seçim')
        self.action_select_item.setText('Obje Seç')
        self.action_select_item.setShortcut('Shift+S')
Esempio n. 11
0
class Music(QMainWindow):
    def __init__(self):
        super(Music, self).__init__()
        self.setGeometry(20, 50, 522, 175)
        self.setMinimumSize(522, 175)
        self.setMaximumSize(522, 175)
        self.setWindowTitle('Muse')
        self.setWindowIcon(QIcon('arti.PNG'))
        self.setFont(QFont('Roboto', 12))

        palette = QPalette()
        palette.setColor(palette.Window, QColor('#000000'))
        palette.setColor(palette.WindowText, QColor('#FFFFFF'))
        self.setPalette(palette)

        self.menubar = QMenuBar(self)
        self.menubar.setGeometry(0, 0, 682, 21)
        self.menubar.setFont(QFont('Roboto', 10))

        self.date_menu = QMenu(self.menubar)
        self.date_menu.setTitle(str(datetime.now().strftime('%d-%m-%Y')))

        self.setMenuBar(self.menubar)
        self.menubar.addAction(self.date_menu.menuAction())

        self.song = QLineEdit(self)
        self.song.setPlaceholderText(
            'Enter the name of song you want to search for:')
        self.song.setGeometry(10, 30, 501, 31)

        self.spotify = QRadioButton(self)
        self.spotify.setText('Spotify')
        self.spotify.setGeometry(120, 80, 101, 21)

        self.gaana = QRadioButton(self)
        self.gaana.setText('Gaana')
        self.gaana.setGeometry(330, 80, 91, 21)

        self.search = QPushButton(self)
        self.search.setText('Search')
        self.search.setGeometry(380, 130, 121, 31)
        self.search.clicked.connect(lambda: self.on_click())
        self.search.setCursor(QCursor(Qt.PointingHandCursor))

        self.label = QLabel(self)
        self.label.setGeometry(10, 130, 341, 31)

    def on_click(self):
        self.song_search = self.song.text()

        if self.song.text():
            if self.spotify.isChecked():
                self.speak('Searching your song on Spotify.')

                spotify_url = 'https://open.spotify.com/search/'
                webbrowser.open(spotify_url + self.song_search)

            elif self.gaana.isChecked():
                self.speak('Searching your song on Gaana.')

                gaana_url = 'https://gaana.com/search/'
                webbrowser.open(gaana_url + self.song_search)

            else:
                self.speak('Please choose either Spotify or Gaana.')
        else:
            self.speak('Please type a song name first')

        self.song.clear()

    def speak(self, audio):
        self.engine = pyttsx3.init('sapi5')
        self.voices = self.engine.getProperty('voices')
        self.engine.setProperty('voice', self.voices[1].id)
        self.engine.setProperty('rate', 165)

        self.engine.say(audio)
        self.label.setText(audio)
        self.engine.runAndWait()
Esempio n. 12
0
class MainWindow(QMainWindow):
    def __init__(self, *args, **kwargs):
        super(MainWindow, self).__init__(*args, **kwargs)
        self.setupUi(self)

        self.player = QMediaPlayer()

        self.player.error.connect(self.erroralert)
        self.player.play()

        # Setup the playlist.
        self.playlist = QMediaPlaylist()
        self.player.setPlaylist(self.playlist)

        # Add viewer for video playback, separate floating window.
        self.viewer = ViewerWindow(self)
        self.viewer.setWindowFlags(self.viewer.windowFlags()
                                   | Qt.WindowStaysOnTopHint)
        self.viewer.setMinimumSize(QSize(480, 360))

        videoWidget = QVideoWidget()
        self.viewer.setCentralWidget(videoWidget)
        self.player.setVideoOutput(videoWidget)

        # Connect control buttons/slides for media player.
        self.playButton.pressed.connect(self.player.play)
        self.pauseButton.pressed.connect(self.player.pause)
        self.stopButton.pressed.connect(self.player.stop)
        self.volumeSlider.valueChanged.connect(self.player.setVolume)

        self.viewButton.toggled.connect(self.toggle_viewer)
        self.viewer.state.connect(self.viewButton.setChecked)

        self.previousButton.pressed.connect(self.playlist.previous)
        self.nextButton.pressed.connect(self.playlist.next)

        self.model = PlaylistModel(self.playlist)
        self.playlistView.setModel(self.model)
        self.playlist.currentIndexChanged.connect(
            self.playlist_position_changed)
        selection_model = self.playlistView.selectionModel()
        selection_model.selectionChanged.connect(
            self.playlist_selection_changed)

        self.player.durationChanged.connect(self.update_duration)
        self.player.positionChanged.connect(self.update_position)
        self.timeSlider.valueChanged.connect(self.player.setPosition)

        self.open_file_action.triggered.connect(self.open_file)

        self.setAcceptDrops(True)

        self.show()

    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(484, 371)
        self.centralWidget = QWidget(MainWindow)
        sizePolicy = QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.centralWidget.sizePolicy().hasHeightForWidth())
        self.centralWidget.setSizePolicy(sizePolicy)
        self.centralWidget.setObjectName("centralWidget")
        self.horizontalLayout = QHBoxLayout(self.centralWidget)
        self.horizontalLayout.setContentsMargins(11, 11, 11, 11)
        self.horizontalLayout.setSpacing(6)
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.verticalLayout = QVBoxLayout()
        self.verticalLayout.setSpacing(6)
        self.verticalLayout.setObjectName("verticalLayout")
        self.playlistView = QListView(self.centralWidget)
        self.playlistView.setAcceptDrops(True)
        self.playlistView.setProperty("showDropIndicator", True)
        self.playlistView.setDragDropMode(QAbstractItemView.DropOnly)
        self.playlistView.setAlternatingRowColors(True)
        self.playlistView.setUniformItemSizes(True)
        self.playlistView.setObjectName("playlistView")
        self.verticalLayout.addWidget(self.playlistView)
        self.horizontalLayout_4 = QHBoxLayout()
        self.horizontalLayout_4.setSpacing(6)
        self.horizontalLayout_4.setObjectName("horizontalLayout_4")
        self.currentTimeLabel = QLabel(self.centralWidget)
        self.currentTimeLabel.setMinimumSize(QSize(80, 0))
        self.currentTimeLabel.setAlignment(Qt.AlignRight | Qt.AlignTrailing
                                           | Qt.AlignVCenter)
        self.currentTimeLabel.setObjectName("currentTimeLabel")
        self.horizontalLayout_4.addWidget(self.currentTimeLabel)
        self.timeSlider = QSlider(self.centralWidget)
        self.timeSlider.setOrientation(Qt.Horizontal)
        self.timeSlider.setObjectName("timeSlider")
        self.horizontalLayout_4.addWidget(self.timeSlider)
        self.totalTimeLabel = QLabel(self.centralWidget)
        self.totalTimeLabel.setMinimumSize(QSize(80, 0))
        self.totalTimeLabel.setAlignment(Qt.AlignLeading | Qt.AlignLeft
                                         | Qt.AlignVCenter)
        self.totalTimeLabel.setObjectName("totalTimeLabel")
        self.horizontalLayout_4.addWidget(self.totalTimeLabel)
        self.verticalLayout.addLayout(self.horizontalLayout_4)
        self.horizontalLayout_5 = QHBoxLayout()
        self.horizontalLayout_5.setSpacing(6)
        self.horizontalLayout_5.setObjectName("horizontalLayout_5")
        self.previousButton = QPushButton(self.centralWidget)
        self.previousButton.setText("")
        icon = QIcon()
        icon.addPixmap(QPixmap("images/control-skip-180.png"), QIcon.Normal,
                       QIcon.Off)
        self.previousButton.setIcon(icon)
        self.previousButton.setObjectName("previousButton")
        self.horizontalLayout_5.addWidget(self.previousButton)
        self.playButton = QPushButton(self.centralWidget)
        self.playButton.setText("")
        icon1 = QIcon()
        icon1.addPixmap(QPixmap("images/control.png"), QIcon.Normal, QIcon.Off)
        self.playButton.setIcon(icon1)
        self.playButton.setObjectName("playButton")
        self.horizontalLayout_5.addWidget(self.playButton)
        self.pauseButton = QPushButton(self.centralWidget)
        self.pauseButton.setText("")
        icon2 = QIcon()
        icon2.addPixmap(QPixmap("images/control-pause.png"), QIcon.Normal,
                        QIcon.Off)
        self.pauseButton.setIcon(icon2)
        self.pauseButton.setObjectName("pauseButton")
        self.horizontalLayout_5.addWidget(self.pauseButton)
        self.stopButton = QPushButton(self.centralWidget)
        self.stopButton.setText("")
        icon3 = QIcon()
        icon3.addPixmap(QPixmap("images/control-stop-square.png"),
                        QIcon.Normal, QIcon.Off)
        self.stopButton.setIcon(icon3)
        self.stopButton.setObjectName("stopButton")
        self.horizontalLayout_5.addWidget(self.stopButton)
        self.nextButton = QPushButton(self.centralWidget)
        self.nextButton.setText("")
        icon4 = QIcon()
        icon4.addPixmap(QPixmap("images/control-skip.png"), QIcon.Normal,
                        QIcon.Off)
        self.nextButton.setIcon(icon4)
        self.nextButton.setObjectName("nextButton")
        self.horizontalLayout_5.addWidget(self.nextButton)
        self.viewButton = QPushButton(self.centralWidget)
        self.viewButton.setText("")
        icon5 = QIcon()
        icon5.addPixmap(QPixmap("images/application-image.png"), QIcon.Normal,
                        QIcon.Off)
        self.viewButton.setIcon(icon5)
        self.viewButton.setCheckable(True)
        self.viewButton.setObjectName("viewButton")
        self.horizontalLayout_5.addWidget(self.viewButton)
        spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                 QSizePolicy.Minimum)
        self.horizontalLayout_5.addItem(spacerItem)
        self.label = QLabel(self.centralWidget)
        self.label.setText("")
        self.label.setPixmap(QPixmap("images/speaker-volume.png"))
        self.label.setObjectName("label")
        self.horizontalLayout_5.addWidget(self.label)
        self.volumeSlider = QSlider(self.centralWidget)
        self.volumeSlider.setMaximum(100)
        self.volumeSlider.setProperty("value", 100)
        self.volumeSlider.setOrientation(Qt.Horizontal)
        self.volumeSlider.setObjectName("volumeSlider")
        self.horizontalLayout_5.addWidget(self.volumeSlider)
        self.verticalLayout.addLayout(self.horizontalLayout_5)
        self.horizontalLayout.addLayout(self.verticalLayout)
        MainWindow.setCentralWidget(self.centralWidget)
        self.menuBar = QMenuBar(MainWindow)
        self.menuBar.setGeometry(QRect(0, 0, 484, 22))
        self.menuBar.setObjectName("menuBar")
        self.menuFIle = QMenu(self.menuBar)
        self.menuFIle.setObjectName("menuFIle")
        MainWindow.setMenuBar(self.menuBar)
        self.statusBar = QStatusBar(MainWindow)
        self.statusBar.setObjectName("statusBar")
        MainWindow.setStatusBar(self.statusBar)
        self.open_file_action = QAction(MainWindow)
        self.open_file_action.setObjectName("open_file_action")
        self.menuFIle.addAction(self.open_file_action)
        self.menuBar.addAction(self.menuFIle.menuAction())

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

    def retranslateUi(self, MainWindow):
        _translate = QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "Failamp"))
        self.currentTimeLabel.setText(_translate("MainWindow", "0:00"))
        self.totalTimeLabel.setText(_translate("MainWindow", "0:00"))
        self.menuFIle.setTitle(_translate("MainWindow", "FIle"))
        self.open_file_action.setText(_translate("MainWindow", "Open file..."))

    def dragEnterEvent(self, e):
        if e.mimeData().hasUrls():
            e.acceptProposedAction()

    def dropEvent(self, e):
        for url in e.mimeData().urls():
            self.playlist.addMedia(QMediaContent(url))

        self.model.layoutChanged.emit()

        # If not playing, seeking to first of newly added + play.
        if self.player.state() != QMediaPlayer.PlayingState:
            i = self.playlist.mediaCount() - len(e.mimeData().urls())
            self.playlist.setCurrentIndex(i)
            self.player.play()

    def open_file(self):
        path, _ = QFileDialog.getOpenFileName(
            self, "Open file", "",
            "mp3 Audio (*.mp3);mp4 Video (*.mp4);Movie files (*.mov);All files (*.*)"
        )

        if path:
            self.playlist.addMedia(QMediaContent(QUrl.fromLocalFile(path)))

        self.model.layoutChanged.emit()

    def update_duration(self, duration):
        print("!", duration)
        print("?", self.player.duration())

        self.timeSlider.setMaximum(duration)

        if duration >= 0:
            self.totalTimeLabel.setText(hhmmss(duration))

    def update_position(self, position):
        if position >= 0:
            self.currentTimeLabel.setText(hhmmss(position))

        # Disable the events to prevent updating triggering a setPosition event (can cause stuttering).
        self.timeSlider.blockSignals(True)
        self.timeSlider.setValue(position)
        self.timeSlider.blockSignals(False)

    def playlist_selection_changed(self, ix):
        # We receive a QItemSelection from selectionChanged.
        i = ix.indexes()[0].row()
        self.playlist.setCurrentIndex(i)

    def playlist_position_changed(self, i):
        if i > -1:
            ix = self.model.index(i)
            self.playlistView.setCurrentIndex(ix)

    def toggle_viewer(self, state):
        if state:
            self.viewer.show()
        else:
            self.viewer.hide()

    def erroralert(self, *args):
        print(args)
class Artigence(QMainWindow):
    def __init__(self):
        super(Artigence, self).__init__()

        # Basic Settings
        self.setGeometry(300, 200, 682, 422)
        self.setMinimumSize(QSize(682, 422))
        self.setMaximumSize(QSize(682, 422))
        self.setWindowIcon(QIcon("arti.PNG"))
        self.setWindowTitle("Artigence Home")

        # Color Scheme
        self.palette = QPalette()
        self.palette.setColor(self.palette.Window, QColor('#000000'))
        self.palette.setColor(self.palette.WindowText, QColor('#FFFFFF'))
        self.setPalette(self.palette)

        self.light_palette = QPalette()
        self.light_palette.setColor(self.light_palette.Window,
                                    QColor('#FFFFFF'))
        self.light_palette.setColor(self.light_palette.WindowText,
                                    QColor('#000000'))

        # Setting MenuBar
        self.menubar = QMenuBar(self)
        self.menubar.setGeometry(0, 0, 682, 21)

        self.date_menu = QMenu(self.menubar)
        self.date_menu.setTitle(str(datetime.now().strftime('%d-%m-%Y')))

        self.theme_menu = QMenu(self.menubar)
        self.theme_menu.setTitle('Theme')

        self.dark_theme = QAction('Dark Theme')
        self.dark_theme.setShortcut(QKeySequence('Ctrl+Shift+D'))
        self.theme_menu.addAction(self.dark_theme)
        self.dark_theme.triggered.connect(lambda: self.dark())

        self.light_theme = QAction('Light Theme')
        self.light_theme.setShortcut(QKeySequence('Ctrl+Shift+L'))
        self.theme_menu.addAction(self.light_theme)
        self.light_theme.triggered.connect(lambda: self.light())

        self.app_menu = QMenu(self.menubar)
        self.app_menu.setTitle('Apps')

        self.calculator_menu = QAction('Calculator')
        self.calculator_menu.setShortcut(QKeySequence('Alt+C'))
        self.app_menu.addAction(self.calculator_menu)
        self.calculator_menu.triggered.connect(lambda: self.calculator_func())

        self.game_menu = QAction('GameHub')
        self.game_menu.setShortcut(QKeySequence('Alt+G'))
        self.app_menu.addAction(self.game_menu)
        self.game_menu.triggered.connect(lambda: self.games_func())

        self.music_menu = QAction('Muse (Music)')
        self.music_menu.setShortcut(QKeySequence('Alt+M'))
        self.app_menu.addAction(self.music_menu)
        self.music_menu.triggered.connect(lambda: self.music_func())

        self.news_menu = QAction('News')
        self.news_menu.setShortcut(QKeySequence('Alt+E'))
        self.app_menu.addAction(self.news_menu)
        self.news_menu.triggered.connect(lambda: self.news_func())

        self.notepad_menu = QAction('Notepad')
        self.notepad_menu.setShortcut(QKeySequence('Alt+N'))
        self.app_menu.addAction(self.notepad_menu)
        self.notepad_menu.triggered.connect(lambda: self.notepad_func())

        self.pronunciator = QAction('Pronunciator')
        self.pronunciator.setShortcut(QKeySequence('Alt+P'))
        self.app_menu.addAction(self.pronunciator)
        self.pronunciator.triggered.connect(lambda: self.pronunciator_func())

        self.translate_menu = QAction('Translate')
        self.translate_menu.setShortcut(QKeySequence('Alt+T'))
        self.app_menu.addAction(self.translate_menu)
        self.translate_menu.triggered.connect(lambda: self.translate_func())

        self.weather_menu = QAction('Weather')
        self.weather_menu.setShortcut(QKeySequence('Alt+W'))
        self.app_menu.addAction(self.weather_menu)
        self.weather_menu.triggered.connect(lambda: self.weather_func())

        self.setMenuBar(self.menubar)
        self.menubar.addAction(self.date_menu.menuAction())
        self.menubar.addAction(self.theme_menu.menuAction())
        self.menubar.addAction(self.app_menu.menuAction())

        # Creating Widgets
        self.query = QLineEdit(self)
        self.query.setGeometry(QRect(20, 30, 451, 41))
        self.query.setMinimumSize(QSize(451, 41))
        self.query.setMaximumSize(QSize(451, 41))
        self.query.setPlaceholderText("Enter your Query Here:")
        self.query.setFont(QFont('Roboto', 16))
        self.query.setClearButtonEnabled(True)

        self.update = QPushButton(self)
        self.update.setGeometry(QRect(491, 30, 171, 41))
        self.update.setMinimumSize(QSize(1, 1))
        self.update.setMaximumSize(QSize(171, 51))
        self.update.setText("What's New in the Updates?")
        self.update.setCursor(QCursor(Qt.PointingHandCursor))

        self.suggestions = QLabel(self)
        self.suggestions.setGeometry(QRect(20, 220, 111, 31))
        self.suggestions.setMinimumSize(QSize(111, 31))
        self.suggestions.setMaximumSize(QSize(111, 31))
        self.suggestions.setText("Suggestions:")
        self.suggestions.setFont(QFont('Roboto', 14))

        self.chrome = QPushButton(self)
        self.chrome.setGeometry(QRect(20, 260, 91, 31))
        self.chrome.setCursor(QCursor(Qt.PointingHandCursor))
        self.chrome.setText('Open Chrome')

        self.games = QPushButton(self)
        self.games.setGeometry(QRect(420, 260, 91, 31))
        self.games.setCursor(QCursor(Qt.PointingHandCursor))
        self.games.setText('Games')

        self.cmd = QPushButton(self)
        self.cmd.setGeometry(QRect(160, 260, 91, 31))
        self.cmd.setCursor(QCursor(Qt.PointingHandCursor))
        self.cmd.setText('Open Cmd')

        self.joke = QPushButton(self)
        self.joke.setGeometry(QRect(160, 310, 91, 31))
        self.joke.setCursor(QCursor(Qt.PointingHandCursor))
        self.joke.setText('Joke Please!!')

        self.music = QPushButton(self)
        self.music.setGeometry(QRect(290, 260, 91, 31))
        self.music.setCursor(QCursor(Qt.PointingHandCursor))
        self.music.setText('Music')

        self.youtube = QPushButton(self)
        self.youtube.setGeometry(QRect(290, 310, 91, 31))
        self.youtube.setCursor(QCursor(Qt.PointingHandCursor))
        self.youtube.setText('Youtube')

        self.time = QPushButton(self)
        self.time.setGeometry(QRect(20, 310, 91, 31))
        self.time.setCursor(QCursor(Qt.PointingHandCursor))
        self.time.setText('Tell Time')

        self.weather = QPushButton(self)
        self.weather.setGeometry(QRect(420, 310, 91, 31))
        self.weather.setCursor(QCursor(Qt.PointingHandCursor))
        self.weather.setText('Weather')

        self.calculator = QPushButton(self)
        self.calculator.setGeometry(QRect(550, 260, 101, 31))
        self.calculator.setCursor(QCursor(Qt.PointingHandCursor))
        self.calculator.setText('Calculator')

        self.wikipedia = QPushButton(self)
        self.wikipedia.setGeometry(QRect(550, 310, 101, 31))
        self.wikipedia.setCursor(QCursor(Qt.PointingHandCursor))
        self.wikipedia.setText('India Wikipedia')

        self.news = QPushButton(self)
        self.news.setGeometry(QRect(20, 360, 91, 31))
        self.news.setCursor(QCursor(Qt.PointingHandCursor))
        self.news.setText('Latest News')

        self.meaning = QPushButton(self)
        self.meaning.setGeometry(QRect(420, 360, 231, 31))
        self.meaning.setCursor(QCursor(Qt.PointingHandCursor))
        self.meaning.setText('Meaning of Obsolete (or any word)')

        self.harry_potter = QPushButton(self)
        self.harry_potter.setGeometry(QRect(290, 360, 91, 31))
        self.harry_potter.setCursor(QCursor(Qt.PointingHandCursor))
        self.harry_potter.setText('Harry Potter')

        self.translate = QPushButton(self)
        self.translate.setGeometry(QRect(160, 360, 91, 31))
        self.translate.setCursor(QCursor(Qt.PointingHandCursor))
        self.translate.setText('Open Translate')

        self.line = QFrame(self)
        self.line.setGeometry(QRect(20, 200, 661, 16))
        self.line.setFrameShape(QFrame.HLine)
        self.line.setFrameShadow(QFrame.Sunken)

        self.label = QLabel(self)
        self.label.setGeometry(QRect(20, 100, 631, 91))
        self.label.setFont(QFont('Roboto', 12))
        self.label.setTextFormat(Qt.AutoText)
        self.label.setWordWrap(True)

        self.wish()

        # Making the Widgets Functional
        self.query.returnPressed.connect(lambda: self.on_enter())
        self.query.returnPressed.connect(lambda: self.clear_text())

        self.update.clicked.connect(lambda: self.update_func())
        self.music.clicked.connect(lambda: self.music_func())
        self.games.clicked.connect(lambda: self.games_func())
        self.calculator.clicked.connect(lambda: self.calculator_func())
        self.weather.clicked.connect(lambda: self.weather_func())
        self.news.clicked.connect(lambda: self.news_func())
        self.translate.clicked.connect(lambda: self.translate_func())
        self.time.clicked.connect(lambda: self.time_func())
        self.joke.clicked.connect(lambda: self.joke_func())
        self.youtube.clicked.connect(lambda: self.youtube_func())
        self.wikipedia.clicked.connect(lambda: self.wikipedia_func())
        self.chrome.clicked.connect(lambda: self.chrome_func())
        self.cmd.clicked.connect(lambda: self.cmd_func())
        self.meaning.clicked.connect(lambda: self.meaning_func())
        self.harry_potter.clicked.connect(lambda: self.potter_func())

    def pronunciator_func(self):
        self.speak('Opening Pronunciator')
        from pronunciator import Pronunciator
        self.pronunciator_win = Pronunciator()
        self.pronunciator_win.show()

    def pong_func(self):
        import pong

    def notepad_func(self):
        self.speak('Opening Notepad')
        from notepad import Notepad
        self.notepad_win = Notepad()
        self.notepad_win.show()

    def update_func(self):
        os.startfile('Each Version Updates.txt')

    def translate_func(self):
        self.speak(
            'Opening Translate\nPlease Wait as opening Translate may take up to 4-5 seconds'
        )
        from translate import Translate
        self.translate_win = Translate()
        self.translate_win.show()

    def games_func(self):
        self.speak('Opening GameHub')
        from games import GameHub
        self.game_win = GameHub()
        self.game_win.show()

    def weather_func(self):
        self.speak('Opening Weather.')
        from weather import Weather
        self.weather_win = Weather()
        self.weather_win.show()

    def music_func(self):
        self.speak('Opening Muse')
        from music import Music
        self.music_win = Music()
        self.music_win.show()

    def calculator_func(self):
        self.speak('Opening Calculator.')
        from calculator import Calculator
        self.calculator_win = Calculator()
        self.calculator_win.show()

    def news_func(self):
        self.speak('Opening News.')
        from news import News
        self.news_win = News()
        self.news_win.show()
        self.speak(
            'Welcome to News.\nThese are the latest international headlines according to BBC News Network.'
        )

    def chrome_func(self):
        try:
            chrome_path = 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'
            os.startfile(chrome_path)
            self.speak('Opening Chrome.')
        except Exception:
            self.speak(
                'No Google Chrome installation found on the host device.')

    def cmd_func(self):
        cmd_path = 'C:\\Windows\\system32\\cmd.exe'
        os.startfile(cmd_path)
        self.speak('Opening Command Prompt.')

    def time_func(self):
        question = 'time'
        app_id = 'LLQ4QY-A7K3LEL4T8'
        client = wolframalpha.Client(app_id)
        res = client.query(question)
        answer = next(res.results).text
        self.speak(answer)

    def joke_func(self):
        self.speak(pyjokes.get_joke())

    def youtube_func(self):
        webbrowser.open('https://www.youtube.com')
        self.speak('Opening Youtube.')

    def wikipedia_func(self):
        try:
            self.speak('Searching Wikipedia. Please Wait...')
            query = 'India'.replace('wikipedia', '')
            result = wikipedia.summary(query, sentences=1)
            self.speak('According to Wikipedia...')
            self.speak(result)
        except Exception as e:
            self.speak(e)

    def meaning_func(self):
        question = 'obsolete'
        app_id = 'LLQ4QY-A7K3LEL4T8'
        client = wolframalpha.Client(app_id)
        res = client.query(question)
        answer = next(res.results).text
        self.speak(answer)

    def potter_func(self):
        new = 2
        google_url = "http://google.com/?#q="
        webbrowser.open(google_url + 'Harry Potter', new=new)

    def clear_text(self):
        self.query.clear()

    def on_enter(self):
        user_query = self.query.text().lower()

        if 'wikipedia' in user_query:
            try:
                self.speak('Searching Wikipedia. Please Wait...')
                user_query = user_query.replace('wikipedia', '')
                result = wikipedia.summary(user_query, sentences=1)
                self.speak('According to Wikipedia...')
                self.speak(result)
            except Exception as e:
                self.speak('Please try again later.')
                self.speak(e)

        elif 'youtube' in user_query:
            webbrowser.open('https://www.youtube.com')
            self.speak('Opening Youtube.')

        elif 'google' in user_query:
            webbrowser.open('https://www.google.com/')
            self.speak('Opening Google.')

        elif 'chrome' in user_query:  # You'll have to download google chrome first on your desktop/pc.
            try:
                chrome_path = 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'
                os.startfile(chrome_path)
                self.speak('Opening Chrome')
            except Exception:
                self.speak(
                    'No Google Chrome installation found on the host device.')

        elif 'cmd' in user_query:
            cmd_path = 'C:\\Windows\\system32\\cmd.exe'
            os.startfile(cmd_path)
            self.speak('Opening Command Prompt.')

        elif 'control panel' in user_query:

            cp_path = 'C:\\Windows\\system32\\control.exe'
            os.startfile(cp_path)
            self.speak('Opening Control Panel.')

        elif 'bye' in user_query or 'goodbye' in user_query or 'good night' in user_query or 'see you later' in user_query:
            self.speak(random.choice(self.bye))
            sys.exit()

        elif 'hello' in user_query or 'hi' in user_query:
            self.speak(random.choice(self.hello))

        elif 'joke' in user_query:
            self.speak(pyjokes.get_joke())

        elif 'who are you' in user_query:
            self.speak('I am Artigence, your artificial intelligence.')

        elif 'map' in user_query or 'maps' in user_query:
            self.speak('Opening Google Maps.')
            webbrowser.open("https://www.google.com/maps")

        elif 'open calculator' in user_query or 'calculator' in user_query:
            self.calculator_func()

        elif 'news' in user_query:
            self.news_func()
            self.speak(
                'Welcome to News.\nThese are the latest international headlines according to BBC News Network.'
            )

        elif 'weather' in user_query:
            self.weather_func()

        elif 'games' in user_query:
            self.games_func()

        elif 'pronunciator' in user_query or 'pronounce' in user_query:
            self.pronunciator_func()

        elif 'translate' in user_query:
            self.translate_func()

        elif 'music' in user_query:
            self.music_func()

        elif 'notepad' in user_query:
            self.notepad_func()

        else:
            try:
                question = user_query
                app_id = 'LLQ4QY-A7K3LEL4T8'
                client = wolframalpha.Client(app_id)
                res = client.query(question)
                answer = next(res.results).text
                self.label.setText(answer)
                self.label.adjustSize()

            except:
                new = 2
                google_url = "http://google.com/?#q="
                query = user_query
                webbrowser.open(google_url + query, new=new)

    # The A.I. will speak through this function
    def speak(self, audio):
        self.engine = pyttsx3.init('sapi5')
        voices = self.engine.getProperty('voices')
        self.engine.setProperty('voice', voices[1].id)
        self.engine.setProperty('rate', 165)
        self.label.setText(audio)
        self.engine.say(audio)
        self.engine.runAndWait()
        self.label.clear()

    def wish(self):
        hour = int(datetime.now().hour)
        if 0 <= hour < 12:
            self.speak('Good Morning.')
        elif 12 <= hour < 18:
            self.speak('Good Afternoon.')
        else:
            self.speak('Good Evening.')

        self.speak('I am Artigence.')
        self.speak('How may I help you today')

    hello = ['Kon\'nichiwa', 'Ciao', 'Hola', 'Bonjour', 'Hello', 'Hi', 'Hiya']
    bye = [
        'Adios', 'Goodbye', 'Bye-Bye', 'See you next time.', 'Artigence Out.',
        'It was nice talking to you sir. Have a nice day.'
    ]

    def dark(self):
        self.setPalette(self.palette)

    def light(self):
        self.setPalette(self.light_palette)
Esempio n. 14
0
class Ui_MainWindow(object):

    image_stack=[None]
    current_effect=""
    def resize(self):
        self.timer.stop()
        temp=QDialog()
        temp.ui=Ui_Dialog_Resize(self.image_stack[-1])
        temp.ui.setupUi(temp)
        temp.show()
        temp.exec_()
        self.image_stack.append(temp.ui.image)
        self.timer.start(1)
        pass

    def cropping(self):
        if type(self.image_stack[-1])==type(None):
            print("lol")
            return
        self.timer.stop()
        temp=QDialog()
        temp.ui=Ui_Dialog(self.image_stack[-1])
        temp.ui.setupUi(temp)
        temp.show()
        temp.exec_()
        self.image_stack.append(temp.ui.image)
        self.timer.start(1)
        pass

    def effectFuctions(self,effect,image,amount):
        if effect=="Brightness":
            return brightness(image, amount=amount)
        elif effect=="Saturation":
            return saturation(image, amount)
        elif effect=="Sharpen":
            return sharpness(image, amount)
        elif effect=="Sepia Effect":
            return sepia(image, amount)
        elif effect=="Warm":
            return warm(image, amount)
        elif effect == "Cold":
            return cold(image, amount)
        elif effect == "Equalize":
            return equalise(image, amount)
        elif effect== "Cartoon":
            return cartoon(image, amount)
        elif effect== "Blurring":
            return blurring(image, amount) 
        elif effect== "Pencil Sketch":
            return pencil_sketch(image, amount)
        elif effect== "Noise Reduction":
            return noise_reduction(image, amount)
        elif effect== "Negetive" :
            return negative(image, amount)
        elif effect== "Vignette":  
            return vignette(image, amount)
        elif effect== "Emboss":
            return emboss(image, amount)
        elif effect== "Redden": # lal panni
            return redden(image, amount)
        elif effect== "Greenify": # hari panni 
            return greenify(image, amount)
        elif effect== "Bloom Blue": # nili panni 
            return nili_panni(image, amount)
        elif effect== "HDR":  
            return hdr(image, amount)
        elif effect== "Yellow":  
            return yellow_panni(image, amount)


    def showFrame(self,frame):
        if type(frame)==type(None):
            self.label.setText(QCoreApplication.translate("MainWindow", u"<html><head/><body style=\"background-color:powderblue;\"><p align=\"center\">Your Image Here</p></body></html>", None))
            return
        if self.listWidget.selectedItems()!=[]:
            effect=self.listWidget.selectedItems()[0].text()
            if effect!=self.current_effect:
                print("LOL")
                self.current_effect=effect
                clearTemp()
            temp=self.effectFuctions(effect,frame.copy(),self.horizontalSlider.value())
            frame= temp if type(temp)!=type(None) else frame
        
        frame=cv2.cvtColor(frame,cv2.COLOR_BGR2RGB)
        image=qimage2ndarray.array2qimage(frame)
        self.label.setPixmap(QPixmap.fromImage(image))
        pass

    def addImage(self):
        #
        self.image_stack=[None]
        filePath,_=QFileDialog.getOpenFileName(QMainWindow(), 'Open file')
        self.image_stack.append(cv2.imread(filePath))
        pass

    def saveImage(self):
        #print("lol")
        filePath,_=QFileDialog.getSaveFileName(QMainWindow(),"Choose the save location")
        self.label.pixmap().save(filePath,"jpg",100)
        
        #self.cv2.imwrite(filePath,self.image_stack[-1])
        #pass
    
    def commit(self):
        frame=self.image_stack[-1]
        if self.listWidget.selectedItems()==[]:
            return
        effect=self.listWidget.selectedItems()[0].text()
        temp=self.effectFuctions(effect,frame,self.horizontalSlider.value())
        #frame= temp if type(temp)!=type(None) else None
        if type(frame)!=type(None):
            self.image_stack.append(temp)
        self.horizontalSlider.setValue(0)
        self.listWidget.setCurrentItem(None)

    def cancle(self):
       self.horizontalSlider.setValue(0)
       self.listWidget.setCurrentItem(None)

    def undo(self):
        if type(self.image_stack)!=type(None):
            self.image_stack.pop()

    def setupUi(self, MainWindow):
        if not MainWindow.objectName():
            MainWindow.setObjectName(u"MainWindow")
        MainWindow.resize(1131, 555)
        self.centralwidget = QWidget(MainWindow)
        self.centralwidget.setObjectName(u"centralwidget")
        self.label = QLabel(self.centralwidget)
        self.label.setObjectName(u"label")
        self.label.setGeometry(QRect(10, 60, 781, 431))
        self.label.setStyleSheet(u"background-color: rgb(85, 255, 255)")
        self.label.setScaledContents(True)
        
        self.listWidget = QListWidget(self.centralwidget)
        no_of_widgets=19
        for i in range(no_of_widgets):
            QListWidgetItem(self.listWidget)
        self.listWidget.setObjectName(u"listWidget")
        self.listWidget.setGeometry(QRect(850, 160, 256, 201))

        self.horizontalSlider = QSlider(self.centralwidget)
        self.horizontalSlider.setObjectName(u"horizontalSlider")
        self.horizontalSlider.setGeometry(QRect(870, 70, 211, 22))
        self.horizontalSlider.setOrientation(Qt.Horizontal)
        #print(self.horizontalSlider.value())
        self.label_2 = QLabel(self.centralwidget)
        self.label_2.setObjectName(u"label_2")
        self.label_2.setGeometry(QRect(930, 10, 101, 51))
        self.label_2.setMinimumSize(QSize(0, 31))
        self.label_2.setScaledContents(True)
        self.label_2.setWordWrap(True)
        self.label_2.setMargin(10)
        
        # ✅ commit button
        self.pushButton = QPushButton(self.centralwidget)
        self.pushButton.setObjectName(u"pushButton")
        self.pushButton.setGeometry(QRect(892, 110, 61, 28))
        self.pushButton.clicked.connect(lambda : self.commit())

        # ❌ cancle button
        self.pushButton_2 = QPushButton(self.centralwidget)
        self.pushButton_2.setObjectName(u"pushButton_2")
        self.pushButton_2.setGeometry(QRect(990, 110, 61, 28))
        self.pushButton_2.clicked.connect(lambda : self.cancle())

        # ↩️ Undo button
        self.pushButton_3 = QPushButton(self.centralwidget)
        self.pushButton_3.setObjectName(u"pushButton_3")
        self.pushButton_3.setGeometry(QRect(370, 20, 61, 28))
        self.pushButton_3.clicked.connect(lambda : self.undo())

        #crop
        self.pushButton_4 = QPushButton(self.centralwidget)
        self.pushButton_4.setObjectName(u"pushButton_4")
        self.pushButton_4.setGeometry(QRect(910, 380, 61, 28))
        self.pushButton_4.clicked.connect(self.cropping)
        
        # Resize
        self.pushButton_5 = QPushButton(self.centralwidget)
        self.pushButton_5.setObjectName(u"pushButton_5")
        self.pushButton_5.setGeometry(QRect(980, 380, 61, 28))
        self.pushButton_5.clicked.connect(self.resize)
        
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QMenuBar(MainWindow)
        self.menubar.setObjectName(u"menubar")

        self.menubar.setGeometry(QRect(0, 0, 1131, 26))
        self.menuNew_File = QMenu(self.menubar)
        self.menuNew_File.setObjectName(u"menuNew_File")

        #New File
        self.actionNew_File = QAction("NewFile")
        self.actionNew_File.triggered.connect(self.addImage)
        self.menuNew_File.addAction(self.actionNew_File)

        #Save File
        self.actionSave_File = QAction("SaveFile")
        self.actionSave_File.triggered.connect(self.saveImage)
        self.menuNew_File.addAction(self.actionSave_File)

        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QStatusBar(MainWindow)
        self.statusbar.setObjectName(u"statusbar")

        self.timer=QTimer()
        self.timer.timeout.connect(lambda : self.showFrame(self.image_stack[-1]) ) 
        self.timer.start(1)

        MainWindow.setStatusBar(self.statusbar)

        self.menubar.addAction(self.menuNew_File.menuAction())
        #self.menubar.addAction(self.menuSave.menuAction())

        self.retranslateUi(MainWindow)

        QMetaObject.connectSlotsByName(MainWindow)
    # setupUi

    def retranslateUi(self, MainWindow):
        MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"MainWindow", None))
        self.label.setText(QCoreApplication.translate("MainWindow", u"<html><head/><body style=\"background-color:powderblue;\"><p align=\"center\">Your Image Here</p></body></html>", None))

        __sortingEnabled = self.listWidget.isSortingEnabled()
        self.listWidget.setSortingEnabled(False)
        ___qlistwidgetitem = self.listWidget.item(0)
        ___qlistwidgetitem.setText(QCoreApplication.translate("MainWindow", u"Brightness", None));
        ___qlistwidgetitem1 = self.listWidget.item(1)
        ___qlistwidgetitem1.setText(QCoreApplication.translate("MainWindow", u"Saturation", None));
        ___qlistwidgetitem2 = self.listWidget.item(2)
        ___qlistwidgetitem2.setText(QCoreApplication.translate("MainWindow", u"Sharpen", None));
        ___qlistwidgetitem3 = self.listWidget.item(3)
        ___qlistwidgetitem3.setText(QCoreApplication.translate("MainWindow", u"Sepia Effect", None));
        ___qlistwidgetitem4 = self.listWidget.item(4)
        ___qlistwidgetitem4.setText(QCoreApplication.translate("MainWindow", u"Warm", None));
        ___qlistwidgetitem5 = self.listWidget.item(5)
        ___qlistwidgetitem5.setText(QCoreApplication.translate("MainWindow", u"Cold", None));
        ___qlistwidgetitem6 = self.listWidget.item(6)
        ___qlistwidgetitem6.setText(QCoreApplication.translate("MainWindow", u"Equalize", None));
        ___qlistwidgetitem7 = self.listWidget.item(7)
        ___qlistwidgetitem7.setText(QCoreApplication.translate("MainWindow", u"Cartoon", None));
        ___qlistwidgetitem8 = self.listWidget.item(8)
        ___qlistwidgetitem8.setText(QCoreApplication.translate("MainWindow", u"Blurring", None)); 
        ___qlistwidgetitem9 = self.listWidget.item(9)
        ___qlistwidgetitem9.setText(QCoreApplication.translate("MainWindow", u"Pencil Sketch", None)); 
        ___qlistwidgetitem10 = self.listWidget.item(10)
        ___qlistwidgetitem10.setText(QCoreApplication.translate("MainWindow", u"Noise Reduction", None));
        ___qlistwidgetitem11 = self.listWidget.item(11)
        ___qlistwidgetitem11.setText(QCoreApplication.translate("MainWindow", u"Negetive", None));
        ___qlistwidgetitem12 = self.listWidget.item(12)
        ___qlistwidgetitem12.setText(QCoreApplication.translate("MainWindow", u"Vignette", None));  #"Redden" "Greenify" "Bloom Blue" "HDR" "Bass"
        ___qlistwidgetitem13 = self.listWidget.item(13)
        ___qlistwidgetitem13.setText(QCoreApplication.translate("MainWindow", u"Emboss", None)); 
        ___qlistwidgetitem14 = self.listWidget.item(14)
        ___qlistwidgetitem14.setText(QCoreApplication.translate("MainWindow", u"Redden", None));
        ___qlistwidgetitem15 = self.listWidget.item(15)
        ___qlistwidgetitem15.setText(QCoreApplication.translate("MainWindow", u"Greenify", None));
        ___qlistwidgetitem16 = self.listWidget.item(16)
        ___qlistwidgetitem16.setText(QCoreApplication.translate("MainWindow", u"Bloom Blue", None));
        ___qlistwidgetitem17 = self.listWidget.item(17)
        ___qlistwidgetitem17.setText(QCoreApplication.translate("MainWindow", u"HDR", None));
        ___qlistwidgetitem18 = self.listWidget.item(18)
        ___qlistwidgetitem18.setText(QCoreApplication.translate("MainWindow", u"Yellow", None));
        self.listWidget.setSortingEnabled(__sortingEnabled)

        self.label_2.setText(QCoreApplication.translate("MainWindow", u"<html><head/><body><p><span style=\" font-size:11pt;\">Amount%</span></p></body></html>", None))
        self.pushButton.setText(QCoreApplication.translate("MainWindow", u"\u2705 ", None))
        self.pushButton_2.setText(QCoreApplication.translate("MainWindow", u"\u274c", None))
        self.pushButton_3.setText(QCoreApplication.translate("MainWindow", u"\u21a9\ufe0f", None))
        self.pushButton_4.setText(QCoreApplication.translate("MainWindow", u"Crop", None))
        self.pushButton_5.setText(QCoreApplication.translate("MainWindow", u"Resize", None))
        self.menuNew_File.setTitle(QCoreApplication.translate("MainWindow", u"File", None))
Esempio n. 15
0
 def testBasic(self):
     '''QMenuBar.addAction(id, callback)'''
     menubar = QMenuBar()
     action = menubar.addAction("Accounts", self._callback)
     action.activate(QAction.Trigger)
     self.assert_(self.called)
Esempio n. 16
0
 def testBasic(self):
     '''QMenuBar.addAction(id, callback)'''
     menubar = QMenuBar()
     action = menubar.addAction("Accounts", self._callback)
     action.activate(QAction.Trigger)
     self.assertTrue(self.called)
Esempio n. 17
0
class MainWindow(QMainWindow):
    """Main application window."""
    def __init__(self, context=None, parent=None):
        super().__init__(parent)
        context = context or Context()

        self._manager = Manager(context)

        # Build top menu
        self.action_new = QAction("New", self)
        self.action_save = QAction("Save", self)
        self.action_open = QAction("Open", self)
        self.action_save_as = QAction("Save As", self)
        self.action_quit = QAction("Quit", self)
        self.action_show_artists = QAction("Artists", self)
        self.action_show_artists.setCheckable(True)
        self.action_show_artists.setChecked(True)
        self.action_show_tasks = QAction("Tasks", self)
        self.action_show_tasks.setCheckable(True)
        self.action_show_tasks.setChecked(True)
        self.action_show_taskgroups = QAction("Task Groups", self)
        self.action_show_taskgroups.setCheckable(True)
        self.action_show_settings = QAction("Settings", self)
        self.action_show_settings.setCheckable(True)
        self.action_show_scores = QAction("Score", self)
        self.action_show_scores.setCheckable(True)

        self.menubar = QMenuBar(self)
        self.menu_file = QMenu("File", self.menubar)
        self.menu_view = QMenu("View", self.menubar)
        self.menubar.addAction(self.menu_file.menuAction())
        self.menubar.addAction(self.menu_view.menuAction())
        self.menu_file.addAction(self.action_new)
        self.menu_file.addAction(self.action_open)
        self.menu_file.addAction(self.action_save)
        self.menu_file.addAction(self.action_save_as)
        self.menu_file.addSeparator()
        self.menu_view.addAction(self.action_show_artists)
        self.menu_view.addAction(self.action_show_tasks)
        self.menu_view.addAction(self.action_show_taskgroups)
        self.menu_view.addAction(self.action_show_settings)
        self.menu_view.addAction(self.action_show_scores)
        self.setMenuBar(self.menubar)

        # Build dock widgets
        self.widget_artists = ArtistsWidget(self, self._manager)
        self.widget_tasks = TasksWidget(self, self._manager)
        self.widget_settings = SettingsWidget(self, self._manager)
        self.widget_scores = ScoresWidget(self)
        self.widget_tasksgroups = TasksGroupsWidget(self, self._manager,
                                                    self.widget_tasks)
        self.widget_gantt = GanttWidget(
            self,
            self._manager,
            self.widget_artists.model,
            self.widget_tasks.model,
            self.widget_artists.table.selectionModel(),
            self.widget_tasks.table.selectionModel(),
        )
        self.widget_footer = FooterBarWidget(self, self._manager)

        self.addDockWidget(Qt.RightDockWidgetArea, self.widget_artists)
        self.addDockWidget(Qt.RightDockWidgetArea, self.widget_tasks)
        self.addDockWidget(Qt.RightDockWidgetArea, self.widget_tasksgroups)
        self.addDockWidget(Qt.LeftDockWidgetArea, self.widget_gantt)
        self.addDockWidget(Qt.LeftDockWidgetArea, self.widget_scores)
        self.addDockWidget(Qt.LeftDockWidgetArea, self.widget_settings)
        self.addToolBar(Qt.BottomToolBarArea, self.widget_footer)

        # Connect events
        self.widget_footer.actionPlay.connect(self._manager.play)
        self.widget_footer.actionStop.connect(self._manager.stop)
        self.widget_footer.actionLiveModeToggle.connect(
            self.on_autosolve_changed)
        self._manager.onSolutionFound.connect(self.on_solution_found)
        self._manager.onContextChanged.connect(self.on_context_changed)
        self._manager.onDirty.connect(self.on_dirty)
        self.action_new.triggered.connect(self.file_new)
        self.action_open.triggered.connect(self.file_open)
        self.action_save.triggered.connect(self.file_save)
        self.action_save_as.triggered.connect(self.file_save_as)
        self.widget_artists.artistDeleted.connect(self._on_artist_deleted)
        self.widget_tasks.taskDeleted.connect(self._on_task_deleted)

        for action, widget in (
            (self.action_show_artists, self.widget_artists),
            (self.action_show_tasks, self.widget_tasks),
            (self.action_show_taskgroups, self.widget_tasksgroups),
            (self.action_show_settings, self.widget_settings),
            (self.action_show_scores, self.widget_scores),
        ):
            widget.setVisible(action.isChecked())
            action.toggled.connect(widget.setVisible)

        self.shortcut = QShortcut(QKeySequence("Space"), self)
        self.shortcut.activated.connect(self._manager.toogle)

        self._manager.restore_autosave()
        self._update_window_title()

    def _update_window_title(self):
        title = "csp4cg"
        if self._manager.path:
            title += f": {self._manager.path}"
        if self._manager.dirty:
            title += " *"
        self.setWindowTitle(title)

    def on_dirty(self, state):
        """Called when solver related data change."""
        self.widget_footer.set_dirty(state)
        self._update_window_title()

    def on_context_changed(self, context: Context):
        """Called when the current context change."""
        self.widget_artists.model.set_context(context)
        self.widget_tasks.model.set_context(context)
        self.widget_tasksgroups.model.set_context(context)
        self.widget_settings.model.set_settings(context.settings)

    def on_autosolve_changed(self, state):
        """Called when the "Live" checkbox state change."""
        self._manager.auto_solve = bool(state)

    def file_new(self):
        """Clear the current session."""
        self._manager.set_context(Context())
        self._update_window_title()

    def file_open(self):
        """Open a saved session."""
        path = show_open_dialog(self, "Load Session", "Session (*.yml)")
        if not path:
            return

        self._manager.open(path)
        self._update_window_title()

    def file_save(self):
        """Save the session to the current file."""
        if not self._manager.path:
            self.file_save_as()
        else:
            self._manager.save()
        self._update_window_title()

    def file_save_as(self):
        """Save the session to a new file."""
        path = show_save_dialog(self, "Save Session", "Session (*.yml)")
        if not path:
            return
        self._manager.save_as(path)
        self._update_window_title()

    def _on_artist_deleted(self):
        """Called when an artist is deleted. Reset related models."""
        for model in (self.widget_tasks.model, self.widget_tasksgroups.model):
            model.beginResetModel()
            model.resetInternalData()
            model.endResetModel()

    def _on_task_deleted(self):
        """Called when a task is deleted. Reset related models."""
        for model in (self.widget_tasksgroups.model, ):
            model.beginResetModel()
            model.resetInternalData()
            model.endResetModel()

    def on_solution_found(self):
        """Called when the solver found a solution."""
        self.widget_tasks.model.beginResetModel()
        self.widget_tasks.model.resetInternalData()
        self.widget_tasks.model.endResetModel()
        self.widget_scores.model.set_scores(self._manager.statistics)
Esempio n. 18
0
class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.resize(1280, 720)
        self.central_widget = QWidget(MainWindow)

        self.splitter = QSplitter(self.central_widget)
        self.splitter.setChildrenCollapsible(False)
        self.splitter.setOpaqueResize(True)

        self.main_grid_layout = QGridLayout(self.central_widget)
        self.main_grid_layout.addWidget(self.splitter)
        self.main_grid_layout.setSizeConstraint(QLayout.SetDefaultConstraint)

        self.tab_widget = QTabWidget(self.central_widget)
        self.tab_widget.setMinimumSize(QSize(500, 0))
        self._set_up_component_tree_view()
        self.splitter.addWidget(self.tab_widget)

        self._set_up_3d_view()

        MainWindow.setCentralWidget(self.central_widget)

        self._set_up_menus(MainWindow)
        self.tab_widget.setCurrentIndex(0)
        QMetaObject.connectSlotsByName(MainWindow)
        self.splitter.setStretchFactor(0, 0)
        self.splitter.setStretchFactor(1, 1)

    def _set_up_3d_view(self):
        self.sceneWidget.setMinimumSize(QSize(600, 0))
        self.splitter.addWidget(self.sceneWidget)

    def _set_up_component_tree_view(self):
        self.sceneWidget = InstrumentView(self.splitter)
        self.component_tree_view_tab = ComponentTreeViewTab(
            scene_widget=self.sceneWidget, parent=self
        )
        self.tab_widget.addTab(self.component_tree_view_tab, "")

    def _set_up_menus(self, MainWindow: QObject):
        self.menu_bar = QMenuBar()
        self.menu_bar.setGeometry(QRect(0, 0, 1280, 720))
        self.file_menu = QMenu(self.menu_bar)
        MainWindow.setMenuBar(self.menu_bar)
        self.status_bar = QStatusBar(MainWindow)
        MainWindow.setStatusBar(self.status_bar)
        self.open_json_file_action = QAction(MainWindow)
        self.open_json_file_action.setShortcut(QKeySequence("Ctrl+O"))
        self.export_to_filewriter_JSON_action = QAction(MainWindow)
        self.export_to_filewriter_JSON_action.setShortcut(QKeySequence("Ctrl+S"))
        self.file_menu.addAction(self.open_json_file_action)
        self.file_menu.addAction(self.export_to_filewriter_JSON_action)

        self.view_menu = QMenu(self.menu_bar)
        self.show_action_labels = QAction(MainWindow)
        self.show_action_labels.setCheckable(True)
        self.show_action_labels.setChecked(True)
        self.simple_tree_view = QAction(MainWindow)
        self.simple_tree_view.setCheckable(True)
        self.about_window = QAction(MainWindow)
        self.view_menu.addAction(self.about_window)
        self.view_menu.addAction(self.show_action_labels)
        self.view_menu.addAction(self.simple_tree_view)

        self.menu_bar.addAction(self.file_menu.menuAction())
        self.menu_bar.addAction(self.view_menu.menuAction())
        self._set_up_titles(MainWindow)

    def _set_up_titles(self, MainWindow):
        MainWindow.setWindowTitle("NeXus Constructor")
        self.tab_widget.setTabText(
            self.tab_widget.indexOf(self.component_tree_view_tab), "Nexus Structure"
        )
        self.file_menu.setTitle("File")
        self.open_json_file_action.setText("Open File writer JSON file")
        self.export_to_filewriter_JSON_action.setText("Export to File writer JSON")

        self.view_menu.setTitle("View")
        self.show_action_labels.setText("Show Button Labels")
        self.simple_tree_view.setText("Use Simple Tree Model View")
        self.about_window.setText("About")

        self.menu_bar.setNativeMenuBar(False)
Esempio n. 19
0
class MainWindow(QMainWindow):
    def __init__(self, title="", icon="", object_name="MainWindow"):
        """
        Template for main window that sets window size and placement, creates menu and status bars, and handles menu
        signals.
    
        :param title: str; Name to be displayed at the top of the window
        :param icon: str; file path to icon image file
        :param object_name: str; Name of main window object
        """

        super().__init__()
        self.setObjectName(object_name)
        self.screen = QDesktopWidget().availableGeometry()
        self.setup_template(title)
        if icon:
            self.setWindowIcon(QIcon(icon))
        self.menu_list = self.menu()
        self.menu_bar = QMenuBar(self)
        self.menu_heads = {}
        self.menu_items = {}
        self.setup_menu(object_name)
        self.menu_signals()
        self.status_bar = QStatusBar(self)
        self.setStatusBar(self.status_bar)

    def menu(self):
        """
        Re-implement this function to define the window menu

        Lists all of the menu operations available in formats:
        {"Menu head": ["Menu item"]}
        {"Menu head 1": ["Menu item under 1"], "Menu head 2": ["Menu item under 2"]}
        {"Menu head": ["Menu item 1", "Menu item 2"]}
        {"Menu head": [["Menu item 1, ["Menu subitem 1", "Menu subitem 2"]], "Menu item 2"]}
        Notice that if subitems are desired, the format is to replace "Menu item" with ["Menu item", [subitems]]
        For a line between menu items, specify five dashes, e.g. {"Menu head": ["Menu item 1", "-----", "Menu item 2"]}
        """

        menu = {
            "File": ["Close"],
            "Example": [
                "Item", ["Item with subitems", ["Subitem 1", "Subitem 2"]],
                "-----", "Another item"
            ]
        }
        return menu

    def menu_operations(self, head, item, subitem=None):
        """
        Re-implement this function to define what happens when each menu item is selected.
        
        :param head: str, menu head name as defined in self.menu()
        :param item: str, menu item name as defined in self.menu()
        :param head: str, menu subitem name, if applicable, as defined in self.menu()
        """

        if head == "File":
            if item == "Close":
                self.close()

    def setup_template(self, title):
        """Sets up window size and title"""

        self.resize(self.screen.width() - 150,
                    self.screen.height() -
                    150)  # Sets window size 150 px from screen edge
        self.centre_on_screen()
        self.setWindowTitle(title)

    def centre_on_screen(self):
        """Centers the screen on the desktop"""

        centre = self.screen.center()
        x, y = centre.x() - self.size().width() / 2, centre.y(
        ) - self.size().height() / 2
        x = 0 if x < 0 else x
        y = 0 if y < 0 else y
        self.move(x, y)

    def menu_signals(self):
        """Interprets the selection of a menu item or subitem and sends the appropriate signal via menu_connections"""

        for head, option in self.menu_items.items():
            for item, widget in option.items():
                if type(
                        widget
                ) == list:  # Open a side menu for any menu item with a list of subitems
                    for subitem, subwidget in widget[1].items():
                        subwidget.triggered.connect(
                            self.menu_connections(head, item, subitem))
                else:
                    widget.triggered.connect(self.menu_connections(head, item))

    def menu_connections(self, head, item, subitem=None):
        """Redirects menu signals to the menu_operations function in the main window class. Leave this."""
        return lambda: self.menu_operations(head, item, subitem)

    def setup_menu(self, object_name):
        """Builds a dictionary of menu item instances based on the menu items specified in menu method"""

        for head, items in self.menu_list.items():
            self.menu_heads[head] = QMenu(self.menu_bar)
            self.menu_bar.addAction(self.menu_heads[head].menuAction())
            self.menu_items[head] = {}
            for item in items:
                if type(item) == str:
                    if item == "-----":
                        self.menu_heads[head].addSeparator()
                    else:
                        self.menu_items[head][item] = QAction(self)
                        self.menu_heads[head].addAction(
                            self.menu_items[head][item])
                elif type(item) == list:
                    root = item[0]
                    self.menu_items[head][root] = []
                    self.menu_items[head][root].append(
                        QMenu(self.menu_heads[head]))
                    self.menu_heads[head].addAction(
                        self.menu_items[head][root][0].menuAction())
                    self.menu_items[head][root].append({})
                    for subitem in item[1]:
                        self.menu_items[head][root][1][subitem] = QAction(self)
                        self.menu_items[head][root][0].addAction(
                            self.menu_items[head][root][1][subitem])

        self.setMenuBar(self.menu_bar)

        _translate = QCoreApplication.translate
        for menu_head, widget in self.menu_heads.items():
            widget.setTitle(_translate(object_name, menu_head))
        for menu_head, menu_item in self.menu_items.items():
            for item, widget in menu_item.items():
                if type(widget) == list:
                    widget[0].setTitle(_translate(object_name, item))
                    for subitem, subwidget in widget[1].items():
                        subwidget.setText(_translate(object_name, subitem))
                else:
                    if item != '-----':
                        widget.setText(_translate(object_name, item))
Esempio n. 20
0
class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.resize(1280, 720)
        self.central_widget = QWidget(MainWindow)

        self.splitter = QSplitter(self.central_widget)
        self.splitter.setChildrenCollapsible(False)
        self.splitter.setOpaqueResize(True)

        self.main_grid_layout = QGridLayout(self.central_widget)
        self.main_grid_layout.addWidget(self.splitter)
        self.main_grid_layout.setSizeConstraint(QLayout.SetDefaultConstraint)

        self.tab_widget = QTabWidget(self.central_widget)
        self.tab_widget.setMinimumSize(QSize(500, 0))
        self._set_up_component_tree_view()
        self._set_up_silx_view()
        self.splitter.addWidget(self.tab_widget)

        self._set_up_3d_view()

        MainWindow.setCentralWidget(self.central_widget)

        self._set_up_menus(MainWindow)
        self.tab_widget.setCurrentIndex(0)
        QMetaObject.connectSlotsByName(MainWindow)
        self.splitter.setStretchFactor(0, 0)
        self.splitter.setStretchFactor(1, 1)

    def _set_up_3d_view(self):
        self.sceneWidget = InstrumentView(self.splitter)
        self.sceneWidget.setMinimumSize(QSize(600, 0))
        self.splitter.addWidget(self.sceneWidget)

    def _set_up_silx_view(self):
        self.silx_tab = QWidget()
        self.silx_tab_layout = QGridLayout(self.silx_tab)
        self.tab_widget.addTab(self.silx_tab, "")

    def _set_up_component_tree_view(self):
        self.component_tree_view_tab = ComponentTreeViewTab(parent=self)
        self.tab_widget.addTab(self.component_tree_view_tab, "")

    def _set_up_menus(self, MainWindow):
        self.menu_bar = QMenuBar()
        self.menu_bar.setGeometry(QRect(0, 0, 1280, 720))
        self.file_menu = QMenu(self.menu_bar)
        MainWindow.setMenuBar(self.menu_bar)
        self.status_bar = QStatusBar(MainWindow)
        MainWindow.setStatusBar(self.status_bar)
        self.open_nexus_file_action = QAction(MainWindow)
        self.open_json_file_action = QAction(MainWindow)
        self.open_idf_file_action = QAction(MainWindow)
        self.export_to_nexus_file_action = QAction(MainWindow)
        self.export_to_filewriter_JSON_action = QAction(MainWindow)
        self.export_to_forwarder_JSON_action = QAction(MainWindow)
        self.file_menu.addAction(self.open_nexus_file_action)
        self.file_menu.addAction(self.open_json_file_action)
        self.file_menu.addAction(self.open_idf_file_action)
        self.file_menu.addAction(self.export_to_nexus_file_action)
        self.file_menu.addAction(self.export_to_filewriter_JSON_action)
        self.file_menu.addAction(self.export_to_forwarder_JSON_action)
        self.menu_bar.addAction(self.file_menu.menuAction())
        self._set_up_titles(MainWindow)

    def _set_up_titles(self, MainWindow):
        MainWindow.setWindowTitle("NeXus Constructor")
        self.tab_widget.setTabText(
            self.tab_widget.indexOf(self.component_tree_view_tab), "Components"
        )
        self.tab_widget.setTabText(
            self.tab_widget.indexOf(self.silx_tab), "NeXus File Layout"
        )
        self.file_menu.setTitle("File")
        self.open_nexus_file_action.setText("Open NeXus file")
        self.open_json_file_action.setText("Open Filewriter JSON file")

        self.open_idf_file_action.setText("Open Mantid IDF file")
        self.export_to_nexus_file_action.setText("Export to NeXus file")
        self.export_to_filewriter_JSON_action.setText("Export to Filewriter JSON")
        self.export_to_forwarder_JSON_action.setText("Export to Forwarder JSON")
Esempio n. 21
0
class MainWindow(QMainWindow):
    def __init__(self, *args, **kwargs):
        super(MainWindow, self).__init__(*args, **kwargs)
        self.setupUi(self)

        # Setup numbers.
        for n in range(0, 10):
            getattr(self, 'pushButton_n%s' % n).pressed.connect(lambda v=n: self.input_number(v))

        # Setup operations.
        self.pushButton_add.pressed.connect(lambda: self.operation(operator.add))
        self.pushButton_sub.pressed.connect(lambda: self.operation(operator.sub))
        self.pushButton_mul.pressed.connect(lambda: self.operation(operator.mul))
        self.pushButton_div.pressed.connect(lambda: self.operation(operator.truediv))  # operator.div for Python2.7

        self.pushButton_pc.pressed.connect(self.operation_pc)
        self.pushButton_eq.pressed.connect(self.equals)

        # Setup actions
        self.actionReset.triggered.connect(self.reset)
        self.pushButton_ac.pressed.connect(self.reset)

        self.actionExit.triggered.connect(self.close)

        self.pushButton_m.pressed.connect(self.memory_store)
        self.pushButton_mr.pressed.connect(self.memory_recall)

        self.memory = 0
        self.reset()

        self.show()

    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(484, 433)
        self.centralWidget = QWidget(MainWindow)
        sizePolicy = QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.centralWidget.sizePolicy().hasHeightForWidth())
        self.centralWidget.setSizePolicy(sizePolicy)
        self.centralWidget.setObjectName("centralWidget")
        self.verticalLayout_2 = QVBoxLayout(self.centralWidget)
        self.verticalLayout_2.setContentsMargins(11, 11, 11, 11)
        self.verticalLayout_2.setSpacing(6)
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        self.verticalLayout = QVBoxLayout()
        self.verticalLayout.setSpacing(6)
        self.verticalLayout.setObjectName("verticalLayout")
        self.lcdNumber = QLCDNumber(self.centralWidget)
        self.lcdNumber.setDigitCount(10)
        self.lcdNumber.setObjectName("lcdNumber")
        self.verticalLayout.addWidget(self.lcdNumber)
        self.gridLayout = QGridLayout()
        self.gridLayout.setSpacing(6)
        self.gridLayout.setObjectName("gridLayout")
        self.pushButton_n4 = QPushButton(self.centralWidget)
        self.pushButton_n4.setMinimumSize(QSize(0, 50))
        font = QFont()
        font.setPointSize(27)
        font.setBold(True)
        font.setWeight(75)
        self.pushButton_n4.setFont(font)
        self.pushButton_n4.setStyleSheet("QPushButton {\n"
"color: #1976D2;\n"
"}")
        self.pushButton_n4.setObjectName("pushButton_n4")
        self.gridLayout.addWidget(self.pushButton_n4, 3, 0, 1, 1)
        self.pushButton_n1 = QPushButton(self.centralWidget)
        self.pushButton_n1.setMinimumSize(QSize(0, 50))
        font = QFont()
        font.setPointSize(27)
        font.setBold(True)
        font.setWeight(75)
        self.pushButton_n1.setFont(font)
        self.pushButton_n1.setStyleSheet("QPushButton {\n"
"color: #1976D2;\n"
"}")
        self.pushButton_n1.setObjectName("pushButton_n1")
        self.gridLayout.addWidget(self.pushButton_n1, 4, 0, 1, 1)
        self.pushButton_n8 = QPushButton(self.centralWidget)
        self.pushButton_n8.setMinimumSize(QSize(0, 50))
        font = QFont()
        font.setPointSize(27)
        font.setBold(True)
        font.setWeight(75)
        self.pushButton_n8.setFont(font)
        self.pushButton_n8.setStyleSheet("QPushButton {\n"
"color: #1976D2;\n"
"}")
        self.pushButton_n8.setObjectName("pushButton_n8")
        self.gridLayout.addWidget(self.pushButton_n8, 2, 1, 1, 1)
        self.pushButton_mul = QPushButton(self.centralWidget)
        self.pushButton_mul.setMinimumSize(QSize(0, 50))
        font = QFont()
        font.setPointSize(27)
        font.setBold(False)
        font.setWeight(50)
        self.pushButton_mul.setFont(font)
        self.pushButton_mul.setObjectName("pushButton_mul")
        self.gridLayout.addWidget(self.pushButton_mul, 2, 3, 1, 1)
        self.pushButton_n7 = QPushButton(self.centralWidget)
        self.pushButton_n7.setMinimumSize(QSize(0, 50))
        font = QFont()
        font.setPointSize(27)
        font.setBold(True)
        font.setWeight(75)
        self.pushButton_n7.setFont(font)
        self.pushButton_n7.setStyleSheet("QPushButton {\n"
"color: #1976D2;\n"
"}")
        self.pushButton_n7.setObjectName("pushButton_n7")
        self.gridLayout.addWidget(self.pushButton_n7, 2, 0, 1, 1)
        self.pushButton_n6 = QPushButton(self.centralWidget)
        self.pushButton_n6.setMinimumSize(QSize(0, 50))
        font = QFont()
        font.setPointSize(27)
        font.setBold(True)
        font.setWeight(75)
        self.pushButton_n6.setFont(font)
        self.pushButton_n6.setStyleSheet("QPushButton {\n"
"color: #1976D2;\n"
"}")
        self.pushButton_n6.setObjectName("pushButton_n6")
        self.gridLayout.addWidget(self.pushButton_n6, 3, 2, 1, 1)
        self.pushButton_n5 = QPushButton(self.centralWidget)
        self.pushButton_n5.setMinimumSize(QSize(0, 50))
        font = QFont()
        font.setPointSize(27)
        font.setBold(True)
        font.setWeight(75)
        self.pushButton_n5.setFont(font)
        self.pushButton_n5.setStyleSheet("QPushButton {\n"
"color: #1976D2;\n"
"}")
        self.pushButton_n5.setObjectName("pushButton_n5")
        self.gridLayout.addWidget(self.pushButton_n5, 3, 1, 1, 1)
        self.pushButton_n0 = QPushButton(self.centralWidget)
        self.pushButton_n0.setMinimumSize(QSize(0, 50))
        font = QFont()
        font.setPointSize(27)
        font.setBold(True)
        font.setWeight(75)
        self.pushButton_n0.setFont(font)
        self.pushButton_n0.setStyleSheet("QPushButton {\n"
"color: #1976D2;\n"
"}")
        self.pushButton_n0.setObjectName("pushButton_n0")
        self.gridLayout.addWidget(self.pushButton_n0, 5, 0, 1, 1)
        self.pushButton_n2 = QPushButton(self.centralWidget)
        self.pushButton_n2.setMinimumSize(QSize(0, 50))
        font = QFont()
        font.setPointSize(27)
        font.setBold(True)
        font.setWeight(75)
        self.pushButton_n2.setFont(font)
        self.pushButton_n2.setStyleSheet("QPushButton {\n"
"color: #1976D2;\n"
"}")
        self.pushButton_n2.setObjectName("pushButton_n2")
        self.gridLayout.addWidget(self.pushButton_n2, 4, 1, 1, 1)
        self.pushButton_n9 = QPushButton(self.centralWidget)
        self.pushButton_n9.setMinimumSize(QSize(0, 50))
        font = QFont()
        font.setPointSize(27)
        font.setBold(True)
        font.setWeight(75)
        self.pushButton_n9.setFont(font)
        self.pushButton_n9.setStyleSheet("QPushButton {\n"
"color: #1976D2;\n"
"}")
        self.pushButton_n9.setObjectName("pushButton_n9")
        self.gridLayout.addWidget(self.pushButton_n9, 2, 2, 1, 1)
        self.pushButton_n3 = QPushButton(self.centralWidget)
        self.pushButton_n3.setMinimumSize(QSize(0, 50))
        font = QFont()
        font.setPointSize(27)
        font.setBold(True)
        font.setWeight(75)
        self.pushButton_n3.setFont(font)
        self.pushButton_n3.setStyleSheet("QPushButton {\n"
"color: #1976D2;\n"
"}")
        self.pushButton_n3.setObjectName("pushButton_n3")
        self.gridLayout.addWidget(self.pushButton_n3, 4, 2, 1, 1)
        self.pushButton_div = QPushButton(self.centralWidget)
        self.pushButton_div.setMinimumSize(QSize(0, 50))
        font = QFont()
        font.setPointSize(27)
        font.setBold(False)
        font.setWeight(50)
        self.pushButton_div.setFont(font)
        self.pushButton_div.setObjectName("pushButton_div")
        self.gridLayout.addWidget(self.pushButton_div, 1, 3, 1, 1)
        self.pushButton_sub = QPushButton(self.centralWidget)
        self.pushButton_sub.setMinimumSize(QSize(0, 50))
        font = QFont()
        font.setPointSize(27)
        font.setBold(False)
        font.setWeight(50)
        self.pushButton_sub.setFont(font)
        self.pushButton_sub.setObjectName("pushButton_sub")
        self.gridLayout.addWidget(self.pushButton_sub, 3, 3, 1, 1)
        self.pushButton_add = QPushButton(self.centralWidget)
        self.pushButton_add.setMinimumSize(QSize(0, 50))
        font = QFont()
        font.setPointSize(27)
        font.setBold(False)
        font.setWeight(50)
        self.pushButton_add.setFont(font)
        self.pushButton_add.setObjectName("pushButton_add")
        self.gridLayout.addWidget(self.pushButton_add, 4, 3, 1, 1)
        self.pushButton_ac = QPushButton(self.centralWidget)
        self.pushButton_ac.setMinimumSize(QSize(0, 50))
        font = QFont()
        font.setPointSize(27)
        font.setBold(False)
        font.setWeight(50)
        self.pushButton_ac.setFont(font)
        self.pushButton_ac.setStyleSheet("QPushButton {\n"
"    color: #f44336;\n"
"}")
        self.pushButton_ac.setObjectName("pushButton_ac")
        self.gridLayout.addWidget(self.pushButton_ac, 1, 0, 1, 1)
        self.pushButton_mr = QPushButton(self.centralWidget)
        self.pushButton_mr.setMinimumSize(QSize(0, 50))
        font = QFont()
        font.setPointSize(27)
        font.setBold(False)
        font.setWeight(50)
        self.pushButton_mr.setFont(font)
        self.pushButton_mr.setStyleSheet("QPushButton {\n"
"   color: #FFC107;\n"
"}")
        self.pushButton_mr.setObjectName("pushButton_mr")
        self.gridLayout.addWidget(self.pushButton_mr, 1, 2, 1, 1)
        self.pushButton_m = QPushButton(self.centralWidget)
        self.pushButton_m.setMinimumSize(QSize(0, 50))
        font = QFont()
        font.setPointSize(27)
        font.setBold(False)
        font.setWeight(50)
        self.pushButton_m.setFont(font)
        self.pushButton_m.setStyleSheet("QPushButton {\n"
"   color: #FFC107;\n"
"}")
        self.pushButton_m.setObjectName("pushButton_m")
        self.gridLayout.addWidget(self.pushButton_m, 1, 1, 1, 1)
        self.pushButton_pc = QPushButton(self.centralWidget)
        self.pushButton_pc.setMinimumSize(QSize(0, 50))
        font = QFont()
        font.setPointSize(27)
        font.setBold(False)
        font.setWeight(50)
        self.pushButton_pc.setFont(font)
        self.pushButton_pc.setObjectName("pushButton_pc")
        self.gridLayout.addWidget(self.pushButton_pc, 5, 1, 1, 1)
        self.pushButton_eq = QPushButton(self.centralWidget)
        self.pushButton_eq.setMinimumSize(QSize(0, 50))
        font = QFont()
        font.setPointSize(27)
        font.setBold(True)
        font.setWeight(75)
        self.pushButton_eq.setFont(font)
        self.pushButton_eq.setStyleSheet("QPushButton {\n"
"color: #4CAF50;\n"
"}")
        self.pushButton_eq.setObjectName("pushButton_eq")
        self.gridLayout.addWidget(self.pushButton_eq, 5, 2, 1, 2)
        self.verticalLayout.addLayout(self.gridLayout)
        self.verticalLayout_2.addLayout(self.verticalLayout)
        MainWindow.setCentralWidget(self.centralWidget)
        self.menuBar = QMenuBar(MainWindow)
        self.menuBar.setGeometry(QRect(0, 0, 484, 22))
        self.menuBar.setObjectName("menuBar")
        self.menuFile = QMenu(self.menuBar)
        self.menuFile.setObjectName("menuFile")
        MainWindow.setMenuBar(self.menuBar)
        self.statusBar = QStatusBar(MainWindow)
        self.statusBar.setObjectName("statusBar")
        MainWindow.setStatusBar(self.statusBar)
        self.actionExit = QAction(MainWindow)
        self.actionExit.setObjectName("actionExit")
        self.actionReset = QAction(MainWindow)
        self.actionReset.setObjectName("actionReset")
        self.menuFile.addAction(self.actionReset)
        self.menuFile.addAction(self.actionExit)
        self.menuBar.addAction(self.menuFile.menuAction())

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

    def retranslateUi(self, MainWindow):
        _translate = QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "Calculon"))
        self.pushButton_n4.setText(_translate("MainWindow", "4"))
        self.pushButton_n4.setShortcut(_translate("MainWindow", "4"))
        self.pushButton_n1.setText(_translate("MainWindow", "1"))
        self.pushButton_n1.setShortcut(_translate("MainWindow", "1"))
        self.pushButton_n8.setText(_translate("MainWindow", "8"))
        self.pushButton_n8.setShortcut(_translate("MainWindow", "8"))
        self.pushButton_mul.setText(_translate("MainWindow", "x"))
        self.pushButton_mul.setShortcut(_translate("MainWindow", "*"))
        self.pushButton_n7.setText(_translate("MainWindow", "7"))
        self.pushButton_n7.setShortcut(_translate("MainWindow", "7"))
        self.pushButton_n6.setText(_translate("MainWindow", "6"))
        self.pushButton_n6.setShortcut(_translate("MainWindow", "6"))
        self.pushButton_n5.setText(_translate("MainWindow", "5"))
        self.pushButton_n5.setShortcut(_translate("MainWindow", "5"))
        self.pushButton_n0.setText(_translate("MainWindow", "0"))
        self.pushButton_n0.setShortcut(_translate("MainWindow", "0"))
        self.pushButton_n2.setText(_translate("MainWindow", "2"))
        self.pushButton_n2.setShortcut(_translate("MainWindow", "2"))
        self.pushButton_n9.setText(_translate("MainWindow", "9"))
        self.pushButton_n9.setShortcut(_translate("MainWindow", "9"))
        self.pushButton_n3.setText(_translate("MainWindow", "3"))
        self.pushButton_n3.setShortcut(_translate("MainWindow", "3"))
        self.pushButton_div.setText(_translate("MainWindow", "÷"))
        self.pushButton_div.setShortcut(_translate("MainWindow", "/"))
        self.pushButton_sub.setText(_translate("MainWindow", "-"))
        self.pushButton_sub.setShortcut(_translate("MainWindow", "-"))
        self.pushButton_add.setText(_translate("MainWindow", "+"))
        self.pushButton_add.setShortcut(_translate("MainWindow", "+"))
        self.pushButton_ac.setText(_translate("MainWindow", "AC"))
        self.pushButton_ac.setShortcut(_translate("MainWindow", "Esc"))
        self.pushButton_mr.setText(_translate("MainWindow", "MR"))
        self.pushButton_mr.setShortcut(_translate("MainWindow", "R"))
        self.pushButton_m.setText(_translate("MainWindow", "M"))
        self.pushButton_m.setShortcut(_translate("MainWindow", "M"))
        self.pushButton_pc.setText(_translate("MainWindow", "%"))
        self.pushButton_pc.setShortcut(_translate("MainWindow", "%"))
        self.pushButton_eq.setText(_translate("MainWindow", "="))
        self.pushButton_eq.setShortcut(_translate("MainWindow", "Return"))
        self.menuFile.setTitle(_translate("MainWindow", "File"))
        self.actionExit.setText(_translate("MainWindow", "Exit"))
        self.actionExit.setShortcut(_translate("MainWindow", "Ctrl+Q"))
        self.actionReset.setText(_translate("MainWindow", "Reset"))
        self.actionReset.setShortcut(_translate("MainWindow", "Ctrl+R"))


    def display(self):
        self.lcdNumber.display(self.stack[-1])

    def reset(self):
        self.state = READY
        self.stack = [0]
        self.last_operation = None
        self.current_op = None
        self.display()

    def memory_store(self):
        self.memory = self.lcdNumber.value()

    def memory_recall(self):
        self.state = INPUT
        self.stack[-1] = self.memory
        self.display()

    def input_number(self, v):
        if self.state == READY:
            self.state = INPUT
            self.stack[-1] = v
        else:
            self.stack[-1] = self.stack[-1] * 10 + v

        self.display()

    def operation(self, op):
        if self.current_op:  # Complete the current operation
            self.equals()

        self.stack.append(0)
        self.state = INPUT
        self.current_op = op

    def operation_pc(self):
        self.state = INPUT
        self.stack[-1] *= 0.01
        self.display()

    def equals(self):
        # Support to allow '=' to repeat previous operation
        # if no further input has been added.
        if self.state == READY and self.last_operation:
            s, self.current_op = self.last_operation
            self.stack.append(s)

        if self.current_op:
            self.last_operation = self.stack[-1], self.current_op

            try:
                self.stack = [self.current_op(*self.stack)]
            except Exception:
                self.lcdNumber.display('Err')
                self.stack = [0]
            else:
                self.current_op = None
                self.state = READY
                self.display()
Esempio n. 22
0
class EditorConfigWindow(QMainWindow):
    def __init__(self):
        super(EditorConfigWindow, self).__init__()
        self.started = False
        self.widget = QWidget()
        self.setupUi(self)

    def setupUi(self, MainWindow):

        if not MainWindow.objectName():
            MainWindow.setObjectName(u"MainWindow")
        MainWindow.resize(1301, 755)
        self.actionGroup_Editor = QAction(MainWindow)
        self.actionGroup_Editor.setObjectName(u"actionGroup_Editor")
        self.actionClient_Editor = QAction(MainWindow)
        self.actionClient_Editor.setObjectName(u"actionClient_Editor")
        self.actionProject_Editor = QAction(MainWindow)
        self.actionProject_Editor.setObjectName(u"actionProject_Editor")
        self.centralwidget = QWidget(MainWindow)
        self.centralwidget.setObjectName(u"centralwidget")
        self.gridLayoutWidget = QWidget(self.centralwidget)
        self.gridLayoutWidget.setObjectName(u"gridLayoutWidget")
        self.gridLayoutWidget.setGeometry(QRect(20, 70, 1261, 621))
        self.gridLayout = QGridLayout(self.gridLayoutWidget)
        self.gridLayout.setObjectName(u"gridLayout")
        self.gridLayout.setContentsMargins(0, 0, 0, 0)
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QMenuBar(MainWindow)
        self.menubar.setObjectName(u"menubar")
        self.menubar.setGeometry(QRect(0, 0, 1301, 20))
        self.menuFile = QMenu(self.menubar)
        self.menuFile.setObjectName(u"menuFile")
        self.menuEditors = QMenu(self.menubar)
        self.menuEditors.setObjectName(u"menuEditors")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QStatusBar(MainWindow)
        self.statusbar.setObjectName(u"statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.menubar.addAction(self.menuFile.menuAction())
        self.menubar.addAction(self.menuEditors.menuAction())
        self.menuEditors.addAction(self.actionGroup_Editor)
        self.menuEditors.addAction(self.actionClient_Editor)
        self.menuEditors.addAction(self.actionProject_Editor)
        self.show()
        # self.retranslateUi(MainWindow)

        QMetaObject.connectSlotsByName(MainWindow)

    # setupUi

    def retranslateUi(self, MainWindow):
        MainWindow.setWindowTitle(
            QCoreApplication.translate("MainWindow", u"MainWindow", None))
        self.actionGroup_Editor.setText(
            QCoreApplication.translate("MainWindow", u"Group Editor", None))
        self.actionClient_Editor.setText(
            QCoreApplication.translate("MainWindow", u"Client Editor", None))
        self.actionProject_Editor.setText(
            QCoreApplication.translate("MainWindow", u"Project Editor", None))
        self.menuFile.setTitle(
            QCoreApplication.translate("MainWindow", u"File", None))
        self.menuEditors.setTitle(
            QCoreApplication.translate("MainWindow", u"Editors", None))
Esempio n. 23
0
    def __init__(self, app, appname, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.hide()
        #self.setMinimumSize(640, 480)
        self.setFixedSize(self.geometry().width(), self.geometry().height())
        self.setWindowIcon(QIcon('icon.ico'))
        self.setWindowTitle(appname)

        # Create menu bar
        menu_bar = QMenuBar()

        help_menu = menu_bar.addAction('&Help')
        about_menu = menu_bar.addAction('A&bout')
        exit_menu = menu_bar.addAction('&Exit')

        self.setMenuBar(menu_bar)

        # Make interface layouts
        window = QWidget()
        layout = QVBoxLayout()

        top_section = QVBoxLayout()

        buttons = QGridLayout()
        middle_section = QHBoxLayout()

        label_section = QHBoxLayout()
        range_section = QGridLayout()
        clarity_section = QHBoxLayout()
        plot_section = QHBoxLayout()
        bottom_section = QVBoxLayout()

        status_layout = QHBoxLayout()

        # Create widgets and items
        figure = plt.figure()
        canvas = FigureCanvas(figure)

        label = QLabel(f'''Welcome to {appname}!
Plot any equation of the form y = f(x).
Use the options below to plot your own equation!''')

        help_message = QMessageBox()
        help_message.setTextFormat(Qt.RichText)
        help_message.setText(f'''<h3>Help</h3>
{appname} lets you plot any equation of the form y = f(x).
<br/>
Enter the function f(x), specify the range of x, and click Plot!
<br/><br/>
Operators : <code>+, -, *, /</code><br/>
Variable : <code>x</code><br/>
Functions : <code>sin, cos, tan</code><br/>
<code>pi</code> : π<br/>
<code>e</code> : Exponential e<br/>
<code>c</code> : Speed of Light<br/>''')
        help_message.setStandardButtons(QMessageBox.Ok)
        help_message.setWindowTitle(f'{appname} - Help')
        self.help = help_message

        help_button = QPushButton('Help...')
        help_button.clicked.connect(self.help.exec_)

        about_message = QMessageBox()
        about_message.setWindowTitle(f'{appname} - About')
        about_message.setTextFormat(Qt.RichText)
        about_message.setText(f'''<h3>About</h3>
{appname} is created in PySide2 (Qt), using \
the Matplotlib and Equation PyPI modules for plotting and parsing expressions respectively.
<br/><br/>
Created by <a href="http://paramsid.com">Param Siddharth</a>.''')
        about_message.setStandardButtons(QMessageBox.Ok)
        self.about = about_message

        about_button = QPushButton('About...')
        about_button.clicked.connect(self.about.exec_)

        expr_label = QLabel('f(x) =')
        expr_input = QLineEdit()

        range_label1 = QLabel('Minimum (x):')
        range_min = QLineEdit()
        range_label2 = QLabel('Maximum (x):')
        range_max = QLineEdit()

        clarity_label = QLabel('Clarity:')
        clarity_spinbox = QSpinBox()
        clarity_spinbox.setRange(1, 10000)
        clarity_spinbox.setValue(100)

        plot_button = QPushButton('Plot')
        plot_button.setMaximumWidth(200)

        status = QStatusBar()
        status_text = QLabel('')
        status_text.setStyleSheet('color: #999999;')

        attribution = QLabel(
            'Made with <span style="color: red;">❤</span> by <a href="http://paramsid.com">Param</a>'
        )
        attribution.setTextFormat(Qt.RichText)
        attribution.setStyleSheet('color: #555555; font-size: 20px;')
        attribution.setAlignment(Qt.AlignRight | Qt.AlignVCenter)

        help_menu.triggered.connect(self.help.exec_)
        about_menu.triggered.connect(self.about.exec_)
        exit_menu.triggered.connect(self.close)

        # Configure backend
        backmath.configure(canvas=canvas,
                           figure=figure,
                           btn=plot_button,
                           text=expr_input,
                           limits=(range_min, range_max),
                           status=status_text,
                           range_text=(range_min, range_max),
                           clarity=clarity_spinbox)

        # Finalize and display
        top_section.addWidget(canvas)

        buttons.addWidget(help_button, 0, 0, 1, 1)
        buttons.addWidget(about_button, 0, 1, 1, 1)

        middle_section.addWidget(label)
        middle_section.addLayout(buttons)

        label_section.addWidget(expr_label)
        label_section.addWidget(expr_input)

        equally_spaced = QSizePolicy(QSizePolicy.Preferred,
                                     QSizePolicy.Preferred)
        equally_spaced.setHorizontalStretch(1)

        range_label1.setSizePolicy(equally_spaced)
        range_min.setSizePolicy(equally_spaced)
        range_label2.setSizePolicy(equally_spaced)
        range_max.setSizePolicy(equally_spaced)

        range_label1.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
        range_label2.setAlignment(Qt.AlignRight | Qt.AlignVCenter)

        range_section.addWidget(range_label1, 0, 0, 1, 1)
        range_section.addWidget(range_min, 0, 1, 1, 1)
        range_section.addWidget(range_label2, 0, 2, 1, 1)
        range_section.addWidget(range_max, 0, 3, 1, 1)

        clarity_label.setAlignment(Qt.AlignRight | Qt.AlignVCenter)

        clarity_section.addWidget(clarity_label)
        clarity_section.addWidget(clarity_spinbox)

        plot_section.addWidget(plot_button)

        status.addWidget(status_text)
        status.addPermanentWidget(attribution)

        status_layout.addWidget(status)

        bottom_section.addLayout(label_section)
        bottom_section.addLayout(range_section)
        bottom_section.addLayout(clarity_section)
        bottom_section.addLayout(plot_section)

        layout.addLayout(top_section)
        layout.addLayout(middle_section)
        layout.addLayout(bottom_section)
        layout.addLayout(status_layout)

        window.setLayout(layout)
        self.setCentralWidget(window)
        self.show()

        status_text.setText('READY ')
Esempio n. 24
0
class Weather(QMainWindow):
    def __init__(self):
        super(Weather, self).__init__()

        self.resize(530, 414)
        self.setMinimumSize(QSize(530, 414))
        self.setMaximumSize(QSize(530, 414))
        self.setGeometry(800, 130, 530, 414)
        self.setFont(QFont('Roboto', 12))
        self.setWindowIcon(QIcon('arti.PNG'))
        self.setWindowTitle('Weather')

        palette = QPalette()
        palette.setColor(palette.Window, QColor('#000000'))
        palette.setColor(palette.WindowText, QColor('#FFFFFF'))
        palette.setColor(palette.Button, QColor("#00FF00"))
        palette.setColor(palette.ButtonText, QColor("#000000"))
        self.setPalette(palette)

        self.menubar = QMenuBar(self)
        self.menubar.setGeometry(0, 0, 682, 21)
        self.menubar.setFont(QFont('Roboto', 10))

        self.date_menu = QMenu(self.menubar)
        self.date_menu.setTitle(str(datetime.now().strftime('%d-%m-%Y')))

        self.setMenuBar(self.menubar)
        self.menubar.addAction(self.date_menu.menuAction())

        self.city = QLineEdit(self)
        self.city.setObjectName(u"city")
        self.city.setGeometry(QRect(10, 30, 511, 41))
        self.city.setMinimumSize(QSize(511, 41))
        self.city.setMaximumSize(QSize(511, 41))
        self.city.setPlaceholderText(
            'Enter the city name of which you want to view the weather.')
        self.city.setToolTip(
            'Enter the city name of which you want to view the weather.')

        self.celsius = QLabel(self)
        self.celsius.setGeometry(QRect(10, 90, 491, 31))

        self.fahrenheit = QLabel(self)
        self.fahrenheit.setGeometry(QRect(10, 140, 491, 31))

        self.kelvin = QLabel(self)
        self.kelvin.setGeometry(QRect(10, 190, 491, 31))

        self.pressure = QLabel(self)
        self.pressure.setGeometry(QRect(10, 240, 491, 31))

        self.humidity = QLabel(self)
        self.humidity.setGeometry(QRect(10, 290, 491, 31))

        self.description = QLabel(self)
        self.description.setGeometry(QRect(10, 340, 491, 31))

        speak('Welcome to the Weather.')

        self.city.returnPressed.connect(lambda: self.weather())
        self.city.returnPressed.connect(lambda: self.clear_text())

    def clear_text(self):
        self.city.clear()

    def weather(self):
        api_key = '28c2103624ed3df9e6093bb50632748b'
        base_url = "http://api.openweathermap.org/data/2.5/weather?"

        city_name = self.city.text()
        complete_url = base_url + "appid=" + api_key + "&q=" + city_name
        response = requests.get(complete_url)
        x = response.json()

        if x['cod'] != '404':
            y = x['main']
            current_temperature = y['temp']
            current_pressure = y['pressure']
            current_humidity = y['humidity']
            z = x['weather']
            weather_description = z[0]['description']

            self.celsius.setText('Temperature (in celsius unit) = ' +
                                 str(current_temperature - 273)[0:5])
            time.sleep(0.5)
            self.fahrenheit.setText('Temperature (in fahrenheit unit) = ' +
                                    str((current_temperature - 273) * 9 / 5 +
                                        32)[0:5])
            time.sleep(0.5)
            self.kelvin.setText('Temperature (in kelvin unit) = ' +
                                str(current_temperature)[0:5])
            time.sleep(0.5)
            self.pressure.setText('Atmospheric pressure (in hPa unit) = ' +
                                  str(current_pressure))
            time.sleep(0.5)
            self.humidity.setText('Humidity (in percentage) = ' +
                                  str(current_humidity))
            time.sleep(0.5)
            self.description.setText('Description = ' +
                                     str(weather_description))

        else:
            speak('City Not Found. Please try again.')
class Translate(QMainWindow):
    def __init__(self):
        super(Translate, self).__init__()
        self.resize(640, 480)
        self.setMinimumSize(640, 480)
        self.setMaximumSize(640, 480)
        self.setWindowTitle('Translate')
        self.setWindowIcon(QIcon('arti.PNG'))

        self.setFont(QFont('Roboto', 12))

        palette = QPalette()
        palette.setColor(palette.Window, QColor('#000000'))
        palette.setColor(palette.WindowText, QColor('#FFFFFF'))
        palette.setColor(palette.Button, QColor("#00FF00"))
        palette.setColor(palette.ButtonText, QColor("#000000"))
        self.setPalette(palette)

        self.menubar = QMenuBar(self)
        self.menubar.setGeometry(0, 0, 682, 21)
        self.menubar.setFont(QFont('Roboto', 10))

        self.date_menu = QMenu(self.menubar)
        self.date_menu.setTitle(str(datetime.now().strftime('%d-%m-%Y')))

        self.setMenuBar(self.menubar)
        self.menubar.addAction(self.date_menu.menuAction())

        self.label = QLabel(self)
        self.label.setGeometry(QRect(0, 40, 631, 91))
        self.label.setAlignment(Qt.AlignCenter)
        self.label.setText(
            'Welcome to Translate \n Tip: The language for text you enter below is always English.'
        )

        self.to_translate = QLineEdit(self)
        self.to_translate.setGeometry(QRect(10, 180, 611, 41))
        self.to_translate.setPlaceholderText('Initial Text:')

        self.label_2 = QLabel(self)
        self.label_2.setGeometry(QRect(10, 270, 151, 31))
        self.label_2.setText('Select Language -->')

        self.translate_button = QPushButton(self)
        self.translate_button.setGeometry(QRect(400, 260, 191, 51))
        self.translate_button.setCursor(QCursor(Qt.PointingHandCursor))
        self.translate_button.setText('Let\'s Translate!!')
        self.translate_button.clicked.connect(lambda: self.button_press())

        self.translated_text = QLabel(self)
        self.translated_text.setGeometry(QRect(20, 350, 601, 71))
        self.translated_text.setAlignment(Qt.AlignCenter)
        self.translated_text.setWordWrap(True)

        self.language = QComboBox(self)
        self.language.addItem("None")
        self.language.addItem("Afrikaans")  # 1
        self.language.addItem("Albanian")  # 2
        self.language.addItem("Amharic")  # 3
        self.language.addItem("Arabic")  # 4
        self.language.addItem("Armenian")  # 5
        self.language.addItem("Azerbaijani")  # 6
        self.language.addItem("Basque")  # 7
        self.language.addItem("Belarusian")  # 8
        self.language.addItem("Bengali")  # 9
        self.language.addItem("Bosnian")  # 10
        self.language.addItem("Bulgarian")  # 11
        self.language.addItem("Catalan")  # 12
        self.language.addItem("Cebuano")  # 13
        self.language.addItem("Chinese (Simplified)")  # 14
        self.language.addItem("Chinese (Traditional)")  # 15
        self.language.addItem("Corsican")  # 16
        self.language.addItem("Croatian")  # 17
        self.language.addItem("Czech")  # 18
        self.language.addItem("Danish")  # 19
        self.language.addItem("Dutch")  # 20
        self.language.addItem("English")  # 21
        self.language.addItem("Esperanto")  # 22
        self.language.addItem("Estonian")  # 23
        self.language.addItem("Finnish")  # 24
        self.language.addItem("French")  # 25
        self.language.addItem("Frisian")  # 26
        self.language.addItem("Galician")  # 27
        self.language.addItem("Georgian")  # 28
        self.language.addItem("German")  # 29
        self.language.addItem("Greek")  # 30
        self.language.addItem("Gujarati")  # 31
        self.language.addItem("Haitian Creole")  # 32
        self.language.addItem("Hausa")  # 33
        self.language.addItem("Hawaiian")  # 34
        self.language.addItem("Hebrew")  # 35
        self.language.addItem("Hindi")  # 36
        self.language.addItem("Hmong")  # 37
        self.language.addItem("Hungarian")  # 38
        self.language.addItem("Icelandic")  # 39
        self.language.addItem("Igbo")  # 40
        self.language.addItem("Indonesian")  # 41
        self.language.addItem("Irish")  # 42
        self.language.addItem("Italian")  # 43
        self.language.addItem("Japanese")  # 44
        self.language.addItem("Javanese")  # 45
        self.language.addItem("Kannada")  # 46
        self.language.addItem("Kazakh")  # 47
        self.language.addItem("Khmer")  # 48
        self.language.addItem("Kinyarwanda")  # 49
        self.language.addItem("Korean")  # 50
        self.language.addItem("Kurdish")  # 51
        self.language.addItem("Kyrgyz")  # 52
        self.language.addItem("Lao")  # 53
        self.language.addItem("Latin")  # 54
        self.language.addItem("Latvian")  # 55
        self.language.addItem("Lithuanian")  # 56
        self.language.addItem("Luxembourgish")  # 57
        self.language.addItem("Macedonian")  # 58
        self.language.addItem("Malagasy")  # 59
        self.language.addItem("Malay")  # 60
        self.language.addItem("Malayalam")  # 61
        self.language.addItem("Maltese")  # 62
        self.language.addItem("Maori")  # 63
        self.language.addItem("Marathi")  # 64
        self.language.addItem("Mongolian")  # 65
        self.language.addItem("Mayanmar (Burmese)")  # 66
        self.language.addItem("Nepali")  # 67
        self.language.addItem("Norwegian")  # 68
        self.language.addItem("Nyanja (Chichewa)")  # 69
        self.language.addItem("Odia (Oriya)")  # 70
        self.language.addItem("Pashto")  # 71
        self.language.addItem("Persian")  # 72
        self.language.addItem("Polish")  # 73
        self.language.addItem("Portugese (Portugal, Brazil)")  # 74
        self.language.addItem("Punjabi")  # 75
        self.language.addItem("Romanian")  # 76
        self.language.addItem("Russian")  # 77
        self.language.addItem("Samoan")  # 78
        self.language.addItem("Scots Gaelic")  # 79
        self.language.addItem("Serbian")  # 80
        self.language.addItem("Sesotho")  # 81
        self.language.addItem("Shona")  # 82
        self.language.addItem("Sindhi")  # 83
        self.language.addItem("Sinhala (Sinhalese)")  # 84
        self.language.addItem("Slovak")  # 85
        self.language.addItem("Slovenian")  # 86
        self.language.addItem("Somali")  # 87
        self.language.addItem("Spanish")  # 88
        self.language.addItem("Sundanese")  # 89
        self.language.addItem("Swahili")  # 90
        self.language.addItem("Swedish")  # 91
        self.language.addItem("Tagalong (Filipino)")  # 92
        self.language.addItem("Tajik")  # 93
        self.language.addItem("Tamil")  # 94
        self.language.addItem("Tatar")  # 95
        self.language.addItem("Telugu")  # 96
        self.language.addItem("Thai")  # 97
        self.language.addItem("Turkish")  # 98
        self.language.addItem("Turkmen")  # 99
        self.language.addItem("Ukrainian")  # 100
        self.language.addItem("Urdu")  # 101
        self.language.addItem("Uyghur")  # 102
        self.language.addItem("Uzbek")  # 103
        self.language.addItem("Vietnamese")  # 104
        self.language.addItem("Welsh")  # 105
        self.language.addItem("Xhosa")  # 106
        self.language.addItem("Yiddish")  # 107
        self.language.addItem("Yoruba")  # 108
        self.language.addItem("Zulu")  # 109
        self.language.setGeometry(QRect(180, 270, 171, 31))
        QMetaObject.connectSlotsByName(self)

    def translate(self, final_lang):
        self.translated_text.setText(
            str(self.translator.translate(to=str(final_lang))))

    def button_press(self):
        self.query = self.to_translate.text()
        self.translator = TextBlob(self.query)
        self.to_translate.clear()

        if self.language.currentIndex() == 0:
            self.translated_text.setText('Please choose a Language First.')

        try:
            if self.language.currentIndex() == 1:
                self.translate('af')

            elif self.language.currentIndex() == 2:
                self.translate('sq')

            elif self.language.currentIndex() == 3:
                self.translate('am')

            elif self.language.currentIndex() == 4:
                self.translate('ar')

            elif self.language.currentIndex() == 5:
                self.translate('hy')

            elif self.language.currentIndex() == 6:
                self.translate('az')

            elif self.language.currentIndex() == 7:
                self.translate('eu')

            elif self.language.currentIndex() == 8:
                self.translate('be')

            elif self.language.currentIndex() == 9:
                self.translate('bn')

            elif self.language.currentIndex() == 10:
                self.translate('bs')

            elif self.language.currentIndex() == 11:
                self.translate('bg')

            elif self.language.currentIndex() == 12:
                self.translate('ca')

            elif self.language.currentIndex() == 13:
                self.translate('ceb')

            elif self.language.currentIndex() == 14:
                try:
                    self.translate('zh-CN')
                except:
                    self.translate('zh')

            elif self.language.currentIndex() == 15:
                self.translate('zh-TW')

            elif self.language.currentIndex() == 16:
                self.translate('co')

            elif self.language.currentIndex() == 17:
                self.translate('hr')

            elif self.language.currentIndex() == 18:
                self.translate('cs')

            elif self.language.currentIndex() == 19:
                self.translate('da')

            elif self.language.currentIndex() == 20:
                self.translate('nl')

            elif self.language.currentIndex() == 21:
                self.translate('en')

            elif self.language.currentIndex() == 22:
                self.translate('eo')

            elif self.language.currentIndex() == 23:
                self.translate('et')

            elif self.language.currentIndex() == 24:
                self.translate('fi')

            elif self.language.currentIndex() == 25:
                self.translate('fr')

            elif self.language.currentIndex() == 26:
                self.translate('fy')

            elif self.language.currentIndex() == 27:
                self.translate('gl')

            elif self.language.currentIndex() == 28:
                self.translate('ka')

            elif self.language.currentIndex() == 29:
                self.translate('de')

            elif self.language.currentIndex() == 30:
                self.translate('el')

            elif self.language.currentIndex() == 31:
                self.translate('gu')

            elif self.language.currentIndex() == 32:
                self.translate('ht')

            elif self.language.currentIndex() == 33:
                self.translate('ha')

            elif self.language.currentIndex() == 34:
                self.translate('haw')

            elif self.language.currentIndex() == 35:
                try:
                    self.translate('he')
                except:
                    self.translate('iw')

            elif self.language.currentIndex() == 36:
                self.translate('hi')

            elif self.language.currentIndex() == 37:
                self.translate('hmn')

            elif self.language.currentIndex() == 38:
                self.translate('hu')

            elif self.language.currentIndex() == 39:
                self.translate('is')

            elif self.language.currentIndex() == 40:
                self.translate('ig')

            elif self.language.currentIndex() == 41:
                self.translate('id')

            elif self.language.currentIndex() == 42:
                self.translate('ga')

            elif self.language.currentIndex() == 43:
                self.translate('it')

            elif self.language.currentIndex() == 44:
                self.translate('ja')

            elif self.language.currentIndex() == 45:
                self.translate('jv')

            elif self.language.currentIndex() == 46:
                self.translate('kn')

            elif self.language.currentIndex() == 47:
                self.translate('kk')

            elif self.language.currentIndex() == 48:
                self.translate('km')

            elif self.language.currentIndex() == 49:
                self.translate('rw')

            elif self.language.currentIndex() == 50:
                self.translate('ko')

            elif self.language.currentIndex() == 51:
                self.translate('ku')

            elif self.language.currentIndex() == 52:
                self.translate('ky')

            elif self.language.currentIndex() == 53:
                self.translate('lo')

            elif self.language.currentIndex() == 54:
                self.translate('la')

            elif self.language.currentIndex() == 55:
                self.translate('lv')

            elif self.language.currentIndex() == 56:
                self.translate('lt')

            elif self.language.currentIndex() == 57:
                self.translate('lb')

            elif self.language.currentIndex() == 58:
                self.translate('mk')

            elif self.language.currentIndex() == 59:
                self.translate('mg')

            elif self.language.currentIndex() == 60:
                self.translate('ms')

            elif self.language.currentIndex() == 61:
                self.translate('ml')

            elif self.language.currentIndex() == 62:
                self.translate('mt')

            elif self.language.currentIndex() == 63:
                self.translate('mi')

            elif self.language.currentIndex() == 64:
                self.translate('mr')

            elif self.language.currentIndex() == 65:
                self.translate('mn')

            elif self.language.currentIndex() == 66:
                self.translate('my')

            elif self.language.currentIndex() == 67:
                self.translate('ne')

            elif self.language.currentIndex() == 68:
                self.translate('no')

            elif self.language.currentIndex() == 69:
                self.translate('ny')

            elif self.language.currentIndex() == 70:
                self.translate('or')

            elif self.language.currentIndex() == 71:
                self.translate('ps')

            elif self.language.currentIndex() == 72:
                self.translate('fa')

            elif self.language.currentIndex() == 73:
                self.translate('pl')

            elif self.language.currentIndex() == 74:
                self.translate('pt')

            elif self.language.currentIndex() == 75:
                self.translate('pa')

            elif self.language.currentIndex() == 76:
                self.translate('ro')

            elif self.language.currentIndex() == 77:
                self.translate('ru')

            elif self.language.currentIndex() == 78:
                self.translate('sm')

            elif self.language.currentIndex() == 79:
                self.translate('gd')

            elif self.language.currentIndex() == 80:
                self.translate('sr')

            elif self.language.currentIndex() == 81:
                self.translate('st')

            elif self.language.currentIndex() == 82:
                self.translate('sn')

            elif self.language.currentIndex() == 83:
                self.translate('sd')

            elif self.language.currentIndex() == 84:
                self.translate('si')

            elif self.language.currentIndex() == 85:
                self.translate('sk')

            elif self.language.currentIndex() == 86:
                self.translate('sl')

            elif self.language.currentIndex() == 87:
                self.translate('so')

            elif self.language.currentIndex() == 88:
                self.translate('es')

            elif self.language.currentIndex() == 89:
                self.translate('su')

            elif self.language.currentIndex() == 90:
                self.translate('sw')

            elif self.language.currentIndex() == 91:
                self.translate('sv')

            elif self.language.currentIndex() == 92:
                self.translate('tl')

            elif self.language.currentIndex() == 93:
                self.translate('tg')

            elif self.language.currentIndex() == 94:
                self.translate('ta')

            elif self.language.currentIndex() == 95:
                self.translate('tt')

            elif self.language.currentIndex() == 96:
                self.translate('te')

            elif self.language.currentIndex() == 97:
                self.translate('th')

            elif self.language.currentIndex() == 98:
                self.translate('tr')

            elif self.language.currentIndex() == 99:
                self.translate('tk')

            elif self.language.currentIndex() == 100:
                self.translate('uk')

            elif self.language.currentIndex() == 101:
                self.translate('ur')

            elif self.language.currentIndex() == 102:
                self.translate('ug')

            elif self.language.currentIndex() == 103:
                self.translate('uz')

            elif self.language.currentIndex() == 104:
                self.translate('vi')

            elif self.language.currentIndex() == 105:
                self.translate('cy')

            elif self.language.currentIndex() == 106:
                self.translate('xh')

            elif self.language.currentIndex() == 107:
                self.translate('yi')

            elif self.language.currentIndex() == 108:
                self.translate('yo')

            elif self.language.currentIndex() == 109:
                self.translate('zu')

        except:
            self.translated_text.setText(
                "An error occurred. Either the initial and final language is same or try "
                "again. \n"
                "Tip2: You cannot translate numbers; only words. 😭😭")
Esempio n. 26
0
    def __init__(self, enigma_api, cursor_handler):
        """Initializes Root QT window widgets
        :param enigma_api: {EnigmaAPI} Shared EnigmaAPI object
        """
        super().__init__()

        # QT WINDOW SETTINGS ==================================================

        self.setWindowIcon(QIcon(BASE_DIR + "enigma_200px.png"))
        main_layout = QVBoxLayout(self)
        self.setLayout(main_layout)

        # SAVE ATTRIBUTES =====================================================

        self.__enigma_api = enigma_api
        logging.info("Qt GUI initialized with EnigmaAPI settings:\n%s",
                     str(enigma_api))

        # MENU BAR ============================================================

        menu = QMenuBar(self)
        save_load_menu = menu.addMenu("Save/load settings")
        save_load_menu.addAction("Save settings", self.save_config)
        save_load_menu.addAction("Load settings", self.load_config)
        menu.addAction("Export message", self.export_message)

        # ROTORS INDICATOR ====================================================

        logging.info("Generating rotor and reflector indicators...")
        self.__rotors = _RotorsHandlerWidget(
            self,
            self.__enigma_api.positions,
            self.__enigma_api.generate_rotate_callback,
            self.__enigma_api.rotate_reflector,
            enigma_api,
            self.refresh_gui,
            enigma_api.reflector_position,
        )

        # LIGHTBOARD FRAME ====================================================

        logging.info("Adding Lightboard...")
        self.__lightboard = _LightboardWidget(self, self.__enigma_api.charset)

        # INPUT OUTPUT FOR ENCRYPTION/DECRYPTION ==============================

        logging.info("Adding I/O textboxes...")
        self.__output_textbox = _OutputTextBoxWidget(
            self, self.__lightboard.light_up, enigma_api.letter_group)
        self.__input_textbox = _InputTextBoxWidget(
            self, enigma_api.encrypt, self.__output_textbox.insert,
            self.__output_textbox, self.__rotors.set_positions,
            enigma_api.letter_group, enigma_api.revert_by,
            enigma_api.buffer_full,
            enigma_api.data()["charset"], cursor_handler)

        # PLUGBOARD BUTTONS ===================================================

        logging.info("Adding Plugboard button")
        self.__plug_button = QPushButton("Plugboard")
        self.__plug_button.setToolTip("Edit plugboard letter pairs")
        self.__plug_button.clicked.connect(self.__open_plugboard_window)

        # SHOW WIDGETS ========================================================

        logging.info("Showing all widgets...")
        main_layout.addWidget(menu, alignment=Qt.AlignTop)
        main_layout.addWidget(self.__rotors, alignment=Qt.AlignBottom)
        main_layout.addWidget(self.__lightboard)
        main_layout.addWidget(
            QLabel("INPUT", self, styleSheet="font-size: 20px"),
            alignment=Qt.AlignCenter,
        )
        main_layout.addWidget(self.__input_textbox)
        main_layout.addWidget(
            QLabel("OUTPUT", self, styleSheet="font-size: 20px"),
            alignment=Qt.AlignCenter,
        )
        main_layout.addWidget(self.__output_textbox)
        main_layout.addWidget(self.__plug_button)

        self.refresh_gui()
        self.show()
class Main(QMainWindow):
    def __init__(self):
        super(Main, self).__init__()

        # Basic Settings
        self.setGeometry(300, 200, 591, 280)
        self.setMinimumSize(QSize(591, 280))
        self.setMaximumSize(QSize(591, 280))
        self.setWindowIcon(QIcon("arti.PNG"))
        self.setWindowTitle("Artigence Updates")
        self.setFont(QFont('Roboto', 12))

        # Color Scheme
        self.palette = QPalette()
        self.palette.setColor(self.palette.Window, QColor('#000000'))
        self.palette.setColor(self.palette.WindowText, QColor('#FFFFFF'))
        self.setPalette(self.palette)

        self.light_palette = QPalette()
        self.light_palette.setColor(self.light_palette.Window, QColor('#FFFFFF'))
        self.light_palette.setColor(self.light_palette.WindowText, QColor('#000000'))

        # Setting MenuBar
        self.menubar = QMenuBar(self)
        self.menubar.setGeometry(0, 0, 682, 21)
        self.menubar.setFont(QFont('Roboto', 10))

        self.date_menu = QMenu(self.menubar)
        self.date_menu.setTitle(str(datetime.now().strftime('%d-%m-%Y')))

        self.theme_menu = QMenu(self.menubar)
        self.theme_menu.setTitle('Theme')

        self.dark_theme = QAction('Dark Theme')
        self.dark_theme.setShortcut(QKeySequence('Ctrl+Shift+D'))
        self.theme_menu.addAction(self.dark_theme)
        self.dark_theme.triggered.connect(lambda: self.dark())

        self.light_theme = QAction('Light Theme')
        self.light_theme.setShortcut(QKeySequence('Ctrl+Shift+L'))
        self.theme_menu.addAction(self.light_theme)
        self.light_theme.triggered.connect(lambda: self.light())

        self.setMenuBar(self.menubar)
        self.menubar.addAction(self.date_menu.menuAction())
        self.menubar.addAction(self.theme_menu.menuAction())

        # Widgets

        self.update_label = QLabel(self)
        self.update_label.setGeometry(20, 30, 551, 41)
        self.update_label.setText('Update Checker')
        self.update_label.setAlignment(Qt.AlignCenter)

        self.available = QLabel(self)
        self.available.setGeometry(20, 110, 541, 61)
        self.available.setText('')
        self.available.setAlignment(Qt.AlignCenter)

        self.yes = QPushButton(self)
        self.yes.setGeometry(350, 230, 75, 33)
        self.yes.setText('Yes')

        self.no = QPushButton(self)
        self.no.setGeometry(440, 230, 145, 33)
        self.no.setText('Just Open My App')

        self.no.clicked.connect(lambda: self.main_func())

    def main_func(self):
        self.setWindowFlags(QtCore.Qt.Tool)
        time.sleep(2)
        from start import Artigence
        self.main = Artigence()
        self.main.show()



    def dark(self):
        self.setPalette(self.palette)

    def light(self):
        self.setPalette(self.light_palette)

    # The A.I. will speak through this function
    def speak(self, audio):
        self.engine = pyttsx3.init('sapi5')
        voices = self.engine.getProperty('voices')
        self.engine.setProperty('voice', voices[1].id)
        self.engine.setProperty('rate', 165)
        self.available.setText(audio)
        self.engine.say(audio)
        self.engine.runAndWait()
        self.available.clear()