4 class pyTivoConfigurator(Frame
):
8 def buildContainerList(self
):
10 frame
.pack(fill
=Y
, expand
=1)
11 scrollbar
= Scrollbar(frame
, orient
=VERTICAL
)
12 self
.container_list
= Listbox(frame
, yscrollcommand
=scrollbar
.set)
13 scrollbar
.config(command
=self
.container_list
.yview
)
14 scrollbar
.pack(side
=RIGHT
, fill
=Y
)
15 self
.container_list
.pack(side
=LEFT
, fill
=BOTH
, expand
=1)
16 self
.container_list
.bind("<Double-Button-1>", self
.selected
)
18 def selected(self
, e
):
19 if not self
.container_list
.curselection():
21 index
= self
.container_list
.curselection()[0]
22 self
.section
= self
.container_list
.get(index
)
26 def buildButtons(self
):
28 frame
.pack(fill
=Y
, expand
=1)
30 save_button
= Button(frame
, text
="Save", command
=self
.save
)
31 save_button
.pack(side
=RIGHT
)
33 add_button
= Button(frame
, text
="Add", command
=self
.add
)
34 add_button
.pack(side
=RIGHT
)
36 restart_button
= Button(frame
, text
="Restart pyTivo", command
=self
.restart
)
37 restart_button
.pack(side
=RIGHT
)
44 sharename
= tkSimpleDialog
.askstring('Add share', 'Share Name')
45 self
.config
.add_section(sharename
)
46 self
.config
.set(sharename
, 'type', 'video')
47 self
.config
.set(sharename
, 'path', '<Pick A Path>')
49 self
.updateContainerList()
52 import win32serviceutil
54 win32serviceutil
.RestartService('pyTivo')
58 frame
.pack(fill
=Y
, expand
=1)
59 l
= Label(frame
, text
="Path")
62 button
= Button(frame
, text
="Browse", command
=self
.setPath
)
63 button
.pack(side
=RIGHT
)
65 self
.path
= Entry(frame
)
66 self
.path
.pack(side
=RIGHT
, fill
=Y
, expand
=1)
73 dir = tkFileDialog
.askdirectory()
75 self
.config
.set(self
.section
, 'path', dir)
79 if not self
.section
or not self
.config
.get(self
.section
, 'path'):
82 self
.path
.delete(0, END
)
83 self
.path
.insert(0, self
.config
.get(self
.section
, 'path'))
85 def updateContainerList(self
):
86 self
.container_list
.delete(0, END
)
87 for section
in self
.config
.sections():
88 if not section
== 'Server':
89 self
.container_list
.insert(END
, section
)
92 self
.config
= ConfigParser
.ConfigParser()
93 self
.config
.read(self
.config_file
)
95 def writeConfig(self
):
96 self
.config
.write(open(self
.config_file
, 'w'))
98 def __init__(self
, master
=None):
99 Frame
.__init
__(self
, master
)
100 self
.master
.title('pyTivoConfigurator')
104 p
= os
.path
.dirname(__file__
)
105 self
.config_file
= os
.path
.join(p
, 'pyTivo.conf')
109 self
.buildContainerList()
113 self
.updateContainerList()
117 if __name__
== '__main__':
119 app
= pyTivoConfigurator(master
=root
)