Back to index

python3.2  3.2.2
Classes | Public Member Functions | Public Attributes | Static Public Attributes
sortvisu.Array Class Reference
Collaboration diagram for sortvisu.Array:
Collaboration graph
[legend]

List of all members.

Classes

class  Cancelled

Public Member Functions

def __init__
def setdata
def setspeed
def destroy
def cancel
def step
def wait
def getsize
def show_partition
def hide_partition
def show_left

Public Attributes

 master
 frame
 label
 canvas
 report
 left
 right
 pivot
 items
 size
 maxvalue
 speed
 stop_mainloop
 in_mainloop

Static Public Attributes

string speed = "normal"
int in_mainloop = 0
int stop_mainloop = 0

Detailed Description

Definition at line 29 of file sortvisu.py.


Class Documentation

class sortvisu::Array::Cancelled

Definition at line 31 of file sortvisu.py.


Constructor & Destructor Documentation

def sortvisu.Array.__init__ (   self,
  master,
  data = None 
)

Definition at line 34 of file sortvisu.py.

00034 
00035     def __init__(self, master, data=None):
00036         self.master = master
00037         self.frame = Frame(self.master)
00038         self.frame.pack(fill=X)
00039         self.label = Label(self.frame)
00040         self.label.pack()
00041         self.canvas = Canvas(self.frame)
00042         self.canvas.pack()
00043         self.report = Label(self.frame)
00044         self.report.pack()
00045         self.left = self.canvas.create_line(0, 0, 0, 0)
00046         self.right = self.canvas.create_line(0, 0, 0, 0)
00047         self.pivot = self.canvas.create_line(0, 0, 0, 0)
00048         self.items = []
00049         self.size = self.maxvalue = 0
00050         if data:
00051             self.setdata(data)

Here is the caller graph for this function:


Member Function Documentation

def sortvisu.Array.cancel (   self)

Definition at line 76 of file sortvisu.py.

00076 
00077     def cancel(self):
00078         self.stop_mainloop = 1
00079         if self.in_mainloop:
00080             self.master.quit()

def sortvisu.Array.destroy (   self)

Definition at line 70 of file sortvisu.py.

00070 
00071     def destroy(self):
00072         self.frame.destroy()

def sortvisu.Array.getsize (   self)

Definition at line 104 of file sortvisu.py.

00104 
00105     def getsize(self):
00106         return self.size

Here is the caller graph for this function:

Definition at line 116 of file sortvisu.py.

00116 
00117     def hide_partition(self):
00118         for i in range(self.size):
00119             item = self.items[i]
00120             self.canvas.itemconfig(item, fill='red')
00121         self.hide_left_right_pivot()

def sortvisu.Array.setdata (   self,
  data 
)

Definition at line 52 of file sortvisu.py.

00052 
00053     def setdata(self, data):
00054         olditems = self.items
00055         self.items = []
00056         for item in olditems:
00057             item.delete()
00058         self.size = len(data)
00059         self.maxvalue = max(data)
00060         self.canvas.config(width=(self.size+1)*XGRID,
00061                            height=(self.maxvalue+1)*YGRID)
00062         for i in range(self.size):
00063             self.items.append(ArrayItem(self, i, data[i]))
00064         self.reset("Sort demo, size %d" % self.size)

def sortvisu.Array.setspeed (   self,
  speed 
)

Definition at line 67 of file sortvisu.py.

00067 
00068     def setspeed(self, speed):
00069         self.speed = speed

def sortvisu.Array.show_left (   self,
  left 
)

Definition at line 122 of file sortvisu.py.

00122 
00123     def show_left(self, left):
00124         if not 0 <= left < self.size:
00125             self.hide_left()
00126             return
        x1, y1, x2, y2 = self.items[left].position()
def sortvisu.Array.show_partition (   self,
  first,
  last 
)

Definition at line 107 of file sortvisu.py.

00107 
00108     def show_partition(self, first, last):
00109         for i in range(self.size):
00110             item = self.items[i]
00111             if first <= i < last:
00112                 self.canvas.itemconfig(item, fill='red')
00113             else:
00114                 self.canvas.itemconfig(item, fill='orange')
00115         self.hide_left_right_pivot()

def sortvisu.Array.step (   self)

Definition at line 81 of file sortvisu.py.

00081 
00082     def step(self):
00083         if self.in_mainloop:
00084             self.master.quit()

def sortvisu.Array.wait (   self,
  msecs 
)

Definition at line 85 of file sortvisu.py.

00085 
00086     def wait(self, msecs):
00087         if self.speed == "fastest":
00088             msecs = 0
00089         elif self.speed == "fast":
00090             msecs = msecs//10
00091         elif self.speed == "single-step":
00092             msecs = 1000000000
00093         if not self.stop_mainloop:
00094             self.master.update()
00095             id = self.master.after(msecs, self.master.quit)
00096             self.in_mainloop = 1
00097             self.master.mainloop()
00098             self.master.after_cancel(id)
00099             self.in_mainloop = 0
00100         if self.stop_mainloop:
00101             self.stop_mainloop = 0
00102             self.message("Cancelled")
00103             raise Array.Cancelled


Member Data Documentation

Definition at line 40 of file sortvisu.py.

Definition at line 36 of file sortvisu.py.

Definition at line 73 of file sortvisu.py.

Definition at line 95 of file sortvisu.py.

Definition at line 47 of file sortvisu.py.

Definition at line 38 of file sortvisu.py.

Definition at line 44 of file sortvisu.py.

Definition at line 35 of file sortvisu.py.

Definition at line 48 of file sortvisu.py.

Definition at line 46 of file sortvisu.py.

Definition at line 42 of file sortvisu.py.

Definition at line 45 of file sortvisu.py.

Definition at line 48 of file sortvisu.py.

string sortvisu.Array.speed = "normal" [static]

Definition at line 65 of file sortvisu.py.

Definition at line 68 of file sortvisu.py.

Definition at line 74 of file sortvisu.py.

Definition at line 77 of file sortvisu.py.


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