Advertisement
MrPinzon

kyra_lyrics.py

May 11th, 2022
1,018
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.73 KB | None | 0 0
  1. import sys
  2. from PyQt6.QtWidgets import QApplication, QMainWindow, QWidget, QPushButton, \
  3.     QHBoxLayout, QVBoxLayout, QLabel, QComboBox, QDial, QLCDNumber, QLineEdit, QDialog
  4. from PyQt6.QtGui import QPixmap, QFont
  5. import requests
  6. from bs4 import BeautifulSoup  # this package can understand HTML code
  7.  
  8. SearchLyrics = requests.get("http://api.chartlyrics.com/apiv1.asmx/SearchLyric?")
  9. SearchLyricText = requests.get("http://api.chartlyrics.com/apiv1.asmx/SearchLyricText?")
  10.  
  11.  
  12. class FirstWindow(QDialog):
  13.     def __init__(self):
  14.         super().__init__()
  15.         self.setWindowTitle("Lyrical Finder")
  16.         layout = QVBoxLayout()
  17.  
  18.         self.label = QLabel("enter song title: ")
  19.         layout.addWidget(self.label)
  20.  
  21.         self.lyrics = QLineEdit()
  22.         layout.addWidget(self.lyrics)
  23.  
  24.         self.find = QPushButton("find!")
  25.         layout.addWidget(self.find)
  26.  
  27.         self.setLayout(layout)
  28.         self.find.pressed.connect(self.Search)
  29.  
  30.     def Search(self):
  31.         self.artists = SearchLyricText.find()
  32.  
  33.  
  34. class SecondWindow(QDialog):
  35.     def __init__(self):
  36.         super().__init__()
  37.         self.setWindowTitle("Song and Artist Finder")
  38.         layout = QVBoxLayout()
  39.  
  40.         self.label = QLabel("enter lyrics: ")
  41.         layout.addWidget(self.label)
  42.  
  43.         self.lyrics = QLineEdit()
  44.         layout.addWidget(self.lyrics)
  45.  
  46.         self.find = QPushButton("find!")
  47.         layout.addWidget(self.find)
  48.  
  49.         self.setLayout(layout)
  50.  
  51.         self.get.pressed.connect(self.Search)
  52.  
  53.     def Search(self):
  54.         self.artists = SearchLyrics.find()
  55.         #this does not work
  56.  
  57.  
  58. class MainWindow(QMainWindow):
  59.     def __init__(self):
  60.         super(MainWindow, self).__init__()
  61.         self.setWindowTitle("Lyrical Assistant")
  62.  
  63.         main_layout = QVBoxLayout()
  64.         layout_setup = QHBoxLayout()
  65.  
  66.         widget = QWidget()
  67.         widget.setLayout(main_layout)
  68.         self.setCentralWidget(widget)
  69.  
  70.         layout_title = QVBoxLayout()
  71.         self.title = QLabel(
  72.             "This program will either allow you get the lyrics of a song, or to search the name of the song (and artist).")
  73.         self.title.setFont(QFont('Georgia', 10))
  74.         layout_title.addWidget(self.title)
  75.         main_layout.addLayout(layout_title)
  76.  
  77.         self.one = QPushButton("search lyrics: ")
  78.         self.two = QPushButton("search name of the song: ")
  79.         layout_setup.addWidget(self.one)
  80.         layout_setup.addWidget(self.two)
  81.         self.one.pressed.connect(self.search_lyrics)
  82.  
  83.         main_layout.addLayout(layout_setup)
  84.  
  85.     def search_lyrics(self):
  86.         lyrics_window = FirstWindow()
  87.         lyrics_window.exec()
  88.  
  89.  
  90. app = QApplication(sys.argv)
  91. w = MainWindow()
  92. w.show()
  93.  
  94. app.exec()
  95.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement