mirror of
https://github.com/nims11/IPod-Shuffle-4g.git
synced 2025-12-07 16:08:00 +09:00
Merge fec609c820 into a97a99ab86
This commit is contained in:
commit
ff635e3fb7
2 changed files with 153 additions and 0 deletions
56
app.py
Normal file
56
app.py
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
from PyQt4 import QtGui # Import the PyQt4 module we'll need
|
||||
import sys # We need sys so that we can pass argv to QApplication
|
||||
|
||||
import design # This file holds our MainWindow and all design related things
|
||||
# it also keeps events etc that we defined in Qt Designer
|
||||
|
||||
class ExampleApp(QtGui.QMainWindow, design.Ui_MainWindow):
|
||||
directorySet = False
|
||||
def __init__(self):
|
||||
# Explaining super is out of the scope of this article
|
||||
# So please google it if you're not familar with it
|
||||
# Simple reason why we use it here is that it allows us to
|
||||
# access variables, methods etc in the design.py file
|
||||
super(self.__class__, self).__init__()
|
||||
self.setupUi(self) # This is defined in design.py file automatically
|
||||
# It sets up layout and widgets that are defined
|
||||
self.btnBrowse.clicked.connect(self.browse_folder)
|
||||
self.btnShuffle.clicked.connect(self.shuffle)
|
||||
def browse_folder(self):
|
||||
directory = QtGui.QFileDialog.getExistingDirectory(self,
|
||||
"Pick a folder")
|
||||
# execute getExistingDirectory dialog and set the directory variable to be equal
|
||||
# to the user selected directory
|
||||
if directory:
|
||||
self.directorySet = True
|
||||
self.btnShuffle.setEnabled(True)
|
||||
self.btnBrowse.setText(directory)
|
||||
|
||||
def shuffle(self):
|
||||
if(self.directorySet):
|
||||
command = "python ipod-shuffle-4g.py"
|
||||
if self.chkTrackVoiceOver.isChecked():
|
||||
command = command + " -t "
|
||||
if self.chkPlaylistVoiceOver.isChecked():
|
||||
command = command + " -p "
|
||||
if self.chkRenameUnicode.isChecked():
|
||||
command = command + " -u "
|
||||
if self.chkTrackGain.isChecked():
|
||||
command = command + " -g " + str(self.trackGain.value())
|
||||
if self.chkAutoDirectoryPlaylist.isChecked():
|
||||
command = command + " -d "
|
||||
if self.chkID3Template.isChecked():
|
||||
command = command + " -i " + str(self.templateTxt.text()) + " "
|
||||
command = command + str(self.btnBrowse.text())
|
||||
print command
|
||||
import os
|
||||
os.system(command)
|
||||
def main():
|
||||
app = QtGui.QApplication(sys.argv) # A new instance of QApplication
|
||||
form = ExampleApp() # We set the form to be our ExampleApp (design)
|
||||
form.show() # Show the form
|
||||
app.exec_() # and execute the app
|
||||
|
||||
|
||||
if __name__ == '__main__': # if we're running file directly and not importing it
|
||||
main() # run the main function
|
||||
97
design.py
Normal file
97
design.py
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Form implementation generated from reading ui file 'blah.ui'
|
||||
#
|
||||
# Created by: PyQt4 UI code generator 4.11.4
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
try:
|
||||
_fromUtf8 = QtCore.QString.fromUtf8
|
||||
except AttributeError:
|
||||
def _fromUtf8(s):
|
||||
return s
|
||||
|
||||
try:
|
||||
_encoding = QtGui.QApplication.UnicodeUTF8
|
||||
def _translate(context, text, disambig):
|
||||
return QtGui.QApplication.translate(context, text, disambig, _encoding)
|
||||
except AttributeError:
|
||||
def _translate(context, text, disambig):
|
||||
return QtGui.QApplication.translate(context, text, disambig)
|
||||
|
||||
class Ui_MainWindow(object):
|
||||
def setupUi(self, MainWindow):
|
||||
MainWindow.setObjectName(_fromUtf8("MainWindow"))
|
||||
MainWindow.setEnabled(True)
|
||||
MainWindow.resize(485, 295)
|
||||
self.centralwidget = QtGui.QWidget(MainWindow)
|
||||
self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
|
||||
self.formLayoutWidget = QtGui.QWidget(self.centralwidget)
|
||||
self.formLayoutWidget.setGeometry(QtCore.QRect(0, 0, 481, 221))
|
||||
self.formLayoutWidget.setObjectName(_fromUtf8("formLayoutWidget"))
|
||||
self.formLayout = QtGui.QFormLayout(self.formLayoutWidget)
|
||||
self.formLayout.setFieldGrowthPolicy(QtGui.QFormLayout.AllNonFixedFieldsGrow)
|
||||
self.formLayout.setObjectName(_fromUtf8("formLayout"))
|
||||
self.chkTrackVoiceOver = QtGui.QCheckBox(self.formLayoutWidget)
|
||||
self.chkTrackVoiceOver.setObjectName(_fromUtf8("chkTrackVoiceOver"))
|
||||
self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.chkTrackVoiceOver)
|
||||
self.chkPlaylistVoiceOver = QtGui.QCheckBox(self.formLayoutWidget)
|
||||
self.chkPlaylistVoiceOver.setObjectName(_fromUtf8("chkPlaylistVoiceOver"))
|
||||
self.formLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.chkPlaylistVoiceOver)
|
||||
self.chkRenameUnicode = QtGui.QCheckBox(self.formLayoutWidget)
|
||||
self.chkRenameUnicode.setObjectName(_fromUtf8("chkRenameUnicode"))
|
||||
self.formLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.chkRenameUnicode)
|
||||
self.chkTrackGain = QtGui.QCheckBox(self.formLayoutWidget)
|
||||
self.chkTrackGain.setObjectName(_fromUtf8("chkTrackGain"))
|
||||
self.formLayout.setWidget(3, QtGui.QFormLayout.LabelRole, self.chkTrackGain)
|
||||
self.trackGain = QtGui.QDoubleSpinBox(self.formLayoutWidget)
|
||||
self.trackGain.setMinimum(0.0)
|
||||
self.trackGain.setObjectName(_fromUtf8("trackGain"))
|
||||
self.formLayout.setWidget(3, QtGui.QFormLayout.FieldRole, self.trackGain)
|
||||
self.chkAutoDirectoryPlaylist = QtGui.QCheckBox(self.formLayoutWidget)
|
||||
self.chkAutoDirectoryPlaylist.setObjectName(_fromUtf8("chkAutoDirectoryPlaylist"))
|
||||
self.formLayout.setWidget(4, QtGui.QFormLayout.LabelRole, self.chkAutoDirectoryPlaylist)
|
||||
self.chkID3Template = QtGui.QCheckBox(self.formLayoutWidget)
|
||||
self.chkID3Template.setObjectName(_fromUtf8("chkID3Template"))
|
||||
self.formLayout.setWidget(5, QtGui.QFormLayout.LabelRole, self.chkID3Template)
|
||||
self.templateTxt = QtGui.QLineEdit(self.formLayoutWidget)
|
||||
self.templateTxt.setObjectName(_fromUtf8("templateTxt"))
|
||||
self.formLayout.setWidget(5, QtGui.QFormLayout.FieldRole, self.templateTxt)
|
||||
self.btnBrowse = QtGui.QPushButton(self.formLayoutWidget)
|
||||
self.btnBrowse.setObjectName(_fromUtf8("btnBrowse"))
|
||||
self.formLayout.setWidget(6, QtGui.QFormLayout.SpanningRole, self.btnBrowse)
|
||||
self.btnShuffle = QtGui.QPushButton(self.centralwidget)
|
||||
self.btnShuffle.setEnabled(False)
|
||||
self.btnShuffle.setGeometry(QtCore.QRect(390, 220, 85, 27))
|
||||
self.btnShuffle.setObjectName(_fromUtf8("btnShuffle"))
|
||||
self.btnCancel = QtGui.QPushButton(self.centralwidget)
|
||||
self.btnCancel.setGeometry(QtCore.QRect(300, 220, 85, 27))
|
||||
self.btnCancel.setObjectName(_fromUtf8("btnCancel"))
|
||||
MainWindow.setCentralWidget(self.centralwidget)
|
||||
self.menubar = QtGui.QMenuBar(MainWindow)
|
||||
self.menubar.setGeometry(QtCore.QRect(0, 0, 485, 25))
|
||||
self.menubar.setObjectName(_fromUtf8("menubar"))
|
||||
MainWindow.setMenuBar(self.menubar)
|
||||
self.statusbar = QtGui.QStatusBar(MainWindow)
|
||||
self.statusbar.setObjectName(_fromUtf8("statusbar"))
|
||||
MainWindow.setStatusBar(self.statusbar)
|
||||
|
||||
self.retranslateUi(MainWindow)
|
||||
QtCore.QMetaObject.connectSlotsByName(MainWindow)
|
||||
|
||||
def retranslateUi(self, MainWindow):
|
||||
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None))
|
||||
self.chkTrackVoiceOver.setText(_translate("MainWindow", "Track Voice Over", None))
|
||||
self.chkPlaylistVoiceOver.setText(_translate("MainWindow", "Playlist Voice Over", None))
|
||||
self.chkRenameUnicode.setText(_translate("MainWindow", "Rename Unicode", None))
|
||||
self.chkTrackGain.setText(_translate("MainWindow", "Track Gain", None))
|
||||
self.chkAutoDirectoryPlaylist.setText(_translate("MainWindow", "Auto Directory Playlists", None))
|
||||
self.chkID3Template.setText(_translate("MainWindow", "ID3 Template", None))
|
||||
self.templateTxt.setPlaceholderText(_translate("MainWindow", "{genre} ,{album}-{artist},leave empty for auto", None))
|
||||
self.btnBrowse.setText(_translate("MainWindow", "Select the IPOD Folder", None))
|
||||
self.btnShuffle.setText(_translate("MainWindow", "Shuffle !", None))
|
||||
self.btnCancel.setText(_translate("MainWindow", "Cancel", None))
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue