Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- from PyQt6.QtWidgets import QApplication, QMainWindow, QWidget, QPushButton, \
- QHBoxLayout, QVBoxLayout, QLabel, QComboBox, QDial, QLCDNumber, QLineEdit, QDialog
- from PyQt6.QtGui import QPixmap, QFont
- import requests
- from bs4 import BeautifulSoup # this package can understand HTML code
- SearchLyrics = requests.get("http://api.chartlyrics.com/apiv1.asmx/SearchLyric?")
- SearchLyricText = requests.get("http://api.chartlyrics.com/apiv1.asmx/SearchLyricText?")
- class FirstWindow(QDialog):
- def __init__(self):
- super().__init__()
- self.setWindowTitle("Lyrical Finder")
- layout = QVBoxLayout()
- self.label = QLabel("enter song title: ")
- layout.addWidget(self.label)
- self.lyrics = QLineEdit()
- layout.addWidget(self.lyrics)
- self.find = QPushButton("find!")
- layout.addWidget(self.find)
- self.setLayout(layout)
- self.find.pressed.connect(self.Search)
- def Search(self):
- self.artists = SearchLyricText.find()
- class SecondWindow(QDialog):
- def __init__(self):
- super().__init__()
- self.setWindowTitle("Song and Artist Finder")
- layout = QVBoxLayout()
- self.label = QLabel("enter lyrics: ")
- layout.addWidget(self.label)
- self.lyrics = QLineEdit()
- layout.addWidget(self.lyrics)
- self.find = QPushButton("find!")
- layout.addWidget(self.find)
- self.setLayout(layout)
- self.get.pressed.connect(self.Search)
- def Search(self):
- self.artists = SearchLyrics.find()
- #this does not work
- class MainWindow(QMainWindow):
- def __init__(self):
- super(MainWindow, self).__init__()
- self.setWindowTitle("Lyrical Assistant")
- main_layout = QVBoxLayout()
- layout_setup = QHBoxLayout()
- widget = QWidget()
- widget.setLayout(main_layout)
- self.setCentralWidget(widget)
- layout_title = QVBoxLayout()
- self.title = QLabel(
- "This program will either allow you get the lyrics of a song, or to search the name of the song (and artist).")
- self.title.setFont(QFont('Georgia', 10))
- layout_title.addWidget(self.title)
- main_layout.addLayout(layout_title)
- self.one = QPushButton("search lyrics: ")
- self.two = QPushButton("search name of the song: ")
- layout_setup.addWidget(self.one)
- layout_setup.addWidget(self.two)
- self.one.pressed.connect(self.search_lyrics)
- main_layout.addLayout(layout_setup)
- def search_lyrics(self):
- lyrics_window = FirstWindow()
- lyrics_window.exec()
- app = QApplication(sys.argv)
- w = MainWindow()
- w.show()
- app.exec()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement