Пример #1
0
def open(title, data): # Public function to open a table window
	#
	# Set geometry parameters (one day, these may be changeable)
	#
	margin = stdwin.textwidth('  ')
	lineheight = stdwin.lineheight()
	#
	# Geometry calculations
	#
	colstarts = [0]
	totwidth = 0
	maxrows = 0
	for coldata in data:
		# Height calculations
		rows = len(coldata)
		if rows > maxrows: maxrows = rows
		# Width calculations
		width = colwidth(coldata) + margin
		totwidth = totwidth + width
		colstarts.append(totwidth)
	#
	# Calculate document and window height
	#
	docwidth, docheight = totwidth, maxrows*lineheight
	winwidth, winheight = docwidth, docheight
	if winwidth > stdwin.textwidth('n')*100: winwidth = 0
	if winheight > stdwin.lineheight()*30: winheight = 0
	#
	# Create the window
	#
	stdwin.setdefwinsize(winwidth, winheight)
	w = gwin.open(title)
	#
	# Set properties and override methods
	#
	w.data = data
	w.margin = margin
	w.lineheight = lineheight
	w.colstarts = colstarts
	w.totwidth = totwidth
	w.maxrows = maxrows
	w.selection = (-1, -1)
	w.lastselection = (-1, -1)
	w.selshown = 0
	w.setdocsize(docwidth, docheight)
	w.draw = draw
	w.mup = mup
	w.arrow = arrow
	#
	# Return
	#
	return w
Пример #2
0
def open(title, data):  # Public function to open a table window
    #
    # Set geometry parameters (one day, these may be changeable)
    #
    margin = stdwin.textwidth('  ')
    lineheight = stdwin.lineheight()
    #
    # Geometry calculations
    #
    colstarts = [0]
    totwidth = 0
    maxrows = 0
    for coldata in data:
        # Height calculations
        rows = len(coldata)
        if rows > maxrows: maxrows = rows
        # Width calculations
        width = colwidth(coldata) + margin
        totwidth = totwidth + width
        colstarts.append(totwidth)
    #
    # Calculate document and window height
    #
    docwidth, docheight = totwidth, maxrows * lineheight
    winwidth, winheight = docwidth, docheight
    if winwidth > stdwin.textwidth('n') * 100: winwidth = 0
    if winheight > stdwin.lineheight() * 30: winheight = 0
    #
    # Create the window
    #
    stdwin.setdefwinsize(winwidth, winheight)
    w = gwin.open(title)
    #
    # Set properties and override methods
    #
    w.data = data
    w.margin = margin
    w.lineheight = lineheight
    w.colstarts = colstarts
    w.totwidth = totwidth
    w.maxrows = maxrows
    w.selection = (-1, -1)
    w.lastselection = (-1, -1)
    w.selshown = 0
    w.setdocsize(docwidth, docheight)
    w.draw = draw
    w.mup = mup
    w.arrow = arrow
    #
    # Return
    #
    return w
Пример #3
0
def open(title, data):  # Display a list of texts in a window
    lineheight = stdwin.lineheight()
    h, v = maxlinewidth(data), len(data) * lineheight
    h0, v0 = h + stdwin.textwidth(' '), v + lineheight
    if h0 > stdwin.textwidth(' ') * 80: h0 = 0
    if v0 > stdwin.lineheight() * 24: v0 = 0
    stdwin.setdefwinsize(h0, v0)
    w = gwin.open(title)
    w.setdocsize(h, v)
    w.lineheight = lineheight
    w.data = data
    w.draw = draw
    w.action = action
    w.mup = mup
    return w
Пример #4
0
def open(title, data): # Display a list of texts in a window
       lineheight = stdwin.lineheight()
       h, v = maxlinewidth(data), len(data)*lineheight
       h0, v0 = h + stdwin.textwidth(' '), v + lineheight
       if h0 > stdwin.textwidth(' ')*80: h0 = 0
       if v0 > stdwin.lineheight()*24: v0 = 0
       stdwin.setdefwinsize(h0, v0)
       w = gwin.open(title)
       w.setdocsize(h, v)
       w.lineheight = lineheight
       w.data = data
       w.draw = draw
       w.action = action
       w.mup = mup
       return w
Пример #5
0
def openlistwindow(dirname):
	list = posix.listdir(dirname)
	list.sort()
	i = 0
	while i < len(list):
		if list[i] == '.' or list[i] == '..':
			del list[i]
		else:
			i = i+1
	for i in range(len(list)):
		name = list[i]
		if path.isdir(path.join(dirname, name)):
			list[i] = list[i] + '/'
	width = maxwidth(list)
	width = width + stdwin.textwidth(' ')	# XXX X11 stdwin bug workaround
	height = len(list) * stdwin.lineheight()
	stdwin.setdefwinsize(width, min(height, 500))
	w = stdwin.open(dirname)
	stdwin.setdefwinsize(0, 0)
	w.setdocsize(width, height)
	w.drawproc = drawlistwindow
	w.mouse = mouselistwindow
	w.close = closelistwindow
	w.dirname = dirname
	w.list = list
	w.selected = -1
	return w
Пример #6
0
 def __init__(self):
     if macspeech:
         self.speaker = MacSpeaker()
     else:
         self.speaker = None
     sys.stdin = open('SCRIPT', 'r')
     self.acts = readscript(sys.stdin)
     maxactor = 0
     for actorlist, actdata in self.acts:
         if len(actorlist) > maxactor:
             maxactor = len(actorlist)
     if not self.loadnextact():
         print 'No acts to play!'
         raise done
     self.lh = stdwin.lineheight()
     self.winheight = (maxactor + 2) * self.lh
     stdwin.setdefwinsize(WINWIDTH, self.winheight)
     self.win = stdwin.open('The Play')
     self.win.setdocsize(WINWIDTH, self.winheight)
     self.win.change(((0, 0), (WINWIDTH, self.winheight)))
     self.menu = self.win.menucreate('Play')
     self.menu.additem('Faster', '+')
     self.menu.additem('Slower', '-')
     self.menu.additem('Quit', 'Q')
     self.speed = 4
Пример #7
0
def main():
    stdwin.setdefwinsize(NCOLS * stdwin.textwidth('12345'), \
       NROWS * stdwin.lineheight() * 3)
    w = stdwin.open('TestColors')
    #
    while 1:
        type, window, detail = stdwin.getevent()
        if type == WE_CLOSE:
            print 'Bye.'
            break
        elif type == WE_SIZE:
            w.change((0, 0), (10000, 10000))
        elif type == WE_DRAW:
            width, height = w.getwinsize()
            d = w.begindrawing()
            for row in range(NROWS):
                for col in range(NCOLS):
                    color = row * NCOLS + col
                    d.setfgcolor(color)
                    p = col * width / NCOLS, row * height / NROWS
                    q = (col+1)*width/NCOLS, \
                     (row+1)*height/NROWS
                    d.paint((p, q))
                    d.setfgcolor(0)
                    d.box((p, q))
                    d.text(p, ` color `)
                    p = p[0], p[1] + d.lineheight()
                    d.setfgcolor(7)
                    d.text(p, ` color `)
            del d
Пример #8
0
	def __init__(self):
		if macspeech:
			self.speaker = MacSpeaker()
		else:
			self.speaker = None
		sys.stdin = open('SCRIPT', 'r')
		self.acts = readscript(sys.stdin)
		maxactor = 0
		for actorlist, actdata in self.acts:
			if len(actorlist) > maxactor:
				maxactor = len(actorlist)
		if not self.loadnextact():
			print 'No acts to play!'
			raise done
		self.lh = stdwin.lineheight()
		self.winheight = (maxactor+2)*self.lh
		stdwin.setdefwinsize(WINWIDTH, self.winheight)
		self.win = stdwin.open('The Play')
		self.win.setdocsize(WINWIDTH, self.winheight)
		self.win.change(((0,0),(WINWIDTH, self.winheight)))
		self.menu = self.win.menucreate('Play')
		self.menu.additem('Faster', '+')
		self.menu.additem('Slower', '-')
		self.menu.additem('Quit', 'Q')
		self.speed = 4
Пример #9
0
def main():
	stdwin.setdefwinsize(NCOLS * stdwin.textwidth('12345'), \
				NROWS * stdwin.lineheight() * 3)
	w = stdwin.open('TestColors')
	#
	while 1:
		type, window, detail = stdwin.getevent()
		if type == WE_CLOSE:
			print 'Bye.'
			break
		elif type == WE_SIZE:
			w.change((0,0), (10000, 10000))
		elif type == WE_DRAW:
			width, height = w.getwinsize()
			d = w.begindrawing()
			for row in range(NROWS):
				for col in range(NCOLS):
					color = row*NCOLS + col
					d.setfgcolor(color)
					p = col*width/NCOLS, row*height/NROWS
					q = (col+1)*width/NCOLS, \
						(row+1)*height/NROWS
					d.paint((p, q))
					d.setfgcolor(0)
					d.box((p, q))
					d.text(p, `color`)
					p = p[0] , p[1]+ d.lineheight()
					d.setfgcolor(7)
					d.text(p, `color`)
			del d
