I am making a music player application using both tkinter and pygame. I found online some ways to implement these two modules (https://mail.python.org/pipermail/tutor/2012-September/091417.html, Using pygame features in Tkinter), but my buttons are not visible. The pygame screen shows up fine, but I cannot get the buttons to show up.
Here is shortened version of my code:
from tkinter import *
import tkinter.filedialog as tk
import tkinter.messagebox as tk2
import os
import pygame
playlist = ['song1.mp3', 'song2.mp3', 'song3.mp3', 'song4.mp3']
class Application(Frame):
def __init__(self,master):
super(Application, self).__init__(master)
#create widgets
self.playlistbox = Listbox(self, selectmode = SINGLE) #listbox
for song in playlist:
self.playlistbox.insert(END, song)
self.playlistbox.grid(row = 1)
self.playButton = Button(self, text = 'Play', command = self.play) #button
self.playButton.grid(row=1, column = 1)
#pygame init
embed = tk.Frame(root, width = 200 , height = 200)
embed.pack()
embed.pack(side = LEFT)
os.environ['SDL_WINDOWID'] = str(embed.winfo_id())
os.environ['SDL_VIDEODRIVER'] = 'windib'
pygame.display.init()
windowSurface = pygame.display.set_mode((200,100))
pygame.mouse.set_visible(True)
def play(self): #play song function
pygame.mixer.music.stop()
selectedSongs = self.playlistbox.curselection()
pygame.mixer.music.load(self.playlistbox.get(0))
pygame.mixer.music.play(0, 0.0)
root = Tk()
root.title('Text Editor')
root.geometry('700x600')
app = Application(root)
app.mainloop()