I am trying to write a program that allows the user to press different buttons in a full screen Tkinter GUI. The operations these buttons preform does not matter for my question, but I am having trouble creating a popup dialogue (askokcancel) to confirm that the user wants to press a button, then run the rest of that buttons code normally if "ok" is pressed. Currently, I have this program running from boot through the /etc/profile file, accessed via
sudo nano /etc/profile
Here I change the directory to the folder containing my python file and have it load my code, and upon booting up it loads my buttons correctly and upon pressing the correct button the popup window appears over the full screen window. However, when I try to run my code through the desktop shell, upon pressing the button, the popup window DOES appear, but is hidden behind the root window. I am not able to click anywhere else, and pressing "tab" and "enter" allows me to navigate between the two choices and pick one, but without being able to see it. I have buttons printing words in the shell, so I know the popup window is actually there.
The full screen makes use of the overrideredirect function, hiding the task bar and other options. When this is set to FALSE, the popup works as intended, but I am trying to make the GUI be the only thing on the screen.
Here is a condensed version of my code:
from Tkinter import*
import tkMessageBox
class Application(Frame):
def run(self):
tkMessageBox.askokcancel("Run Confirmation!", "Are you sure?")
print "RUN Code Intitates"
def createWidgets(self):
self.button1 = Button(self,height=15,width=20)
self.button1["command"] = self.run
self.button1.pack({"side": "left"})
def __init__(self, master=None):
Frame.__init__(self, master)
self.pack()
self.createWidgets()
root = Tk()
w, h = root.winfo_screenwidth(), root.winfo_screenheight()
root.overrideredirect(1)
root.geometry("%dx%d+0+0" % (800, 480))
app = Application(master=root)
app.mainloop()
root.destroy()
I am by no means a computer science major and have only been working with raspberry pi, tkinter, and python for a couple weeks, so if I am missing something basic I apologize. I am using an 8" touchscreen display made for raspberry pi as my screen.