tkinter: Can't "lower" a widget

Post here if you need help with creating a Graphical User Interface in Python.

tkinter: Can't "lower" a widget

Postby rovf » Fri Jan 31, 2014 10:18 am

I try to use the lower() method to make a button invisible (it should still take up it's space), but I always get the error message "can't lower widget .... below". I have seen this problem discussed already in various forums, and I tried to apply the solution, which is usually provided as a response, but it still doesn't work for me, so maybe I misunderstood something. Here is the relevant part of the code:

Code: Select all
....
        self.widget=Frame(_parent) # _parent is the Tk() object in my case
        self.control=Frame(self.widget)
        self.hscrollbar=Scrollbar(self.control,orient=HORIZONTAL,command=self.scrollHandler)
        self.textarea=Entry(self.widget, textvariable=self.text_v, state="readonly", width=_settings.showarea_width())
        self.textarea.pack()
        self.buttons=Frame(self.control)
        self.button_edit_challenge=Button(self.buttons,text='.....',state=DISABLED,command=self.edit_challenge)
        self.button_edit_challenge.pack(in_=self.buttons,side=LEFT)
        self.button_cancel_edit=Button(self.buttons,text='Cancel',state=DISABLED,command=self.cancel_edit)
        self.button_cancel_edit.pack(in_=self.buttons,side=LEFT) # THIS IS THE BUTTON WHICH SHOULD BE HIDDEN INITIALLY
        self.buttons.pack(side=RIGHT)
        self.hscrollbar.pack(side=LEFT,fill="x",expand=True)
        self.control.pack(fill="both",expand=True)
        self.button_cancel_edit.lower(self.buttons) # THIS GIVES ERROR MESSAGE


The error message is: _tkinter.TclError: can't lower ".3386704.3386904.3387224.454864" below ".3386704.3386904.3387224"

How do I have to do it correctly, and what mistake did I do?

Note: From what I read, I have learned that we can not lower a widget below its parent, but we can bypass this restriction by using the '_in' parameter of the packer (or grid manager). My guess is that I didn't use this parameter properly.
rovf
 
Posts: 25
Joined: Fri Aug 16, 2013 4:35 pm

Re: tkinter: Can't "lower" a widget

Postby wuf » Fri Jan 31, 2014 11:23 am

Hi rovf

Try this:
Code: Select all
from tkinter import *

class MyApp(object):
    def __init__(self, _parent):
       
        self.text_v = StringVar()
        self.widget=Frame(_parent) # _parent is the Tk() object in my case
        self.widget.pack(padx=5, pady=5) # !! Was missing in your script !!
        self.control=Frame(self.widget)
        self.hscrollbar=Scrollbar(self.control,orient=HORIZONTAL,command=self.scrollHandler)
        #self.textarea=Entry(self.widget, textvariable=self.text_v, state="readonly", width=_settings.showarea_width())
        self.textarea=Entry(self.widget, textvariable=self.text_v, state="readonly", width=40)
        self.textarea.pack()
        self.buttons=Frame(self.control)
        self.button_edit_challenge=Button(self.buttons,text='.....',state=DISABLED,command=self.edit_challenge)
        self.button_edit_challenge.pack(in_=self.buttons,side=LEFT)
        self.button_cancel_edit=Button(self.buttons,text='Cancel',state=DISABLED,command=self.cancel_edit)
        self.button_cancel_edit.pack(in_=self.buttons,side=LEFT) # THIS IS THE BUTTON WHICH SHOULD BE HIDDEN INITIALLY
        self.buttons.pack(side=RIGHT)
        self.hscrollbar.pack(side=LEFT,fill="x",expand=True)
        self.control.pack(fill="both",expand=True)
       
        #self.button_cancel_edit.lower(self.buttons) # THIS GIVES ERROR MESSAGE
        self.button_cancel_edit.pack_forget() # !! This is the replacement of the above line!!
       
        #self.button_cancel_edit.pack() # !! uncomment this line to make the Cnacel-Button visible again !!
           
    def scrollHandler(self, *args):
        pass
       
    def edit_challenge(self):
        pass
       
    def cancel_edit(self):
        pass

if __name__=='__main__':
    def toggle_button_visibilty():
        if test_button['text'] == 'Show':
            my_app.button_cancel_edit.pack()
            test_button['text'] = 'Hide'
        else:
            my_app.button_cancel_edit.pack_forget()
            test_button['text'] = 'Show'
               
    app_win = Tk()
    app_win.geometry('+{0}+{1}'.format(10, 10))
    my_app = MyApp(app_win)
    test_button = Button(app_win, text= 'Show',
        command=toggle_button_visibilty)
    test_button.pack(pady=2)
    app_win.mainloop()

wuf ;)
wuf
 
Posts: 38
Joined: Fri Feb 08, 2013 6:42 am

Re: tkinter: Can't "lower" a widget

Postby rovf » Fri Jan 31, 2014 11:39 am

Thank you for providing your suggestion. I will try it, but a few questions:

(1) I already received in the past the suggestion to inherit my class from 'object'. Is this just good style (so that the methods applying to all objects, can also be uniformly applied to my class as well), or does this have additional importance for my case?

(2) Why is it important to use padx/pady, when packing self.widget, and how do you arrive at especially those magical value of 5? I thought this would only effect the way it looks (i.e. giving kind of an internal border), so it's more a question of aesthetics, whether we want padding. Since you write "was missing", I assume that this padding is necessary here. Could you explain why?

(3) I have read about pack_forget(), but my understanding was, that with this method, the widget simply disappears and the other (sibling-) widgets will take up its space. This was described here: http://stackoverflow.com/questions/3819 ... ot-visible
In this thread, it was suggested that, if we want the space occupied by the disappearing widget, still be reserved, we have to use the lower() method in it. Is there a possibility to use lower() for my problem? Or did I simply misunderstand the explanations in that posting at stackoverflow?

(4) In another forum, I found the suggestion to make the button foreground the same colour than the button background. Since I disable the button anyway during the time it is hidden, this seems to be a possible approach too, but it feels a bit like a hack to me. What do you think about this solution?

Thank you for your patience.
rovf
 
Posts: 25
Joined: Fri Aug 16, 2013 4:35 pm

Re: tkinter: Can't "lower" a widget

Postby wuf » Fri Jan 31, 2014 12:43 pm

Hi rovf

I will answer questions step by step. OK!.
rovf wrote:(2) Why is it important to use padx/pady, when packing self.widget, and how do you arrive at especially those magical value of 5? I thought this would only effect the way it looks (i.e. giving kind of an internal border), so it's more a question of aesthetics, whether we want padding. Since you write "was missing", I assume that this padding is necessary here. Could you explain why?

a) The padx and pady is not of importance it's really just aesthetics.
b) The 5 is not a magical value you can choose any positive integer value.
c) Why packing the 'widget'. Try out my following script which is omitting the packing of 'widget':
Code: Select all
from tkinter import *

class MyApp(object):
    def __init__(self, _parent):
       
        self.text_v = StringVar()
        self.widget=Frame(_parent) # _parent is the Tk() object in my case
        #self.widget.pack(padx=5, pady=5) # !! Was missing in your script !!
        self.control=Frame(self.widget)
        self.hscrollbar=Scrollbar(self.control,orient=HORIZONTAL,command=self.scrollHandler)
        self.textarea=Entry(self.widget, textvariable=self.text_v, state="readonly", width=40)
        self.textarea.pack()
        self.buttons=Frame(self.control)
        self.button_edit_challenge=Button(self.buttons,text='.....',state=DISABLED,command=self.edit_challenge)
        self.button_edit_challenge.pack(in_=self.buttons,side=LEFT)
        self.button_cancel_edit=Button(self.buttons,text='Cancel',state=DISABLED,command=self.cancel_edit)
        self.button_cancel_edit.pack(in_=self.buttons,side=LEFT) # THIS IS THE BUTTON WHICH SHOULD BE HIDDEN INITIALLY
        self.buttons.pack(side=RIGHT)
        self.hscrollbar.pack(side=LEFT,fill="x",expand=True)
        self.control.pack(fill="both",expand=True)
       
        #self.button_cancel_edit.lower(self.buttons) # THIS GIVES ERROR MESSAGE
        self.button_cancel_edit.pack_forget() # !! This is the replacement of the above line!!
       
        #self.button_cancel_edit.pack() # !! uncomment this line to make the Cancel-Button visible again !!
           
    def scrollHandler(self, *args):
        pass
       
    def edit_challenge(self):
        pass
       
    def cancel_edit(self):
        pass

