Embedding a Pygame window into a Tkinter or WxPython frame

A friend and I are making a game in pygame. We would like to have a pygame window embedded into a tkinter or WxPython frame, so that we can include text input, buttons, and dropdown menus that are supported by WX or Tkinter. I have scoured the internet for an answer, but all I have found are people asking the same question, none of these have been well answered.

When do I need to call mainloop in a Tkinter application?

Every tkinter tutorial I have seen claims that tkinter.mainloop must be called for windows to be drawn and events to be processed, and they always call this function, even in hello world programs. However, when I try these out in the interactive shell, windows are drawn correctly without having to call mainloop. This example of embedding matplotlib graphics in tkinter produces a relatively complex application, with buttons for panning, zooming and resizing a plot within a tkinter window, and again, this all works if you remove the call to mainloop and run the code in the interactive shell. Of course, if I run the script (with mainloop removed) outside the interactive shell, the program ends too quickly to see what happens, but if I add a call to input to hold the program open everything works correctly (I’m running python 3.2.2 on linux).

While Loop Locks Application

I have been banging my head for a while now on a application I am working on. After many hours trying to debug an issue where the interface locks up and nothing else can take place I figured out it was the dreaded While loop. See this example below and run it. When you start the while loop by clicking on the button you cannot do anything else on the screen. In this is case it is just a simple alert button that needs pressing.

How to use an image for the background in tkinter?

#import statements from Tkinter import * import tkMessageBox import tkFont from PIL import ImageTk,Image Code to import image: app = Tk() app.title("Welcome") image2 =Image.open('C:\Users\adminp\Desktop\titlepage\front.gif') image1 = ImageTk.PhotoImage(image2) w = image1.width() h = image1.height() app.geometry('%dx%d+0+0' % (w,h)) #app.configure(background='C:\Usfront.png') #app.configure(background = image1) labelText = StringVar() labelText.set("Welcome !!!!") #labelText.fontsize('10') label1 = Label(app, image=image1, textvariable=labelText, font=("Times New Roman", 24), … Read more