Work on GUI a bit

This commit is contained in:
Salt 2020-03-07 02:53:14 -06:00
parent 20e0e3a059
commit 73811a910a
2 changed files with 42 additions and 3 deletions

View File

@ -10,12 +10,17 @@
from appdirs import AppDirs
from pathlib import Path
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import (
QAction, qApp, QApplication, QMainWindow
)
import argparse
import eyed3
import json
import logging
import math
import pathlib
import types
import sys
import youtube_dl
@ -136,6 +141,35 @@ class Library:
except (KeyboardInterrupt, EOFError):
logging.debug('Interrupt received, exiting')
class BadWitchGUI(QMainWindow):
# A Qt5 GUI
def __init__(self, badwitch, library):
super().__init__()
# Basics
self.badwitch = badwitch
self.lib = library
# Init actions
self.initActions()
# Init UI
self.initUI()
def initActions(self):
self.exitAct = QAction(QIcon.fromTheme('application-exit'), '&Exit', self)
self.exitAct.setShortcut('Ctrl+Q')
self.exitAct.setStatusTip('Exit Bad Witch')
self.exitAct.triggered.connect(qApp.quit)
def initUI(self):
# Main window shenanigans
self.resize(900, 900)
self.setWindowTitle('Bad Witch')
self.setWindowIcon(QIcon.fromTheme('audio-headphones'))
# Menubar
menubar = self.menuBar()
fileMenu = menubar.addMenu('&File')
fileMenu.addAction(self.exitAct)
self.show()
class BadWitch:
# Our program
def __init__(self):
@ -149,7 +183,7 @@ class BadWitch:
self.argparser.add_argument('-d', '--debug', action='store_true',
help='Show even more status messages')
self.argparser.add_argument('action', metavar='action', nargs='?',
choices=['download', 'edit', 'list'],
choices=['download', 'edit', 'gui', 'list'],
help='Action to perform on the library')
# Set up appdirs
self.dirs = AppDirs('badwitch', 'rehashedsalt')
@ -170,7 +204,10 @@ class BadWitch:
# Perform action
if self.args.action == 'download':
lib.download()
return
if self.args.action == 'gui':
qapp = QApplication(sys.argv)
gui = BadWitchGUI(self, lib)
sys.exit(qapp.exec_())
elif self.args.action == 'edit':
print('Bad Witch interactive $ibrary editor')
print('^C to abort, ^D to finish changes')
@ -246,7 +283,8 @@ class BadWitch:
print('\t' + str(songcontent['track'])
+ ' - ' + song
+ ' by ' + songcontent['artist'])
return
else:
print('Nothing to do')
badwitch = BadWitch()
badwitch.execute()

View File

@ -1,3 +1,4 @@
appdirs>=1.4.3
eyed3>=0.8.8
PyQt5>=5.12.3
youtube-dl