1

I have problem in my Tkinter application.

The code is the following:

def help_stats(self):
    self.help_about = tkinter.Toplevel(relief=tkinter.GROOVE)
    self.help_about.title('Statistika')
    self.help_about.config(width="350", height="300")   
    self.help_about.resizable(width=tkinter.FALSE, height=tkinter.FALSE)
    self.help_about_label = tkinter.Label(self.help_about,
                                          text="Something")
    self.help_about_label.pack(side=tkinter.TOP, expand=1,
                               fill=tkinter.BOTH, padx=20, pady=10)

If I click on something in my menu, this function is called, and a new window is created. I need, from that created window, to delete minimise Button and only leave the closing button. Is that possible?

nbro
  • 15,395
  • 32
  • 113
  • 196
Nefritox
  • 147
  • 1
  • 3
  • 10

1 Answers1

1

use attributes as shown below. It removes both minimize and maximize button. I have tested the code on Windows 8.

self.help_about.attributes("-toolwindow",1)

Modify your code as shown below:

def help_stats(self):
    self.help_about = tkinter.Toplevel(relief=tkinter.GROOVE)
    self.help_about.attributes("-toolwindow",1)
    self.help_about.title('Statistika')
    self.help_about.config(width="350", height="300")   
    self.help_about.resizable(width=tkinter.FALSE, height=tkinter.FALSE)
    self.help_about_label = tkinter.Label(self.help_about, text="Something")
    self.help_about_label.pack(side=tkinter.TOP, expand=1, fill=tkinter.BOTH, padx=20, pady=10)
Vinkal
  • 2,964
  • 1
  • 19
  • 19
  • well i try this too, and it give me error Exception in Tkinter callback Traceback (most recent call last): File "C:\Python34\lib\tkinter\__init__.py", line 1533, in __call__ return self.func(*args) File "C:\Users\Psychotronix\Dropbox\PROJEKT 1.py", line 76, in help_stats self.help_about.attribute("-toolwindow",1) AttributeError: 'function' object has no attribute 'attribute' – Nefritox Mar 01 '15 at 19:17
  • Which OS are you running this code on? It's working for me as expected without any error on Windows 8 – Vinkal Mar 01 '15 at 19:19
  • you have given `attribute`. That's why it's complaining. use `attributes`. copy paste the code from the Answer otherwise – Vinkal Mar 01 '15 at 19:48
  • well i must have problem somewhere else, if i use it in new project it works :) thank you – Nefritox Mar 01 '15 at 19:53
  • 1
    does not work on ubuntu: bad attribute "-toolwindow": must be -alpha, -topmost, -zoomed, -fullscreen, or -type – Murmel Oct 13 '16 at 11:29