if __name__=='__main__':
    def toggle_button_visibilty():
        if test_button['text'] == 'Show':
            my_app.button_cancel_edit.pack()
            test_button['text'] = 'Hide'
        else:
            my_app.button_cancel_edit.pack_forget()
            test_button['text'] = 'Show'
               
    app_win = Tk()
    app_win.geometry('+{0}+{1}'.format(10, 10))
    my_app = MyApp(app_win)
    test_button = Button(app_win, text= 'Show',
        command=toggle_button_visibilty)
    test_button.pack(pady=2)
    app_win.mainloop()

A wish and tip from me when you next time show a script in this Forum show it as executable test skript. When you look at my script you can see your self how much additional effort was necessary to test it. Thanks.

wuf ;)
wuf
 
Posts: 38
Joined: Fri Feb 08, 2013 6:42 am

Re: tkinter: Can't "lower" a widget

Postby rovf » Fri Jan 31, 2014 1:08 pm

A wish and tip from me when you next time show a script in this Forum show it as executable test skript.


I tried to avoid posting code which I believed to be not necessary for that example (actually, I thought I just made a simple mistake in my usage of lower()), and copied only that part from my application which I considered relevant. But you are right, especially in this case the minimum running example would have been much more useful, and not much longer than what I had posted.
rovf
 
Posts: 25
Joined: Fri Aug 16, 2013 4:35 pm

Re: tkinter: Can't "lower" a widget

Postby wuf » Fri Jan 31, 2014 7:44 pm

(1) I already received in the past the suggestion to inherit my class from 'object'. Is this just good style (so that the methods applying to all objects, can also be uniformly applied to my class as well), or does this have additional importance for my case?

Code: Select all
class MyClass:
class MyClass():

I would always replace by:
Code: Select all
class MyClass(object):
because the class does inherit information from new style classes.

Of course when you inherit a Tkinter class for instance:
Code: Select all
class MyGui(Tkinter.Frame):
you don't have to add the name 'object'.

(3) I have read about pack_forget(), but my understanding was, that with this method, the widget simply disappears and the other (sibling-) widgets will take up its space. This was described here: http://stackoverflow.com/questions/3819 ... ot-visible
In this thread, it was suggested that, if we want the space occupied by the disappearing widget, still be reserved, we have to use the lower() method in it. Is there a possibility to use lower() for my problem? Or did I simply misunderstand the explanations in that posting at stackoverflow?

a) You are right the pack_forget() method doesn't work corecctly. Instead use grid_remove.
b) The 'lower'- or 'lift'-methods do not work with widgeds which are embedded in a master widget because they can't be lower below or lift above the master. But the lower- lift.methods are working with widgets within a master when they have the same master reference.
With the following scripts you can all posibilities.

Test script lower and lift:
Code: Select all
#!/usr/bin/env python
# coding: UTF-8

# Tests with 'lower' and 'lift'

try:
    #~~ For Python 2.x
    import Tkinter as tk
except ImportError:
    #~~ For Python 3.x
    import tkinter as tk

TEST_WIN_XPOS = 100
TEST_WIN_YPOS = 100
TEST_WIN_WIDTH = 500
TEST_WIN_HEIGHT = 500
TEST_WIN_TITLE = 'Lower and lift test'
TEST_BACK_GND = 'palegoldenrod'

MSG_01 = 'Lower frame'
MSG_02 = 'Lift frame'
MSG_03 = 'Lower button'
MSG_04 = 'Lift button'

