Page 1 of 1

Prevent Tkinter window minimize

Posted: Fri Mar 22, 2019 7:44 am
by picandies
Hello, using tkinter on rpi3...I have a window & need to prevent it from being minimized.
Using root.overrideredirect(True) is not an option, since it removes the top bar & all 3 controls (min/max/close)

Even when I set root.resizable(width=FALSE, height=FALSE) , the window size can't be dragged, but the minimize button still reduces it! This needs to be prevented.
How could I get rid of only the minimize button? (preferred)
or, how can I respond to the minimize button event & restore the size?
Or another way of locking the size, so it can never be reduced, by any means?

Re: Prevent Tkinter window minimize

Posted: Fri Mar 22, 2019 12:57 pm
by klricks
Use openbox config

Code: Select all

obconf
Click on [Appearance]
Remove "I" from the Button order:

Re: Prevent Tkinter window minimize

Posted: Fri Mar 22, 2019 2:14 pm
by picandies
Use openbox config
WHAT????!! this is a python program using tkinter...it this a python? or a tkinter command or library

How would you click on something? Your explanation needs redone.

Re: Prevent Tkinter window minimize

Posted: Fri Mar 22, 2019 7:25 pm
by picandies
How do you either:

1) Prevent the minimize button from functioning
2) Remove the only minimize button from the corner of the frame
3) Capture the minimize event & cause it to be undone (effectively ignored)

Re: Prevent Tkinter window minimize

Posted: Fri Mar 22, 2019 8:01 pm
by Andyroo
Assuming root is the main window

Code: Select all

root.resizable(0,0)
should remove the max / min buttons IF the window manager lets you - some things under LINUX are not under control of the program (as in Windows) but in control of the window manager.

You could also try

Code: Select all

root.overrideredirect(1)
to totally remove the top part of the window (may be a bit overkill though)

You may want to look into the overrideredirect() function as well - this gives you more abilities but is more complex.

Re: Prevent Tkinter window minimize

Posted: Fri Mar 22, 2019 11:09 pm
by klricks
picandies wrote:
Fri Mar 22, 2019 2:14 pm
Use openbox config
WHAT????!! this is a python program using tkinter...it this a python? or a tkinter command or library

How would you click on something? Your explanation needs redone.
What I described is a global setting and will remove the minimize [-] from all program app dialogs including tkinter programs.

Re: Prevent Tkinter window minimize

Posted: Fri Mar 22, 2019 11:47 pm
by picandies
Hi andyroo I don't think your suggestions do any of these
1) Prevent the minimize button from functioning
2) Remove the only minimize button from the corner of the frame
3) Capture the minimize event & cause it to be undone (effectively ignored)

Minimize is THE ONLY thing to be affected. The title bar must remain.


What I described is a global setting and will remove the minimize [-] from all program app dialogs including tkinter programs.
Not sure this is so good...things like the file browser will be affected?
Can you post the exact steps? I don't want to scrap my rpi & everything on it.

Re: Prevent Tkinter window minimize

Posted: Sat Mar 23, 2019 12:24 am
by klricks
picandies wrote:
Fri Mar 22, 2019 11:47 pm
...

What I described is a global setting and will remove the minimize [-] from all program app dialogs including tkinter programs.
Not sure this is so good...things like the file browser will be affected?
Can you post the exact steps? I don't want to scrap my rpi & everything on it.
All windows will be instantly affected though it is easy to change it back.
I pretty much already gave step by step...
1. Open a terminal and type obconf then press [Enter]
2. Click on [Appearance] in left side pane.
3. Find under Window Titles..... Button order: [NLIMC]
4. Remove "I" from the Button order: [NLMC]
5. Close obconf and ignore error messages in terminal.

Note that Openbox Config Manager (obconf) can be added to the Preferences in main menu by using main menu editor.

Re: Prevent Tkinter window minimize

