Work on GUI a bit
This commit is contained in:
parent
20e0e3a059
commit
73811a910a
44
badwitch.py
44
badwitch.py
@ -10,12 +10,17 @@
|
|||||||
|
|
||||||
from appdirs import AppDirs
|
from appdirs import AppDirs
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from PyQt5.QtGui import QIcon
|
||||||
|
from PyQt5.QtWidgets import (
|
||||||
|
QAction, qApp, QApplication, QMainWindow
|
||||||
|
)
|
||||||
import argparse
|
import argparse
|
||||||
import eyed3
|
import eyed3
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import math
|
import math
|
||||||
import pathlib
|
import pathlib
|
||||||
|
import types
|
||||||
import sys
|
import sys
|
||||||
import youtube_dl
|
import youtube_dl
|
||||||
|
|
||||||
@ -136,6 +141,35 @@ class Library:
|
|||||||
except (KeyboardInterrupt, EOFError):
|
except (KeyboardInterrupt, EOFError):
|
||||||
logging.debug('Interrupt received, exiting')
|
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:
|
class BadWitch:
|
||||||
# Our program
|
# Our program
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -149,7 +183,7 @@ class BadWitch:
|
|||||||
self.argparser.add_argument('-d', '--debug', action='store_true',
|
self.argparser.add_argument('-d', '--debug', action='store_true',
|
||||||
help='Show even more status messages')
|
help='Show even more status messages')
|
||||||
self.argparser.add_argument('action', metavar='action', nargs='?',
|
self.argparser.add_argument('action', metavar='action', nargs='?',
|
||||||
choices=['download', 'edit', 'list'],
|
choices=['download', 'edit', 'gui', 'list'],
|
||||||
help='Action to perform on the library')
|
help='Action to perform on the library')
|
||||||
# Set up appdirs
|
# Set up appdirs
|
||||||
self.dirs = AppDirs('badwitch', 'rehashedsalt')
|
self.dirs = AppDirs('badwitch', 'rehashedsalt')
|
||||||
@ -170,7 +204,10 @@ class BadWitch:
|
|||||||
# Perform action
|
# Perform action
|
||||||
if self.args.action == 'download':
|
if self.args.action == 'download':
|
||||||
lib.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':
|
elif self.args.action == 'edit':
|
||||||
print('Bad Witch interactive $ibrary editor')
|
print('Bad Witch interactive $ibrary editor')
|
||||||
print('^C to abort, ^D to finish changes')
|
print('^C to abort, ^D to finish changes')
|
||||||
@ -246,7 +283,8 @@ class BadWitch:
|
|||||||
print('\t' + str(songcontent['track'])
|
print('\t' + str(songcontent['track'])
|
||||||
+ ' - ' + song
|
+ ' - ' + song
|
||||||
+ ' by ' + songcontent['artist'])
|
+ ' by ' + songcontent['artist'])
|
||||||
return
|
else:
|
||||||
|
print('Nothing to do')
|
||||||
|
|
||||||
badwitch = BadWitch()
|
badwitch = BadWitch()
|
||||||
badwitch.execute()
|
badwitch.execute()
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
appdirs>=1.4.3
|
appdirs>=1.4.3
|
||||||
eyed3>=0.8.8
|
eyed3>=0.8.8
|
||||||
|
PyQt5>=5.12.3
|
||||||
youtube-dl
|
youtube-dl
|
||||||
|
Loading…
Reference in New Issue
Block a user