I am fairly new to programming and really new to programming in Python. And I have made a countdown timer for fun to try to learn programming. It looks like this:  I need help with to play an audio file when the counter is at zero. For example, when the 1 min button has been pressed, it needs to play an audio file when it reaches zero. The same goes for the other buttons. I don't know how to play audio in Python, and how to connect in a way so it plays when the program meets the requirement of the counter = &quot;00:00:00&quot;. Here is my entire code: import tkinter as tk def update(seconds):     global after     if seconds &gt;= 0:         countdown.set(seconds_to_time(seconds))         after = root.after(1000, lambda: update(seconds - 1))     else:         root.after_cancel(after)  def seconds_to_time(seconds):     hours = seconds // 3600     seconds -= hours * 3600     minutes = seconds // 60     seconds -= minutes * 60     return f'{hours:02d}:{minutes:02d}:{seconds:02d}'  def stop():     try:         root.after_cancel(after)     except NameError:         pass  #GUI root = tk.Tk() root.title(&quot;Tequila timer&quot;)  #Load of background with the tequila bottle canvas = tk.Canvas(root, width=423, height=700) canvas.pack() Load = tk.PhotoImage(file=&quot;Flaske.png&quot;) canvas.create_image(211, 350, image=Load)  countdown = tk.StringVar() countdown.set(&quot;00:00:00&quot;)  #buttons btn_10sek = tk.Button(root, text=&quot;10 sekunder&quot;, width=10, height=5, command=lambda:  update(10)) btn_10sek_v = canvas.create_window(140, 300, window=btn_10sek)  btn_1min = tk.Button(root, text=&quot;1 min&quot;, width=10, height=5, command=lambda:  update(60)) btn_1min_v = canvas.create_window(283, 300, window=btn_1min)  btn_10min = tk.Button(root, text=&quot;10 min&quot;, width=10, height=5, command=lambda:  update(60 * 10)) bt1_10min_v = canvas.create_window(140, 425, window=btn_10min)  btn_1time = tk.Button(root, text=&quot;1 time&quot;, width=10, height=5, command=lambda:  update(3600)) bt1_1time_v = canvas.create_window(283, 425, window=btn_1time)  btn_2timer = tk.Button(root, text=&quot;2 timer&quot;, width=10, height=5, command=lambda:  update(7200)) bt1_2timer_v = canvas.create_window(140, 550, window=btn_2timer)  btn_stop = tk.Button(root, text=&quot;Stop tiden&quot;, width=10, height=5, command=stop) bt1_stop_v = canvas.create_window(283, 550, window=btn_stop)  btn_luk = tk.Button(root, text=&quot;Luk ned&quot;, width=12, height=3, command=root.quit) bt1_luk_v = canvas.create_window(211, 635, window=btn_luk)  #Display label = tk.Label(root, textvariable=countdown, width=9, font=(&quot;arial black&quot;, 40, &quot;bold&quot;), fg=&quot;red&quot;) label.pack() label_v = canvas.create_window(211, 165, window=label)  #Overskrift over = tk.Label(root, text=&quot;Tequila timer&quot;, font=(&quot;arial black&quot;, 40, &quot;bold&quot;), fg=&quot;red&quot;) over.pack() over_v = canvas.create_window(211, 30, window=over)  root.mainloop()  Update!!! I figured it out. I used the simpleaudio library and made a if statement that said seconds &lt; 0. What this does is that when the counter is done with counting down to zero, it plays the audio file because seconds is now below 0. I added into my time_function which is called &quot;update(seconds&quot;, so it looks like this: def update(seconds):     global after     if seconds &gt;= 0:         countdown.set(seconds_to_time(seconds))         after = root.after(1000, lambda: update(seconds - 1))     else:         root.after_cancel(after)      if seconds &lt; 0:         wave_obj = sa.WaveObject.from_wave_file(&quot;Te.wav&quot;)         play_obj = wave_obj.play()         play_obj.wait_done()
What's the easiest way to play a sound file (.wav) in Python? By easiest I mean both most platform independent and requiring the least dependencies. pygame is certainly an option, but it seems overkill for just sound.
For any smooth manifold, is it true that for any two points on the manifold, there exists a chart that covers the two points? My iPhone 5 won't boot anymore and when I plug it in my MacBook, it goes to recovery mode (cable logo => iTunes logo).  So I tried to restore it using iTunes but I keep getting this error    Any idea how to fix it?  While it was plugged in I tried holding power + home, it reboots the device and goes back to recovery mode and then any restore attempt results in a 2001 error as well. When it's not plugged in nothing will make it boot. Cannot downgrade wpa_supplicant to fix Wi-Fi connection to a corporate network (WPA2/PEAP with no CA certificate) in Ubuntu 18.04 I recently upgraded my Ubuntu from 16.04 to 18.04 (clean install, full wipe). Now I can no longer connect to the corporate network at my office (perhaps related to these bugs: , ). What proved to fix this issue in Ubuntu 16.04 is the answer to ; Downgrade wpa_supplicant to 2.1.  However, even with the linode repository, this fix can no longer be applied. There is no version for wpa_supplicant below 2.6 to the best of my knowledge for Ubuntu 18.04.  My question is this: How can I downgrade wpa_supplicant to 2.1 for Ubuntu 18.04?  Configuration needed for corporate the wifi connection:   Security: WPA &amp; WPA2 Enterprise Authentication: Protected EAP (PEAP) Checkbox No CA certificate required. Inner authentication: MSCHAPv2 Force pagebreak after every sentence/paragraph Is there a way to force a pagebreak after every sentence or paragraph?  This may seem like an odd thing to do, but for catching typos and just general editing I find it much easier to look at a sentence or paragraph in isolation so that I am not tempted to skip ahead.  Currently, I just zoom in so I can only see a few word at a time, but this is not a perfect solution. Can I use Ctrl+Shift for changing languages? I can't set this hotkey for changing keyboard languages.  At this moment Alt+Shift switch languages, but I can't see this hotkey in keyboard hotkeys list or in   gsettings list-recursively  org.gnome.desktop.wm.keybindings | sort | more   output. I was going to ask , but I came to the conclusion that I'm not going to do it (asking and building).  Now my question is: why is it (usually, if we leave the silly high-end prices alone) more expensive to build a bike from scratch? How can I execute `date` inside of a cron tab job? I want to create a log file for a cron script that has the current hour in the log file name. This is the command I tried to use:  0 * * * * echo hello &gt;&gt; ~/cron-logs/hourly/test`date "+%d"`.log   Unfortunately I get this message when that runs:  /bin/sh: -c: line 0: unexpected EOF while looking for matching ``' /bin/sh: -c: line 1: syntax error: unexpected end of file   I have tried escaping the date part in various ways, but without much luck. Is it possible to make this happen in-line in a crontab file or do I need to create a shell script to do this? Sum of (example: 0+1+2+3 = 6 , 0+1+2+3+4+5+6+7 = 28 and so on) For which $n$ is the sum: $$\sum_{k=0}^{n}10^k$$ a prime number? Are they finite? In Obi-Wan's Order 66 warning transmission why didn't he tell the surviving Jedi about the Sith, including Palpatine's true identity? If you've seen the premiere episode of Rebels, you will have seen Obi-Wan's warning message that he broadcast to Jedi throughout the galaxy in RotS. In this message he speaks cryptically &amp; warns of a "dark shadow" falling &amp; to avoid the temple &amp; await a "new hope".   Wouldn't it have been useful to inform the Jedi that their mortal enemy the Sith had returned? And specifically that Palpatine himself was a Sith? You'd assume that the majority of the Jedi who were not in the loop of the Council would be unaware of the existence of the Sith. Yoda mentions a few times that they should keep it under wraps. I think now would've been the time to reveal the truth. The more info the surviving Jedi have the better. Who knows if the likes of Kanan knows anything about the Sith's return! I find Obi-Wan's omission of this information bizarre. Actually I have installed the new Ubuntu 15.04 64bit, and when I'm trying to install Steam on it, there is a problem. In fact I have downloaded the deb package from steam website, installed it and when I start it nothing happens. I tried to start it from terminal and what I've got  $ steam Running Steam on ubuntu 15.04 64-bit STEAM_RUNTIME is enabled automatically Installing breakpad exception handler for appid(steam)/version(0_client) libGL error: unable to load driver: r600_dri.so libGL error: driver pointer missing libGL error: failed to load driver: r600 libGL error: unable to load driver: swrast_dri.so libGL error: failed to load driver: swrast GUI/Unity crashing in 16.04 LTS after updates 2018-01-04, compiz segfaults The latest updates (4/1/2018) make my laptop constantly crash the GUI/Unity:  (Intel Pentium su4100 processor)  syslog:  Jan  5 11:38:53 1810 kernel: [ 1850.327738] compiz[11911]: segfault at 0 ip 00007f6c7baf0c16 sp 00007ffd5ec71c60 error 4 in i965_dri.so[7f6c7b513000+82d000]   After login I end up with an empty desktop, just a wallpaper, GUI/Unity are in a crash loop:   No panel.  No dash.  Can't start a program. Launcher disappears. Sidebar disappears. System crash. Windows key not working. The key combination Alt+Tab not working.   Simply, the computer is not usable. Same for guest login. The only thing working: open up a terminal CTRL+ALT+T to examine log files.  I somehow forced  to let me log in and file the bug, but still lots of problems:   Dash not working Alt+Tab not working Sometimes windows all disappear for a few seconds     Any ideas for a solution or workaround?   UPDATE     If you have the same/ very similar problems, follow the link to my    report and mark there that you're affected too. Or file your own. Please leave a comment   if you wish, or upvote - this is a nasty problem - but an answer should   offer a fix or a workaround so users can use their computer again.    Without , Ubuntu can't fix issues. How to get a list of applications installed in Ubuntu dash? Deferring admission to a computer science graduate program How to clear the interpreter console? Remove array element based on object property This is a question I've been asked several times by students and I tend to have a hard time phrasing it in terms they can understand. This is a natural question to ask and it is not usually well covered in textbooks, so I would like to know of various perspectives and explanations that I can use when teaching.  The question comes up naturally in what is usually students' second course in quantum physics / quantum mechanics. At that stage one is fairly comfortable with the concept of wavefunctions and with the Schrödinger equation, and has had some limited exposure to operators. One common case, for example, is to explain that some operators commute and that this means the corresponding observables are 'compatible' and that there exists a mutual eigenbasis; the commutation relation is usually expressed as $[A,B]=0$ but no more is said about that object.  This naturally leaves students wondering     what is, exactly, the physical significance of the object $[A,B]$ itself?   and this is not an easy question. I would like answers to address this directly, ideally at a variety of levels of abstraction and required background. Note also that I'm much more interested in the object $[A,B]$ itself than what the consequences and interpretations are when it is zero, as those are far easier and explored in much more depth in most resources.    One reason this is a hard question (and that commutators are such confusing objects for students) is that they serve a variety of purposes, with only thin connecting threads between them (at least as seen from the bottom-up perspective).   Commutation relations are usually expressed in the form $[A,B]=0$ even though, a priori, there appears to be little motivation for the introduction of such terminology. A lot of stock is placed behind the canonical commutation relation $[x,p]=i \hbar$, though it is not always clear what it means.  (In my view, the fundamental principle that this encodes is essentially de Broglie's relation $\lambda=h/p$; this is made rigorous by the  but that's quite a bit to expect a student to grasp at a first go.) From this there is a natural extension to the Heisenberg Uncertainty Principle, which in its general form includes a commutator (and an anticommutator, to make things worse). Canonically-conjugate pairs of observables are often introduced, and this is often aided by observations on commutators. (On the other hand, the energy-time and angle-angular momentum conjugacy relations cannot be expressed in terms of commutators, making things even fuzzier.) Commutators are used very frequently, for example, when studying the angular momentum algebra of quantum mechanics. It is clear they play a big role in encoding symmetries in quantum mechanics but it is hardly made clear how and why, and particularly why the combination $AB-BA$ should be important for symmetry considerations.  This becomes even more important in more rigorous treatments of quantum mechanics, where the specifics of the Hilbert space become less important and the algebra of observable operators takes centre stage. The commutator is the central operation of that algebra, but again it's not very clear why that combination should be special. An analogy is occasionally made to the Poisson brackets of hamiltonian mechanics, but this hardly helps - Poisson brackets are equally mysterious. This also ties the commutator in with time evolution, both on the classical side and via the Heisenberg equation of motion.   I can't think of any more at the moment but they are a huge number of opposing directions which can make everything very confusing, and there is rarely a uniting thread. So: what are commutators, exactly, and why are they so important? Chrome asks for password to unlock keyring on startup In Google Chrome, when I go to a login page, a window pops up asking to "Enter password for keyring 'default' to unlock". In most cases, whether I click Cancel or enter my password, the login form gets auto filled anyway.  How do I get rid of the popup? I want it to auto login each time, not ask for my system password. The dialog box never appears for any other apps. Can't run my hello world in C Why can't an electric field line suddenly break? My book has the following question in it as an exercise:  An electrostatic field line is a continuous curve i.e. a field line cannot have sudden breaks. Why not?  I cannot seem to be able to reason for or against this statement.  Can somebody please tell me why they can't suddenly break and if that were to happen then what will be its outcome?