ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/PyBlade.py
Revision: 8
Committed: Sat May 5 04:21:19 2012 UTC (13 years, 10 months ago) by ninoborges
Content type: text/x-python
File size: 5078 byte(s)
Log Message:
Initial Import

File Contents

# Content
1 ## PyBlade.py
2 ## This program is a frontend to BladeEnd which is a MP3 encoder. You must first rip the cd (I use CD creator)
3 ## since blade dosent have this feature.
4 ## EBorges
5 ## 06.28.03
6
7 import Pmw,Tkinter,os
8 from tkFileDialog import askopenfilename
9 from tkMessageBox import showinfo
10 from tkDirectoryChooser import Chooser
11
12
13 def Main():
14 root = Pmw.initialise()
15 MainNb = Pmw.NoteBook(root)
16 MainNb.pack()
17 # <---PyBlade Main Section-->
18 bladeMainTab = MainNb.add('PyBlade')
19 bladeMainGroup = Pmw.Group(bladeMainTab, tag_text = 'Convert to MP3')
20 bladeMainGroup.pack(fill = 'both', expand = 1, padx = 10, pady = 10)
21 FileOrDir = []
22 var = Tkinter.IntVar()
23 var.set(0)
24 bladeFileGroup = Pmw.Group(bladeMainGroup.interior(),tag_pyclass= Tkinter.Radiobutton, tag_text = 'Single File',
25 tag_value = 0,tag_variable = var)
26 bladeFileGroup.pack(fill = 'x', padx = 20, pady = 5)
27 FileOrDir.append(bladeFileGroup)
28 bladeFileField = Pmw.EntryField(bladeFileGroup.interior(), labelpos = 'w',
29 label_text = 'Select the file you wish to convert: ')
30 fileBrowseButton = Tkinter.Button(bladeFileGroup.interior(), text = 'Browse', command =
31 (lambda bladeFileFieldOBJ = bladeFileField, Type = 'file':
32 CF_UpdateField(bladeFileFieldOBJ,Type)))
33 fileBrowseButton.pack(side = Tkinter.RIGHT, padx=5)
34 bladeFileField.pack(padx = 5)
35 bladeDirGroup = Pmw.Group(bladeMainGroup.interior(),tag_pyclass= Tkinter.Radiobutton, tag_text = 'Directory of Files',
36 tag_value = 1,tag_variable = var)
37 bladeDirGroup.pack(fill = 'x', padx = 20, pady = 5)
38 FileOrDir.append(bladeDirGroup)
39 bladeDirField = Pmw.EntryField(bladeDirGroup.interior(), labelpos = 'w',
40 label_text = 'Select the Dir of files for conversion: ')
41 dirBrowseButton = Tkinter.Button(bladeDirGroup.interior(), text = 'Browse', command =
42 (lambda bladeDirFieldOBJ = bladeDirField, Type = 'dir':
43 CF_UpdateField(bladeDirFieldOBJ,Type)))
44 dirBrowseButton.pack(side = Tkinter.RIGHT, padx=5)
45 bladeDirField.pack(padx=5)
46
47 # <--PyBlade Main Section End-->
48 # <----About Section---->
49 About = MainNb.add('About')
50 copyRightText = copyRightInfo()
51 groupA = Pmw.Group(About, tag_text = 'About PyBlade')
52 groupA.pack(fill = 'both', expand = 1, padx = 10, pady = 10)
53 copyRight = Pmw.LabeledWidget(groupA.interior(), labelpos = 'w',label_text = copyRightText)
54 copyRight.pack()
55 # <----About Section END---->
56 mainOkCancel = Pmw.ButtonBox(bladeMainGroup.interior())
57 mainOkCancel.pack(side = Tkinter.BOTTOM,padx = 5, pady = 5)
58 mainOkCancel.add('Ok',command = (lambda radioSelection = var, bladeFileFieldOBJ = bladeFileField, bladeDirFieldOBJ = bladeDirField:
59 ConvertToMP3(radioSelection, bladeFileFieldOBJ, bladeDirFieldOBJ)))
60 mainOkCancel.add('Cancel',command = root.destroy)
61 mainOkCancel.alignbuttons()
62 root.title('PyBlade v0.01')
63 root.mainloop()
64
65 def CF_UpdateField(entryOBJ,Type):
66 if Type == 'file':
67 file = askopenfilename()
68 entryOBJ.setentry(file)
69 if Type == 'dir':
70 directory = Chooser().show()
71 entryOBJ.setentry(directory)
72
73 def ConvertToMP3(radioSelection,singleFileOBJ,fullDirOBJ):
74 if radioSelection.get():
75 convertThis = '"' + fullDirOBJ.get() + '/' + '*' + '"'
76 else:
77 convertThis = singleFileOBJ.get()
78 convertThis = convertThis.replace("/",'\\\\')
79 print convertThis
80 #mp3Dir = os.path.join(os.path.expanduser('~'),"Colection\\mp3s")
81 mp3Dir = 'c:\\Documents and Settings\\eaborges\\My Documents\\Colection\\mp3s'
82 #os.system(os.path.join(os.path.expanduser('~'),'Python DataFiles\\BladeEnc\\BladeEnc.exe'))
83 #print os.path.join('c:\\',os.path.expanduser('~'),'Python DataFiles\\BladeEnc\\BladeEnc.exe')
84 ## status = os.system('cusrmgr.exe -u %s -m \\\%s -alg Administrators'%(User,Machine))
85 os.system('cmd /C "C:\\Documents and Settings\\eaborges\\My Documents\\Python DataFiles\\PyBlade\\BladeEnc\\BladeEnc.exe" %s %s'% (convertThis,mp3Dir))
86 #print '"C:\\Documents and Settings\\eaborges\\My Documents\\Python DataFiles\\PyBlade\\BladeEnc\\BladeEnc.exe" %s %s'%(convertThis, mp3Dir)
87
88 def copyRightInfo():
89 mainText = """PyBlade.exe
90
91 Version 0.12
92 Copyright (C) 2002 Emanuel Borges
93 All Rights Reserved
94
95 This software is released under the terms of the GPL. Which states
96 that you can Copy, Distribute and even modify this code as long as
97 you never redistribute the original or modified code as closed source.
98
99 For information about this program or to report bugs contact:
100 Emanuel Borges
101 email: Eaborges@hotmail.com
102 """
103 return mainText
104
105 if __name__ == '__main__':
106 Main()