/offlineimap/head: changeset 320

Reworked the canvas. Before, problem was the label and buttons to the
right of the lights would make the window too wide. When the button
got added, the window would get even wider. That was because the
canvas would not shrink. My workaround is to use a separate canvas for
each light. Seems to be OK here....
This commit is contained in:
jgoerzen 2003-01-07 01:00:43 +01:00
parent 612a8e4ac4
commit 8eea66bc36

View File

@ -342,15 +342,12 @@ class LEDAccountFrame:
return LEDThreadFrame(s.canvas) return LEDThreadFrame(s.canvas)
def _createcanvas(self, parent): def _createcanvas(self, parent):
c = LEDCanvas(parent, background = 'black', height = 20, bd = 0, c = LEDFrame(parent)
highlightthickness = 0)
c.setLEDCount(0)
c.createLEDLock()
self.canvas = c self.canvas = c
c.pack(side = LEFT, expand = 0, fill = X) c.pack(side = LEFT, expand = 0, fill = X)
#c.pack(side = LEFT, expand = 0, fill = X)
def startsleep(s, sleepsecs): def startsleep(s, sleepsecs):
print 351
s.sleeping_abort = 0 s.sleeping_abort = 0
s.button = Button(s.frame, text = "Sync now", command = s.syncnow, s.button = Button(s.frame, text = "Sync now", command = s.syncnow,
background = "black", activebackground = "black", background = "black", activebackground = "black",
@ -362,11 +359,9 @@ class LEDAccountFrame:
s.button.pack(side = LEFT) s.button.pack(side = LEFT)
def syncnow(s): def syncnow(s):
print 357
s.sleeping_abort = 1 s.sleeping_abort = 1
def sleeping(s, sleepsecs, remainingsecs): def sleeping(s, sleepsecs, remainingsecs):
print 360
if remainingsecs: if remainingsecs:
s.button.config(text = 'Sync now (%d:%02d remain)' % \ s.button.config(text = 'Sync now (%d:%02d remain)' % \
(remainingsecs / 60, remainingsecs % 60)) (remainingsecs / 60, remainingsecs % 60))
@ -376,33 +371,20 @@ class LEDAccountFrame:
del s.button del s.button
return s.sleeping_abort return s.sleeping_abort
class LEDCanvas(Canvas): class LEDFrame(Frame):
"""This holds the different lights.""" """This holds the different lights."""
def createLEDLock(self): def getnewobj(self):
self.ledlock = Lock() retval = Canvas(self, background = 'black', height = 20, bd = 0,
def acquireLEDLock(self): highlightthickness = 0, width = 10)
self.ledlock.acquire() retval.pack(side = LEFT, padx = 0, pady = 0, ipadx = 0, ipady = 0)
def releaseLEDLock(self): return retval
self.ledlock.release()
def setLEDCount(self, arg):
self.ledcount = arg
def getLEDCount(self):
return self.ledcount
def incLEDCount(self):
self.ledcount += 1
class LEDThreadFrame: class LEDThreadFrame:
"""There is one of these for each little light.""" """There is one of these for each little light."""
def __init__(self, master): def __init__(self, master):
self.canvas = master self.canvas = master.getnewobj()
self.color = '' self.color = ''
try: self.ovalid = self.canvas.create_oval(5, 5, 10,
self.canvas.acquireLEDLock()
startpos = 5 + self.canvas.getLEDCount() * 10
self.canvas.incLEDCount()
finally:
self.canvas.releaseLEDLock()
self.ovalid = self.canvas.create_oval(startpos, 5, startpos + 5,
10, fill = 'gray', 10, fill = 'gray',
outline = '#303030') outline = '#303030')
@ -473,13 +455,13 @@ class Blinkenlights(BlinkenBase, VerboseUI):
menubar.add_command(label = "Exit", command = s.terminate) menubar.add_command(label = "Exit", command = s.terminate)
s.top.config(menu = menubar) s.top.config(menu = menubar)
s.menubar = menubar s.menubar = menubar
s.gettf().setcolor('red')
s._msg(version.banner)
s.text.see(END) s.text.see(END)
s.top.resizable(width = 0, height = 0)
if s.config.has_option("ui.Tk.Blinkenlights", "showlog") and \ if s.config.has_option("ui.Tk.Blinkenlights", "showlog") and \
s.config.getboolean("ui.Tk.Blinkenlights", "showlog"): s.config.getboolean("ui.Tk.Blinkenlights", "showlog"):
s._togglelog() s._togglelog()
s.gettf().setcolor('red')
s.top.resizable(width = 0, height = 0)
s._msg(version.banner)
def _togglelog(s): def _togglelog(s):
if s.textenabled: if s.textenabled:
@ -494,7 +476,7 @@ class Blinkenlights(BlinkenBase, VerboseUI):
s.top.update() s.top.update()
else: else:
s.text.pack(side = BOTTOM, expand = 1, fill = BOTH) s.text.pack(side = TOP, expand = 1, fill = BOTH)
s.textenabled = 1 s.textenabled = 1
s.top.update() s.top.update()
s.top.geometry("") s.top.geometry("")
@ -508,7 +490,6 @@ class Blinkenlights(BlinkenBase, VerboseUI):
BlinkenBase.sleep(s, sleepsecs) BlinkenBase.sleep(s, sleepsecs)
def sleeping(s, sleepsecs, remainingsecs): def sleeping(s, sleepsecs, remainingsecs):
print 503
return BlinkenBase.sleeping(s, sleepsecs, remainingsecs) return BlinkenBase.sleeping(s, sleepsecs, remainingsecs)
def _rescroll(s): def _rescroll(s):