#๐Ÿ”’ way to improve my code

4 messages ยท Page 1 of 1 (latest)

abstract sedge
#

im new to python and im getting use to tkinter but there no easy way to add sound i import pygame and create a hybrid code

import tkinter as tk

import pygame
pygame.init()
pygame.mixer.init()

button_sound = pygame.mixer.Sound("music/button_click.mp3")

main_window = tk.Tk()

#the main_window look
main_window.attributes("-fullscreen",True)
main_window.geometry("500x500")
main_window.title("project")
main_window.config(background="black")

#the close button
def press_button():
button_sound.play()

main_close = tk.Button(
main_window,
text="close",
command=press_button,
font=("arial",20,"bold"),
bg="black",
fg="white",
padx=98)
main_close.place(x=530,y=325)

i want to know ways to improve the code. this code is part of my python

young wrenBOT
#

@abstract sedge

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

young wrenBOT
#

@abstract sedge

Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.