Пример #10
0
	def mouse_down(self, detail):
		(h, v), clicks, button, mask = detail
		if clicks != 2:
			return
		i = v / stdwin.lineheight()
		if 5 <= i < len(self.displaylist):
			import string
			name = string.splitfields(self.displaylist[i],' = ')[0]
			if not self.dict.has_key(name):
				stdwin.fleep()
				return
			value = self.dict[name]
			if not hasattr(value, '__dict__'):
				stdwin.fleep()
				return
			name = 'instance ' + `value`
			if self.debugger.framewindows.has_key(name):
				self.debugger.framewindows[name].popup()
			else:
				self.debugger.framewindows[name] = \
					  FrameWindow(self.debugger,
						  self.frame, value.__dict__,
						  name)
			return
		stdwin.fleep()
Пример #11
0
def setdimensions(win):
	width, height = win.getwinsize()
	height = height - stdwin.lineheight()
	if width < height: size = width
	else: size = height
	halfwidth = width/2
	halfheight = height/2
	win.center = halfwidth, halfheight
	win.radius = size*45/100
	win.width = width
	win.height = height
	win.corner = width, height
	win.mainarea = ORIGIN, win.corner
	win.lineheight = stdwin.lineheight()
	win.farcorner = width, height + win.lineheight
	win.statusarea = (0, height), win.farcorner
	win.fullarea = ORIGIN, win.farcorner
Пример #12
0
def setdimensions(win):
	width, height = win.getwinsize()
	height = height - stdwin.lineheight()
	if width < height: size = width
	else: size = height
	halfwidth = width/2
	halfheight = height/2
	win.center = halfwidth, halfheight
	win.radius = size*45/100
	win.width = width
	win.height = height
	win.corner = width, height
	win.mainarea = ORIGIN, win.corner
	win.lineheight = stdwin.lineheight()
	win.farcorner = width, height + win.lineheight
	win.statusarea = (0, height), win.farcorner
	win.fullarea = ORIGIN, win.farcorner
Пример #13
0
 def __init__(self):
     self.sourcewindows = {}
     self.framewindows = {}
     bdb.Bdb.__init__(self)
     width = WIDTH * stdwin.textwidth('0')
     height = HEIGHT * stdwin.lineheight()
     stdwin.setdefwinsize(width, height)
     basewin.BaseWindow.__init__(self, '--Stack--')
     self.closed = 0
Пример #14
0
	def __init__(self):
		self.sourcewindows = {}
		self.framewindows = {}
		bdb.Bdb.__init__(self)
		width = WIDTH*stdwin.textwidth('0')
		height = HEIGHT*stdwin.lineheight()
		stdwin.setdefwinsize(width, height)
		basewin.BaseWindow.__init__(self, '--Stack--')
		self.closed = 0
Пример #15
0
 def open(self, title):
     stdwin.setfont("7x14")
     self.charwidth = stdwin.textwidth("m")
     self.lineheight = stdwin.lineheight()
     self.docwidth = self.width * self.charwidth
     self.docheight = self.height * self.lineheight
     stdwin.setdefwinsize(self.docwidth + 2, self.docheight + 2)
     stdwin.setdefscrollbars(0, 0)
     self.window = stdwin.open(title)
     self.window.setdocsize(self.docwidth + 2, self.docheight + 2)
Пример #16
0
 def open(self, title):
     stdwin.setfont('7x14')
     self.charwidth = stdwin.textwidth('m')
     self.lineheight = stdwin.lineheight()
     self.docwidth = self.width * self.charwidth
     self.docheight = self.height * self.lineheight
     stdwin.setdefwinsize(self.docwidth + 2, self.docheight + 2)
     stdwin.setdefscrollbars(0, 0)
     self.window = stdwin.open(title)
     self.window.setdocsize(self.docwidth + 2, self.docheight + 2)
Пример #17
0
def ibackward(win):
	lh = stdwin.lineheight() # XXX Should really use the window's...
	h, v = win.getorigin()
	if v <= 0:
		stdwin.fleep()
		return
	width, height = win.getwinsize()
	increment = max(lh, ((height - 2*lh) / lh) * lh)
	v = max(0, v - increment)
	win.setorigin(h, v)
Пример #18
0
def ibackward(win):
    lh = stdwin.lineheight()  # XXX Should really use the window's...
    h, v = win.getorigin()
    if v <= 0:
        stdwin.fleep()
        return
    width, height = win.getwinsize()
    increment = max(lh, ((height - 2 * lh) / lh) * lh)
    v = max(0, v - increment)
    win.setorigin(h, v)
