コード例 #1
0
def main():
    from TextEdit import TextEdit
    from WindowParent import WindowParent, MainLoop
    w = WindowParent().create('Test TextEdit', (0, 0))
    t = TextEdit().create(w, (40, 4))
    w.realize()
    MainLoop()
コード例 #2
0
def main():
    import sys
    args = sys.argv[1:]
    if not args:
        args = ['.']
        # Mac: args = [':']
    for arg in args:
        w = DirListWindow().create(arg)
    MainLoop()
コード例 #3
0
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()
コード例 #4
0
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()
コード例 #5
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()
コード例 #6
0
def main():
    #
    # Create the widget hierarchy, top-down
    #
    # 1. Create the window
    #
    window = WindowParent().create('Radio Groups', (0, 0))
    #
    # 2. Create a horizontal split to contain the groups
    #
    topsplit = HSplit().create(window)
    #
    # 3. Create vertical splits, one for each group
    #
    group1 = VSplit().create(topsplit)
    group2 = VSplit().create(topsplit)
    group3 = VSplit().create(topsplit)
    #
    # 4. Create individual radio buttons, each in their own split
    #
    b11 = RadioButton().definetext(group1, 'Group 1 button 1')
    b12 = RadioButton().definetext(group1, 'Group 1 button 2')
    b13 = RadioButton().definetext(group1, 'Group 1 button 3')
    #
    b21 = RadioButton().definetext(group2, 'Group 2 button 1')
    b22 = RadioButton().definetext(group2, 'Group 2 button 2')
    b23 = RadioButton().definetext(group2, 'Group 2 button 3')
    #
    b31 = RadioButton().definetext(group3, 'Group 3 button 1')
    b32 = RadioButton().definetext(group3, 'Group 3 button 2')
    b33 = RadioButton().definetext(group3, 'Group 3 button 3')
    #
    # 5. Define the grouping for the radio buttons.
    #    Note: this doesn't have to be the same as the
    #    grouping is splits (although it usually is).
    #    Also set the 'hook' procedure for each button
    #
    list1 = [b11, b12, b13]
    list2 = [b21, b22, b23]
    list3 = [b31, b32, b33]
    #
    for b in list1:
        b.group = list1
        b.on_hook = myhook
    for b in list2:
        b.group = list2
        b.on_hook = myhook
    for b in list3:
        b.group = list3
        b.on_hook = myhook
    #
    # 6. Select a default button in each group
    #
    b11.select(1)
    b22.select(1)
    b33.select(1)
    #
    # 6. Realize the window
    #
    window.realize()
    #
    # 7. Dispatch events until the window is closed
    #
    MainLoop()
    #
    # 8. Report final selections
    #
    print 'You selected the following choices:'
    if b11.selected: print '1.1'
    if b12.selected: print '1.2'
    if b13.selected: print '1.3'
    if b21.selected: print '2.1'
    if b22.selected: print '2.2'
    if b23.selected: print '2.3'
    if b31.selected: print '3.1'
    if b32.selected: print '3.2'
    if b33.selected: print '3.3'
コード例 #7
0
ファイル: rec.py プロジェクト: olympu/ancient-pythons
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()