I have searched wide and far for this question, but noone seems to know. I create a simple tkinter window (tcl 8.5) in python 2.7 and want it maximized, just as if I would hit the maximize button in top right corner. Using the -fullscreen option is not an option since it removes the title bar.
I tried the following:
import Tkinter
root = Tkinter.Tk()
root.overrideredirect(True)
# Set window to be size of screen
root.geometry("{0}x{1}+0+0".format(root.winfo_screenwidth(), root.winfo_screenheight()))
The problem is that the window is now below the Windows taskbar and some of my elements are therefore not shown. An easy hack would be to set height to screenheight-some_constant, or calculate some_constant based on data from the operating system. However, this seems like an extremely ugly hack.
Is there any way to maximize a window in tkinter in a clean way where the window is above the (Windows) taskbar and still has a title bar?
i know this is an old question but i have tested the following code on an XP system (32bit) with python 2.7.6, using TCL version 8.5 and tk version 8.5.
code:
import Tkinter as tk
root = tk.Tk()
root.state("zoomed")
root.mainloop()
this does start the window maximised on the primary monitor.
it does have pitfalls - i have been unable to make it maximise on another monitor, but does work reliably without covering the title bar or taskbar.
and as you want to keep the title bar i would leave out the overrideredirect.
Related
I am trying to make a Tkinter app, and it has no title bar.
I have added revisability with size grip, moving the window around and minimizing
However, I am trying to make the Tkinter window full sized, AND SHOW THE TASKBAR
here is my code
def funel():
root.overrideredirect(False)
root.state('zoomed')
root.overrideredirect(True)
messagebox.showerror("This feature is not added yet", "This feature is not added yet. Please give me help")
fullscreen_btn.bind("<Button-1>", lambda event: funel_exit())
So yeah... it Fullscreen's, however it does hide the taskbar. I WANT THE TASKBAR NOT TO BE HIDDEN
if my question aint clear, please inform.
I've been trying to make use of the overrideredirect() function in tkinter, but I'm facing a small issue.
Here's a sample code snippet:
from tkinter import *
root = Tk()
root.geometry("500x500+200+200")
root.overrideredirect(True)
mainloop()
Here when I press Window + D the window minimizes like it's supposed to, but if I restore any minimized app or open a new application (like Chrome), the tkinter window gets restored too instead of staying minimized.
Is there any way to fix this problem? It would be great if anyone could help me out.
I'm having a problem with changing the background of this part of the window:
How do I change it?
As I see you are using windows.
This color is set by the theme you are currently using. It is the same for every window.
So I cross out the possibility of only using the Tkinter module for this.
Tkinter is responsible for what is in the window but the window manager decides about the border. For example in Ubuntu the window would look totally different.
I guess, you would need some windows specific calls for that.
You can remove the border with root.overrideredirect(1) if I remember correctly.
PS: put "windows" into the tags of this question.
Here is a little window I made practising tkinter and I know how to change the icon next to the title as I did in code, but I would like some help changing the app icon in my MacOS dock because right now it is the python launcher icon. If anyone could help me that would be great. Also, I know there is nothing in the windows but I don't need that at the moment.
#Import the tkinter module
import tkinter
#Create a window
window = tkinter.Tk()
#Title the window
window.title("Welcome to ECS, we are excited to have you in class")
#Change the window size
window.geometry("400x100")
#Icon next to the title
window.wm_iconbitmap('33mm33.icns')
#Here is where I would like to be able to change the application icon
#Draw the windows and start the application
window.mainloop()
I'm currently working with Tkinter and Python 2.7 on Linux and I was wondering if there was a way to remove the TK() window border frame and title bar without using overrideredirect(1).
I have my own close button and overrideredirect(1) presents me with a few issues that I can't accept:
GUI always on top
can't iconify then deiconify properly
no keyboard input so can't type into fields (see python tkinter overrideredirect; cannot receive keystrokes (Linux))
I can't use attributes("-fullscreen", True) as the titlebar and borders remain.
The window decoration is all handled by the window manager so what you are trying to do is find a way to tell the window manager to decorate your window differently from a standard application window. Tk provides overrideredirect to have the window manager completely ignore this window but we can also use Extended Window Manager Hints to declare the intended use of this toplevel window to the window manager. This is done for instance for tooltip and splashscreen windows to allow the manager to provide minimal decoration and possibly special animations.
In your case, adding a 'splash' hint should do what you want
root = tk.Tk()
root.wm_attributes('-type', 'splash')
You will need Tk 8.5 or above for this.
You must give your root window name before your command.
Like this:
from tkinter import *
root=Tk()
root.wm_attributes('-fullscreen','true')
root.mainloop()