Пример #19
0
def makewindow():
    stdwin.setdefwinsize(DEFWIDTH, DEFHEIGHT + stdwin.lineheight())
    win = stdwin.open("clock")
    setdimensions(win)
    win.set = 1  # True when alarm is set
    win.time = 11 * 60 + 40  # Time when alarm must go off
    win.ring = 0  # True when alarm is ringing
    win.dispatch = cdispatch
    mainloop.register(win)
    settimer(win)
    return win
Пример #20
0
def iforward(win):
	lh = stdwin.lineheight() # XXX Should really use the window's...
	h, v = win.getorigin()
	docwidth, docheight = win.getdocsize()
	width, height = win.getwinsize()
	if v + height >= docheight:
		stdwin.fleep()
		return
	increment = max(lh, ((height - 2*lh) / lh) * lh)
	v = v + increment
	win.setorigin(h, v)
Пример #21
0
def iforward(win):
    lh = stdwin.lineheight()  # XXX Should really use the window's...
    h, v = win.getorigin()
    docwidth, docheight = win.getdocsize()
    width, height = win.getwinsize()
    if v + height >= docheight:
        stdwin.fleep()
        return
    increment = max(lh, ((height - 2 * lh) / lh) * lh)
    v = v + increment
    win.setorigin(h, v)
Пример #22
0
def makewindow():
	stdwin.setdefwinsize(DEFWIDTH, DEFHEIGHT + stdwin.lineheight())
	win = stdwin.open('clock')
	setdimensions(win)
	win.set = 1		# True when alarm is set
	win.time = 11*60 + 40	# Time when alarm must go off
	win.ring = 0		# True when alarm is ringing
	win.dispatch = cdispatch
	mainloop.register(win)
	settimer(win)
	return win
Пример #23
0
 def mouse_down(self, detail):
     (h, v), clicks, button, mask = detail
     i = v / stdwin.lineheight()
     if 0 <= i < len(self.stack):
         if i != self.curindex:
             self.curindex = i
             self.curframe = self.stack[self.curindex][0]
             self.refreshstack()
         elif clicks == 2:
             self.do_frame()
     else:
         stdwin.fleep()
Пример #24
0
	def define_field(self, name, label, lines, chars):
		self.fieldnames.append(name)
		lh = stdwin.lineheight()
		cw = stdwin.textwidth('m')
		left = 20*cw
		top = self.formheight + 4
		right = left + chars*cw
		bottom = top + lines*lh
		te = None
		self.fields[name] = (label, left, top, right, bottom, te)
		self.formheight = bottom + 2
		self.formwidth = max(self.formwidth, right + 4)
Пример #25
0
	def mouse_down(self, detail):
		(h, v), clicks, button, mask = detail
		i = v / stdwin.lineheight()
		if 0 <= i < len(self.stack):
			if i != self.curindex:
				self.curindex = i
				self.curframe = self.stack[self.curindex][0]
				self.refreshstack()
			elif clicks == 2:
				self.do_frame()
		else:
			stdwin.fleep()
Пример #26
0
 def refreshstack(self):
     height = stdwin.lineheight() * (1 + len(self.stack))
     self.win.setdocsize((0, height))
     self.refreshall()  # XXX be more subtle later
     # Also pass the information on to the source windows
     filename = self.curframe.f_code.co_filename
     lineno = self.curframe.f_lineno
     for fn in self.sourcewindows.keys():
         w = self.sourcewindows[fn]
         if fn == filename:
             w.setlineno(lineno)
         else:
             w.resetlineno()
Пример #27
0
	def refreshstack(self):
		height = stdwin.lineheight() * (1 + len(self.stack))
		self.win.setdocsize((0, height))
		self.refreshall() # XXX be more subtle later
		# Also pass the information on to the source windows
		filename = self.curframe.f_code.co_filename
		lineno = self.curframe.f_lineno
		for fn in self.sourcewindows.keys():
			w = self.sourcewindows[fn]
			if fn == filename:
				w.setlineno(lineno)
			else:
				w.resetlineno()
