[Tutor] Percent done bar

Thomi Richards thomi@thomi.imail.net.nz
Mon Nov 18 20:59:01 2002


> I think a neater effect for a percent bar is obtained by using a line 
> object on a small canvas, as in the following:
> (Alan: you'll notice that the code for the app, GUI, etc, is lifted 
> directly from your tutorial)

ahaaa!! that much better! I couldn't figure out that text scroll bar
(surely that's meant to be for scrolling text??).. Hope you don't mind
if i use this :-)

> 
> from Tkinter import *
> 
> class ClearApp:
>     def __init__(self, parent=0):
>        self.mainWindow = Frame(parent)
>        self.percentbar = Canvas(self.mainWindow)
>        self.percentbar.config(height=10, width=100, bg='black')
>        self.percentbar.create_line(0, 6, 0, 6, fill='red', width = 3, 
> tag='bar')
>        self.percentbar.pack()
> 
> 
>        fOuter = Frame(self.mainWindow, border=1, relief="sunken")
>        fButtons = Frame(fOuter, border=1, relief="raised")
>        bDraw = Button(fButtons, text="Draw Bar",
>                        width=8, height=1, command=self.drawBar)
>        bQuit = Button(fButtons, text="Quit",
>                        width=8, height=1,
>                        command=self.mainWindow.quit)
>        bDraw.pack(side="left", padx=15, pady=1)
>        bQuit.pack(side="right", padx=15, pady=1)
>        fButtons.pack(fill=X)
>        fOuter.pack(fill=X)
>        self.mainWindow.pack()
> 
>        self.mainWindow.master.title("Percent bar")
> 
>     def drawBar(self):
>        global x
>        if x < 100 : x = x+10
>        app.percentbar.coords('bar', 0, 6, x, 6)
> 
> 
> app = ClearApp()
> x = 0
> app.mainWindow.mainloop()
> 
> 
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor


-- 
This is a subliminal message.
Thomi Richards,
thomi@imail.net.nz