class Test(object):
   
    def __init__(self, title="Test-Module"):
       
        self.win = tk.Tk()
        self.win.title("Lower and lift test")
        self.win.geometry('{0}x{1}+{2}+{3}'.format(
            TEST_WIN_WIDTH, TEST_WIN_HEIGHT, TEST_WIN_XPOS,
            TEST_WIN_YPOS))
        self.win.protocol("WM_DELETE_WINDOW", self.close)
        self.win.config(bg=TEST_BACK_GND)
       
        #---TEST-CODE BEGIN---------------------------------------------
        self.button_level = tk.StringVar()
        self.frame_level = tk.StringVar()
       
        self.main_frame = tk.Frame(self.win, highlightthickness=0,
            bg='steelblue')
        self.main_frame.place(x=20, y=20, width=300, height=300)
       
        self.label_main_frame = tk.Label(self.main_frame, text='main_frame',
            bg=self.main_frame['bg'], fg='white')
        self.label_main_frame.pack(anchor='nw')
       
        self.frame = tk.Frame(self.win, bg='green')
        self.frame.place(x=200, y=200, width=200, height=200)

        self.label_frame = tk.Label(self.frame, text='frame',
            bg=self.frame['bg'])
        self.label_frame.pack(anchor='nw')
       
        self.button = tk.Button(self.win, text='button',
            highlightthickness=0)
        self.button.place(x=80, y=80)
       
        self.button_frame = tk.Frame(self.win)
        self.button_frame.pack(side='bottom')
       
        tk.Button(self.button_frame,
            textvariable=self.frame_level, width=12,
            command=self.change_frame_level).pack(
            side='left')

        tk.Button(self.button_frame,
            textvariable=self.button_level, width=12,
            command=self.change_button_level).pack(
            side='left')
           
        self.frame_level.set(MSG_01)
        self.button_level.set(MSG_03)

    def change_frame_level(self):
        # Lower the 'frame' below or lift it above the
        # 'main_frame'
        message = self.frame_level.get()
        if message == MSG_01:
            self.frame.lower(self.main_frame)
            self.frame_level.set(MSG_02)
           
        if message == MSG_02:
            self.frame.lift(self.main_frame)
            self.frame_level.set(MSG_01)
   
    def change_button_level(self):
        # Lower the 'show_button' below or lift it above the
        # 'main_frame'
        message = self.button_level.get()
        if message == MSG_03:
            self.button.lower(self.main_frame)
            self.button_level.set(MSG_04)
           
        if message == MSG_04:
            self.button.lift(self.main_frame)
            self.button_level.set(MSG_03)
        #---TEST-CODE END-----------------------------------------------
       
    def close(self):
        # Add here things which have to be done before shutdown
        self.win.destroy()
        print ("Shut down application")

    def run(self):
        self.win.mainloop()
       
Test(TEST_WIN_TITLE).run()

Test script for pack_forget (Here you can see the problems):
Code: Select all
#!/usr/bin/env python
# coding: UTF-8

from functools import partial
try:
    #~~ For Python 2.x
    import Tkinter as tk
except ImportError:
    #~~ For Python 3.x
    import tkinter as tk

TEST_WIN_XPOS = 100
TEST_WIN_YPOS = 100
TEST_WIN_WIDTH = 400
TEST_WIN_HEIGHT = 200
TEST_TITLE = "Pack widget hide/show-test"

MSG_01 = 'Hide Button-2'
MSG_02 = 'Show Button-2'
MSG_03 = 'Add Button-4'
MSG_04 = 'Remove Button-4'

class Test(object):

    def __init__(self, title="Test-Module"):
       
        self.win = tk.Tk()
        self.win.title(title)
        self.win.geometry('{0}x{1}+{2}+{3}'.format(
            TEST_WIN_WIDTH, TEST_WIN_HEIGHT, TEST_WIN_XPOS,
            TEST_WIN_YPOS))
        self.win.protocol("WM_DELETE_WINDOW", self.close)
        self.win.option_add("*HighlightThickness", 0)
       
    #---TEST-CODE BEGIN-------------------------------------------------
        self.main_frame = tk.Frame(self.win, bg='steelblue')
        self.main_frame.pack(fill='both', expand=True)
       
        self.buttons_frame = tk.Frame(self.main_frame)
        self.buttons_frame.pack(expand=True)
       
        self.button_01 = tk.Button(self.buttons_frame, text='Button-1')
        self.button_01.pack(side='left')

        self.button_02 = tk.Button(self.buttons_frame, text='Button-2')
        self.button_02.pack(side='left')

        self.button_03 = tk.Button(self.buttons_frame, text='Button-3')
        self.button_03.pack(side='left')
       
        self.control_buttons_frame = tk.Frame(self.main_frame)
        self.control_buttons_frame.pack(side='bottom', fill='x')
       
        self.ctr_var_01 = tk.StringVar()
        tk.Button(self.control_buttons_frame, width=17,
            textvariable=self.ctr_var_01, command=partial(
            self.hide_show_button, self.button_02, self.ctr_var_01)
                ).pack(side='left', expand=True)
        self.ctr_var_01.set(MSG_01)

        self.ctr_var_02 = tk.StringVar()
        tk.Button(self.control_buttons_frame, width=17,
            textvariable=self.ctr_var_02, command=partial(
            self.add_remove_button, self.ctr_var_02)).pack(
                side='left', expand=True)
        self.ctr_var_02.set(MSG_03)
   
    def hide_show_button(self, button, var):
        message = var.get()
        if message == MSG_01:
            self.pack_infos = button.pack_info()
            button.pack_forget()
            var.set(MSG_02)
           
        if message == MSG_02:
            button.pack_configure(self.pack_infos)
            self.ctr_var_01.set(MSG_01)
       
    def add_remove_button(self, var):
        message = var.get()
        if message == MSG_03:
            self.button_04 = tk.Button(self.buttons_frame,
                text='Button-4')
            self.button_04.pack(side='left')
            var.set(MSG_04)
           
        if message == MSG_04:
            self.button_04.destroy()
            var.set(MSG_03)
       
    #---TEST-CODE END---------------------------------------------------
       
    def close(self):
        # Add here things which have to be done before shutdown
        self.win.destroy()
        print ("Shut down application")

    def run(self):
        self.win.mainloop()
       
