O'Reilly Forums: djphinesse - Viewing Profile - O'Reilly Forums

Jump to content

User Rating: -----

Reputation: 0 Neutral
Group:
Members
Active Posts:
16 (0.01 per day)
Most Active In:
Head First Programming (7 posts)
Joined:
10-February 10
Profile Views:
2,270
Last Active:
User is offline Jan 02 2014 09:29 PM
Currently:
Offline

My Information

Member Title:
Active Member
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Not Telling Not Telling

Contact Information

E-mail:
Click here to e-mail me

Posts I've Made

  1. In Topic: Ch 10 Pg.360( Global Name 'intvar' Is Not Defined) Why! :(

    14 December 2013 - 09:59 PM

    I figured mine out as well!

    I had not put parentheses in order to make stop a method. Also, I needed to place the shutdown method inside the sound_panel module and include the protocol method inside there too.
  2. In Topic: Ch 10 Pg.360( Global Name 'intvar' Is Not Defined) Why! :(

    14 December 2013 - 10:44 AM

    Not working for me! I get:

    Exception in Tkinter callback
    Traceback (most recent call last):
      File "C:\Python34\lib\tkinter\__init__.py", line 1475, in __call__
        return self.func(*args)
      File "C:\Users\Charlie\Documents\Python\djMix4.py", line 15, in shutdown
        track.stop()
    NameError: name 'track' is not defined


    Here's my code:

    from tkinter import *
    import pygame.mixer
    
    def create_gui(app, mixer, sound_file):
        
        def track_toggle():
            if track_playing.get() == 1:
                track.play(loops = -1)
            else:
                track.stop
    
        def change_volume(v):
            track.set_volume(volume.get())
    
        track = mixer.Sound(sound_file)
        track_playing = IntVar()
        track_button = Checkbutton(app, variable = track_playing,
                                   command = track_toggle,
                                   text = sound_file)
        track_button.pack(side = 'left')
    
        volume = DoubleVar()
        volume.set(track.get_volume())
        volume_scale = Scale(variable = volume,
                             from_ = 0.0,
                             to = 1.0,
                             resolution = 0.1,
                             command = change_volume,
                             label = 'Volume',
                             orient = 'horizontal')
        volume_scale.pack(side = 'right')
    


    from tkinter import *
    import pygame.mixer
    from sound_panel import *
    
    app = Tk()
    app.title("Head First DJ")
    
    mixer = pygame.mixer
    mixer.init()
    
    create_gui(app, mixer, "50459_M_RED_Nephlimizer.wav")
    create_gui(app, mixer, "49119_M_RED_HardBouncer.wav")
    
    def shutdown():
        track.stop()
        app.destroy()
    
    
    app.protocol("WM_DELETE_WINDOW", shutdown)
    app.mainloop()
    
    


    View Postvonn, on 10 June 2011 - 12:21 AM, said:

    • I GOT IT!!
    • I HAD NOT PLACED THE IMPORT lines on top

  3. In Topic: Chapter 8 Code Error

    11 December 2013 - 08:35 AM

    What is the error that you're getting from this code?
  4. In Topic: Chapter 6 Page 183 New Method

    11 December 2013 - 08:34 AM

    If it works, cool. But that is a lot more typing just to get the same effect :/

    But its great to learn new ways to achieve things in programming, that way you know you've really learned something :)
  5. In Topic: Python 3 With Windows 7

    11 December 2013 - 08:32 AM

    I am running Py 3.4 under W7. Did you get it working yet?