Python Forum
popup message box code runs in Windows, but not in Linux
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
popup message box code runs in Windows, but not in Linux
#9
An update:

I don't appear to have the same problem if I call the message box from a button or from a menu.  I put the message box code inside a def named doNothing in this code.  Either the "Insert Image" button or any of the menus can call it.  It runs fine.  The message boxes pop up in the foreground.  

### https://www.youtube.com/watch?v=PSm-tq5M-Dc  <== menus
### https://www.youtube.com/watch?v=D24Vx3_IM8U&t=23s   <=== Toolbar
from tkinter import *
import tkinter.messagebox      ### Pull in ability to make message boxes

def doNothing():
   # print("Okay, okay, I won't")
   answer = tkinter.messagebox.askquestion('Question 1', 'Do you like silly faces?')

   if answer == 'yes':
       tkinter.messagebox.showinfo('Really', 'Here ya go 8===D~ ')
       # print(' 8===D~ ')
   elif answer == 'no':
       tkinter.messagebox.showinfo('Really', 'You sure are boring')

def doSomething():
   filewin = Toplevel(root)
   button = Button(filewin, text="Do something button")
   button.pack()

root = Tk()

### ************* Main Menu ***********************************

menu = Menu(root)
root.config(menu=menu)

subMenu = Menu(menu)
menu.add_cascade(label="File", menu=subMenu)
subMenu.add_command(label="New Project ...", command=doNothing)
subMenu.add_command(label="New", command=doNothing)
subMenu.add_separator()
subMenu.add_command(label="Exit", command=doNothing)

editMenu = Menu(menu)
menu.add_cascade(label="Edit", menu=editMenu)
editMenu.add_command(label="Redo", command=doNothing)

### ************   The Toolbar ***********************************

toolbar = Frame(root, bg="blue")

insertButt = Button(toolbar, text="Insert Image", command=doNothing)
insertButt.pack(side=LEFT, padx=2, pady=2)
printButt = Button(toolbar, text="Print", command=doSomething)
printButt.pack(side=LEFT, padx=10, pady=10)

toolbar.pack(side=TOP, fill=X)  ### fill=X makes it fill up all space in the X direction (horizontally)

### ************   The Statusbar ***********************************

status = Label(root, text="Preparing to do nothing...", bd=1, relief=SUNKEN, anchor=W)
status.pack(side=BOTTOM, fill=X)  ### fill = X makes sure that it spans the entire bottom

root.mainloop()
So I think I'm good.  My worries were that I would create some real application and the user would choose something and the message box would be in the background unbeknownst to him, but that doesn't appear to be the case.
Reply


Messages In This Thread
RE: popup message box code runs in Windows, but not in Linux - by Luke_Drillbrain - May-02-2017, 08:09 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] Hover over highlighted text and open popup window DrakeSoft 2 1,589 Oct-29-2022, 04:30 PM
Last Post: DrakeSoft
  POPUP on widget Entry taratata2020 4 3,833 Mar-10-2020, 05:04 PM
Last Post: taratata2020
  [WxPython] How to show remove button at the right side of the hovering item of a combobox popup? indrajitmajumdar 0 2,546 Mar-28-2019, 11:24 AM
Last Post: indrajitmajumdar
  [Tkinter] [SOLVED] Create per button popup menu py2.7 AceScottie 5 6,261 May-31-2018, 12:39 AM
Last Post: AceScottie
  Code fails on Mac, works on Windows and Raspberry Pi eugenedakin 4 4,061 May-30-2018, 03:49 AM
Last Post: eugenedakin
  [PyQt] source code is not running in REDHAT 7 linux platform shridhara 0 2,141 May-23-2018, 07:58 AM
Last Post: shridhara
  Please advice Linux library - tray icon, popup windows, ICQ/Skype style etc ramendik 5 4,121 Dec-03-2017, 04:35 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020