コード例 #1
0
ファイル: page2.py プロジェクト: chusopr/musync
    def __init__(self):
        super().__init__()
        page2Layout = QVBoxLayout(self)

        table_header = QHBoxLayout()
        label0 = QLabel()
        label0.setObjectName("label0")
        table_header.addWidget(label0)
        table_header.addItem(QSpacerItem(1, 1, QSizePolicy.Expanding, QSizePolicy.Minimum))
        label1 = QLabel()
        label1.setObjectName("label1")
        table_header.addWidget(label1)
        page2Layout.addLayout(table_header)

        hLine = QFrame(self.__songs_table)
        hLine.setFrameShape(QFrame.HLine)
        hLine.setFrameShadow(QFrame.Sunken)
        page2Layout.addWidget(hLine)

        scrollArea = QScrollArea()
        scrollClient = QWidget()
        scrollClient.setObjectName("scrollClient")
        scrollArea.setWidgetResizable(True)
        scrollArea.setWidget(scrollClient)
        page2Layout.addWidget(scrollArea)

        self.__new_song_row.connect(self.__add_song_row)
コード例 #2
0
ファイル: ui.py プロジェクト: ramesharun/caribou
    def __init__(self, route=None):
        super().__init__()

        layout = QVBoxLayout()
        self.route = route

        self.preview_text_edit = QTextEdit()
        self.preview_text_edit.setFont(TEXT_FONT)
        self.preview_text_edit.setReadOnly(True)

        if route is not None:
            if route.group is not None:
                for parameter in route.group.parameters:
                    param_layout = self._create_parameter_layout(
                        route.group.storage_prefix, parameter)
                    layout.addLayout(param_layout)

                line = QFrame()
                line.setFrameShape(QFrame.HLine)
                line.setFrameShadow(QFrame.Sunken)
                layout.addWidget(line)

            for parameter in route.parameters:
                param_layout = self._create_parameter_layout(
                    route.storage_prefix, parameter)
                layout.addLayout(param_layout)

        self.highlighter = TextHighlighter(self.preview_text_edit.document())
        self._update_preview()
        layout.addWidget(self.preview_text_edit)

        self.setLayout(layout)
コード例 #3
0
 def horizontal_line():
     line = QFrame()
     line.setFrameShape(QFrame.HLine)
     line.setFrameShadow(QFrame.Sunken)
     line.setFixedHeight(2)
     line.setContentsMargins(0, 30, 0, 0)
     return line
コード例 #4
0
ファイル: page1.py プロジェクト: chusopr/musync
    def __create_source_layout(self, side):
        sourceLayout = QVBoxLayout()
        selectedSourceFrame = QFrame()
        selectedSourceFrame.setFrameShape(QFrame.Box)
        selectedSourceFrame.setFrameShadow(QFrame.Raised)
        selectedSourceLayout = QGridLayout(selectedSourceFrame)
        sourceLabel = QLabel("Selected account: None")
        sourceLabel.setObjectName("SourceLabel{}".format(side))
        selectedSourceLayout.addWidget(sourceLabel, 0, 0)
        changeSourceBtn = QPushButton("Change...")
        changeSourceBtn.clicked.connect(lambda: self.__account_select(side))
        selectedSourceLayout.addWidget(changeSourceBtn, 0, 1)
        playlistLabel = QLabel("Selected playlist:")
        playlistLabel.setObjectName("PlaylistLabel{}".format(side))
        playlistLabel.setDisabled(True)
        selectedSourceLayout.addWidget(playlistLabel, 1, 0)
        playlistSelect = QComboBox()
        playlistSelect.setDisabled(True)
        playlistSelect.setObjectName("Playlist{}".format(side))
        playlistSelect.currentIndexChanged.connect(
            lambda: self.__playlist_select(side))
        selectedSourceLayout.addWidget(playlistSelect, 1, 1)
        sourceLayout.addWidget(selectedSourceFrame)

        trackList = QListWidget()
        trackList.setObjectName("Tracklist{}".format(side))
        trackList.currentItemChanged.connect(self.__track_select)
        sourceLayout.addWidget(trackList)
        return sourceLayout
コード例 #5
0
class Separator:
    def __init__(self):
        self.widget = QFrame()
        self.widget.setFrameShape(QFrame.HLine)
        self.widget.setFrameShadow(QFrame.Sunken)

    def getWidget(self):
        return self.widget
コード例 #6
0
def _create_vertical_line():
    vertical_line = QFrame()
    vertical_line.setFixedWidth(20)
    vertical_line.setFrameShape(QFrame.VLine)
    vertical_line.setFrameShadow(QFrame.Sunken)
    vertical_line.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred)
    vertical_line.setMinimumHeight(300)
    return vertical_line
コード例 #7
0
ファイル: reporter_ui.py プロジェクト: Solertis/spore-1
    def build_ui(self):
        self.setGeometry(50, 50, 450, 300)
        self.setMinimumSize(400, 300)
        self.setWindowTitle('Spore Reporter')

        layout = QVBoxLayout()

        #  self.err_wdg = QWidget()
        #  err_layout = QHBoxLayout(self.err_wdg)
        #  layout.addWidget(err_wdg)
        #
        #  err_lbl = 'Ops..\nSpore seems to have caused an error.\n'

        info_msg = 'Help to improve Spore by anonymously submitting your logs'
        self.info_lbl = QLabel(info_msg)
        layout.addWidget(self.info_lbl)

        self.address_edt = QLineEdit()
        self.address_edt.setPlaceholderText('E-Mail Address (optional)')
        layout.addWidget(self.address_edt)

        self.subject_edt = QLineEdit()
        self.subject_edt.setPlaceholderText('Subject (optional)')
        layout.addWidget(self.subject_edt)

        self.msg_edt = QTextEdit()
        self.msg_edt.setPlaceholderText('Message (optional)')
        self.msg_edt.setFixedHeight(60)
        layout.addWidget(self.msg_edt)

        self.log_edt = QTextEdit()
        self.log_edt.setReadOnly(True)
        self.log_edt.setLineWrapMode(QTextEdit.NoWrap)
        layout.addWidget(self.log_edt)

        ctrl_layout = QGridLayout()
        layout.addLayout(ctrl_layout)

        self.submit_btn = QPushButton('Submit')
        ctrl_layout.addWidget(self.submit_btn, 0, 0, 1, 1)

        self.cancel_btn = QPushButton('Cancel')
        ctrl_layout.addWidget(self.cancel_btn, 0, 1, 1, 1)

        line = QFrame()
        line.setFrameShape(QFrame.HLine)
        line.setFrameShadow(QFrame.Sunken)
        ctrl_layout.addWidget(line, 1, 0, 1, 2)

        self.disable_btn = QPushButton('Disable Reporter')
        ctrl_layout.addWidget(self.disable_btn, 2, 0, 1, 1)

        self.auto_btn = QPushButton('Send Reports Automatically')
        ctrl_layout.addWidget(self.auto_btn, 2, 1, 1, 1)

        self.setLayout(layout)
コード例 #8
0
class Layout_Main_Window(QWidget):
    def __init__(self):
        QWidget.__init__(self)
        self.Main_Layout = QHBoxLayout()
        self.Child_1 = Layout_Child_1()
        self.Child_2 = Layout_Child_2()
        self.Main_Layout.addWidget(self.Child_1)
        self.line = QFrame()
        self.line.setFrameShape(QFrame.VLine)
        self.line.setFrameShadow(QFrame.Sunken)
        self.Main_Layout.addWidget(self.line)
        self.Main_Layout.addWidget(self.Child_2)
        self.setLayout(self.Main_Layout)
コード例 #9
0
 def __init__(self, parent=None):
     '''Constructor Function'''
     QWidget.__init__(self, parent)
     self.Main_Layout = QHBoxLayout()
     self.Child_1 = Layout_Child_1()
     self.Child_2 = Layout_Child_2()
     self.Main_Layout.addWidget(self.Child_1)
     # Add a Saperator
     line = QFrame()
     line.setFrameShape(QFrame.VLine)
     line.setFrameShadow(QFrame.Sunken)
     self.Main_Layout.addWidget(line)
     self.Main_Layout.addWidget(self.Child_2)
     self.setLayout(self.Main_Layout)
コード例 #10
0
ファイル: gui.py プロジェクト: EugeneOros/WebCheck
class PageAbout(QWidget):
    def __init__(self, parent=None):
        QWidget.__init__(self)
        parent.addWidget(self)
        self.gridLayout_about = QGridLayout(self)

        self.frame_about = QFrame(self)
        self.frame_about.setEnabled(True)
        self.frame_about.setStyleSheet(styles.frame_about)
        self.frame_about.setFrameShape(QFrame.StyledPanel)
        self.frame_about.setFrameShadow(QFrame.Raised)
        self.gridLayout_about.addWidget(self.frame_about, 0, 1, 1, 1)

        self.gridLayout_frame_about = QGridLayout(self.frame_about)
        self.gridLayout_frame_about.setContentsMargins(-1, 60, -1, -1)

        self.spacer_about_l = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                          QSizePolicy.Minimum)
        self.spacer_about_r = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                          QSizePolicy.Minimum)
        self.spacer_about_b = QSpacerItem(20, 40, QSizePolicy.Minimum,
                                          QSizePolicy.Expanding)
        self.gridLayout_frame_about.addItem(self.spacer_about_l, 0, 0, 1, 1)
        self.gridLayout_frame_about.addItem(self.spacer_about_r, 0, 2, 1, 1)
        self.gridLayout_frame_about.addItem(self.spacer_about_b, 3, 1, 1, 1)

        self.label_about_name = QLabel("WebCheck", self.frame_about)
        self.label_about_name.setStyleSheet(styles.label_about_name)
        self.label_about_name.setAlignment(Qt.AlignCenter)
        self.gridLayout_frame_about.addWidget(self.label_about_name, 0, 1, 1,
                                              1)

        self.label_about_name = QLabel(
            "Made by Eugene Oros & Michał Piotrowski", self.frame_about)
        self.label_about_name.setStyleSheet(styles.label_about_made)
        self.label_about_name.setAlignment(Qt.AlignCenter)
        self.gridLayout_frame_about.addWidget(self.label_about_name, 1, 1, 1,
                                              1)

        self.label_about_version = QLabel("Version 1.0.0", self.frame_about)
        self.label_about_version.setStyleSheet(styles.label_about_version)
        self.label_about_version.setAlignment(Qt.AlignCenter)
        self.gridLayout_frame_about.addWidget(self.label_about_version, 2, 0,
                                              1, 3)

        self.label_about_c = QLabel("\u00a9 All rights reserved",
                                    self.frame_about)
        self.label_about_c.setStyleSheet(styles.label_about_c)
        self.label_about_c.setAlignment(Qt.AlignCenter)
        self.gridLayout_frame_about.addWidget(self.label_about_c, 3, 0, 1, 3)
コード例 #11
0
 def set_up_group_box(self):
     self.desc_group_box.setLayout(QVBoxLayout())
     self.desc_label = QLabel(self.model.desc)
     self.desc_label.setWordWrap(True)
     self.desc_group_box.layout().addWidget(self.desc_label)
     if isinstance(self.model, (MonsterCard)):
         self.desc_group_box.setTitle(self.get_group_box_title())
         line = QFrame()
         line.setFrameShape((QFrame.HLine))
         line.setFrameShadow(QFrame.Sunken)
         self.desc_group_box.layout().addWidget(line)
         label = QLabel(
             f"ATK/{self.model.attack}  DEF/{self.model.defence}")
         label.setAlignment(Qt.AlignRight)
         self.desc_group_box.layout().addWidget(label)
コード例 #12
0
    def __init__(self):
        super(Main_Widget,self).__init__()

        First = First_Widget()
        Second = Second_Widget()
        Third = Second_Widget()
        Line = QFrame()
        Line.setFrameShape(QFrame.VLine)
        Line.setFrameShadow(QFrame.Sunken)
        H_Layout = QHBoxLayout()
        H_Layout.addWidget(Second)
        #H_Layout.addWidget(First)
        H_Layout.addWidget(Line)
        H_Layout.addWidget(Third)
        self.setLayout(H_Layout)
コード例 #13
0
ファイル: 7.py プロジェクト: nithincyberitus/QtPython-0.1
    def __init__(self):
        super(Zero_Layout,self).__init__()
        First = First_Layout()
        Second = Second_Layout()
        Third = Third_Layout()

        H_layout = QHBoxLayout()
        
        H_layout.addWidget(First)
        line = QFrame()
        line.setFrameShape(QFrame.VLine)
        line.setFrameShadow(QFrame.Sunken)
        H_layout.addWidget(line)
        #H_layout.addWidget(Second)
        H_layout.addWidget(Third)
        self.setLayout(H_layout)
コード例 #14
0
    def __init__(self, controller, parent=None):
        super(CommandParser, self).__init__(parent)
        self.controller = controller
        cmnd2send_label = QLabel('Command:')
        cmnd2send_label.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)

        self.cmnd2send_editor = QLineEdit()

        # cmnd2send_editor.setKeyboardTracking(False)
        self.cmnd2send_editor.setAlignment(Qt.AlignLeft)
        self.cmnd2send_editor.setSizePolicy(QSizePolicy.MinimumExpanding,
                                            QSizePolicy.Fixed)
        # cmnd2send_editor.setClearButtonEnabled()
        send_button = QPushButton('Send')
        send_button.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)

        separator = QFrame()
        separator.setFrameShape(QFrame.HLine)
        separator.setFrameShadow(QFrame.Sunken)
        separator.setSizePolicy(QSizePolicy.MinimumExpanding,
                                QSizePolicy.Fixed)

        scrollbar = QScrollBar()
        cmnd_received_label = QLabel('RESPONSE:')
        self.cmnd_received_window = QTextEdit()
        # self.cmnd_received_window.moveCursor(QTextCursor.Down)
        self.cmnd_received_window.setReadOnly(True)
        self.cmnd_received_window.setVerticalScrollBar(scrollbar)

        # Layout
        editor_layout = QGridLayout()
        editor_layout.addWidget(cmnd2send_label, 0, 0)
        editor_layout.addWidget(self.cmnd2send_editor, 0, 1)
        editor_layout.addWidget(send_button, 0, 2)

        editor_layout.addWidget(separator, 1, 0, 1, 3)

        editor_layout.addWidget(cmnd_received_label, 2, 0, 1, 3)
        editor_layout.addWidget(self.cmnd_received_window, 3, 0, 1, 3)

        layout = QHBoxLayout()
        layout.addLayout(editor_layout)
        self.setLayout(layout)

        # Signals and slots
        send_button.clicked.connect(self.parse_cmnd)
コード例 #15
0
class Welcome_Widget(QWidget):
    def __init__(self, parent=None):
        super(Welcome_Widget, self).__init__(parent)
        self.setUp_UI()

    def setUp_UI(self):
        self.image = Image_Widget(self)
        self.line = QFrame()
        self.line.setFrameShape(QFrame.VLine)
        self.line.setFrameShadow(QFrame.Sunken)
        self.login = Login_Widget(self)
        self.layout = QHBoxLayout()
        self.layout.addWidget(self.image)
        self.layout.addWidget(self.line)
        self.layout.addWidget(self.login)

        self.setLayout(self.layout)
コード例 #16
0
    def _init_widgets(self):
        self.resize(530, 180)
        main_layout = QVBoxLayout()
        frame = QFrame()
        frame.setFrameShape(QFrame.NoFrame)
        frame.setFrameShadow(QFrame.Plain)
        frameLayout = QVBoxLayout()
        self.connectRad = QRadioButton(frame)
        self.createRad = QRadioButton(frame)
        self.connectRad.setChecked(True)
        self.connectRad.toggled.connect(self.handleRadioButtons)
        self.createRad.toggled.connect(self.handleRadioButtons)
        frameLayout.addWidget(self.connectRad)
        internalFrame = QFrame()
        internalFrameLayout = QHBoxLayout(internalFrame)
        hostLabel = QLabel()
        portLabel = QLabel()
        self.hostText = QLineEdit()
        self.portText = QLineEdit()
        internalFrameLayout.addWidget(hostLabel)
        internalFrameLayout.addWidget(self.hostText)
        internalFrameLayout.addWidget(portLabel)
        internalFrameLayout.addWidget(self.portText)
        self.portText.setMaximumSize(QSize(80, 200))
        internalFrame.setLayout(internalFrameLayout)
        frameLayout.addWidget(internalFrame)
        frameLayout.addWidget(self.createRad)
        frame.setLayout(frameLayout)

        self.buttonBox = QDialogButtonBox(self)
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel
                                          | QDialogButtonBox.Ok)
        self.buttonBox.accepted.connect(self.accept)
        self.buttonBox.rejected.connect(self.reject)

        main_layout.addWidget(frame)
        main_layout.addWidget(self.buttonBox)

        self.setLayout(main_layout)
        self.setWindowTitle("Cartprograph Connect")
        self.connectRad.setText("Connect to Existing Cartprograph Server")
        self.createRad.setText("Create New Cartprograph Server")
        hostLabel.setText("Host")
        portLabel.setText("Port")
コード例 #17
0
class Ui_FE14ChapterEditor(QMainWindow):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.toolbar = QToolBar()
        self.addToolBar(self.toolbar)
        self.add_chapter_action = QAction("Add Chapter")
        self.hide_selector_action = QAction("Toggle Selection Pane")
        self.toolbar.addAction(self.add_chapter_action)
        self.toolbar.addSeparator()
        self.toolbar.addAction(self.hide_selector_action)

        self.selector_layout = QVBoxLayout()
        self.chapter_search_bar = QLineEdit()
        self.chapter_search_bar.setPlaceholderText("Search...")
        self.chapter_list_view = QListView()
        self.selector_layout.addWidget(self.chapter_search_bar)
        self.selector_layout.addWidget(self.chapter_list_view)
        self.selector_widget = QWidget()
        self.selector_widget.setLayout(self.selector_layout)
        self.selector_widget.setFixedWidth(225)

        self.config_tab = FE14ChapterConfigTab()
        self.map_tab = FE14MapEditor()
        self.characters_tab = FE14CharacterEditor(is_person=True)
        self.conversation_tab = FE14ConversationEditor()
        self.tab_widget = QTabWidget()
        self.tab_widget.addTab(self.config_tab, "Config")
        self.tab_widget.addTab(self.map_tab, "Map")
        self.tab_widget.addTab(self.characters_tab, "Characters")
        self.tab_widget.addTab(self.conversation_tab, "Text")

        self.main_layout = QHBoxLayout()
        self.main_widget = QWidget()
        self.visual_splitter = QFrame()
        self.visual_splitter.setFrameShape(QFrame.VLine)
        self.visual_splitter.setFrameShadow(QFrame.Sunken)
        self.main_widget.setLayout(self.main_layout)
        self.main_layout.addWidget(self.selector_widget)
        self.main_layout.addWidget(self.visual_splitter)
        self.main_layout.addWidget(self.tab_widget)
        self.setCentralWidget(self.main_widget)
コード例 #18
0
class Card(QWidget):
    def __init__(self, parent: QWidget, card_details: Dict[str, Any]):
        super().__init__()
        if parent is not None:
            self.setParent(parent)
        self.model = create_card(card_details)
        self.setupUi()

    def get_card_background_colour(self):
        if isinstance(self.model, SpellCard):
            return QColor(CardColours[CardType.SPELL])
        elif isinstance(self.model, TrapCard):
            return QColor(CardColours[CardType.TRAP])
        else:
            pass

    def setupUi(self):
        self.main_layout = QVBoxLayout()

        self.name_attr_layout = QHBoxLayout()
        self.name_label = QLabel(self.model.name)
        font = self.name_label.font()
        font.setBold(True)
        font.setCapitalization(QFont.AllUppercase)
        font.setPointSize(12)
        self.name_label.setFont(font)
        self.name_label.setMargin(5)
        pixmap = get_attr_icon(self.model.attribute)
        self.attr_icon = QLabel()
        self.attr_icon.setPixmap(pixmap)
        self.attr_icon.setAlignment(Qt.AlignRight)
        self.name_attr_layout.addWidget(self.name_label)
        self.name_attr_layout.addWidget(self.attr_icon)
        self.main_layout.addLayout(self.name_attr_layout)

        self.level_layout = QHBoxLayout()
        self.main_layout.addLayout(self.level_layout)

        self.picture_frame = QFrame()
        self.picture_frame.setFixedSize(250, 250)
        self.picture_frame.setFrameStyle(QFrame.Box | QFrame.Plain)
        self.picture_frame.setFrameShadow(QFrame.Shadow.Raised)
        self.picture_frame.setLineWidth(1)
        self.picture_frame.setContentsMargins(0, 0, 0, 0)
        self.picture_frame.setLayout(QGridLayout())
        self.image_holder = QLabel()

        pixmap = self._get_card_image()
        self.image_holder.setPixmap(
            pixmap.scaled(
                self.picture_frame.width(),
                self.picture_frame.height(),
                Qt.KeepAspectRatio,
            ))

        self.picture_frame.layout().addWidget(self.image_holder)

        self.main_layout.addWidget(self.picture_frame)

        # Card sets here?

        self.desc_group_box = QGroupBox()
        self.desc_group_box.setMaximumWidth(250)
        self.set_up_group_box()
        self.main_layout.addWidget(self.desc_group_box)

        self.id_label = QLabel(self.model.id)
        self.id_label.setAlignment(Qt.AlignLeft)
        self.id_label.setMargin(5)
        self.main_layout.addWidget(self.id_label)

        self.setLayout(self.main_layout)

        pal = QPalette()
        pal.setColor(QPalette.Background, self.get_card_background_colour())
        self.setAutoFillBackground(True)
        self.setPalette(pal)

    def _get_card_image(self):
        image_name = self.model.img_url.split("/")[-1]

        if os.path.exists(self.get_image_path(image_name)):
            image = Image.open(self.get_image_path(image_name))
        else:
            image_data = requests.get(self.model.img_url).content
            image = Image.open(BytesIO(image_data))
            image.save(self.get_image_path(image_name))
        image = image.crop((44, 106, 380, 438))  # this is about correct
        data = image.tobytes("raw", "RGB")
        qimage = QImage(data, image.size[0], image.size[1],
                        QImage.Format_RGB888)
        pixmap = QPixmap.fromImage(qimage)
        return pixmap

    def get_image_path(self, image_name):
        return os.path.join(os.getcwd(), "images", image_name)

    def set_up_group_box(self):
        self.desc_group_box.setLayout(QVBoxLayout())
        self.desc_label = QLabel(self.model.desc)
        self.desc_label.setWordWrap(True)
        self.desc_group_box.layout().addWidget(self.desc_label)
        if isinstance(self.model, (MonsterCard)):
            self.desc_group_box.setTitle(self.get_group_box_title())
            line = QFrame()
            line.setFrameShape((QFrame.HLine))
            line.setFrameShadow(QFrame.Sunken)
            self.desc_group_box.layout().addWidget(line)
            label = QLabel(
                f"ATK/{self.model.attack}  DEF/{self.model.defence}")
            label.setAlignment(Qt.AlignRight)
            self.desc_group_box.layout().addWidget(label)

    def get_group_box_title(self):
        return "[TEST/TEST]"
