tkinter simpledialog not working on Mac 10.14 - python

I'm creating a UI with python 3.7 with tkinter. I have a button that should open a dialog and ask for a string input, in windows it works entirely as expected but for some reason it won't work on any of 3 Macs I've tried. On the Macs the main window goes gray on top and you can't interact with it, so it's as if a dialog window has opened, but the dialog window is nowhere to be found. Python is not crashing or giving any error messages either. It's baffling to me that I have not been able to find any similar problems searching online.
The button calls this method:
def add_goal(self):
newgoal = simpledialog.askstring("Input", "What goal would you like to begin tracking?", parent=self.root)
self.goal_list.goals.append(goal.Goal(newgoal,0,0))
self.set_listbox()
print(self.goal_list)
I have tested the button with only a print statement so I know the button works.
I have also tested the button with only the simpledialog line so I know the other parts aren't causing a problem. I have also tried simpledialog.askinteger just to see and that didn't work either.
If relevant I'm doing from tkinter import simpledialog at the top.
And again this all works perfectly fine on windows.
Thanks for any help, I can post the entire code if anyone wants but I don't think any of it is relevant.

Was using root.attributes("-topmost", True), the code was derived from a program that was meant to be at the front of the screen at all times which is why that line was there to begin with, but I realized it was no longer necessary and it seems to be the source of the problem.

Related

WxPython exit button doesn´t always works

I am using a code designed by another person in MAC OS. I am using Windows instead and have slightly modified it, but the problem comes when using the GUI that is created.
I have already dealt with a similar issue with a slider. Once I pressed the slider, I couldn´t release it or press another button. I was forced to quit the GUI and start again. I solved it by changing the event command from EVT_COMMAND_SCROLL to EVT_COMMAND_SCROLL_THUMBTRACK. However I did not understand why it worked in MAC OS and does not work in Windows.
Now, I want to close the GUI with the typical cross inside the red button in the right corner of the window. I can do it if it is the first order I do in the GUI. If I first press any button or slider, the exit button does not work.
It made me consider if a major problem is hidden in the code which I am not seeing. I am new at wxPython, which is the module used in the code.
I just ask for your opinion and hope it is a basic error.
Thanks very much

I'm struggling with being able to close a simple widget using tkinter

I have some Python experience and wish to learn about GUI development using tkinter.
I can create a simple widget, but when I try to close the window, things "hang" and nothing happens. Only by restarting the Python kernel can I get the window to close.
I'm running Python 3.7 using Spyder and, based upon some simple examples I've found in other forums tried the following:
import tkinter
root = tkinter.Tk()
root.title("Hello!")
simple_label = tkinter.Label(root, text="Easy, right?")
closing_button = tkinter.Button(root, text="Close window",
command=root.destroy)
simple_label.pack()
closing_button.pack()
root.mainloop()
As I mention above, the window does not close when I click my mouse on the Close Window button. I just get the "swirly" indicator on my Mac indicating the program is not responding. However, I am able to perform calculations in the Spyder console.
The code works fine, but what you should do is open the program in the Python IDLE that comes when you download Python. When you run the program it should open up the Python Launcher, which allows you to interact your your GUI (And it will let you close click the close button) I am using a Mac and everything works fine.
I was analyzing your case and we BOTH did something we didn't notice after.
When you use the "root.destroy" command, you should add parenthesis after.. Had the same thing happening to me
Added root.destroy ( ) and worked flawlessly. <-- Use it without SPACES
Hope it helps someone in the future!

Tkinter GUI buttons become invisible after creating app using Py2App

I built a small GUI using Tkinter. The GUI features, among some other elements, three buttons. These buttons serve to open a dystem dialog and select certain data-files etc. One of the three buttons is a 'Go' button that runs the underlying data-processing.
When running the .py script the GUI works fine. However, after creating a developer app in alias mode using Py2App the buttons have become invisible! They're still there and usable, but invisible until interacted with.
How can I prevent this from happening?
I was stuck in your exact situation for quite some time. When I ran my tkinter script, it worked perfectly and all the buttons showed up, but once I packaged it, the buttons stopped showing up (They were still there but you couldn't see them). After a long time of trying random things, I found out how to make the buttons and their text show up again. Simply resize the window. Even a difference of 1 or 2 pixels does the trick. I have not yet found a way to PREVENT this issue, but at least this makes the app look right.
Please reply if you figure out a solution to prevent this!
Good Luck!

Python - My tkinter button always looked pushed

Very dumb question but in my Python 2.7 program (which works perfectly) the buttons of my tkinter GUI always take their graphical pushed position whenever I click on them. Is this a known issue, and is there any way around this?

Maximize button does not work using Tkinter in RHEL5

I created a minimal Tkinter GUI as follows:
import Tkinter
root = Tkinter.Tk()
root.mainloop()
Everything is fine if I run the above code on RHEL5, except that the maximize button does not work properly(resizing is available). If I click the button, the window does not expand to occupy the whole screen. And I belive this issue is platform-specific, because there is no such issue for the same code on Windows.
Does anyone know the reason for this? Is there any solution? Thanks!
It works for me in Fluxbox. Try putting something in root like a label so it has something to display. Probably won't make any difference but worth a try.

Categories

Resources