Пример #28
0
def main():
    global ok
    digits_seen = 0
    thread.start_new_thread(worker, ())
    tw = stdwin.textwidth('0 ')
    lh = stdwin.lineheight()
    stdwin.setdefwinsize(20 * tw, 20 * lh)
    stdwin.setdefscrollbars(0, 1)
    win = stdwin.open('digits of pi')
    options = win.menucreate('Options')
    options.additem('Auto scroll')
    autoscroll = 1
    options.check(0, autoscroll)
    while 1:
        win.settimer(1)
        type, w, detail = stdwin.getevent()
        if type == WE_CLOSE:
            ok = 0
            sys.exit(0)
        elif type == WE_DRAW:
            (left, top), (right, bottom) = detail
            digits_seen = len(digits)
            d = win.begindrawing()
            for i in range(digits_seen):
                h = (i % 20) * tw
                v = (i / 20) * lh
                if top - lh < v < bottom:
                    d.text((h, v), digits[i])
            d.close()
        elif type == WE_TIMER:
            n = len(digits)
            if n > digits_seen:
                win.settitle( ` n ` + ' digits of pi')
                d = win.begindrawing()
                for i in range(digits_seen, n):
                    h = (i % 20) * tw
                    v = (i / 20) * lh
                    d.text((h, v), digits[i])
                d.close()
                digits_seen = n
                height = (v + 20 * lh) / (20 * lh) * (20 * lh)
                win.setdocsize(0, height)
                if autoscroll:
                    win.show((0, v), (h + tw, v + lh))
        elif type == WE_MENU:
            menu, item = detail
            if menu == options:
                if item == 0:
                    autoscroll = (not autoscroll)
                    options.check(0, autoscroll)
Пример #29
0
def main():
	global ok
	digits_seen = 0
	thread.start_new_thread(worker, ())
	tw = stdwin.textwidth('0 ')
	lh = stdwin.lineheight()
	stdwin.setdefwinsize(20 * tw, 20 * lh)
	stdwin.setdefscrollbars(0, 1)
	win = stdwin.open('digits of pi')
	options = win.menucreate('Options')
	options.additem('Auto scroll')
	autoscroll = 1
	options.check(0, autoscroll)
	while 1:
		win.settimer(1)
		type, w, detail = stdwin.getevent()
		if type == WE_CLOSE:
			ok = 0
			sys.exit(0)
		elif type == WE_DRAW:
			(left, top), (right, bottom) = detail
			digits_seen = len(digits)
			d = win.begindrawing()
			for i in range(digits_seen):
				h = (i % 20) * tw
				v = (i / 20) * lh
				if top-lh < v < bottom:
					d.text((h, v), digits[i])
			d.close()
		elif type == WE_TIMER:
			n = len(digits)
			if n > digits_seen:
				win.settitle(`n` + ' digits of pi')
				d = win.begindrawing()
				for i in range(digits_seen, n):
					h = (i % 20) * tw
					v = (i / 20) * lh
					d.text((h, v), digits[i])
				d.close()
				digits_seen = n
				height = (v + 20*lh) / (20*lh) * (20*lh)
				win.setdocsize(0, height)
				if autoscroll:
					win.show((0, v), (h+tw, v+lh))
		elif type == WE_MENU:
			menu, item = detail
			if menu == options:
				if item == 0:
					autoscroll = (not autoscroll)
					options.check(0, autoscroll)
Пример #30
0
def setdimensions(width, height):
       if width < height: size = width
       else: size = height
       halfwidth = width/2
       halfheight = height/2
       G.center = halfwidth, halfheight
       G.radius = size*45/100
       G.width = width
       G.height = height
       G.corner = width, height
       G.mainarea = origin, G.corner
       G.lineheight = stdwin.lineheight()
       G.farcorner = width, height + G.lineheight
       G.statusarea = (0, height), G.farcorner
       G.fullarea = origin, G.farcorner
Пример #31
0
	def __init__(self, debugger, frame, dict, name):
		self.debugger = debugger
		self.frame = frame # Not used except for identity tests
		self.dict = dict
		self.name = name
		nl = max(MINHEIGHT, len(self.dict) + 5)
		nl = min(nl, MAXHEIGHT)
		width = WIDTH*stdwin.textwidth('0')
		height = nl*stdwin.lineheight()
		stdwin.setdefwinsize(width, height)
		basewin.BaseWindow.__init__(
			  self, '--Frame ' + name + '--')
		# XXX Should use current function name
		self.initeditor()
		self.displaylist = ['>>>', '', '-'*WIDTH]
		self.refreshframe()
Пример #32
0
	def __init__(self, title, contents):
		self.contents = contents
		self.linecount = countlines(self.contents)
		#
		self.lineheight = lh = stdwin.lineheight()
		self.leftmargin = self.getmargin()
		self.top = 0
		self.rightmargin = 30000 # Infinity
		self.bottom = lh * self.linecount
		#
		width = WIDTH*stdwin.textwidth('0')
		height = lh*min(MAXHEIGHT, self.linecount)
		stdwin.setdefwinsize(width, height)
		basewin.BaseWindow.__init__(self, title)
		#
		self.win.setdocsize(0, self.bottom)
		self.initeditor()