コード例 #19
0
    def __init__(self):
        super(SidePanel, self).__init__()

        # Internal variables
        self._coverdir = path.join("data", "images", "covers")
        self._id = 0
        self._imagedata = ""
        size = [220, 16]  # Width, Height (for QLineEdits/QTextEdits)

        # QDockWidget settings
        self.setAllowedAreas(Qt.RightDockWidgetArea)
        self.setFeatures(QDockWidget.DockWidgetClosable)
        self.setFixedWidth(350)
        self.setVisible(False)

        # Fonts
        bold = QFont()
        bold.setBold(True)
        boldUnderline = QFont()
        boldUnderline.setBold(True)
        boldUnderline.setUnderline(True)

        # Horizontal line
        hline = QFrame()
        hline.setFrameShape(QFrame.HLine)
        hline.setFrameShadow(QFrame.Sunken)

        """Widgets"""
        # Cover
        self.cover = QLabel()
        self.cover.setAlignment(Qt.AlignCenter)
        self.cover.setMinimumHeight(200)
        self.cover.setMaximumSize(self.width(), 250)
        # Buttons
        self.fetchInfoButton = QPushButton("Fetch missing info")
        self.fetchInfoButton.setToolTip("Try to fetch info from MobyGames")
        self.fetchInfoButton.clicked.connect(self._fetchInfo)
        self.editDetailsButton = QPushButton("Edit")
        self.editDetailsButton.setCheckable(True)
        self.editDetailsButton.clicked.connect(self._editDetails)
        self.saveDetailsButton = QPushButton("Save")
        self.saveDetailsButton.clicked.connect(self._saveInfo)
        self.fetchPriceButton = QPushButton("Update price data")
        self.fetchPriceButton.setToolTip("Try to update price data from Pricecharting")
        self.fetchPriceButton.clicked.connect(self._fetchPriceData)
        self.savePriceButton = QPushButton("Save")
        self.savePriceButton.clicked.connect(self._saveInfo)

        # Info layout widgets
        self.nameInfoLabel = QLabel("Name:")
        self.nameInfoLabel.setFont(bold)
        self.nameDataLabel = QLabel()
        self.nameDataLabel.setWordWrap(True)
        self.platformInfoLabel = QLabel("Platform:")
        self.platformInfoLabel.setFont(bold)
        self.platformDataLabel = QLabel()
        self.publisherInfoLabel = QLabel("Publisher:")
        self.publisherInfoLabel.setFont(bold)
        self.publisherDataLabel = QLabel()
        self.developerInfoLabel = QLabel("Developer:")
        self.developerInfoLabel.setFont(bold)
        self.developerDataLabel = QLabel()
        self.regionInfoLabel = QLabel("Region:")
        self.regionInfoLabel.setFont(bold)
        self.regionDataLabel = QLabel()
        self.codeInfoLabel = QLabel("Code:")
        self.codeInfoLabel.setFont(bold)
        self.codeDataLabel = QLabel()
        self.codeDataLabel.setWordWrap(True)
        self.itemInfoLabel = QLabel("Game:")
        self.itemInfoLabel.setFont(bold)
        self.itemDataLabel = QLabel()
        self.boxInfoLabel = QLabel("Box:")
        self.boxInfoLabel.setFont(bold)
        self.boxDataLabel = QLabel()
        self.manualInfoLabel = QLabel("Manual:")
        self.manualInfoLabel.setFont(bold)
        self.manualDataLabel = QLabel()
        self.genreInfoLabel = QLabel("Genre:")
        self.genreInfoLabel.setFont(bold)
        self.genreDataLabel = QLabel()
        self.yearInfoLabel = QLabel("Year:")
        self.yearInfoLabel.setFont(bold)
        self.yearDataLabel = QLabel()
        self.commentInfoLabel = QLabel("Comment:")
        self.commentInfoLabel.setFont(bold)
        self.commentDataLabel = QLabel()
        self.commentDataLabel.setWordWrap(True)
        self.platformsInfoLabel = QLabel("Available for:")
        self.platformsInfoLabel.setFont(bold)
        self.platformsDataLabel = QLabel()
        self.platformsDataLabel.setWordWrap(True)
        self.platformsDataLabel.setMaximumHeight(50)  # Can get quite large otherwise

        # Edit layout widgets
        self.nameEditLabel = QLabel("Name:")
        self.nameEditLabel.setFont(bold)
        self.nameDataTE = QTextEdit()
        self.nameDataTE.setMaximumSize(size[0], size[1] * 2)
        self.platformEditLabel = QLabel("Platform:")
        self.platformEditLabel.setFont(bold)
        self.platformDataLE = QLineEdit()
        self.platformDataLE.setMaximumSize(size[0], size[1])
        self.publisherEditLabel = QLabel("Publisher:")
        self.publisherEditLabel.setFont(bold)
        self.publisherDataLE = QLineEdit()
        self.publisherDataLE.setMaximumSize(size[0], size[1])
        self.developerEditLabel = QLabel("Developer:")
        self.developerEditLabel.setFont(bold)
        self.developerDataLE = QLineEdit()
        self.developerDataLE.setMaximumSize(size[0], size[1])
        self.regionEditLabel = QLabel("Region:")
        self.regionEditLabel.setFont(bold)
        self.regionDataCoB = QComboBox()
        self.regionDataCoB.addItems(("NTSC (JP)", "NTSC (NA)", "PAL"))
        self.regionDataCoB.setMinimumWidth(size[0])  # If not set it will be too small
        self.regionDataCoB.setMaximumSize(size[0], size[1])
        self.codeEditLabel = QLabel("Code:")
        self.codeEditLabel.setFont(bold)
        self.codeDataLE = QLineEdit()
        self.codeDataLE.setMaximumSize(size[0], size[1])
        self.itemEditLabel = QLabel("Game:")
        self.itemEditLabel.setFont(bold)
        self.itemDataCB = QCheckBox()
        self.itemDataCB.setChecked(False)
        self.boxEditLabel = QLabel("Box:")
        self.boxEditLabel.setFont(bold)
        self.boxDataCB = QCheckBox()
        self.boxDataCB.setChecked(False)
        self.manualEditLabel = QLabel("Manual:")
        self.manualEditLabel.setFont(bold)
        self.manualDataCB = QCheckBox()
        self.manualDataCB.setChecked(False)
        self.genreEditLabel = QLabel("Genre:")
        self.genreEditLabel.setFont(bold)
        self.genreDataLE = QLineEdit()
        self.genreDataLE.setMaximumSize(size[0], size[1])
        self.yearEditLabel = QLabel("Year:")
        self.yearEditLabel.setFont(bold)
        self.yearDataLE = QLineEdit()
        self.yearDataLE.setMaximumSize(size[0], size[1])
        self.commentEditLabel = QLabel("Comment:")
        self.commentEditLabel.setFont(bold)
        self.commentDataTE = QTextEdit()
        self.commentDataTE.setMaximumSize(size[0], size[1] * 2)
        self.platformsEditLabel = QLabel("Available for:")
        self.platformsEditLabel.setFont(bold)
        self.platformsDataTE = QTextEdit()
        self.platformsDataTE.setMaximumSize(size[0], size[1] * 2)

        # Price widgets
        self.paidPriceLabel = QLabel("Paid:")
        self.paidPriceLabel.setFont(bold)
        self.paidPriceDataLE = QLineEdit()
        self.paidPriceDataLE.setMaximumSize(60, size[1])
        self.paidPriceDataLE.setAlignment(Qt.AlignRight)
        self.loosePriceLabel = QLabel("Loose:")
        self.loosePriceLabel.setFont(bold)
        self.loosePriceDataLabel = QLabel()
        self.loosePriceDataLabel.setAlignment(Qt.AlignRight)
        self.cibPriceLabel = QLabel("CIB:")
        self.cibPriceLabel.setFont(bold)
        self.cibPriceDataLabel = QLabel()
        self.cibPriceDataLabel.setAlignment(Qt.AlignRight)
        self.newPriceLabel = QLabel("New:")
        self.newPriceLabel.setFont(bold)
        self.newPriceDataLabel = QLabel()
        self.newPriceDataLabel.setAlignment(Qt.AlignRight)

        """Layouts"""
        # Cover
        self.coverVbox = QVBoxLayout()
        self.coverVbox.addWidget(self.cover, 1)
        self.coverVbox.addWidget(hline, 0)

        # Buttons
        self.detailsButtonHbox = QHBoxLayout()
        self.detailsButtonHbox.addWidget(self.fetchInfoButton, 0)
        self.detailsButtonHbox.addWidget(self.editDetailsButton, 0)
        self.detailsButtonHbox.addWidget(self.saveDetailsButton, 0)
        self.priceButtonHbox = QHBoxLayout()
        self.priceButtonHbox.addWidget(self.fetchPriceButton, 0)
        self.priceButtonHbox.addWidget(self.savePriceButton, 0)

        # Info layouts
        self.nameInfoHbox = QHBoxLayout()
        self.nameInfoHbox.addWidget(self.nameInfoLabel, 0)
        self.nameInfoHbox.addWidget(self.nameDataLabel, 0)
        self.platformInfoHbox = QHBoxLayout()
        self.platformInfoHbox.addWidget(self.platformInfoLabel, 0)
        self.platformInfoHbox.addWidget(self.platformDataLabel, 0)
        self.publisherInfoHbox = QHBoxLayout()
        self.publisherInfoHbox.addWidget(self.publisherInfoLabel, 0)
        self.publisherInfoHbox.addWidget(self.publisherDataLabel, 0)
        self.developerInfoHbox = QHBoxLayout()
        self.developerInfoHbox.addWidget(self.developerInfoLabel, 0)
        self.developerInfoHbox.addWidget(self.developerDataLabel, 0)
        self.regionInfoHbox = QHBoxLayout()
        self.regionInfoHbox.addWidget(self.regionInfoLabel, 0)
        self.regionInfoHbox.addWidget(self.regionDataLabel, 0)
        self.codeInfoHbox = QHBoxLayout()
        self.codeInfoHbox.addWidget(self.codeInfoLabel, 0)
        self.codeInfoHbox.addWidget(self.codeDataLabel, 0)
        self.itemInfoHbox = QHBoxLayout()
        self.itemInfoHbox.addWidget(self.itemInfoLabel, 0)
        self.itemInfoHbox.addWidget(self.itemDataLabel, 0)
        self.boxInfoHbox = QHBoxLayout()
        self.boxInfoHbox.addWidget(self.boxInfoLabel, 0)
        self.boxInfoHbox.addWidget(self.boxDataLabel, 0)
        self.manualInfoHbox = QHBoxLayout()
        self.manualInfoHbox.addWidget(self.manualInfoLabel, 0)
        self.manualInfoHbox.addWidget(self.manualDataLabel, 0)
        self.genreInfoHbox = QHBoxLayout()
        self.genreInfoHbox.addWidget(self.genreInfoLabel, 0)
        self.genreInfoHbox.addWidget(self.genreDataLabel, 0)
        self.yearInfoHbox = QHBoxLayout()
        self.yearInfoHbox.addWidget(self.yearInfoLabel, 0)
        self.yearInfoHbox.addWidget(self.yearDataLabel, 0)
        self.commentInfoHbox = QHBoxLayout()
        self.commentInfoHbox.addWidget(self.commentInfoLabel, 0)
        self.commentInfoHbox.addWidget(self.commentDataLabel, 0)
        self.platformsInfoHbox = QHBoxLayout()
        self.platformsInfoHbox.addWidget(self.platformsInfoLabel, 0)
        self.platformsInfoHbox.addWidget(self.platformsDataLabel, 0)

        # Edit layouts
        self.nameEditHbox = QHBoxLayout()
        self.nameEditHbox.addWidget(self.nameEditLabel, 0)
        self.nameEditHbox.addWidget(self.nameDataTE, 0)
        self.platformEditHbox = QHBoxLayout()
        self.platformEditHbox.addWidget(self.platformEditLabel, 0)
        self.platformEditHbox.addWidget(self.platformDataLE, 0)
        self.publisherEditHbox = QHBoxLayout()
        self.publisherEditHbox.addWidget(self.publisherEditLabel, 0)
        self.publisherEditHbox.addWidget(self.publisherDataLE, 0)
        self.developerEditHbox = QHBoxLayout()
        self.developerEditHbox.addWidget(self.developerEditLabel, 0)
        self.developerEditHbox.addWidget(self.developerDataLE, 0)
        self.regionEditHbox = QHBoxLayout()
        self.regionEditHbox.addWidget(self.regionEditLabel, 0)
        self.regionEditHbox.addWidget(self.regionDataCoB, 0)
        self.codeEditHbox = QHBoxLayout()
        self.codeEditHbox.addWidget(self.codeEditLabel, 0)
        self.codeEditHbox.addWidget(self.codeDataLE, 0)
        self.itemEditHbox = QHBoxLayout()
        self.itemEditHbox.addWidget(self.itemEditLabel, 0)
        self.itemEditHbox.addWidget(self.itemDataCB, 0)
        self.itemEditHbox.addSpacing(135)
        self.boxEditHbox = QHBoxLayout()
        self.boxEditHbox.addWidget(self.boxEditLabel, 0)
        self.boxEditHbox.addWidget(self.boxDataCB, 0)
        self.boxEditHbox.addSpacing(135)
        self.manualEditHbox = QHBoxLayout()
        self.manualEditHbox.addWidget(self.manualEditLabel, 0)
        self.manualEditHbox.addWidget(self.manualDataCB, 0)
        self.manualEditHbox.addSpacing(135)
        self.genreEditHbox = QHBoxLayout()
        self.genreEditHbox.addWidget(self.genreEditLabel, 0)
        self.genreEditHbox.addWidget(self.genreDataLE, 0)
        self.yearEditHbox = QHBoxLayout()
        self.yearEditHbox.addWidget(self.yearEditLabel, 0)
        self.yearEditHbox.addWidget(self.yearDataLE, 0)
        self.commentEditHbox = QHBoxLayout()
        self.commentEditHbox.addWidget(self.commentEditLabel, 0)
        self.commentEditHbox.addWidget(self.commentDataTE, 0)
        self.platformsEditHbox = QHBoxLayout()
        self.platformsEditHbox.addWidget(self.platformsEditLabel, 0)
        self.platformsEditHbox.addWidget(self.platformsDataTE, 0)

        # Price layouts
        self.paidPriceHbox = QHBoxLayout()
        self.paidPriceHbox.addWidget(self.paidPriceLabel, 0)
        self.paidPriceHbox.addWidget(self.paidPriceDataLE, 0)
        self.loosePriceHbox = QHBoxLayout()
        self.loosePriceHbox.addWidget(self.loosePriceLabel, 0)
        self.loosePriceHbox.addWidget(self.loosePriceDataLabel, 0)
        self.cibPriceHbox = QHBoxLayout()
        self.cibPriceHbox.addWidget(self.cibPriceLabel, 0)
        self.cibPriceHbox.addWidget(self.cibPriceDataLabel, 0)
        self.newPriceHbox = QHBoxLayout()
        self.newPriceHbox.addWidget(self.newPriceLabel, 0)
        self.newPriceHbox.addWidget(self.newPriceDataLabel, 0)

        # Info layout
        self.infoLayout = QVBoxLayout()
        self.infoLayout.addLayout(self.nameInfoHbox, 0)
        self.infoLayout.addLayout(self.platformInfoHbox, 0)
        self.infoLayout.addLayout(self.publisherInfoHbox, 0)
        self.infoLayout.addLayout(self.developerInfoHbox, 0)
        self.infoLayout.addLayout(self.genreInfoHbox, 0)
        self.infoLayout.addLayout(self.regionInfoHbox, 0)
        self.infoLayout.addLayout(self.yearInfoHbox, 0)
        self.infoLayout.addLayout(self.codeInfoHbox, 0)
        self.infoLayout.addLayout(self.itemInfoHbox, 0)
        self.infoLayout.addLayout(self.boxInfoHbox, 0)
        self.infoLayout.addLayout(self.manualInfoHbox, 0)
        self.infoLayout.addLayout(self.commentInfoHbox, 0)
        self.infoLayout.addLayout(self.platformsInfoHbox, 0)

        # Edit layout
        self.editLayout = QVBoxLayout()
        self.editLayout.addLayout(self.nameEditHbox, 0)
        self.editLayout.addLayout(self.platformEditHbox, 0)
        self.editLayout.addLayout(self.publisherEditHbox, 0)
        self.editLayout.addLayout(self.developerEditHbox, 0)
        self.editLayout.addLayout(self.genreEditHbox, 0)
        self.editLayout.addLayout(self.regionEditHbox, 0)
        self.editLayout.addLayout(self.yearEditHbox, 0)
        self.editLayout.addLayout(self.codeEditHbox, 0)
        self.editLayout.addLayout(self.itemEditHbox, 0)
        self.editLayout.addLayout(self.boxEditHbox, 0)
        self.editLayout.addLayout(self.manualEditHbox, 0)
        self.editLayout.addLayout(self.commentEditHbox, 0)
        self.editLayout.addLayout(self.platformsEditHbox, 0)

        # Price layout
        self.priceLayout = QVBoxLayout()
        self.priceLayout.addLayout(self.paidPriceHbox, 0)
        self.priceLayout.addLayout(self.loosePriceHbox, 0)
        self.priceLayout.addLayout(self.cibPriceHbox, 0)
        self.priceLayout.addLayout(self.newPriceHbox, 0)
        self.priceLayout.addStretch(1)
        self.priceLayout.addLayout(self.priceButtonHbox, 0)

        """Main layout"""
        self.infoWidget = QWidget()
        self.infoWidget.setLayout(self.infoLayout)
        self.editWidget = QWidget()
        self.editWidget.setLayout(self.editLayout)
        # Add info and edit widgets to a stacked layout so we can switch layouts when editing
        self.stackedLayout = QStackedLayout()
        self.stackedLayout.addWidget(self.infoWidget)
        self.stackedLayout.addWidget(self.editWidget)
        self.stackedLayout.setCurrentIndex(0)  # Default to info layout

        self.detailsLayout = QVBoxLayout()
        self.detailsLayout.addLayout(self.coverVbox, 1)
        self.detailsLayout.addLayout(self.stackedLayout, 0)
        self.detailsLayout.addLayout(self.detailsButtonHbox, 0)
        self.detailsWidget = QWidget()
        self.detailsWidget.setLayout(self.detailsLayout)

        self.priceWidget = QWidget()
        self.priceWidget.setLayout(self.priceLayout)

        self.tab = QTabWidget()
        self.tab.addTab(self.detailsWidget, "Details")
        self.tab.addTab(self.priceWidget, "Price info")
        self.setWidget(self.tab)
