Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
unittestgui.ProgressBar Class Reference

List of all members.

Public Member Functions

def __init__
def setProgressFraction
def paint

Public Attributes

 canvas
 rect
 text
 fraction
 color

Detailed Description

A simple progress bar that shows a percentage progress in
the given colour.

Definition at line 435 of file unittestgui.py.


Constructor & Destructor Documentation

def unittestgui.ProgressBar.__init__ (   self,
  args,
  kwargs 
)

Definition at line 439 of file unittestgui.py.

00439 
00440     def __init__(self, *args, **kwargs):
00441         tk.Frame.__init__(self, *args, **kwargs)
00442         self.canvas = tk.Canvas(self, height='20', width='60',
00443                                 background='white', borderwidth=3)
00444         self.canvas.pack(fill=tk.X, expand=1)
00445         self.rect = self.text = None
00446         self.canvas.bind('<Configure>', self.paint)
00447         self.setProgressFraction(0.0)


Member Function Documentation

def unittestgui.ProgressBar.paint (   self,
  args 
)

Definition at line 454 of file unittestgui.py.

00454 
00455     def paint(self, *args):
00456         totalWidth = self.canvas.winfo_width()
00457         width = int(self.fraction * float(totalWidth))
00458         height = self.canvas.winfo_height()
00459         if self.rect is not None: self.canvas.delete(self.rect)
00460         if self.text is not None: self.canvas.delete(self.text)
00461         self.rect = self.canvas.create_rectangle(0, 0, width, height,
00462                                                  fill=self.color)
00463         percentString = "%3.0f%%" % (100.0 * self.fraction)
00464         self.text = self.canvas.create_text(totalWidth/2, height/2,
00465                                             anchor=tk.CENTER,
00466                                             text=percentString)

def unittestgui.ProgressBar.setProgressFraction (   self,
  fraction,
  color = 'blue' 
)

Definition at line 448 of file unittestgui.py.

00448 
00449     def setProgressFraction(self, fraction, color='blue'):
00450         self.fraction = fraction
00451         self.color = color
00452         self.paint()
00453         self.canvas.update_idletasks()


Member Data Documentation

Definition at line 441 of file unittestgui.py.

Definition at line 450 of file unittestgui.py.

Definition at line 449 of file unittestgui.py.

Definition at line 444 of file unittestgui.py.

Definition at line 444 of file unittestgui.py.


The documentation for this class was generated from the following file: