0

I am having problems trying to display a default tkinter askyesno dialog on top of my main window, which has no borders( I am using overrideredirect(1) ). Having a borderless window is a must in my case.

The dialog always opens behind the main window. Creating a custom dialog, also borderless seems to work, but I am wandering if there is a way to make the default askYesNo dialog appear on top of a borderless window. I am running the code on Raspbian (a version of Debian).

The python code is attached below:

from Tkinter import *
from tkMessageBox import *

def imageLabelPressed():

    print("Call button pressed")
    selected = lb.get(whichSelected())

    if (askyesno("Call", "Do you want to call %s?" % (selected) )):
        print("Call started")
    else:
        print("Cancel call")

win = Tk()
win.geometry('800x480')

backgroundImg = PhotoImage(file = "background.png")
backgroundLabel = Label(win, image = backgroundImg)
backgroundLabel.place(x=0, y=0, relwidth=1, relheight=1)

lb=Listbox(win, height=9)
lb.pack(side = LEFT, fill = BOTH, expand = 1)

callImage = PhotoImage(file = "callButton.png")
dButt = Label(win, text = "Some text", relief = FLAT, highlightthickness = 0, border = 0, image = callImage)
dButt.bind("<Button-1>", imageLabelPressed)
dButt.pack()

win.overrideredirect(1)
mainloop()

Thanks!

Bogdan N
  • 43
  • 6
  • `win.geometry('800x480')` add some x,y value for free space. – dsgdfg Jul 21 '16 at 10:29
  • I want the app to cover the whole screen, so the user can't exit from it ( it will be placed outdoors). The resolution of the screen is 800x480. – Bogdan N Jul 21 '16 at 10:35
  • `win.grab_set()` on open dialog, finished job call `win.grab_release()` On base : http://stackoverflow.com/questions/15363923/disable-the-underlying-window-when-a-popup-is-created-in-python-tkinter (include alternatives) – dsgdfg Jul 21 '16 at 10:48
  • "Stack" got a lot similar question and answer. What a `information pollution` ? – dsgdfg Jul 21 '16 at 10:53
  • Unfortunately with `win.grab_set()` and `win.grab_release()` the pop up is still under the main window. @dsgdfg I have searched "Stack" and tried solutions suggested but none of them worked for me. – Bogdan N Jul 21 '16 at 11:09
  • Are you sure ? http://stackoverflow.com/questions/1892339/how-to-make-a-window-jump-to-the-front – dsgdfg Jul 21 '16 at 12:11
  • if any solution resolve your problem, go to related answer type a answer include your question. My word is `global talk` so not personal(i am sorry if accepted as `personal message` !) – dsgdfg Jul 21 '16 at 12:24
  • @BogdanN what kind of problems are you having? You've said: "I am having problems...", but you have not mentioned the problems you are having. "Introduce the problem before you post any code In the body of your question, start by expanding on the summary you put in the title. Explain how you encountered the problem you're trying to solve, and any difficulties that have prevented you from solving it yourself. The first paragraph in your question is the second thing most readers will see, so make it as engaging and informative as possible."-[Asking](http://stackoverflow.com/help/how-to-ask) – Parviz Karimli Jul 21 '16 at 13:34
  • @BogdanN there are some mistakes in your code. For example if you use `bind`, input `event` inside the function which your button returns. – Parviz Karimli Jul 22 '16 at 17:21
  • @BogdanN, secondly, `imageLabelPressed` returns `NameError: name 'whichSelected' is not defined` – Parviz Karimli Jul 22 '16 at 17:22
  • @BogdanN, please solve other problems, and leave only what you are asking us. – Parviz Karimli Jul 22 '16 at 17:24

0 Answers0