コード例 #20
0
class PropertyTreeDelegateEditor(QFrame):
    """A special editor that handles renaming blocks and groups."""
    sizeHintChanged = Signal(object)
    """Emitted when the widget changes sizeHint. Delegate should update it's geometry."""

    def __init__(self, parent=None):
        super().__init__(parent)
        layout = QVBoxLayout()
        self.setLayout(layout)            
        self.setContentsMargins(0, 0, 0, 0)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)
        self.setAutoFillBackground(True)
        self.setFocusPolicy(Qt.StrongFocus)
        self.setFrameStyle(QFrame.Panel | QFrame.Plain)

        self._fallback_text = None
        self._experiment = None

        self.line_edit = QLineEdit()
        self.line_edit.setFrame(False)
        self.message_label = QLabel()
        self.message_label.hide()

        # Divider line
        self.divider_line = QFrame()
        self.divider_line.setFrameShape(QFrame.HLine)
        self.divider_line.setFrameShadow(QFrame.Plain)
        self.divider_line.setLineWidth(1)

        layout.addWidget(self.line_edit)
        layout.addWidget(self.divider_line)
        layout.addWidget(self.message_label)

        self.line_edit.textChanged.connect(self._updateMessage)
    
    def experiment(self):
        return self._experiment

    def setExperiment(self, ex):
        self._experiment = ex

    def fallbackText(self):
        return self._fallback_text

    def text(self):
        """Get the current text value of the editor widget.
        If editing has not been finished succesfully, returns fallbackText().
        """
        (text_ok, _) = self.experiment().checkName(self.line_edit.text())
        if text_ok:
            return self.line_edit.text()
        else:
            return self.fallbackText()
    
    def setFallbackText(self, text):
        """Set the fallback text value to be used if the editing was not succesfully finished.
        The text() method returns this value or the line_edit text.
        """
        self._fallback_text = text

    def setText(self, text):
        """Set currently editable text. Equivalent to self.line_edit.setText."""
        self.line_edit.setText(text)
    
    def _updateMessage(self):
        """Update the displayed message in response to changed text."""
        if self.line_edit.text() == self.fallbackText():
            # Perform no check
            text_ok = True
        else:
            (text_ok, reason) = self.experiment().checkName(self.line_edit.text())
        
        if text_ok:
            self.message_label.hide()
            self.divider_line.hide()
        else:
            self.message_label.setText(reason)
            self.message_label.show()
            self.divider_line.show()
        
        self.sizeHintChanged.emit(self)
    
    def focusInEvent(self, event):
        super().focusInEvent(event)
        self.line_edit.setFocus()
コード例 #21
0
class Ui_FE14CharacterEditor(QMainWindow):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.search_bar = QLineEdit()
        self.search_bar.setPlaceholderText("Search...")
        self.search_bar.setFixedWidth(225)
        self.characters_list_view = QListView()
        self.characters_list_view.setContextMenuPolicy(
            QtCore.Qt.CustomContextMenu)
        self.characters_list_view.setFixedWidth(225)
        self.characters_list_layout = QVBoxLayout()
        self.characters_list_layout.addWidget(self.search_bar)
        self.characters_list_layout.addWidget(self.characters_list_view)

        self.character_details_box = QGroupBox(title="Character Details")
        self.portrait_display = QGraphicsView()
        self.portrait_display.setFixedSize(140, 140)
        self.character_details_form_contents_1 = QWidget()
        self.character_details_form_contents_2 = QWidget()
        self.character_details_layout = QHBoxLayout()
        self.character_details_layout.addWidget(self.portrait_display)
        self.character_details_layout.addWidget(
            self.character_details_form_contents_1)
        self.character_details_layout.addWidget(
            self.character_details_form_contents_2)
        self.character_details_box.setLayout(self.character_details_layout)
        self.character_details_box.setFixedHeight(200)

        self.tab_widget = QTabWidget()
        self.ids_tab = QWidget()
        self.classes_tab = QWidget()
        self.stats_tab = QScrollArea()
        self.skills_tab = QScrollArea()
        self.misc_tab = QScrollArea()
        self.portraits_tab = PortraitViewer()

        self.stats_contents = QWidget()
        self.stats_tab.setWidget(self.stats_contents)
        self.stats_tab.setWidgetResizable(True)
        self.stats_layout = QVBoxLayout()
        self.stats_layout.setAlignment(QtCore.Qt.AlignTop)
        self.stats_contents.setLayout(self.stats_layout)

        self.skills_contents = QWidget()
        self.skills_tab.setWidget(self.skills_contents)
        self.skills_tab.setWidgetResizable(True)

        self.misc_contents = QWidget()
        self.misc_tab.setWidget(self.misc_contents)
        self.misc_tab.setWidgetResizable(True)
        self.misc_layout = QVBoxLayout()
        self.misc_layout.setAlignment(QtCore.Qt.AlignTop)
        self.misc_contents.setLayout(self.misc_layout)

        self.tab_widget.addTab(self.ids_tab, "IDs")
        self.tab_widget.addTab(self.classes_tab, "Classes")
        self.tab_widget.addTab(self.stats_tab, "Stats")
        self.tab_widget.addTab(self.skills_tab, "Skills")
        self.tab_widget.addTab(self.misc_tab, "Misc.")
        self.tab_widget.addTab(self.portraits_tab, "Portraits")

        self.editor_layout = QVBoxLayout()
        self.editor_layout.addWidget(self.character_details_box)
        self.editor_layout.addWidget(self.tab_widget)

        self.main_layout = QHBoxLayout()
        self.main_layout.addLayout(self.characters_list_layout)
        self.visual_splitter = QFrame()
        self.visual_splitter.setFrameShape(QFrame.VLine)
        self.visual_splitter.setFrameShadow(QFrame.Sunken)
        self.main_layout.addWidget(self.visual_splitter)
        self.main_layout.addLayout(self.editor_layout)

        self.tool_bar = QToolBar()
        self.action_add = QAction(text="Add")
        self.action_remove = QAction(text="Remove")
        self.action_copy_to = QAction(text="Copy To")
        self.tool_bar.addActions(
            [self.action_add, self.action_remove, self.action_copy_to])

        self.addToolBar(self.tool_bar)

        self.resize(1000, 600)
        central_widget = QWidget()
        central_widget.setLayout(self.main_layout)
        self.setWindowTitle("Character Editor")
        self.setWindowIcon(QIcon("paragon.ico"))
        self.setCentralWidget(central_widget)
コード例 #22
0
class NavFrame(QFrame):
    def __init__(self, parent=None):
        QFrame.__init__(self, parent)
        self.setStyleSheet("""QFrame{ background-color:#43454f;}""")
        self.setFrameShape(QFrame.StyledPanel)
        self.setFrameShadow(QFrame.Raised)

        self.frame_nav = QFrame(self)
        self.frame_nav.setMinimumSize(QSize(220, 300))
        self.frame_nav.setStyleSheet("""QFrame{ background-color:#43454f;}""")
        self.frame_nav.setFrameShape(QFrame.StyledPanel)
        self.frame_nav.setFrameShadow(QFrame.Raised)

        self.gridLayout = QGridLayout(self)
        self.gridLayout.setContentsMargins(11, -1, 11, -1)
        self.gridLayout.addWidget(self.frame_nav, 3, 0, 1, 4)

        # set program img and name
        self.label_img = QLabel(self)
        self.label_img.setFixedSize(QSize(60, 60))
        self.label_img.setPixmap(QPixmap(os.path.join(path, 'img/icon.png')))
        # self.label_img.setPixmap(QPixmap("../img/icon.png"))
        self.label_img.setScaledContents(True)
        self.gridLayout.addWidget(self.label_img, 2, 1, 1, 1)

        self.label_name = QLabel("WebCheck        ", self)
        self.label_name.setStyleSheet(styles.label_icon_name)
        self.gridLayout.addWidget(self.label_name, 2, 2, 1, 1)

        self.spacer_name_l = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
        self.spacer_name_r = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
        self.spacer_name_t = QSpacerItem(20, 70, QSizePolicy.Minimum, QSizePolicy.Maximum)
        self.gridLayout.addItem(self.spacer_name_l, 2, 0, 1, 1)
        self.gridLayout.addItem(self.spacer_name_r, 2, 3, 1, 1)
        self.gridLayout.addItem(self.spacer_name_t, 1, 1, 1, 2)

        # set bottom layout for keeping gb in it
        self.gridLayout_b = QGridLayout(self.frame_nav)
        self.spacer_gb_l = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
        self.spacer_gb_r = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
        self.spacer_gb_t = QSpacerItem(0, 20, QSizePolicy.Minimum, QSizePolicy.Maximum)
        self.spacer_gb_b = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
        self.gridLayout_b.addItem(self.spacer_gb_l, 1, 2, 1, 1)
        self.gridLayout_b.addItem(self.spacer_gb_r, 1, 0, 1, 1)
        self.gridLayout_b.addItem(self.spacer_gb_t, 0, 1, 1, 1)
        self.gridLayout_b.addItem(self.spacer_gb_b, 2, 1, 1, 1)

        # set gb and radio buttons
        self.groupBox = QGroupBox("", self.frame_nav)
        self.gridLayout_b.addWidget(self.groupBox, 1, 1, 1, 1)
        self.groupBox.setMinimumSize(QSize(220, 350))
        self.groupBox.setStyleSheet("""QGroupBox{background-image: url(ui/img/radioline.png);  border: none;}""")
        self.verticalLayout_gb = QVBoxLayout(self.groupBox)

        self.radioButton_add = QRadioButton(" Add", self.groupBox)
        self.radioButton_add.setStyleSheet(styles.btn_radio)
        self.verticalLayout_gb.addWidget(self.radioButton_add)

        self.radioButton_monitored = QRadioButton(" Monitored", self.groupBox)
        self.radioButton_monitored.setStyleSheet(styles.btn_radio)
        self.verticalLayout_gb.addWidget(self.radioButton_monitored)

        self.radioButton_options = QRadioButton(" Options", self.groupBox)
        self.radioButton_options.setStyleSheet(styles.btn_radio)
        self.verticalLayout_gb.addWidget(self.radioButton_options)

        self.radioButton_about = QRadioButton(" About", self.groupBox)
        self.radioButton_about.setStyleSheet(styles.btn_radio)
        self.verticalLayout_gb.addWidget(self.radioButton_about)
コード例 #23
0
class ElementAllegroMonitored(QFrame):

    def __init__(self, name, link, is_done, price, xpath, time, is_monitoring, parent=None, shared_dict=None):
        QFrame.__init__(self, parent)
        self.shared_dict = shared_dict
        self.setMinimumSize(QSize(0, 300))
        self.setStyleSheet("""QFrame{border-bottom: 0.5px solid #aaa;}""")
        self.setFrameShape(QFrame.StyledPanel)
        self.setFrameShadow(QFrame.Raised)
        self.horizontalLayout = QHBoxLayout(self)

        # create description frame and layout
        self.frame_description = QFrame(self)
        self.frame_description.setMinimumSize(QSize(440, 16777215))
        self.frame_description.setStyleSheet("""QFrame{border: none;}""")
        self.frame_description.setFrameShape(QFrame.StyledPanel)
        self.frame_description.setFrameShadow(QFrame.Raised)
        self.gridLayout_description = QGridLayout(self.frame_description)
        self.horizontalLayout.addWidget(self.frame_description)
        self.gridLayout_description.setColumnStretch(0, 1)
        self.gridLayout_description.setColumnStretch(1, 2)
        self.gridLayout_description.setColumnStretch(2, 3)
        self.gridLayout_description.setColumnStretch(3, 1)
        self.gridLayout_description.setColumnStretch(4, 6)

        # fill description layout
        self.label_name = QLabel(name, self.frame_description)
        self.label_name.setStyleSheet(styles.label_allegro_monitored_name)
        self.label_name.setTextFormat(Qt.MarkdownText)
        self.label_name.setAlignment(Qt.AlignJustify | Qt.AlignVCenter)
        self.label_name.setWordWrap(False)
        self.gridLayout_description.addWidget(self.label_name, 0, 0, 1, 5)

        self.url_link = "<a href=\"" + link + "\" style = \" color: #838836; text-decoration: none; font-family:corbel; title=\"Go to monitored page\"\">check product</a>"
        self.label_monitored_link = QLabel(url_link, self.frame_description)
        self.label_monitored_link.setStyleSheet(styles.label_allegro_monitored_link)
        self.gridLayout_description.addWidget(self.label_monitored_link, 1, 1, 2, 2)
        self.label_monitored_link.setOpenExternalLinks(True)

        self.label_stat = QLabel(self.frame_description)
        self.label_stat.setStyleSheet(styles.label_allegro_monitored_stat)
        self.gridLayout_description.addWidget(self.label_stat, 1, 4, 1, 1)

        self.label_is_on = QLabel(self.frame_description)
        self.label_is_on.setStyleSheet(styles.label_allegro_monitored_stat)
        self.gridLayout_description.addWidget(self.label_is_on, 5, 0, 1, 2)

        self.label_new_time = QLabel("Actual refresh time[s]: " + str(time)+" s", self.frame_description)
        self.label_new_time.setStyleSheet(styles.label_allegro_monitored_stat)
        self.gridLayout_description.addWidget(self.label_new_time, 4, 0, 1, 3)

        self.lineEdit_new_time = QLineEdit(self.frame_description)
        self.lineEdit_new_time.setMinimumSize(QSize(0, 33))
        self.lineEdit_new_time.setStyleSheet(styles.lineEdit)
        self.gridLayout_description.addWidget(self.lineEdit_new_time, 4, 3, 1, 2)
        self.lineEdit_new_time.setPlaceholderText("Set new interval")

        self.label_new_price = QLabel("Actual price: " + str(price), self)
        self.label_new_price.setStyleSheet(styles.label_allegro_monitored_stat)
        self.gridLayout_description.addWidget(self.label_new_price, 3, 0, 1, 3)

        self.lineEdit_new_price = QLineEdit(self)
        self.lineEdit_new_price.setMinimumSize(QSize(0, 35))
        self.lineEdit_new_price.setStyleSheet(styles.lineEdit)
        self.gridLayout_description.addWidget(self.lineEdit_new_price, 3, 3, 1, 2)
        self.lineEdit_new_price.setPlaceholderText("Set new price")

        self.label_img_link = QLabel(self.frame_description)
        self.label_img_link.setMaximumSize(QSize(20, 20))
        self.label_img_link.setStyleSheet("""QLabel{border: none;}""")
        self.label_img_link.setPixmap(QPixmap(os.path.join(path, "img/link.png")))
        self.label_img_link.setScaledContents(True)
        self.gridLayout_description.addWidget(self.label_img_link, 1, 0, 2, 1)

        self.label_img_stat = QLabel("done", self.frame_description)
        if is_done:
            self.label_stat.setText("done")
            self.label_img_stat.setPixmap(QPixmap(os.path.join(path, "img/check.png")))
        else:
            self.label_stat.setText("in progress")
            self.label_img_stat.setPixmap(QPixmap(os.path.join(path, "img/loading.png")))
        self.label_img_stat.setMaximumSize(QSize(20, 20))
        self.label_img_stat.setStyleSheet("""QLabel{border: none;}""")
        self.label_img_stat.setScaledContents(True)
        self.gridLayout_description.addWidget(self.label_img_stat, 1, 3, 1, 1)

        self.label_img_monitor = QLabel("done", self.frame_description)
        if is_monitoring:
            monitor_text = "I am just monitoring"
            self.label_img_monitor.setPixmap(QPixmap(os.path.join(path, "img/monitoring.png")))
        else:
            monitor_text = "I am going to buy"
            self.label_img_monitor.setPixmap(QPixmap(os.path.join(path, "img/buy.png")))
        self.label_is_monitoring = QLabel(monitor_text, self)
        self.label_is_monitoring.setStyleSheet(styles.label_allegro_monitored_stat)
        self.gridLayout_description.addWidget(self.label_is_monitoring, 2, 4, 1, 1)

        self.label_img_monitor.setMaximumSize(QSize(20, 20))
        self.label_img_monitor.setStyleSheet("""QLabel{border: none;}""")
        self.label_img_monitor.setScaledContents(True)
        self.gridLayout_description.addWidget(self.label_img_monitor, 2, 3, 1, 1)





        # create spacer and delete btn
        self.spacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
        self.horizontalLayout.addItem(self.spacer)

        self.pushButton_delete = QPushButton(self)
        # self.pushButton_delete.clicked.connect( lambda: self.deleteLater())
        self.pushButton_delete.clicked.connect(lambda: self.on_delete(link))
        icon = QIcon()
        icon.addFile(os.path.join(path, "img/delete.png"), QSize(), QIcon.Selected, QIcon.Off)
        # icon.Active.addFile(os.path.join(path, "img/icon.png"), QSize(), QIcon.Selected, QIcon.Off)
        self.pushButton_delete.setIcon(icon)
        self.pushButton_delete.setIconSize(QSize(50, 50))
        self.pushButton_delete.setStyleSheet("""QPushButton{border:none; }""")
        self.pushButton_delete.setCursor(QCursor(Qt.PointingHandCursor))
        # self.pushButton_delete.ico
        self.horizontalLayout.addWidget(self.pushButton_delete)

        self.is_on = data.get_switch_state(link)
        self.pushButton_switch = QPushButton(self)
        self.pushButton_switch.clicked.connect(lambda: self.on_switch(link))
        self.icon_on = QIcon()
        self.icon_off = QIcon()
        self.icon_on.addFile(os.path.join(path, "img/switch_on.png"), QSize(), QIcon.Selected, QIcon.On)
        self.icon_off.addFile(os.path.join(path, "img/switch_off.png"), QSize(), QIcon.Selected, QIcon.Off)
        if self.is_on:
            self.label_is_on.setText("Disable")
            self.pushButton_switch.setIcon(self.icon_on)
        else:
            self.label_is_on.setText("Enable")
            self.pushButton_switch.setIcon(self.icon_off)
        self.pushButton_switch.setIconSize(QSize(100, 40))
        self.pushButton_switch.setStyleSheet("""QPushButton{border:none; }""")
        self.pushButton_switch.setCursor(QCursor(Qt.PointingHandCursor))
        self.gridLayout_description.addWidget(self.pushButton_switch, 5, 2, 1, 1)

        self.pushButton_save_changes = QPushButton("Save", self)
        self.pushButton_save_changes.clicked.connect(lambda: self.on_save_changes(link))
        self.pushButton_save_changes.setIconSize(QSize(100, 20))
        self.pushButton_save_changes.setStyleSheet(styles.btn_dark)
        self.pushButton_save_changes.setCursor(QCursor(Qt.PointingHandCursor))
        self.gridLayout_description.addWidget(self.pushButton_save_changes, 5, 3, 1, 2)

    def on_delete(self, link):
        data.delete_monitored_element(link)
        self.deleteLater()
        self.shared_dict['isTerminatedP2'] = True

    def on_save_changes(self, link):
        data.change_price_time(link, self.lineEdit_new_price.text(), self.lineEdit_new_time.text())
        if self.lineEdit_new_price.text() != '':
            self.label_new_price.setText("Actual price: " + self.lineEdit_new_price.text())
        if self.lineEdit_new_time.text() != '':
            self.label_new_time.setText("Actual refresh time[s]: " + self.lineEdit_new_time.text() + " s")
        self.lineEdit_new_time.clear()
        self.lineEdit_new_price.clear()
        self.shared_dict['isTerminatedP2'] = True

    def on_switch(self, link):
        # m.stop_run_monitor()
        if self.is_on:
            self.label_is_on.setText("Enable")
            self.pushButton_switch.setIcon(self.icon_off)
            self.is_on = False
            data.switch_state(self.is_on, link)
        else:
            self.label_is_on.setText("Disable")
            self.pushButton_switch.setIcon(self.icon_on)
            self.is_on = True
            data.switch_state(self.is_on, link)
        self.shared_dict['isTerminatedP2'] = True
