#!/usr/bin/python
# -*- coding: utf-8 -*-

"""
ZetCode Tkinter tutorial

In this script, we show how to
use the Listbox widget.

Author: Jan Bodnar
Last modified: November 2015
Website: www.zetcode.com
"""

from ttk import Frame, Label
from Tkinter import Tk, BOTH, Listbox, StringVar, END
import soco


class Example(Frame):

    def __init__(self, parent):
        Frame.__init__(self, parent)

        self.parent = parent

        self.initUI()


    def initUI(self):

        self.parent.title("Listbox")

        self.pack(fill=BOTH, expand=1)

        acts = ['Scarlett Johansson', 'Rachel Weiss',
            'Natalie Portman', 'Jessica Alba']

        lb = Listbox(self)
        for i in soco.discover():
            lb.insert(END, i.player_name)

        lb.bind("<<ListboxSelect>>", self.onSelect)

        lb.pack(pady=15)

        self.var = StringVar()
        self.label = Label(self, text=0, textvariable=self.var)
        self.label.pack()


    def onSelect(self, val):

        sender = val.widget
        idx = sender.curselection()
        value = sender.get(idx)

        self.var.set(value)


def main():

    root = Tk()
    ex = Example(root)
    root.geometry("300x250+300+300")
    root.mainloop()


if __name__ == '__main__':
    main()
@@ -44,250 +44,290 @@
 %22%22%22%0A
-ZetCode Tkinter tutorial%0A%0AIn this script, we show how to%0Ause the Listbox widget.%0A%0AAuthor: Jan Bodnar%0ALast modified: November 2015%0AWebsite: www.zetcode.com%0A%22%22%22%0A%0Afrom ttk import Frame, Label%0Afrom Tkinter import Tk, BOTH, Listbox, StringVar, END
+Sonos-GUI-URI%0A%0AThis is the first attempt to create a window to stream a URI to the Sonos Speakers.%0A%0AAuthor: Jim Scherer%0A%22%22%22%0A%0Afrom Tkinter import Tk, LEFT, RIGHT, BOTH, RAISED, Listbox, StringVar, END, X%0Afrom ttk import Frame, Style, Label, Button, Entry%0Aimport tkMessageBox as mbox%0A
 %0Aimp
@@ -534,23 +534,25 @@
 .title(%22
-Listbox
+Sonos URI
 %22)%0A%0A    
@@ -599,100 +599,213 @@
     
-acts = %5B'Scarlett Johansson', 'Rachel Weiss',%0A            'Natalie Portman', 'Jessica Alba'%5D
+self.style = Style()%0A        self.style.theme_use(%22default%22)%0A%0A        frame = Frame(self, relief=RAISED, borderwidth=1)%0A        frame.pack(fill=BOTH, expand=True)%0A%0A        self.pack(fill=BOTH, expand=True)
 %0A%0A  
@@ -823,20 +823,21 @@
 Listbox(
-self
+frame
 )%0A      
@@ -1044,20 +1044,21 @@
 = Label(
-self
+frame
 , text=0
@@ -1105,24 +1105,608 @@
 bel.pack()%0A%0A
+        self.lblUri = Label(frame, text=%22URI%22, width=6)%0A        self.lblUri.pack(side=LEFT, padx=5, pady=5)%0A%0A        self.entryUri = Entry(frame)%0A        self.entryUri.pack(fill=X, padx=5, expand=True)%0A%0A        self.lblPlayfile = Label(frame, text=0, textvariable=self.entryUri)%0A%0A        closeButton = Button(self, text=%22Close%22, command=self.parent.destroy)%0A        closeButton.pack(side=RIGHT, padx=5, pady=5)%0A        okButton = Button(self, text=%22OK%22, command=self.onOk)%0A        okButton.pack(side=RIGHT)%0A%0A    def onOk(self):%0A        mbox.showinfo(%22Info%22, self.parent.entryUri.val)%0A
 %0A    def onS
@@ -1723,17 +1723,16 @@
 , val):%0A
-%0A
         
@@ -1849,17 +1849,16 @@
 value)%0A%0A
-%0A
 def main
@@ -1924,13 +1924,13 @@
 ry(%22
-300x2
+900x3
 50+3

update sonos.py for gui