Пример #33
0
 def __init__(self, title, contents):
     self.contents = contents
     self.linecount = countlines(self.contents)
     #
     self.lineheight = lh = stdwin.lineheight()
     self.leftmargin = self.getmargin()
     self.top = 0
     self.rightmargin = 30000  # Infinity
     self.bottom = lh * self.linecount
     #
     width = WIDTH * stdwin.textwidth('0')
     height = lh * min(MAXHEIGHT, self.linecount)
     stdwin.setdefwinsize(width, height)
     basewin.BaseWindow.__init__(self, title)
     #
     self.win.setdocsize(0, self.bottom)
     self.initeditor()
Пример #34
0
	def re_eval(self):
		import string, repr
		expr = string.strip(self.editor.gettext())
		if expr == '':
			output = ''
		else:
			globals = self.frame.f_globals
			globals['__privileged__'] = 1
			locals = self.dict
			try:
				value = eval(expr, globals, locals)
				output = repr.repr(value)
			except:
				output = sys.exc_type + ': ' + `sys.exc_value`
		self.displaylist[1] = output
		lh = stdwin.lineheight()
		r = (-10, 0), (30000, 2*lh)
		self.win.change(r)
		self.editor.setfocus(0, len(expr))
Пример #35
0
	def refreshframe(self):
		import repr
		del self.displaylist[3:]
		self.re_eval()
		names = self.dict.keys()
		for key, label in ('__args__', 'Args: '), \
				  ('__return__', 'Return: '):
			if self.dict.has_key(key):
				names.remove(key)
				value = self.dict[key]
				label = label + repr.repr(value)
			self.displaylist.append(label)
		names.sort()
		for name in names:
			value = self.dict[name]
			line = name + ' = ' + repr.repr(value)
			self.displaylist.append(line)
		self.win.setdocsize(0, \
			stdwin.lineheight() * len(self.displaylist))
		self.refreshall() # XXX Be more subtle later
Пример #36
0
def main():
	delay = DEF_DELAY
	#
	try:
		thisuser = posix.environ['LOGNAME']
	except:
		thisuser = posix.environ['USER']
	#
	printers = sys.argv[1:]
	if printers:
		# Strip '-P' from printer names just in case
		# the user specified it...
		for i in range(len(printers)):
			if printers[i][:2] == '-P':
				printers[i] = printers[i][2:]
	else:
		if posix.environ.has_key('PRINTER'):
			printers = [posix.environ['PRINTER']]
		else:
			printers = [DEF_PRINTER]
	#
	width = stdwin.textwidth('in')*20
	height = len(printers) * stdwin.lineheight() + 5
	stdwin.setdefwinsize(width, height)
	stdwin.setdefscrollbars(0, 0)
	#
	win = stdwin.open('lpwin')
	#
	win.printers = printers
	win.colors = [c_unknown] * len(printers)
	win.texts = printers[:]
	win.next = 0
	win.delay = DEF_DELAY
	win.thisuser = thisuser
	win.dispatch = lpdispatch
	#
	win.settimer(1)
	#
	mainloop.register(win)
	mainloop.mainloop()
Пример #37
0
def main():
	import stdwin
	from WindowParent import WindowParent, MainLoop
	from FormSplit import FormSplit
	from Buttons import Label
	from TextEdit import TextEdit
	#
	stdwin.setdefscrollbars(0, 0)
	#
	w = WindowParent().create('FormTest', (0, 0))
	f = FormSplit().create(w)
	#
	h, v = 0, 0
	for label in testlabels:
		f.placenext(h, v)
		lbl = Label().definetext(f, label)
		f.placenext(h + 100, v)
		txt = TextEdit().createboxed(f, (40, 2), (2, 2))
		#txt = TextEdit().create(f, (40, 2))
		v = v + 2*stdwin.lineheight() + 10
	#
	w.realize()
	#
	MainLoop()
Пример #38
0
def main():
    import stdwin
    from WindowParent import WindowParent, MainLoop
    from FormSplit import FormSplit
    from Buttons import Label
    from TextEdit import TextEdit
    #
    stdwin.setdefscrollbars(0, 0)
    #
    w = WindowParent().create('FormTest', (0, 0))
    f = FormSplit().create(w)
    #
    h, v = 0, 0
    for label in testlabels:
        f.placenext(h, v)
        lbl = Label().definetext(f, label)
        f.placenext(h + 100, v)
        txt = TextEdit().createboxed(f, (40, 2), (2, 2))
        #txt = TextEdit().create(f, (40, 2))
        v = v + 2 * stdwin.lineheight() + 10
    #
    w.realize()
    #
    MainLoop()