コード例 #24
0
class PageAllegroAdd(QWidget):
    def __init__(self, parent=None, shared_dict=None):
        QWidget.__init__(self, parent)
        parent.addWidget(self)
        self.shared_dict = shared_dict
        self.gridLayout = QGridLayout(self)
        self.gridLayout.setContentsMargins(0, 0, 0, 0)
        self.gridLayout.setRowStretch(0, 1)
        self.gridLayout.setRowStretch(1, 1)
        self.gridLayout.setRowStretch(2, 1)
        self.gridLayout.setRowStretch(3, 1)
        self.gridLayout.setRowStretch(4, 1)
        self.gridLayout.setRowStretch(5, 1)
        self.gridLayout.setRowStretch(6, 1)
        self.gridLayout.setRowStretch(7, 1)
        self.gridLayout.setRowStretch(8, 1)
        self.gridLayout.setRowStretch(9, 1)
        self.gridLayout.setRowStretch(10, 1)
        self.gridLayout.setRowStretch(11, 1)
        self.gridLayout.setRowStretch(12, 1)
        self.gridLayout.setRowStretch(13, 1)
        self.gridLayout.setRowStretch(14, 2)
        self.gridLayout.setRowStretch(15, 1)
        self.gridLayout.setColumnStretch(0, 5)
        self.gridLayout.setColumnStretch(1, 5)
        self.gridLayout.setColumnStretch(2, 1)
        self.gridLayout.setColumnStretch(3, 2)
        self.gridLayout.setColumnStretch(4, 1)
        self.gridLayout.setColumnStretch(5, 2)
        self.gridLayout.setColumnStretch(6, 1)
        self.gridLayout.setColumnStretch(7, 2)
        self.gridLayout.setColumnStretch(8, 3)
        self.gridLayout.setColumnStretch(9, 5)

        # create lineEdits
        self.lineEdit_login = QLineEdit(self)
        self.lineEdit_login.setMinimumSize(QSize(0, 60))
        self.lineEdit_login.setSizeIncrement(QSize(40, 40))
        self.lineEdit_login.setStyleSheet(styles.lineEdit)
        self.lineEdit_login.setMaxLength(32767)
        self.gridLayout.addWidget(self.lineEdit_login, 4, 1, 1, 3)
        self.lineEdit_login.setPlaceholderText("login or email of your account")

        self.lineEdit_password = QLineEdit(self)
        self.lineEdit_password.setMinimumSize(QSize(20, 60))
        self.lineEdit_password.setStyleSheet(styles.lineEdit)
        self.lineEdit_password.setEchoMode(QLineEdit.Password)
        self.lineEdit_password.setReadOnly(False)
        self.gridLayout.addWidget(self.lineEdit_password, 7, 1, 1, 3)
        self.lineEdit_password.setPlaceholderText("password of your account")

        self.lineEdit_email = QLineEdit(self)
        self.lineEdit_email.setMinimumSize(QSize(0, 60))
        self.lineEdit_email.setStyleSheet(styles.lineEdit)
        self.lineEdit_email.setFrame(True)
        self.lineEdit_email.setEchoMode(QLineEdit.Normal)
        self.gridLayout.addWidget(self.lineEdit_email, 7, 5, 1, 4)
        self.lineEdit_email.setPlaceholderText("email to which the notification will be sent")

        self.lineEdit_link = QLineEdit(self)
        self.lineEdit_link.setMinimumSize(QSize(0, 60))
        self.lineEdit_link.setStyleSheet(styles.lineEdit)
        self.gridLayout.addWidget(self.lineEdit_link, 10, 1, 1, 8)
        self.lineEdit_link.setPlaceholderText("link to the page that you want to monitor")

        self.lineEdit_price = QLineEdit(self)
        self.lineEdit_price.setMinimumSize(QSize(0, 60))
        self.lineEdit_price.setStyleSheet(styles.lineEdit)
        self.gridLayout.addWidget(self.lineEdit_price, 13, 1, 1, 1)
        self.lineEdit_price.setPlaceholderText("Price below which to notificate")

        self.lineEdit_xpath = QLineEdit(self)
        self.lineEdit_xpath.setMinimumSize(QSize(0, 60))
        self.lineEdit_xpath.setStyleSheet(styles.lineEdit)
        self.gridLayout.addWidget(self.lineEdit_xpath, 13, 3, 1, 3)
        self.lineEdit_xpath.setPlaceholderText("XPATH of element with the price")

        self.lineEdit_time = QLineEdit(self)
        self.lineEdit_time.setMinimumSize(QSize(0, 60))
        self.lineEdit_time.setStyleSheet(styles.lineEdit)
        self.gridLayout.addWidget(self.lineEdit_time, 13, 7, 1, 2)
        self.lineEdit_time.setPlaceholderText("interval between refreshes")

        # Create Labels
        self.label_title = QLabel("Add new monitoring object", self)
        self.label_title.setStyleSheet(styles.label_title)
        self.label_title.setAlignment(Qt.AlignCenter)
        self.gridLayout.addWidget(self.label_title, 0, 1, 1, 8)

        self.label_info = QLabel("", self)
        self.label_info.setStyleSheet(styles.label_info_wrong)
        self.label_info.setAlignment(Qt.AlignCenter)
        self.gridLayout.addWidget(self.label_info, 1, 1, 1, 8)

        self.label_login = QLabel("Allegro login", self)
        self.label_login.setStyleSheet(styles.label_lineEdit)
        self.gridLayout.addWidget(self.label_login, 3, 1, 1, 3)

        self.label_password = QLabel("Allegro password", self)
        self.label_password.setStyleSheet(styles.label_lineEdit)
        self.gridLayout.addWidget(self.label_password, 6, 1, 1, 3)

        self.label_email = QLabel("Email to notificate", self)
        self.label_email.setStyleSheet(styles.label_lineEdit)
        self.gridLayout.addWidget(self.label_email, 6, 5, 1, 4)

        self.label_link = QLabel("Product link", self)
        self.label_link.setStyleSheet(styles.label_lineEdit)
        self.gridLayout.addWidget(self.label_link, 9, 1, 1, 8)

        self.label_price = QLabel("Price", self)
        self.label_price.setStyleSheet(styles.label_lineEdit)
        self.gridLayout.addWidget(self.label_price, 12, 1, 1, 1)

        self.label_xpath = QLabel("Monitored element", self)
        self.label_xpath.setStyleSheet(styles.label_lineEdit)
        self.gridLayout.addWidget(self.label_xpath, 12, 3, 1, 3)

        self.label_time = QLabel("Refresh time[s]", self)
        self.label_time.setStyleSheet(styles.label_lineEdit)
        self.gridLayout.addWidget(self.label_time, 12, 7, 1, 2)

        self.pushButton_search = QPushButton(self)
        self.pushButton_search.clicked.connect(lambda: webbrowser.open('https://allegro.pl/'))
        icon = QIcon()
        icon.addFile(os.path.join(path, "img/search.png"), QSize(), QIcon.Selected, QIcon.Off)
        self.pushButton_search.setIcon(icon)
        self.pushButton_search.setIconSize(QSize(100, 100))
        self.pushButton_search.setStyleSheet("""QPushButton{border:none;}""")
        self.pushButton_search.setCursor(QCursor(Qt.PointingHandCursor))
        self.gridLayout.addWidget(self.pushButton_search, 3, 7, 3, 1)

        # Create spacers
        self.spacer_search_l = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
        self.gridLayout.addItem(self.spacer_search_l, 5, 5, 1, 2)

        self.spacer_search_r = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
        self.gridLayout.addItem(self.spacer_search_r, 5, 8, 1, 1)

        self.spacer_search_t = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
        self.gridLayout.addItem(self.spacer_search_t, 2, 1, 1, 8)

        self.spacer_search_b = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
        self.gridLayout.addItem(self.spacer_search_b, 5, 1, 1, 8)

        self.spacer_email_l = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
        self.gridLayout.addItem(self.spacer_email_l, 7, 4, 1, 1)

        self.spacer_link_l = QSpacerItem(40, 20, QSizePolicy.MinimumExpanding, QSizePolicy.Minimum)
        self.gridLayout.addItem(self.spacer_link_l, 13, 0, 1, 1)

        self.spacer_link_r = QSpacerItem(40, 20, QSizePolicy.MinimumExpanding, QSizePolicy.Minimum)
        self.gridLayout.addItem(self.spacer_link_r, 13, 9, 1, 1)

        self.spacer_link_t = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
        self.gridLayout.addItem(self.spacer_link_t, 8, 1, 1, 8)

        self.spacer_link_b = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
        self.gridLayout.addItem(self.spacer_link_b, 11, 1, 1, 8)

        self.spacer_price_b = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
        self.gridLayout.addItem(self.spacer_price_b, 14, 1, 1, 7)

        # create frame bottom
        self.frame_bottom = QFrame(self)
        self.frame_bottom.setStyleSheet("""QFrame{background-color: #fff; padding: 10px;}""")
        self.frame_bottom.setFrameShape(QFrame.StyledPanel)
        self.frame_bottom.setFrameShadow(QFrame.Raised)
        self.gridLayout.addWidget(self.frame_bottom, 15, 0, 1, 10)
        self.horizontalLayout_frame_bottom = QHBoxLayout(self.frame_bottom)

        self.spacer_frame_bottom_l = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
        self.horizontalLayout_frame_bottom.addItem(self.spacer_frame_bottom_l)

        self.pushButton_bn = QPushButton("Buy when price drops", self.frame_bottom)
        self.pushButton_bn.setMinimumSize(QSize(0, 40))
        self.pushButton_bn.setStyleSheet(styles.btn_light)
        self.horizontalLayout_frame_bottom.addWidget(self.pushButton_bn)
        self.pushButton_bn.setShortcut("Return")

        self.spacer_frame_bottom_c = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
        self.horizontalLayout_frame_bottom.addItem(self.spacer_frame_bottom_c)

        self.pushButton_monitor = QPushButton("Monitor", self.frame_bottom)
        self.pushButton_monitor.clicked.connect(lambda: self.new_link_handler(True))
        self.pushButton_monitor.setMinimumSize(QSize(0, 40))
        self.pushButton_monitor.setStyleSheet(styles.btn_dark)
        self.horizontalLayout_frame_bottom.addWidget(self.pushButton_monitor)

        self.spacer_frame_bottom_r = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
        self.horizontalLayout_frame_bottom.addItem(self.spacer_frame_bottom_r)

        self.horizontalLayout_frame_bottom.setStretch(0, 1)
        self.horizontalLayout_frame_bottom.setStretch(1, 1)
        self.horizontalLayout_frame_bottom.setStretch(2, 2)
        self.horizontalLayout_frame_bottom.setStretch(3, 1)
        self.horizontalLayout_frame_bottom.setStretch(4, 1)
        self.timer = QTimer(self)

        auto_login, auto_pwd, auto_email, auto_time = data.get_autofill()
        self.lineEdit_login.setText(auto_login)
        self.lineEdit_password.setText(auto_pwd)
        self.lineEdit_email.setText(auto_email)
        self.lineEdit_time.setText(str(auto_time))

    def new_link_handler(self, is_monitoring):
        # check if fields were filled properly
        no_warnings = True
        is_email = False
        link = ""
        login = ""
        email = ""
        password = ""
        xpath = ""
        price = 0
        time = 60
        if self.lineEdit_email.text() == "":
            self.lineEdit_email.setStyleSheet(styles.lineEdit_warning)
            no_warnings = False
        else:
            self.lineEdit_email.setStyleSheet(styles.lineEdit)
            email = self.lineEdit_email.text()
            for symbol in email:
                if symbol == '@':
                    is_email = True
            if not is_email:
                self.lineEdit_email.setStyleSheet(styles.lineEdit_warning)
                no_warnings = False
        if self.lineEdit_login.text() == "":
            self.lineEdit_login.setStyleSheet(styles.lineEdit_warning)
            no_warnings = False
        else:
            self.lineEdit_login.setStyleSheet(styles.lineEdit)
            login = self.lineEdit_login.text()
        if self.lineEdit_link.text() == "":
            self.lineEdit_link.setStyleSheet(styles.lineEdit_warning)
            no_warnings = False
        else:
            self.lineEdit_link.setStyleSheet(styles.lineEdit)
            link = self.lineEdit_link.text()

        if self.lineEdit_password.text() == "":
            self.lineEdit_password.setStyleSheet(styles.lineEdit_warning)
            no_warnings = False
        else:
            self.lineEdit_password.setStyleSheet(styles.lineEdit)
            password = self.lineEdit_password.text()

        if self.lineEdit_price.text() == "":
            self.lineEdit_price.setStyleSheet(styles.lineEdit_warning)
            no_warnings = False
        else:
            self.lineEdit_price.setStyleSheet(styles.lineEdit)
            price = float(self.lineEdit_price.text())

        if self.lineEdit_xpath.text() == "":
            self.lineEdit_xpath.setStyleSheet(styles.lineEdit_warning)
            no_warnings = False
        else:
            self.lineEdit_xpath.setStyleSheet(styles.lineEdit)
            xpath = self.lineEdit_xpath.text()

        if self.lineEdit_time.text() == "":
            self.lineEdit_time.setStyleSheet(styles.lineEdit_warning)
            no_warnings = False
        else:
            self.lineEdit_time.setStyleSheet(styles.lineEdit)
            time = int(self.lineEdit_time.text())

        if no_warnings:
            self.lineEdit_login.clear()
            self.lineEdit_password.clear()
            self.lineEdit_email.clear()
            self.lineEdit_link.clear()
            self.lineEdit_price.clear()
            self.lineEdit_xpath.clear()
            self.lineEdit_time.clear()
            try:
                data.add_monitored_elements(login, email, password, link, price, xpath, time, is_monitoring)
                self.shared_dict['isTerminatedP2'] = True
            except InvalidArgumentException:
                self.set_info_text("Warning. Wrong link submitted", True)
            except KeyError:
                self.set_info_text("Error. This page has already monitored", True)
            else:
                self.set_info_text("Info. Object was successfully added", False)
                self.lineEdit_login.setText(self.auto_login)
                self.lineEdit_password.setText(self.auto_pwd)
                self.lineEdit_email.setText(self.auto_email)
                self.lineEdit_time.setText(self.auto_time)
                self.lineEdit_link.clear()
                self.lineEdit_price.clear()
                self.lineEdit_xpath.clear()
        else:
            self.set_info_text("Warning. Fill all field properly", True)
        return data.get_element(link)

    # def on_monitor(self):
    #     new_price = monitoring.check_if_price_lower(self.label_link, self.label_xpath, self.label_price, self.label_time)
    #     email_send.send_email(self.label_email, self.label_link, new_price)

    def set_info_text(self, text, is_warning):
        self.label_info.setText(text)
        if is_warning:
            self.label_info.setStyleSheet(styles.label_info_wrong)
        else:
            self.label_info.setStyleSheet(styles.label_info_right)
        self.timer.setInterval(5000)
        self.timer.timeout.connect(lambda: self.label_info.setText(""))
        self.timer.start()
