コード例 #1
0
ファイル: DirList.py プロジェクト: arandilopez/z-eves
	def create(self, parent, dirname):
		self = VSplit.create(self, parent)
		names = os.listdir(dirname)
		for name in names:
			if os.path.isdir(os.path.join(dirname, name)):
				fullname = os.path.join(dirname, name)
				btn = SubdirButton().definetext(self, fullname)
			elif name[-3:] == '.py':
				btn = ModuleButton().definetext(self, name)
			else:
				btn = FileButton().definetext(self, name)
		return self
コード例 #2
0
def opencontrolwindow():
	cw = WindowParent().create('Jukebox', (0, 0))
	v = VSplit().create(cw)
	#
	gain = ComplexSlider().define(v)
	gain.setminvalmax(0, G.gain, 255)
	gain.settexts('  ', '  ')
	gain.sethook(gain_setval_hook)
	#
	stop = PushButton().definetext(v, 'Stop')
	stop.hook = stop_hook
	#
	cw.realize()
	return cw
コード例 #3
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'
コード例 #4
0
ファイル: rec.py プロジェクト: tomjackbear/python-0.9.1
                 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
 #
コード例 #5
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()