Test(TEST_TITLE).run()

Test script for grid_remove:
Code: Select all
#!/usr/bin/env python
# coding: UTF-8


from functools import partial
try:
    #~~ For Python 2.x
    import Tkinter as tk
except ImportError:
    #~~ For Python 3.x
    import tkinter as tk

TEST_WIN_XPOS = 100
TEST_WIN_YPOS = 100
TEST_WIN_WIDTH = 400
TEST_WIN_HEIGHT = 200
TEST_TITLE = "Grid widget hide/show-test"

MSG_01 = 'Hide Button-2'
MSG_02 = 'Show Button-2'
MSG_03 = 'Add Button-4'
MSG_04 = 'Destroy Button-4'

class Test(object):

    def __init__(self, title="Test-Module"):
       
        self.win = tk.Tk()
        self.win.title(title)
        self.win.geometry('{0}x{1}+{2}+{3}'.format(
            TEST_WIN_WIDTH, TEST_WIN_HEIGHT, TEST_WIN_XPOS,
            TEST_WIN_YPOS))
        self.win.protocol("WM_DELETE_WINDOW", self.close)
        self.win.option_add("*HighlightThickness", 0)
       
    #---TEST-CODE BEGIN-------------------------------------------------
        self.main_frame = tk.Frame(self.win, bg='steelblue')
        self.main_frame.pack(fill='both', expand=True)
       
        self.buttons_frame = tk.Frame(self.main_frame)
        self.buttons_frame.pack(expand=True)
       
        self.button_01 = tk.Button(self.buttons_frame, text='Button-1')
        self.button_01.grid(row=0, column=0)

        self.button_02 = tk.Button(self.buttons_frame, text='Button-2')
        self.button_02.grid(row=0, column=1)

        self.button_03 = tk.Button(self.buttons_frame, text='Button-3')
        self.button_03.grid(row=0, column=2)
       
        self.control_buttons_frame = tk.Frame(self.main_frame)
        self.control_buttons_frame.pack(side='bottom', fill='x')
       
        self.ctr_var_01 = tk.StringVar()
        tk.Button(self.control_buttons_frame, width=17,
            textvariable=self.ctr_var_01, command=partial(
            self.hide_show_button, self.button_02, self.ctr_var_01)
                ).pack(side='left', expand=True)
        self.ctr_var_01.set(MSG_01)

        self.ctr_var_02 = tk.StringVar()
        tk.Button(self.control_buttons_frame, width=17,
            textvariable=self.ctr_var_02, command=partial(
            self.add_remove_button, self.ctr_var_02)).pack(
                side='left', expand=True)
        self.ctr_var_02.set(MSG_03)
   
    def hide_show_button(self, button, var):
        message = var.get()
        if message == MSG_01:
            button.grid_remove()
            var.set(MSG_02)
           
        if message == MSG_02:
            button.grid()
            var.set(MSG_01)
       
    def add_remove_button(self, var):
        message = var.get()
        if message == MSG_03:
            self.button_04 = tk.Button(self.buttons_frame,
                text='Button-4')
            self.button_04.grid(row=0, column=3)
            var.set(MSG_04)
           
        if message == MSG_04:
            self.button_04.destroy()
            var.set(MSG_03)
       
    #---TEST-CODE END---------------------------------------------------
       
    def close(self):
        # Add here things which have to be done before shutdown
        self.win.destroy()
        print ("Shut down application")

    def run(self):
        self.win.mainloop()
       
Test(TEST_TITLE).run()


(4) In another forum, I found the suggestion to make the button foreground the same colour than the button background. Since I disable the button anyway during the time it is hidden, this seems to be a possible approach too, but it feels a bit like a hack to me. What do you think about this solution?

Hide with button background color and disabled:
Code: Select all
#!/usr/bin/env python
# coding: UTF-8


from functools import partial
try:
    #~~ For Python 2.x
    import Tkinter as tk