Пример #39
0
def openlistwindow(dirname):
	list = os.listdir(dirname)
	list.sort()
	i = 0
	while i < len(list):
		if list[i][0] == '.':
			del list[i]
		else:
			i = i+1
	for i in range(len(list)):
		fullname = os.path.join(dirname, list[i])
		if os.path.isdir(fullname):
			info = '/'
		else:
			try:
				size = os.stat(fullname)[ST_SIZE]
				info = `(size + 1023)/1024` + 'k'
			except IOError:
				info = '???'
			info = '(' + info + ')'
		list[i] = list[i], info
	width = maxwidth(list)
	# width = width + stdwin.textwidth(' ')	# XXX X11 stdwin bug workaround
	height = len(list) * stdwin.lineheight()
	stdwin.setdefwinsize(width, min(height, 500))
	stdwin.setdefscrollbars(0, 1)
	w = stdwin.open(dirname)
	stdwin.setdefwinsize(0, 0)
	w.setdocsize(width, height)
	w.drawproc = drawlistwindow
	w.mouse = mouselistwindow
	w.close = closelistwindow
	w.dirname = dirname
	w.list = list
	w.selected = -1
	return w
Пример #40
0
def openlistwindow(dirname):
    list = os.listdir(dirname)
    list.sort()
    i = 0
    while i < len(list):
        if list[i][0] == '.':
            del list[i]
        else:
            i = i + 1
    for i in range(len(list)):
        fullname = os.path.join(dirname, list[i])
        if os.path.isdir(fullname):
            info = '/'
        else:
            try:
                size = os.stat(fullname)[ST_SIZE]
                info = ` (size + 1023) / 1024 ` + 'k'
            except IOError:
                info = '???'
            info = '(' + info + ')'
        list[i] = list[i], info
    width = maxwidth(list)
    # width = width + stdwin.textwidth(' ')	# XXX X11 stdwin bug workaround
    height = len(list) * stdwin.lineheight()
    stdwin.setdefwinsize(width, min(height, 500))
    stdwin.setdefscrollbars(0, 1)
    w = stdwin.open(dirname)
    stdwin.setdefwinsize(0, 0)
    w.setdocsize(width, height)
    w.drawproc = drawlistwindow
    w.mouse = mouselistwindow
    w.close = closelistwindow
    w.dirname = dirname
    w.list = list
    w.selected = -1
    return w
Пример #41
0
def openlistwindow(dirname):
       list = posix.listdir(dirname)
       list.sort()
       i = 0
       while i < len(list):
               if list[i] = '.' or list[i] = '..':
                       del list[i]
               else:
                       i = i+1
       for i in range(len(list)):
               name = list[i]
               if path.isdir(path.cat(dirname, name)):
                       list[i] = list[i] + '/'
       width = maxwidth(list)
       width = width + stdwin.textwidth(' ')   # XXX X11 stdwin bug workaround
       height = len(list) * stdwin.lineheight()
       stdwin.setdefwinsize(width, min(height, 500))
       w = stdwin.open(dirname)
       stdwin.setdefwinsize(0, 0)
       w.setdocsize(width, height)
       w.drawproc = drawlistwindow
       w.mouse = mouselistwindow
       w.close = closelistwindow
       w.dirname = dirname
       w.list = list
       w.selected = -1
       return w

def maxwidth(list):
       width = 1
       for name in list:
Пример #42
0
def start(ref):
	stdwin.setdefscrollbars(0, 1)
	stdwin.setfont(FONT)
	stdwin.setdefwinsize(76*stdwin.textwidth('x'), 22*stdwin.lineheight())
	makewindow('ibrowse', ref)
	mainloop()
Пример #43
0
def isummary(win):
	stdwin.setdefwinsize(76*stdwin.textwidth('x'), 22*stdwin.lineheight())
	makewindow('ibrowse', 'Summary')
Пример #44
0
def itutor(win):
	# The course looks best at 76x22...
	stdwin.setdefwinsize(76*stdwin.textwidth('x'), 22*stdwin.lineheight())
	makewindow('ibrowse', 'Help')