Posted: Sat Mar 23, 2019 10:54 pm
by hippy
klricks wrote:
Fri Mar 22, 2019 11:09 pm
What I described is a global setting and will remove the minimize [-] from all program app dialogs including tkinter programs.
I have to side with the OP here; what they want is a way to not have the minimise button appear in one particular program and/or for one particular form or dialogue. Not tweak any global settings which will have an effect on everything else.

I have done it myself, but can't remember how, it was using Python 2.7, and it might have still been there but disabled, or maybe even just did nothing when clicked. I recall it was a little problematic. If no one else can provide the answer I'll see if I can dig out what I did.

Re: Prevent Tkinter window minimize

Posted: Sun Mar 24, 2019 4:44 am
by picandies
I have done it myself, but can't remember how, it was using Python 2.7, and it might have still been there but disabled, or maybe even just did nothing when clicked. I recall it was a little problematic. If no one else can provide the answer I'll see if I can dig out what I did.
I'd sure appreciate it. @hippy ..I've come up dry. This is Python 3.5.3, latest, stretch and tkinter. Maybe using some type of wm_ setting?

Re: Prevent Tkinter window minimize

Posted: Sun Mar 24, 2019 7:04 am
by gkreidl

Re: Prevent Tkinter window minimize

Posted: Sun Mar 24, 2019 3:48 pm
by hippy
picandies wrote:
Sun Mar 24, 2019 4:44 am
I have done it myself, but can't remember how, it was using Python 2.7, and it might have still been there but disabled, or maybe even just did nothing when clicked. I recall it was a little problematic. If no one else can provide the answer I'll see if I can dig out what I did.
I'd sure appreciate it. @hippy ..I've come up dry. This is Python 3.5.3, latest, stretch and tkinter. Maybe using some type of wm_ setting?
It could have been. I looked around but can't find any code for it. And I'm starting to suspect that whatever I would have had would have been for Windows, maybe using Win32.py (or whatever). I recall it was something I did while trying to get System Tray minimising working.

But maybe I am misremembering. I found stuff which removes both minimise and maximise, disables maximise or close, but not removes, disables or traps minimises. And all that code is for Windows.

Having searched on Google I can't find anything to do it either. It might be worth considering Qt, wx, or some other framework than Tkinter.

Re: Prevent Tkinter window minimize

Posted: Mon Mar 25, 2019 10:25 pm
by picandies
How do you capture the minimize event (when you click on _ in the window corner). At least then I can have the callback maximize it.

Is this actually doing an iconify? (not sure what that is), If so, how do you capture that?

Re: Prevent Tkinter window minimize

Posted: Tue Mar 26, 2019 8:50 am
by gkreidl
picandies wrote:
Mon Mar 25, 2019 10:25 pm
How do you capture the minimize event (when you click on _ in the window corner). At least then I can have the callback maximize it.

Is this actually doing an iconify? (not sure what that is), If so, how do you capture that?
root.bind("<Unmap>"....

https://stackoverflow.com/questions/383 ... in-tkinter
https://www.tcl.tk/man/tcl8.4/TkCmd/bind.htm#M13

Re: Prevent Tkinter window minimize

Posted: Tue Mar 26, 2019 9:47 am
by hippy
gkreidl wrote:
Tue Mar 26, 2019 8:50 am
root.bind("<Unmap>"....
Not perfect, but this bounces the "tool window" back to how it was whenever it is minimised -

Code: Select all

import Tkinter as tk

class App:
  def __init__(self):
    self.root = tk.Tk()
    tk.Label(self.root, text="main window").pack()
    self.t = tk.Toplevel()
    tk.Label(self.t, text="tool window").pack()
    self.t.bind("<Unmap>", self.OnUnmap)
    self.root.mainloop()

  def OnUnmap(self, event):
    self.t.wm_deiconify()

app = App()

Re: Prevent Tkinter window minimize

Posted: Tue Mar 26, 2019 8:53 pm
by picandies
Thanks for the good info (never heard of "unmap") & also the sample code---about to go give it a try!