except ImportError:
    #~~ For Python 3.x
    import tkinter as tk

TEST_WIN_XPOS = 100
TEST_WIN_YPOS = 100
TEST_WIN_WIDTH = 400
TEST_WIN_HEIGHT = 200
TEST_TITLE = "Hide button with background color"

MSG_01 = 'Hide Button-2'
MSG_02 = 'Show Button-2'
MSG_03 = 'Add Button-4'
MSG_04 = 'Destroy Button-4'

class Test(object):

    def __init__(self, title="Test-Module"):
       
        self.win = tk.Tk()
        self.win.title(title)
        self.win.geometry('{0}x{1}+{2}+{3}'.format(
            TEST_WIN_WIDTH, TEST_WIN_HEIGHT, TEST_WIN_XPOS,
            TEST_WIN_YPOS))
        self.win.protocol("WM_DELETE_WINDOW", self.close)
        self.win.option_add("*HighlightThickness", 0)
       
    #---TEST-CODE BEGIN-------------------------------------------------
        self.main_frame = tk.Frame(self.win, bg='steelblue')
        self.main_frame.pack(fill='both', expand=True)
       
        self.buttons_frame = tk.Frame(self.main_frame)
        self.buttons_frame.pack(expand=True)
       
        self.button_01 = tk.Button(self.buttons_frame, text='Button-1')
        self.button_01.grid(row=0, column=0)

        self.button_02 = tk.Button(self.buttons_frame, text='Button-2')
        self.button_02.grid(row=0, column=1)

        self.button_03 = tk.Button(self.buttons_frame, text='Button-3')
        self.button_03.grid(row=0, column=2)
       
        self.control_buttons_frame = tk.Frame(self.main_frame)
        self.control_buttons_frame.pack(side='bottom', fill='x')
       
        self.ctr_var_01 = tk.StringVar()
        tk.Button(self.control_buttons_frame, width=17,
            textvariable=self.ctr_var_01, command=partial(
            self.hide_show_button, self.button_02, self.ctr_var_01)
                ).pack(side='left', expand=True)
        self.ctr_var_01.set(MSG_01)

        self.ctr_var_02 = tk.StringVar()
        tk.Button(self.control_buttons_frame, width=17,
            textvariable=self.ctr_var_02, command=partial(
            self.add_remove_button, self.ctr_var_02)).pack(
                side='left', expand=True)
        self.ctr_var_02.set(MSG_03)
   
    def hide_show_button(self, button, var):
        message = var.get()
        if message == MSG_01:
            bg = button['bg']
            disabled_fg = button['disabledforeground']
            button.disabled_fg = disabled_fg
            button.config(state='disabled', disabledforeground=bg)
           
            var.set(MSG_02)
           
        if message == MSG_02:
            disabled_fg = button.disabled_fg
            button.config(state='normal',
                disabledforeground=disabled_fg)
            var.set(MSG_01)
       
    def add_remove_button(self, var):
        message = var.get()
        if message == MSG_03:
            self.button_04 = tk.Button(self.buttons_frame,
                text='Button-4')
            self.button_04.grid(row=0, column=3)
            var.set(MSG_04)
           
        if message == MSG_04:
            self.button_04.destroy()
            var.set(MSG_03)
       
    #---TEST-CODE END---------------------------------------------------
       
    def close(self):
        # Add here things which have to be done before shutdown
        self.win.destroy()
        print ("Shut down application")

    def run(self):
        self.win.mainloop()
       
Test(TEST_TITLE).run()
Of course with this solution the button space doesn't disappear. Here you have to decide personally what you like.

wuf ;)
Last edited by Yoriz on Fri Jan 31, 2014 11:24 pm, edited 1 time in total.
Reason: Merged posts
wuf
 
Posts: 38
Joined: Fri Feb 08, 2013 6:42 am

Re: tkinter: Can't "lower" a widget

Postby rovf » Sat Feb 01, 2014 7:30 am

You are right the pack_forget() method doesn't work corecctly. Instead use grid_remove.


... which means that I would have to refactor my code to use the grid manager instead of the packer. I see.

Of course with this solution the button space doesn't disappear.


.... which is exactly what I want to achieve, so maybe this solution isn't that much a hack after all.

Thanks a lot for taking so much time to provide such a plethora of solutions!
rovf
 
Posts: 25
Joined: Fri Aug 16, 2013 4:35 pm


Return to GUI

Who is online

Users browsing this forum: Google Feedfetcher and 1 guest