コード例 #25
0
class Ui_Whatspy(object):
    def setupUi(self, Ventana):
        if not Ventana.objectName():
            Ventana.setObjectName(u"Ventana")
        Ventana.resize(424, 600)
        Ventana.setAttribute(Qt.WA_TranslucentBackground)
        Ventana.setWindowFlag(Qt.FramelessWindowHint)
        Ventana.setStyleSheet(
            u"*{\n"
            "	font-family: century gothic;\n"
            "}\n"
            "\n"
            "QSizeGrip{\n"
            "       background: transparent;\n"
            "}\n"
            "\n"
            "QLabel{\n"
            "	color: white;\n"
            "}\n"
            "\n"
            "QScrollBar:vertical {\n"
            "            border: 1px solid #999999;\n"
            "            width:12px;    \n"
            "            margin: 0px 0px 0px 0px;\n"
            "        }\n"
            "        QScrollBar::handle:vertical {         \n"
            "       \n"
            "            min-height: 0px;\n"
            "          	border: 0px solid red;\n"
            "			border-radius: 4px;\n"
            "			background-color: rgb(182, 182, 182);\n"
            "        }\n"
            "        QScrollBar::add-line:vertical {       \n"
            "            height: 0px;\n"
            "            subcontrol-position: bottom;\n"
            "            subcontrol-origin: margin;\n"
            "        }\n"
            "        QScrollBar::sub-line:vertical {\n"
            "            height: 0 px;\n"
            "            subcontrol-position: top;\n"
            "            subcontrol-origin: margin;\n"
            "        }")
        self.gridLayout = QGridLayout(Ventana)
        self.gridLayout.setObjectName(u"gridLayout")
        self.gridLayout.setContentsMargins(0, 0, 0, 0)
        self.VentanaFrame = QFrame(Ventana)
        self.VentanaFrame.setObjectName(u"VentanaFrame")
        self.VentanaFrame.setStyleSheet(
            u"QFrame#VentanaFrame{\n"
            "	background-color: qlineargradient(spread:pad, x1:0.953, y1:1, x2:1, y2:0, stop:0 	#075E54, stop:1 #128C7E);\n"
            "	border-radius: 5px;\n"
            "}")
        self.VentanaFrame.setFrameShape(QFrame.StyledPanel)
        self.VentanaFrame.setFrameShadow(QFrame.Raised)
        self.gridLayout_2 = QGridLayout(self.VentanaFrame)
        self.gridLayout_2.setObjectName(u"gridLayout_2")
        self.gridLayout_2.setContentsMargins(-1, 0, -1, -1)
        self.Contenedor = QFrame(self.VentanaFrame)
        self.Contenedor.setObjectName(u"Contenedor")
        self.Contenedor.setStyleSheet(u"QFrame#Contenedor{\n"
                                      "	background-color: #128C7E;\n"
                                      "	border-radius: 5px;\n"
                                      "}")
        self.Contenedor.setFrameShape(QFrame.StyledPanel)
        self.Contenedor.setFrameShadow(QFrame.Raised)
        self.gridLayout_5 = QGridLayout(self.Contenedor)
        self.gridLayout_5.setObjectName(u"gridLayout_5")
        self.gridLayout_5.setContentsMargins(0, 10, 0, 10)
        self.frameAcciones = QFrame(self.Contenedor)
        self.frameAcciones.setObjectName(u"frameAcciones")
        sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.frameAcciones.sizePolicy().hasHeightForWidth())
        self.frameAcciones.setSizePolicy(sizePolicy)
        self.frameAcciones.setStyleSheet(u"")
        self.frameAcciones.setFrameShape(QFrame.StyledPanel)
        self.frameAcciones.setFrameShadow(QFrame.Raised)
        self.gridLayout_4 = QGridLayout(self.frameAcciones)
        self.gridLayout_4.setObjectName(u"gridLayout_4")
        self.btnExportar = QPushButton(self.frameAcciones)
        self.btnExportar.setObjectName(u"btnExportar")
        sizePolicy1 = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Minimum)
        sizePolicy1.setHorizontalStretch(0)
        sizePolicy1.setVerticalStretch(0)
        sizePolicy1.setHeightForWidth(
            self.btnExportar.sizePolicy().hasHeightForWidth())
        self.btnExportar.setSizePolicy(sizePolicy1)
        self.btnExportar.setMinimumSize(QSize(100, 30))
        self.btnExportar.setCursor(QCursor(Qt.PointingHandCursor))
        self.btnExportar.setStyleSheet(u"QPushButton#btnExportar{\n"
                                       "background-color: #ecf0f1;\n"
                                       "border-radius: 5px;\n"
                                       "}\n"
                                       "\n"
                                       "QPushButton#btnExportar:hover{\n"
                                       "background-color: #bdc3c7;\n"
                                       "border-radius: 5px;\n"
                                       "}")
        icon1 = QIcon()
        icon1.addFile(u":/logo/exportar.png", QSize(), QIcon.Normal, QIcon.Off)
        self.btnExportar.setIcon(icon1)
        self.btnExportar.setIconSize(QSize(16, 16))

        self.gridLayout_4.addWidget(self.btnExportar, 0, 2, 1, 1)

        self.btnAbrir = QPushButton(self.frameAcciones)
        self.btnAbrir.setObjectName(u"btnAbrir")
        sizePolicy1.setHeightForWidth(
            self.btnAbrir.sizePolicy().hasHeightForWidth())
        self.btnAbrir.setSizePolicy(sizePolicy1)
        self.btnAbrir.setMinimumSize(QSize(100, 30))
        self.btnAbrir.setCursor(QCursor(Qt.PointingHandCursor))
        self.btnAbrir.setStyleSheet(u"QPushButton#btnAbrir{\n"
                                    "background-color: #ecf0f1;\n"
                                    "border-radius: 5px;\n"
                                    "}\n"
                                    "\n"
                                    "QPushButton#btnAbrir:hover{\n"
                                    "background-color: #bdc3c7;\n"
                                    "}")
        icon2 = QIcon()
        icon2.addFile(u":/logo/anadir.png", QSize(), QIcon.Normal, QIcon.Off)
        self.btnAbrir.setIcon(icon2)
        self.btnAbrir.setIconSize(QSize(16, 16))

        self.gridLayout_4.addWidget(self.btnAbrir, 0, 1, 1, 1)

        self.horizontalSpacer_2 = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                              QSizePolicy.Minimum)

        self.gridLayout_4.addItem(self.horizontalSpacer_2, 0, 0, 1, 1)

        self.horizontalSpacer_3 = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                              QSizePolicy.Minimum)

        self.gridLayout_4.addItem(self.horizontalSpacer_3, 0, 3, 1, 1)

        self.gridLayout_5.addWidget(self.frameAcciones, 2, 0, 1, 1)

        self.frameTabla = QFrame(self.Contenedor)
        self.frameTabla.setObjectName(u"frameTabla")
        sizePolicy2 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
        sizePolicy2.setHorizontalStretch(0)
        sizePolicy2.setVerticalStretch(0)
        sizePolicy2.setHeightForWidth(
            self.frameTabla.sizePolicy().hasHeightForWidth())
        self.frameTabla.setSizePolicy(sizePolicy2)
        self.frameTabla.setStyleSheet(u"")
        self.frameTabla.setFrameShape(QFrame.StyledPanel)
        self.frameTabla.setFrameShadow(QFrame.Raised)
        self.horizontalLayout_2 = QHBoxLayout(self.frameTabla)
        self.horizontalLayout_2.setObjectName(u"horizontalLayout_2")
        self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0)
        self.horizontalSpacer_4 = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                              QSizePolicy.Minimum)

        self.horizontalLayout_2.addItem(self.horizontalSpacer_4)

        self.tableWidget = QTableWidget(self.frameTabla)
        if (self.tableWidget.columnCount() < 2):
            self.tableWidget.setColumnCount(2)
        __qtablewidgetitem = QTableWidgetItem()
        self.tableWidget.setHorizontalHeaderItem(0, __qtablewidgetitem)
        __qtablewidgetitem1 = QTableWidgetItem()
        self.tableWidget.setHorizontalHeaderItem(1, __qtablewidgetitem1)
        if (self.tableWidget.rowCount() < 50):
            self.tableWidget.setRowCount(50)
        __qtablewidgetitem2 = QTableWidgetItem()
        self.tableWidget.setItem(0, 0, __qtablewidgetitem2)
        self.tableWidget.setObjectName(u"tableWidget")
        sizePolicy1.setHeightForWidth(
            self.tableWidget.sizePolicy().hasHeightForWidth())
        self.tableWidget.setSizePolicy(sizePolicy1)
        self.tableWidget.setMinimumSize(QSize(350, 0))
        self.tableWidget.setStyleSheet(u"QTableWidget#tableWidget:item{\n"
                                       "color:white;\n"
                                       "font-weight: bold;\n"
                                       "}\n"
                                       "\n"
                                       "QTableWidget#tableWidget{\n"
                                       "border-radius:4px;\n"
                                       "background-color: #128C7E;\n"
                                       "}")
        self.tableWidget.setRowCount(50)

        self.horizontalLayout_2.addWidget(self.tableWidget)

        self.horizontalSpacer_5 = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                              QSizePolicy.Minimum)

        self.horizontalLayout_2.addItem(self.horizontalSpacer_5)

        self.gridLayout_5.addWidget(self.frameTabla, 3, 0, 1, 1)

        self.header = QFrame(self.Contenedor)
        self.header.setObjectName(u"header")
        sizePolicy.setHeightForWidth(
            self.header.sizePolicy().hasHeightForWidth())
        self.header.setSizePolicy(sizePolicy)
        self.header.setStyleSheet(u"")
        self.header.setFrameShape(QFrame.StyledPanel)
        self.header.setFrameShadow(QFrame.Raised)
        self.horizontalLayout = QHBoxLayout(self.header)
        self.horizontalLayout.setObjectName(u"horizontalLayout")
        self.horizontalLayout.setContentsMargins(0, 0, 5, 0)
        self.horizontalSpacer = QSpacerItem(0, 0, QSizePolicy.Expanding,
                                            QSizePolicy.Minimum)

        self.horizontalLayout.addItem(self.horizontalSpacer)

        self.btnVerde = QPushButton(self.header)
        self.btnVerde.setObjectName(u"btnVerde")
        self.btnVerde.setMaximumSize(QSize(16, 16))
        self.btnVerde.setCursor(QCursor(Qt.PointingHandCursor))
        self.btnVerde.setStyleSheet(u"QPushButton#btnVerde{\n"
                                    "	background-color: #27ae60;\n"
                                    "	border-radius: 8px;\n"
                                    "}\n"
                                    "\n"
                                    "QPushButton#btnVerde:hover{\n"
                                    "	background-color: #10ac84;\n"
                                    "	border-radius: 8px;\n"
                                    "}")

        self.horizontalLayout.addWidget(self.btnVerde)

        self.btnAmarillo = QPushButton(self.header)
        self.btnAmarillo.setObjectName(u"btnAmarillo")
        self.btnAmarillo.setMaximumSize(QSize(16, 16))
        self.btnAmarillo.setCursor(QCursor(Qt.PointingHandCursor))
        self.btnAmarillo.setStyleSheet(u"QPushButton#btnAmarillo{\n"
                                       "background-color: yellow;\n"
                                       "border-radius: 8px;\n"
                                       "}\n"
                                       "\n"
                                       "QPushButton#btnAmarillo:hover{\n"
                                       "background-color: #f1c40f;\n"
                                       "border-radius: 8px;\n"
                                       "}\n"
                                       "")

        self.horizontalLayout.addWidget(self.btnAmarillo)

        self.btnRojo = QPushButton(self.header)
        self.btnRojo.setObjectName(u"btnRojo")
        self.btnRojo.setMaximumSize(QSize(16, 16))
        self.btnRojo.setCursor(QCursor(Qt.PointingHandCursor))
        self.btnRojo.setStyleSheet(u"QPushButton#btnRojo{\n"
                                   "background-color: red;\n"
                                   "border-radius: 8px;\n"
                                   "}\n"
                                   "\n"
                                   "QPushButton#btnRojo:hover{\n"
                                   "background-color: #e74c3c;\n"
                                   "border-radius: 8px;\n"
                                   "}")

        self.horizontalLayout.addWidget(self.btnRojo)

        self.gridLayout_5.addWidget(self.header, 0, 0, 1, 1)

        self.frameLogo = QFrame(self.Contenedor)
        self.frameLogo.setObjectName(u"frameLogo")
        sizePolicy.setHeightForWidth(
            self.frameLogo.sizePolicy().hasHeightForWidth())
        self.frameLogo.setSizePolicy(sizePolicy)
        self.frameLogo.setStyleSheet(u"")
        self.frameLogo.setFrameShape(QFrame.StyledPanel)
        self.frameLogo.setFrameShadow(QFrame.Raised)
        self.gridLayout_3 = QGridLayout(self.frameLogo)
        self.gridLayout_3.setObjectName(u"gridLayout_3")
        self.lblWhatsPy = QLabel(self.frameLogo)
        self.lblWhatsPy.setObjectName(u"lblWhatsPy")
        font = QFont()
        font.setFamily(u"century gothic")
        font.setBold(True)
        font.setWeight(75)
        self.lblWhatsPy.setFont(font)
        self.lblWhatsPy.setAlignment(Qt.AlignCenter)

        self.gridLayout_3.addWidget(self.lblWhatsPy, 1, 0, 1, 1)

        self.icon = QLabel(self.frameLogo)
        self.icon.setObjectName(u"icon")
        self.icon.setMaximumSize(QSize(70, 70))
        self.icon.setPixmap(QPixmap(u":/logo/logo.png"))
        self.icon.setScaledContents(True)

        self.gridLayout_3.addWidget(self.icon, 0, 0, 1, 1)

        self.gridLayout_5.addWidget(self.frameLogo, 1, 0, 1, 1)

        self.label = QLabel(self.Contenedor)
        self.label.setObjectName(u"label")
        sizePolicy.setHeightForWidth(
            self.label.sizePolicy().hasHeightForWidth())
        self.label.setSizePolicy(sizePolicy)
        self.label.setFont(font)
        self.label.setAlignment(Qt.AlignCenter)

        self.gridLayout_5.addWidget(self.label, 4, 0, 1, 1)

        self.gridLayout_2.addWidget(self.Contenedor, 0, 0, 1, 1)

        self.lblGrip = QLabel(self.VentanaFrame)
        self.lblGrip.setObjectName(u"lblGrip")
        sizePolicy.setHeightForWidth(
            self.lblGrip.sizePolicy().hasHeightForWidth())
        self.lblGrip.setSizePolicy(sizePolicy)
        self.lblGrip.setMaximumSize(QSize(10, 10))
        self.lblGrip.setCursor(QCursor(Qt.BusyCursor))
        self.lblGrip.setLayoutDirection(Qt.RightToLeft)
        self.lblGrip.setStyleSheet(
            u"QLabel#lblGrip:hover{\n"
            "	background: rgb(18, 140, 126);\n"
            "	border-radius: 5px;\n"
            "}\n"
            "\n"
            "QLabel#lblGrip{\n"
            "	background-color: qlineargradient(spread:pad, x1:0.953, y1:1, x2:1, y2:0, stop:0 	#075E54, stop:1 #128C7E);\n"
            "	border-radius: 5px;\n"
            "}")

        self.gridLayout_2.addWidget(self.lblGrip, 1, 0, 1, 1)

        self.gridLayout.addWidget(self.VentanaFrame, 0, 0, 1, 1)

        self.retranslateUi(Ventana)

        QMetaObject.connectSlotsByName(Ventana)

    # setupUi

    def retranslateUi(self, Ventana):
        Ventana.setWindowTitle(
            QCoreApplication.translate("Ventana", u"Form", None))
        self.btnExportar.setText(
            QCoreApplication.translate("Ventana", u"Exportar", None))
        self.btnAbrir.setText(
            QCoreApplication.translate("Ventana", u"Abrir TXT", None))
        ___qtablewidgetitem = self.tableWidget.horizontalHeaderItem(0)
        ___qtablewidgetitem.setText(
            QCoreApplication.translate("Ventana", u"N\u00fameros", None))
        ___qtablewidgetitem1 = self.tableWidget.horizontalHeaderItem(1)
        ___qtablewidgetitem1.setText(
            QCoreApplication.translate("Ventana", u"Mensajes", None))

        __sortingEnabled = self.tableWidget.isSortingEnabled()
        self.tableWidget.setSortingEnabled(False)
        self.tableWidget.setSortingEnabled(__sortingEnabled)

        self.btnVerde.setText("")
        self.btnAmarillo.setText("")
        self.btnRojo.setText("")
        self.lblWhatsPy.setText(
            QCoreApplication.translate("Ventana", u"WhatsPy", None))
        self.icon.setText("")
        self.label.setText(
            QCoreApplication.translate(
                "Ventana", u"Todav\u00eda no haz cargado ning\u00fan chat",
                None))
        self.lblGrip.setText("")
