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.
Related
very simple problem, I just try to make tkinter window that you are not able to move with the mouse. the problem is that I don't find a function that can do it, the only thing that I found is making it not resizable and stuff like that, I also found a function that hides the bar and making it not resizable or moveable, but it doesn't help me cause I still want it to have the default window bar, let's just say I have a normal window here:
import tkinter as TK
window = TK.Tk()
window.geometry('1200x800')
window.mainloop()
so just tell me if you know how to make it impossible to move the window with the mouse, how to do that, the code should work fine with fullscreen and other functionality like that by the way.
In Tkinter I find a small problem. I am unable to use an Entry/Text/Scrolledtext/any widget that the user can enter letters into after using a Tkinter simpledialog prompt. The entry widget works fine before using the prompt, but after the prompt I am unable to enter stuff into the widget. It's as though the widget becomes disabled. No exception is thrown. However, I can access the widget again once I click on another window and click on my Tkinter window again.
I have tried using the focus_get method on the entry widget. It doesn't work.
I have also tried doing entry.config(state='normal'). That doesn't work.
I could not think of anything else to try. Searching the web doesn't work; nothing relevant comes up.
Here's some example code:
import tkinter as tk
import tkinter.simpledialog as dialog
def get_string():
string = dialog.askstring("Title", "Prompt")
print(string)
root = tk.Tk()
entry = tk.Entry(root)
button = tk.Button(root, text="Get String", command=get_string)
entry.pack()
button.pack()
root.mainloop()
For the problem to show, you need to click on the button, and then try to use the entry widget; it doesn't work for me.
I am using Python 3.9.6, on macOS.
Edit: after a few people commented, this problem is probably specific to macOS Big Sur; this problem isn't there on Windows, OSX, or Linux.
So, I left the project alone for a while, and now I've updated to macOS Monterey and Python 3.10. With these updates, I now find the problem disappeared.
Here's a snippet of my test code
from tkinter import *
master=Tk()
master.geometry('640x340')
Button(master,text='check').pack()
def new():
print('done')
from pywinauto import Desktop, Application
master.after(1000,new)
master.mainloop()
In exactly one second the tkinter window which is created reduces in size, same thing happens for the button as well. This is just test code which I wrote after tracking down this problem in the application I am trying to build. Could somebody tell me why the window changes in size, and what I can do to prevent this?
I have checked all I could, the official documentation only mentions Tkinter once and that is referring to pywinauto’s backend, and I don't think it is relevant. Here on page 5.
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.
I'm trying to set the Activity (not sure of the proper term, see screenshot) name for a Tkinter app. I'm not a Linux expert, novice, or really even beginner, but the system about dialog lists my test machine as Fedora 30. Window Manager is Gnome.
Code can't get much simpler:
import tkinter as tk
master=tk.Tk()
master.title("My lil' Application")
master.mainloop()
This is most likely either a very simple or impossible thing to accomplish. I've not been able to come up with the magical search terms that result in an answer yet. This seems like something that someone else must have run into though which means the answer has to be out there.
Thank you for your time.
Solution from stovfl:
import tkinter as tk
master=tk.Tk(className="My lil' Application")
master.title("My lil' Application")
master.mainloop()