Пример #45
0
def main():
	#
	# Set a reasonable default window size.
	# If we are using a fixed-width font this will open a 80x24 window;
	# for variable-width fonts we approximate this based on an average
	#
	stdwin.setdefwinsize(40*stdwin.textwidth('in'), 24*stdwin.lineheight())
	#
	# Create global menus (as local variables)
	#
	filemenu = make_file_menu(stdwin)
	editmenu = make_edit_menu(stdwin)
	findmenu = make_find_menu(stdwin)
	#
	# Get the list of files from the command line (maybe none)
	#
	files = sys.argv[1:]
	#
	# Open any files -- errors will be reported but do won't stop us
	#
	for filename in files:
		open_file(filename)
	#
	# If there were no files, or none of them could be opened,
	# put up a dialog asking for a filename
	#
	if not windows:
		try:
			open_dialog(None)
		except KeyboardInterrupt:
			pass		# User cancelled
	#
	# If the dialog was cancelled, create an empty new window
	#
	if not windows:
		new_window(None)
	#
	# Main event loop -- stop when we have no open windows left
	#
	while windows:
		#
		# Get the next event -- ignore interrupts
		#
		try:
			type, window, detail = event = stdwin.getevent()
		except KeyboardInterrupt:
			type, window, detail = event = WE_NONE, None, None
		#
		# Event decoding switch
		#
		if not window:
			pass		# Ignore such events
		elif type == WE_MENU:
			#
			# Execute menu operation
			#
			menu, item = detail
			try:
				menu.actions[item](window)
			except KeyboardInterrupt:
				pass	# User cancelled
		elif type == WE_CLOSE:
			#
			# Close a window
			#
			try:
				close_dialog(window)
			except KeyboardInterrupt:
				pass	# User cancelled
		elif type == WE_SIZE:
			#
			# A window was resized --
			# let the text object recompute the line breaks
			# and change the document size accordingly,
			# so scroll bars will work
			#
			fix_textsize(window)
		elif window.textobject.event(event):
			#
			# The event was eaten by the text object --
			# set the changed flag if not already set
			#
			if type == WE_CHAR or \
			   type == WE_COMMAND and detail in changing:
				window.changed = 1
				fix_docsize(window)
		#
		# Delete all objects that may still reference the window
		# in the event -- this is needed otherwise the window
		# won't actually be closed and may receive further
		# events, which will confuse the event decoder
		#
		del type, window, detail, event
Пример #46
0
def start(ref):
    stdwin.setdefscrollbars(0, 1)
    stdwin.setfont(FONT)
    stdwin.setdefwinsize(76 * stdwin.textwidth('x'), 22 * stdwin.lineheight())
    makewindow('ibrowse', ref)
    mainloop()
Пример #47
0
def isummary(win):
    stdwin.setdefwinsize(76 * stdwin.textwidth('x'), 22 * stdwin.lineheight())
    makewindow('ibrowse', 'Summary')
Пример #48
0
               if type = WE_DRAW:
                       drawproc(detail)
               elif type = WE_TIMER:
                       settimer()
                       drawproc(everywhere)
               elif type in mouse_events:
                       mouseclick(type, detail)
               elif type = WE_ACTIVATE:
                       if A.ring:
                               # Turn the ringing off
                               A.ring = 0
                               G.w.begindrawing().invert(G.mainarea)
               elif type = WE_SIZE:
                       G.w.change(everywhere)
                       width, height = G.w.getwinsize()
                       height = height - stdwin.lineheight()
                       setdimensions(width, height)
               elif type = WE_CLOSE:
                       break

def setdimensions(width, height):
       if width < height: size = width
       else: size = height
       halfwidth = width/2
       halfheight = height/2
       G.center = halfwidth, halfheight
       G.radius = size*45/100
       G.width = width
       G.height = height
       G.corner = width, height
       G.mainarea = origin, G.corner
Пример #49
0
def itutor(win):
    # The course looks best at 76x22...
    stdwin.setdefwinsize(76 * stdwin.textwidth('x'), 22 * stdwin.lineheight())
    makewindow('ibrowse', 'Help')
Пример #50
0
def openlistwindow(dirname):
	list = posix.listdir(dirname)
	list.sort()
	i = 0
	while i < len(list):
		if list[i] = '.' or list[i] = '..':
			del list[i]
		else:
			i = i+1
	for i in range(len(list)):
		name = list[i]
		if path.isdir(path.cat(dirname, name)):
			list[i] = list[i] + '/'
	width = maxwidth(list)
	width = width + stdwin.textwidth(' ')	# XXX X11 stdwin bug workaround
	height = len(list) * stdwin.lineheight()
	stdwin.setdefwinsize(width, min(height, 500))
	w = stdwin.open(dirname)
	stdwin.setdefwinsize(0, 0)
	w.setdocsize(width, height)
	w.drawproc = drawlistwindow
	w.mouse = mouselistwindow
	w.close = closelistwindow
	w.dirname = dirname
	w.list = list
	w.selected = -1
	return w

def maxwidth(list):
	width = 1
	for name in list:
Пример #51
0
	def initeditor(self):
		r = (stdwin.textwidth('>>> '), 0), (30000, stdwin.lineheight())
		self.editor = self.win.textcreate(r)
Пример #52
0
# Pass this program the Holy Grail script on stdin.