コード例 #26
0
ファイル: settings.py プロジェクト: cernyd/newnigma
    def generate_components(self, reflectors, rotors, rotor_n, charset):
        """Generates currently displayed components based on Enigma model
        :param reflectors: {str} Reflector labels
        :param rotors: {[str, str, str]} Rotor labels
        :param rotor_n: {int} Number of rotors the Enigma model has
        """
        # REFLECTOR SETTINGS ===================================================
        spacing = 15
        style = "font-size: 18px; text-align: center;"

        reflector_frame = QFrame(self.__settings_frame)
        reflector_frame.setFrameStyle(QFrame.StyledPanel | QFrame.Plain)

        reflector_layout = QVBoxLayout(reflector_frame)
        reflector_layout.setSpacing(spacing)
        reflector_layout.addWidget(
            QLabel("REFLECTOR", reflector_frame, styleSheet=style),
            alignment=Qt.AlignHCenter,
        )

        self.__reflector_group = QButtonGroup(reflector_frame)
        reflector_layout.setAlignment(Qt.AlignTop)

        for i, model in enumerate(reflectors):
            radio = QRadioButton(model, reflector_frame)
            radio.setToolTip(
                "Reflector is an Enigma component that \nreflects "
                "letters from the rotors back to the lightboard")
            self.__reflector_group.addButton(radio)
            self.__reflector_group.setId(radio, i)
            reflector_layout.addWidget(radio, alignment=Qt.AlignTop)

        reflector_layout.addStretch()
        reflector_layout.addWidget(self.__ukwd_button)

        self.__reflector_group.button(0).setChecked(True)
        self.__reflector_group.buttonClicked.connect(self.refresh_ukwd)
        self.__settings_layout.addWidget(reflector_frame)

        # ROTOR SETTINGS =======================================================

        self.__rotor_selectors = []
        self.__ring_selectors = []
        self.__rotor_frames = []

        for rotor in range(rotor_n):
            rotor_frame = QFrame(self.__settings_frame)
            rotor_frame.setFrameStyle(QFrame.StyledPanel | QFrame.Plain)
            rotor_layout = QVBoxLayout(rotor_frame)
            rotor_layout.setAlignment(Qt.AlignTop)
            rotor_layout.setSpacing(spacing)
            rotor_frame.setLayout(rotor_layout)

            # ROTOR RADIOS =====================================================

            label = QLabel(SELECTOR_LABELS[-rotor_n:][rotor],
                           rotor_frame,
                           styleSheet=style)
            label.setToolTip(SELECTOR_TOOLTIPS[-rotor_n:][rotor])

            rotor_layout.addWidget(label, alignment=Qt.AlignHCenter)

            button_group = QButtonGroup(rotor_frame)

            final_rotors = rotors

            if "Beta" in rotors:
                logging.info(
                    "Enigma M4 rotors detected, adjusting radiobuttons...")
                if rotor == 0:
                    final_rotors = ["Beta", "Gamma"]
                else:
                    final_rotors.remove("Beta")
                    final_rotors.remove("Gamma")

            for i, model in enumerate(final_rotors):
                radios = QRadioButton(model, rotor_frame)
                button_group.addButton(radios)
                button_group.setId(radios, i)
                rotor_layout.addWidget(radios, alignment=Qt.AlignTop)

            button_group.button(0).setChecked(True)

            # RINGSTELLUNG =====================================================

            combobox = QComboBox(rotor_frame)
            for i, label in enumerate(LABELS[:len(charset)]):
                combobox.addItem(label, i)

            h_rule = QFrame(rotor_frame)
            h_rule.setFrameShape(QFrame.HLine)
            h_rule.setFrameShadow(QFrame.Sunken)

            self.__ring_selectors.append(combobox)
            self.__rotor_selectors.append(button_group)

            rotor_layout.addStretch()
            rotor_layout.addWidget(h_rule)
            rotor_layout.addWidget(
                QLabel("RING SETTING", rotor_frame, styleSheet=style),
                alignment=Qt.AlignHCenter,
            )
            rotor_layout.addWidget(combobox)

            self.__settings_layout.addWidget(rotor_frame)
            self.__rotor_frames.append(rotor_frame)
コード例 #27
0
class Ui_Dialog(object):
    def setupUi(self, Dialog):
        if Dialog.objectName():
            Dialog.setObjectName(u"Dialog")
        Dialog.resize(878, 528)
        icon = QIcon()
        icon.addFile("./icon.ico")
        Dialog.setWindowIcon(icon)
        self.verticalLayout = QVBoxLayout(Dialog)
        self.verticalLayout.setObjectName(u"verticalLayout")
        self.horizontalLayout = QHBoxLayout()
        self.horizontalLayout.setObjectName(u"horizontalLayout")
        self.questionLable = QLabel(Dialog)
        self.questionLable.setObjectName(u"questionLable")
        font = QFont()
        font.setFamily(u"\u5fae\u8f6f\u96c5\u9ed1")
        font.setPointSize(12)
        self.questionLable.setFont(font)
        self.questionLable.setWordWrap(True)
        self.questionLable.setMargin(0)
        self.questionLable.setIndent(0)

        self.horizontalLayout.addWidget(self.questionLable)

        self.lcd = QLCDNumber(Dialog)
        self.lcd.setObjectName(u"lcd")
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lcd.sizePolicy().hasHeightForWidth())
        self.lcd.setSizePolicy(sizePolicy)
        self.lcd.setMinimumSize(QSize(120, 60))
        self.lcd.setSmallDecimalPoint(True)
        self.lcd.setDigitCount(4)
        self.lcd.setSegmentStyle(QLCDNumber.Flat)
        self.lcd.setProperty("value", 120.000000000000000)

        self.horizontalLayout.addWidget(self.lcd)

        self.verticalLayout.addLayout(self.horizontalLayout)

        self.line = QFrame(Dialog)
        self.line.setObjectName(u"line")
        self.line.setFrameShape(QFrame.HLine)
        self.line.setFrameShadow(QFrame.Sunken)

        self.verticalLayout.addWidget(self.line)

        self.answerLable = QLabel(Dialog)
        self.answerLable.setObjectName(u"answerLable")
        font1 = QFont()
        font1.setFamily(u"Yu Gothic UI")
        font1.setPointSize(14)
        self.answerLable.setFont(font1)
        self.answerLable.setWordWrap(True)

        self.verticalLayout.addWidget(self.answerLable)

        self.retranslateUi(Dialog)

        QMetaObject.connectSlotsByName(Dialog)

    # setupUi

    def retranslateUi(self, Dialog):
        Dialog.setWindowTitle(
            QCoreApplication.translate("Dialog", u"Dialog", None))

    # retranslateUi

    def setupUi_(self, question, answer, time):
        self.questionLable.setText(question)
        self.answerLable.setText(answer)
        self.lcd.setDigitCount(3)  # 设置lcd的显示位数
        self.lcd.display(time)
        self.timer1 = QTimer()
        self.timer1.timeout.connect(self.setlcd1)
        self.timer1.start(1000)
        # self.timer2 = QTimer()
        # self.timer2.timeout.connect(self.setlcd2)

    def setlcd1(self):
        self.lcd.display(self.lcd.intValue() - 1)
        if self.lcd.intValue() == 0:
            self.timer1.stop()

            # self.lcd.setSegmentStyle(QLCDNumber.Flat)
            # self.lcd.setStyleSheet("color: red;")

            # self.timer2.start(1000)

    def setlcd2(self):
        self.lcd.display(self.lcd.intValue() + 1)
コード例 #28
0
 def _add_line(self):
     line = QFrame()
     line.setFrameShape((QFrame.HLine))
     line.setFrameShadow(QFrame.Sunken)
     self.main_layout.addWidget(line)
コード例 #29
0
class Ui_FilewriterCtrl(object):
    def setupUi(self, FilewriterCtrl):
        FilewriterCtrl.resize(649, 450)
        broker_placeholder_text = "address:port/topic"
        self.central_widget = QWidget(FilewriterCtrl)
        self.vertical_layout_2 = QVBoxLayout(self.central_widget)
        self.vertical_layout = QVBoxLayout()
        self.horizontal_layout = QHBoxLayout()
        self.horizontal_layout.setContentsMargins(-1, -1, 0, -1)
        self.status_layout = QVBoxLayout()
        self.status_layout.setContentsMargins(-1, -1, -1, 0)
        self.status_topic_layout = QHBoxLayout()
        self.status_topic_layout.setContentsMargins(-1, -1, -1, 0)
        self.status_broker_label = QLabel(self.central_widget)
        self.status_topic_layout.addWidget(self.status_broker_label)
        self.status_broker_edit = QLineEdit(self.central_widget)
        self.status_broker_edit.setPlaceholderText(broker_placeholder_text)

        self.status_topic_layout.addWidget(self.status_broker_edit)
        self.status_layout.addLayout(self.status_topic_layout)
        self.line_2 = QFrame(self.central_widget)
        self.line_2.setFrameShape(QFrame.HLine)
        self.line_2.setFrameShadow(QFrame.Sunken)
        self.status_layout.addWidget(self.line_2)
        self.file_writer_table_group = QGroupBox(self.central_widget)
        size_policy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding)
        size_policy.setHorizontalStretch(0)
        size_policy.setVerticalStretch(1)
        size_policy.setHeightForWidth(
            self.file_writer_table_group.sizePolicy().hasHeightForWidth())
        self.file_writer_table_group.setSizePolicy(size_policy)
        self.vertical_layout_4 = QVBoxLayout(self.file_writer_table_group)
        self.vertical_layout_3 = QVBoxLayout()
        self.file_writers_list = QTreeView(self.file_writer_table_group)
        self.file_writers_list.setEditTriggers(
            QAbstractItemView.NoEditTriggers)
        self.file_writers_list.setIndentation(0)
        self.vertical_layout_3.addWidget(self.file_writers_list)
        self.vertical_layout_4.addLayout(self.vertical_layout_3)
        self.status_layout.addWidget(self.file_writer_table_group)
        self.files_group = QGroupBox(self.central_widget)
        size_policy.setHorizontalStretch(0)
        size_policy.setVerticalStretch(4)
        size_policy.setHeightForWidth(
            self.files_group.sizePolicy().hasHeightForWidth())
        self.files_group.setSizePolicy(size_policy)
        self.vertical_layout_6 = QVBoxLayout(self.files_group)
        self.files_list = QTreeView(self.files_group)
        self.files_list.setIndentation(0)
        self.vertical_layout_6.addWidget(self.files_list)
        self.vertical_layout_5 = QVBoxLayout()
        self.horizontal_layout_4 = QHBoxLayout()
        spacer = QSpacerItem(40, 20, QSizePolicy.Expanding,
                             QSizePolicy.Minimum)
        self.horizontal_layout_4.addItem(spacer)
        self.stop_file_writing_button = QPushButton(self.files_group)
        self.stop_file_writing_button.setEnabled(False)
        self.horizontal_layout_4.addWidget(self.stop_file_writing_button)
        self.vertical_layout_5.addLayout(self.horizontal_layout_4)
        self.vertical_layout_6.addLayout(self.vertical_layout_5)
        self.status_layout.addWidget(self.files_group)
        self.horizontal_layout.addLayout(self.status_layout)
        self.line = QFrame(self.central_widget)
        self.line.setFrameShape(QFrame.VLine)
        self.line.setFrameShadow(QFrame.Sunken)
        self.horizontal_layout.addWidget(self.line)

        self.command_layout = QVBoxLayout()
        self.command_layout.setContentsMargins(-1, 0, -1, 0)
        self.command_broker_layout = QHBoxLayout()
        self.command_broker_label = QLabel(self.central_widget)
        self.command_broker_layout.addWidget(self.command_broker_label)
        self.command_broker_edit = QLineEdit(self.central_widget)
        self.command_broker_edit.setPlaceholderText(broker_placeholder_text)
        self.command_broker_layout.addWidget(self.command_broker_edit)
        self.command_layout.addLayout(self.command_broker_layout)
        self.command_widget = FilewriterCommandWidget(FilewriterCtrl)
        self.command_layout.addWidget(self.command_widget)

        self.horizontal_layout.addLayout(self.command_layout)
        self.vertical_layout.addLayout(self.horizontal_layout)
        self.vertical_layout_2.addLayout(self.vertical_layout)
        FilewriterCtrl.setCentralWidget(self.central_widget)

        self.status_broker_label.setText("Status broker")
        self.file_writer_table_group.setTitle("File-writers")
        self.files_group.setTitle("Files")
        self.stop_file_writing_button.setText("Stop file-writing")
        self.command_broker_label.setText("Command broker")
        self.command_broker_edit.setPlaceholderText("address:port/topic")

        QMetaObject.connectSlotsByName(FilewriterCtrl)
コード例 #30
0
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)