def main(): print 'wdiff: warning: this program does NOT make backups' argv = sys.argv flags = '' if len(argv) >= 2 and argv[1][:1] == '-': flags = argv[1] del argv[1] stdwin.setdefscrollbars(0, 1) m = mainmenu() # Create menu earlier than windows if len(argv) == 2: # 1 argument w = anyopen(argv[1]) if not w: return elif len(argv) == 3: # 2 arguments w = anydiff(argv[1], argv[2], flags) w.parent = () else: sys.stdout = sys.stderr print 'usage:', argv[0], '[diff-flags] dir-1 [dir-2]' sys.exit(2) del w # It's preserved in gwin.windows while 1: try: gwin.mainloop() break except KeyboardInterrupt: pass # Just continue...
def main(): print "wdiff: warning: this program does NOT make backups" argv = sys.argv flags = "" if len(argv) >= 2 and argv[1][:1] == "-": flags = argv[1] del argv[1] stdwin.setdefscrollbars(0, 1) m = mainmenu() # Create menu earlier than windows if len(argv) == 2: # 1 argument w = anyopen(argv[1]) if not w: return elif len(argv) == 3: # 2 arguments w = anydiff(argv[1], argv[2], flags) w.parent = () else: sys.stdout = sys.stderr print "usage:", argv[0], "[diff-flags] dir-1 [dir-2]" sys.exit(2) del w # It's preserved in gwin.windows while 1: try: gwin.mainloop() break except KeyboardInterrupt: pass # Just continue...
def main(): player = cd.open() stdwin.setdefscrollbars(0, 0) win = stdwin.open('CD') win.player = player win.dispatch = cddispatch mainloop.register(win) win.settimer(10) mainloop.mainloop()
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)
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)
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)
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)
def main(n): from CSplit import CSplit # stdwin.setdefscrollbars(0, 0) # the_window = WindowParent().create('TestCSplit', (0, 0)) the_csplit = CSplit().create(the_window) # for i in range(n): the_child = PushButton().define(the_csplit) the_child.settext( ` (i + n - 1) % n + 1 `) # the_window.realize() # MainLoop()
def main(n): from CSplit import CSplit # stdwin.setdefscrollbars(0, 0) # the_window = WindowParent().create('TestCSplit', (0, 0)) the_csplit = CSplit().create(the_window) # for i in range(n): the_child = PushButton().define(the_csplit) the_child.settext(`(i+n-1)%n+1`) # the_window.realize() # MainLoop()
def main(n): from FormSplit import FormSplit # stdwin.setdefscrollbars(1, 1) # the_window = WindowParent().create('TestFormSplit', (0, 0)) the_form = FormSplit().create(the_window) # for i in range(n): if i % 3 == 0: the_form.placenext(i*40, 0) the_child = PushButton().define(the_form) the_child.settext('XXX-' + `i` + '-YYY') # the_window.realize() # MainLoop()
def main(n): from FormSplit import FormSplit # stdwin.setdefscrollbars(1, 1) # the_window = WindowParent().create('TestFormSplit', (0, 0)) the_form = FormSplit().create(the_window) # for i in range(n): if i % 3 == 0: the_form.placenext(i * 40, 0) the_child = PushButton().define(the_form) the_child.settext('XXX-' + ` i ` + '-YYY') # the_window.realize() # MainLoop()
def open(self): if self.window: return self.formwidth = max(100, self.formwidth) self.formheight = max(50, self.formheight) stdwin.setdefwinsize(self.formwidth, self.formheight) stdwin.setdefscrollbars(0, 0) self.window = stdwin.open(self.title) self.window.setdocsize(self.formwidth, self.formheight) for name in self.fieldnames: label, left, top, right, bottom, te = \ self.fields[name] rect = (left, top), (right, bottom) te = self.window.textcreate(rect) te.setactive(0) te.setview(rect) self.fields[name] = \ label, left, top, right, bottom, te if self.fieldnames: self.setfocus(self.fieldnames[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()
def opencontrolwindow(): stdwin.setdefscrollbars(0, 0) cw = WindowParent().create('Jukebox', (0, 0)) # stop = PushButton().definetext(cw, ' Stop ') stop.hook = stop_hook stop.enable(0) G.stop = stop # cw.realize() # G.ratemenu = cw.win.menucreate('Rate') for r in rates: G.ratemenu.additem(r) if G.rate == 0: G.ratemenu.check(0, 1) else: for i in len(range(rates)): if rates[i] == `G.rate`: G.ratemenu.check(i, 1) # return cw
def opencontrolwindow(): stdwin.setdefscrollbars(0, 0) cw = WindowParent().create('Jukebox', (0, 0)) # stop = PushButton().definetext(cw, ' Stop ') stop.hook = stop_hook stop.enable(0) G.stop = stop # cw.realize() # G.ratemenu = cw.win.menucreate('Rate') for r in rates: G.ratemenu.additem(r) if G.rate == 0: G.ratemenu.check(0, 1) else: for i in len(range(rates)): if rates[i] == ` G.rate `: G.ratemenu.check(i, 1) # return cw
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()
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
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
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()
def main(): # # Turn off scroll bars # stdwin.setdefscrollbars(0, 0) # # Set default state # G.gain = 60 G.rate = 3 G.nomuting = 0 G.savefile = '@rec' # # Set default values # G.data = '' G.playing = 0 G.recording = 0 G.sogram = 0 # # Parse options # optlist, args = getopt.getopt(sys.argv[1:], 'mdg:r:') # for optname, optarg in optlist: if 0: # (So all cases start with elif) pass elif optname == '-d': G.debug = 1 elif optname == '-g': G.gain = string.atoi(optarg) if not (0 < G.gain < 256): raise optarg.error, '-g gain out of range' elif optname == '-m': G.nomuting = (not G.nomuting) elif optname == '-r': G.rate = string.atoi(optarg) if not (1 <= G.rate <= 3): raise optarg.error, '-r rate out of range' # if args: G.savefile = args[0] # # Initialize the sound package # audio.setoutgain(G.nomuting * G.gain) # Silence the speaker audio.setrate(G.rate) # # Create the WindowParent and VSplit # G.window = WindowParent().create('Recorder', (0, 0)) w = G.vsplit = VSplit().create(G.window) # # VU-meter # G.vubtn = VUMeter().define(w) # # Radiobuttons for rates # r1btn = RadioButton().definetext(w, '32 K/sec') r1btn.on_hook = rate_hook r1btn.rate = 1 # r2btn = RadioButton().definetext(w, '16 K/sec') r2btn.on_hook = rate_hook r2btn.rate = 2 # r3btn = RadioButton().definetext(w, '8 K/sec') r3btn.on_hook = rate_hook r3btn.rate = 3 # radios = [r1btn, r2btn, r3btn] r1btn.group = r2btn.group = r3btn.group = radios for r in radios: if r.rate == G.rate: r.select(1) # # Other controls # G.recbtn = TimeOutToggleButton().definetext(w, 'Record') G.recbtn.on_hook = record_on_hook G.recbtn.timer_hook = record_timer_hook G.recbtn.off_hook = record_off_hook # G.mutebtn = CheckButton().definetext(w, 'Mute') G.mutebtn.select(not G.nomuting) G.mutebtn.hook = mute_hook # G.playbtn = TimeOutToggleButton().definetext(w, 'Playback') G.playbtn.on_hook = play_on_hook G.playbtn.timer_hook = play_timer_hook G.playbtn.off_hook = play_off_hook # G.gainbtn = ComplexSlider().define(w) G.gainbtn.settexts(' Volume: ', ' ') G.gainbtn.setminvalmax(0, G.gain, 255) G.gainbtn.sethook(gain_hook) # G.sizebtn = Label().definetext(w, ` len(G.data) ` + ' bytes') # #G.showbtn = PushButton().definetext(w, 'Sound-o-gram...') #G.showbtn.hook = show_hook # G.savebtn = PushButton().definetext(w, 'Save...') G.savebtn.hook = save_hook # G.quitbtn = PushButton().definetext(w, 'Quit') G.quitbtn.hook = quit_hook G.playbtn.enable(0) G.savebtn.enable(0) #G.showbtn.enable(0) start_vu() G.window.realize() # # Event loop # MainLoop()
def main(): # # Turn off scroll bars # stdwin.setdefscrollbars(0, 0) # # Set default state # G.gain = 60 G.rate = 3 G.nomuting = 0 G.savefile = '@rec' # # Set default values # G.data = '' G.playing = 0 G.recording = 0 G.sogram = 0 # # Parse options # optlist, args = getopt.getopt(sys.argv[1:], 'mdg:r:') # for optname, optarg in optlist: if 0: # (So all cases start with elif) pass elif optname == '-d': G.debug = 1 elif optname == '-g': G.gain = string.atoi(optarg) if not (0 < G.gain < 256): raise optarg.error, '-g gain out of range' elif optname == '-m': G.nomuting = (not G.nomuting) elif optname == '-r': G.rate = string.atoi(optarg) if not (1 <= G.rate <= 3): raise optarg.error, '-r rate out of range' # if args: G.savefile = args[0] # # Initialize the sound package # audio.setoutgain(G.nomuting * G.gain) # Silence the speaker audio.setrate(G.rate) # # Create the WindowParent and VSplit # G.window = WindowParent().create('Recorder', (0, 0)) w = G.vsplit = VSplit().create(G.window) # # VU-meter # G.vubtn = VUMeter().define(w) # # Radiobuttons for rates # r1btn = RadioButton().definetext(w, '32 K/sec') r1btn.on_hook = rate_hook r1btn.rate = 1 # r2btn = RadioButton().definetext(w, '16 K/sec') r2btn.on_hook = rate_hook r2btn.rate = 2 # r3btn = RadioButton().definetext(w, '8 K/sec') r3btn.on_hook = rate_hook r3btn.rate = 3 # radios = [r1btn, r2btn, r3btn] r1btn.group = r2btn.group = r3btn.group = radios for r in radios: if r.rate == G.rate: r.select(1) # # Other controls # G.recbtn = TimeOutToggleButton().definetext(w, 'Record') G.recbtn.on_hook = record_on_hook G.recbtn.timer_hook = record_timer_hook G.recbtn.off_hook = record_off_hook # G.mutebtn = CheckButton().definetext(w, 'Mute') G.mutebtn.select(not G.nomuting) G.mutebtn.hook = mute_hook # G.playbtn = TimeOutToggleButton().definetext(w, 'Playback') G.playbtn.on_hook = play_on_hook G.playbtn.timer_hook = play_timer_hook G.playbtn.off_hook = play_off_hook # G.gainbtn = ComplexSlider().define(w) G.gainbtn.settexts(' Volume: ', ' ') G.gainbtn.setminvalmax(0, G.gain, 255) G.gainbtn.sethook(gain_hook) # G.sizebtn = Label().definetext(w, `len(G.data)` + ' bytes') # #G.showbtn = PushButton().definetext(w, 'Sound-o-gram...') #G.showbtn.hook = show_hook # G.savebtn = PushButton().definetext(w, 'Save...') G.savebtn.hook = save_hook # G.quitbtn = PushButton().definetext(w, 'Quit') G.quitbtn.hook = quit_hook G.playbtn.enable(0) G.savebtn.enable(0) #G.showbtn.enable(0) start_vu() G.window.realize() # # Event loop # MainLoop()
def start(ref): stdwin.setdefscrollbars(0, 1) stdwin.setfont(FONT) stdwin.setdefwinsize(76*stdwin.textwidth('x'), 22*stdwin.lineheight()) makewindow('ibrowse', ref) mainloop()
def start(ref): stdwin.setdefscrollbars(0, 1) stdwin.setfont(FONT) stdwin.setdefwinsize(76 * stdwin.textwidth('x'), 22 * stdwin.lineheight()) makewindow('ibrowse', ref) mainloop()