Posts

Showing posts with the label tkinter

Why does my pong game freeze after the ball hits the bottom and it doesn't display the “Game Over” screen?

Why does my pong game freeze after the ball hits the bottom and it doesn't display the “Game Over” screen? I am a high school student and also a python enthusiast. I am trying to make a pong game in python and most of it worked but I am trying to make the program wait 3 seconds before the ball starts moving and when the ball hits the bottom the program just freezes and it doesn't display the "Game Over" screen. Would anyone be able to help me with this? Here is the code I am working on. from tkinter import * import random import time class Ball: def __init__(self, canvas, color, size, paddle): self.canvas = canvas self.paddle = paddle self.id = canvas.create_oval(15, 15, size, size, fill=color) self.canvas.move(self.id, 245, 100) self.xspeed = random.randrange(-3,3) self.yspeed = -1 self.hit_bottom = False self.score = 0 def draw(self): self.canvas.move(self.id, self.xspeed,...

How to insert a picture into the splash screen?

Image
How to insert a picture into the splash screen? I just want to know how could I insert a picture into the splash screen? from tkinter import * #splash screen class SplashScreen(Frame): def __init__(self, master=None, width=0.8, height=0.6, useFactor=True): Frame.__init__(self, master) self.pack(side=TOP, fill=BOTH, expand=YES) # get screen width and height ws = self.master.winfo_screenwidth() hs = self.master.winfo_screenheight() w = (useFactor and ws * width) or width h = (useFactor and ws * height) or height # calculate position x, y x = (ws / 2) - (w / 2) y = (hs / 2) - (h / 2) self.master.geometry('%dx%d+%d+%d' % (w, h, x, y)) self.master.overrideredirect(True) self.lift() if __name__ == '__main__': root = Tk() sp = SplashScreen(root) sp.config(bg="#3632ff") m = Label(sp, text="MH60 NAVIGATION APP") m.pack(side=TOP, expa...