tkinter listboxes with resizable columns - recursion fatal error









up vote
0
down vote

favorite












I'm using the .place method. The following code is a working simplification of resizable columns and the error message which occurs while mouse-moving the columns after a short time.



import tkinter as tk


def column_drag(event):
#print(event.x)
for ii, i in enumerate(column_head):
if ii != 0:
currCur = root.winfo_pointerx() - root.winfo_rootx()
if currCur <= column_head[ii].winfo_x() + 10 and currCur >= column_head[ii].winfo_x() - 10:
if currCur <= column_head[ii].winfo_x() + 10 and currCur >= column_head[ii].winfo_x() - 10:
column_head[ii].configure(cursor="sb_h_double_arrow")
column_posx[ii] = currCur
column_user[ii] = True
refresh_run_display()
else: column_head[ii].configure(cursor="arrow")

def resize(event):
refresh_run_display()


def refresh_run_display():
ii = len(column_body)-1
for i in reversed(column_body):
# Last column
if ii+1 == len(column_body):
if column_user[ii] is False:
column_head[ii].place(x=ii * 150, y=0, height=20, width=root.winfo_width())
column_head[ii].update()
column_body[ii].place(x=ii * 150, y=column_head[ii].winfo_height(), height=120, width=root.winfo_width())
if column_user[ii] is True:
column_head[ii].place(x=column_posx[ii], y=0, height=20, width=root.winfo_width())
column_head[ii].update()
column_body[ii].place(x=column_posx[ii], y=column_head[ii].winfo_height(), height=120, width=root.winfo_width())
#middle column
if ii+1 != len(column_body) and ii != 0:
if column_user[ii] is False:
column_head[ii].place(x=ii * 150, y=0, height=20, width=column_head[ii+1].winfo_x())
column_head[ii].update()
column_body[ii].place(x=ii * 150, y=column_head[ii].winfo_height(), height=120, width=column_head[ii+1].winfo_x())
if column_user[ii] is True:
column_head[ii].place(x=column_posx[ii], y=0, height=20, width=column_head[ii+1].winfo_x())
column_head[ii].update()
column_body[ii].place(x=column_posx[ii], y=column_head[ii].winfo_height(), height=120, width=column_head[ii+1].winfo_x())
#first column
if ii == 0:
if column_user[ii] is False:
column_head[ii].place(x=1, y=0, height=20, width=column_head[ii+1].winfo_x())
column_head[ii].update()
column_body[ii].place(x=1, y=column_head[ii].winfo_height(), height=120, width=column_head[ii+1].winfo_x())
if column_user[ii] is True:
column_head[ii].place(x=1, y=0, height=20, width=column_head[ii+1].winfo_x())
column_head[ii].update()
column_body[ii].place(x=1, y=column_head[ii].winfo_height(), height=120, width=column_head[ii+1].winfo_x())
ii = ii - 1



root = tk.Tk()
gui_w = 650
gui_h = 270
gui_h_old = 0
x = (root.winfo_screenwidth()/2) - (gui_w/2)
y = (root.winfo_screenheight()/2) - (gui_h/2)
root.geometry('%dx%d+%d+%d' % (gui_w, gui_h, x, y))
root.bind('<Configure>', resize)
root.minsize(width=350, height=315)
root.maxsize(width=root.winfo_screenwidth(), height=root.winfo_screenheight())


column_names = ['id', 'name', 'size', 'time']
column_body = [tk.Listbox(borderwidth=0, highlightthickness=0, exportselection=0, activestyle='none') for i in column_names]
column_head = [tk.Button(text=i, borderwidth=0.5, relief="ridge", anchor="w") for i in column_names]
[i.bind("<Motion>", column_drag) for i in column_head]

column_lead = [False for i in column_names]; column_lead[0] = True
column_flip = [False for i in column_names]
column_user = [False for i in column_names]
column_posx = [0 for i in column_names]

root.mainloop()


Error message:



Fatal Python error: Cannot recover from stack overflow.

Current thread 0x00001440 (most recent call first):
File "C:python37libtkinter__init__.py", line 1704 in __call__
File "C:python37libtkinter__init__.py", line 1177 in update
File "path.../tst.py", line 42 in refresh_run_display
File "path.../tst.py", line 14 in column_drag
Process finished with exit code -1073740791 (0xC0000409)


I'd like to keep the current format if possible. Please help!










share|improve this question

























    up vote
    0
    down vote

    favorite












    I'm using the .place method. The following code is a working simplification of resizable columns and the error message which occurs while mouse-moving the columns after a short time.



    import tkinter as tk


    def column_drag(event):
    #print(event.x)
    for ii, i in enumerate(column_head):
    if ii != 0:
    currCur = root.winfo_pointerx() - root.winfo_rootx()
    if currCur <= column_head[ii].winfo_x() + 10 and currCur >= column_head[ii].winfo_x() - 10:
    if currCur <= column_head[ii].winfo_x() + 10 and currCur >= column_head[ii].winfo_x() - 10:
    column_head[ii].configure(cursor="sb_h_double_arrow")
    column_posx[ii] = currCur
    column_user[ii] = True
    refresh_run_display()
    else: column_head[ii].configure(cursor="arrow")

    def resize(event):
    refresh_run_display()


    def refresh_run_display():
    ii = len(column_body)-1
    for i in reversed(column_body):
    # Last column
    if ii+1 == len(column_body):
    if column_user[ii] is False:
    column_head[ii].place(x=ii * 150, y=0, height=20, width=root.winfo_width())
    column_head[ii].update()
    column_body[ii].place(x=ii * 150, y=column_head[ii].winfo_height(), height=120, width=root.winfo_width())
    if column_user[ii] is True:
    column_head[ii].place(x=column_posx[ii], y=0, height=20, width=root.winfo_width())
    column_head[ii].update()
    column_body[ii].place(x=column_posx[ii], y=column_head[ii].winfo_height(), height=120, width=root.winfo_width())
    #middle column
    if ii+1 != len(column_body) and ii != 0:
    if column_user[ii] is False:
    column_head[ii].place(x=ii * 150, y=0, height=20, width=column_head[ii+1].winfo_x())
    column_head[ii].update()
    column_body[ii].place(x=ii * 150, y=column_head[ii].winfo_height(), height=120, width=column_head[ii+1].winfo_x())
    if column_user[ii] is True:
    column_head[ii].place(x=column_posx[ii], y=0, height=20, width=column_head[ii+1].winfo_x())
    column_head[ii].update()
    column_body[ii].place(x=column_posx[ii], y=column_head[ii].winfo_height(), height=120, width=column_head[ii+1].winfo_x())
    #first column
    if ii == 0:
    if column_user[ii] is False:
    column_head[ii].place(x=1, y=0, height=20, width=column_head[ii+1].winfo_x())
    column_head[ii].update()
    column_body[ii].place(x=1, y=column_head[ii].winfo_height(), height=120, width=column_head[ii+1].winfo_x())
    if column_user[ii] is True:
    column_head[ii].place(x=1, y=0, height=20, width=column_head[ii+1].winfo_x())
    column_head[ii].update()
    column_body[ii].place(x=1, y=column_head[ii].winfo_height(), height=120, width=column_head[ii+1].winfo_x())
    ii = ii - 1



    root = tk.Tk()
    gui_w = 650
    gui_h = 270
    gui_h_old = 0
    x = (root.winfo_screenwidth()/2) - (gui_w/2)
    y = (root.winfo_screenheight()/2) - (gui_h/2)
    root.geometry('%dx%d+%d+%d' % (gui_w, gui_h, x, y))
    root.bind('<Configure>', resize)
    root.minsize(width=350, height=315)
    root.maxsize(width=root.winfo_screenwidth(), height=root.winfo_screenheight())


    column_names = ['id', 'name', 'size', 'time']
    column_body = [tk.Listbox(borderwidth=0, highlightthickness=0, exportselection=0, activestyle='none') for i in column_names]
    column_head = [tk.Button(text=i, borderwidth=0.5, relief="ridge", anchor="w") for i in column_names]
    [i.bind("<Motion>", column_drag) for i in column_head]

    column_lead = [False for i in column_names]; column_lead[0] = True
    column_flip = [False for i in column_names]
    column_user = [False for i in column_names]
    column_posx = [0 for i in column_names]

    root.mainloop()


    Error message:



    Fatal Python error: Cannot recover from stack overflow.

    Current thread 0x00001440 (most recent call first):
    File "C:python37libtkinter__init__.py", line 1704 in __call__
    File "C:python37libtkinter__init__.py", line 1177 in update
    File "path.../tst.py", line 42 in refresh_run_display
    File "path.../tst.py", line 14 in column_drag
    Process finished with exit code -1073740791 (0xC0000409)


    I'd like to keep the current format if possible. Please help!










    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I'm using the .place method. The following code is a working simplification of resizable columns and the error message which occurs while mouse-moving the columns after a short time.



      import tkinter as tk


      def column_drag(event):
      #print(event.x)
      for ii, i in enumerate(column_head):
      if ii != 0:
      currCur = root.winfo_pointerx() - root.winfo_rootx()
      if currCur <= column_head[ii].winfo_x() + 10 and currCur >= column_head[ii].winfo_x() - 10:
      if currCur <= column_head[ii].winfo_x() + 10 and currCur >= column_head[ii].winfo_x() - 10:
      column_head[ii].configure(cursor="sb_h_double_arrow")
      column_posx[ii] = currCur
      column_user[ii] = True
      refresh_run_display()
      else: column_head[ii].configure(cursor="arrow")

      def resize(event):
      refresh_run_display()


      def refresh_run_display():
      ii = len(column_body)-1
      for i in reversed(column_body):
      # Last column
      if ii+1 == len(column_body):
      if column_user[ii] is False:
      column_head[ii].place(x=ii * 150, y=0, height=20, width=root.winfo_width())
      column_head[ii].update()
      column_body[ii].place(x=ii * 150, y=column_head[ii].winfo_height(), height=120, width=root.winfo_width())
      if column_user[ii] is True:
      column_head[ii].place(x=column_posx[ii], y=0, height=20, width=root.winfo_width())
      column_head[ii].update()
      column_body[ii].place(x=column_posx[ii], y=column_head[ii].winfo_height(), height=120, width=root.winfo_width())
      #middle column
      if ii+1 != len(column_body) and ii != 0:
      if column_user[ii] is False:
      column_head[ii].place(x=ii * 150, y=0, height=20, width=column_head[ii+1].winfo_x())
      column_head[ii].update()
      column_body[ii].place(x=ii * 150, y=column_head[ii].winfo_height(), height=120, width=column_head[ii+1].winfo_x())
      if column_user[ii] is True:
      column_head[ii].place(x=column_posx[ii], y=0, height=20, width=column_head[ii+1].winfo_x())
      column_head[ii].update()
      column_body[ii].place(x=column_posx[ii], y=column_head[ii].winfo_height(), height=120, width=column_head[ii+1].winfo_x())
      #first column
      if ii == 0:
      if column_user[ii] is False:
      column_head[ii].place(x=1, y=0, height=20, width=column_head[ii+1].winfo_x())
      column_head[ii].update()
      column_body[ii].place(x=1, y=column_head[ii].winfo_height(), height=120, width=column_head[ii+1].winfo_x())
      if column_user[ii] is True:
      column_head[ii].place(x=1, y=0, height=20, width=column_head[ii+1].winfo_x())
      column_head[ii].update()
      column_body[ii].place(x=1, y=column_head[ii].winfo_height(), height=120, width=column_head[ii+1].winfo_x())
      ii = ii - 1



      root = tk.Tk()
      gui_w = 650
      gui_h = 270
      gui_h_old = 0
      x = (root.winfo_screenwidth()/2) - (gui_w/2)
      y = (root.winfo_screenheight()/2) - (gui_h/2)
      root.geometry('%dx%d+%d+%d' % (gui_w, gui_h, x, y))
      root.bind('<Configure>', resize)
      root.minsize(width=350, height=315)
      root.maxsize(width=root.winfo_screenwidth(), height=root.winfo_screenheight())


      column_names = ['id', 'name', 'size', 'time']
      column_body = [tk.Listbox(borderwidth=0, highlightthickness=0, exportselection=0, activestyle='none') for i in column_names]
      column_head = [tk.Button(text=i, borderwidth=0.5, relief="ridge", anchor="w") for i in column_names]
      [i.bind("<Motion>", column_drag) for i in column_head]

      column_lead = [False for i in column_names]; column_lead[0] = True
      column_flip = [False for i in column_names]
      column_user = [False for i in column_names]
      column_posx = [0 for i in column_names]

      root.mainloop()


      Error message:



      Fatal Python error: Cannot recover from stack overflow.

      Current thread 0x00001440 (most recent call first):
      File "C:python37libtkinter__init__.py", line 1704 in __call__
      File "C:python37libtkinter__init__.py", line 1177 in update
      File "path.../tst.py", line 42 in refresh_run_display
      File "path.../tst.py", line 14 in column_drag
      Process finished with exit code -1073740791 (0xC0000409)


      I'd like to keep the current format if possible. Please help!










      share|improve this question













      I'm using the .place method. The following code is a working simplification of resizable columns and the error message which occurs while mouse-moving the columns after a short time.



      import tkinter as tk


      def column_drag(event):
      #print(event.x)
      for ii, i in enumerate(column_head):
      if ii != 0:
      currCur = root.winfo_pointerx() - root.winfo_rootx()
      if currCur <= column_head[ii].winfo_x() + 10 and currCur >= column_head[ii].winfo_x() - 10:
      if currCur <= column_head[ii].winfo_x() + 10 and currCur >= column_head[ii].winfo_x() - 10:
      column_head[ii].configure(cursor="sb_h_double_arrow")
      column_posx[ii] = currCur
      column_user[ii] = True
      refresh_run_display()
      else: column_head[ii].configure(cursor="arrow")

      def resize(event):
      refresh_run_display()


      def refresh_run_display():
      ii = len(column_body)-1
      for i in reversed(column_body):
      # Last column
      if ii+1 == len(column_body):
      if column_user[ii] is False:
      column_head[ii].place(x=ii * 150, y=0, height=20, width=root.winfo_width())
      column_head[ii].update()
      column_body[ii].place(x=ii * 150, y=column_head[ii].winfo_height(), height=120, width=root.winfo_width())
      if column_user[ii] is True:
      column_head[ii].place(x=column_posx[ii], y=0, height=20, width=root.winfo_width())
      column_head[ii].update()
      column_body[ii].place(x=column_posx[ii], y=column_head[ii].winfo_height(), height=120, width=root.winfo_width())
      #middle column
      if ii+1 != len(column_body) and ii != 0:
      if column_user[ii] is False:
      column_head[ii].place(x=ii * 150, y=0, height=20, width=column_head[ii+1].winfo_x())
      column_head[ii].update()
      column_body[ii].place(x=ii * 150, y=column_head[ii].winfo_height(), height=120, width=column_head[ii+1].winfo_x())
      if column_user[ii] is True:
      column_head[ii].place(x=column_posx[ii], y=0, height=20, width=column_head[ii+1].winfo_x())
      column_head[ii].update()
      column_body[ii].place(x=column_posx[ii], y=column_head[ii].winfo_height(), height=120, width=column_head[ii+1].winfo_x())
      #first column
      if ii == 0:
      if column_user[ii] is False:
      column_head[ii].place(x=1, y=0, height=20, width=column_head[ii+1].winfo_x())
      column_head[ii].update()
      column_body[ii].place(x=1, y=column_head[ii].winfo_height(), height=120, width=column_head[ii+1].winfo_x())
      if column_user[ii] is True:
      column_head[ii].place(x=1, y=0, height=20, width=column_head[ii+1].winfo_x())
      column_head[ii].update()
      column_body[ii].place(x=1, y=column_head[ii].winfo_height(), height=120, width=column_head[ii+1].winfo_x())
      ii = ii - 1



      root = tk.Tk()
      gui_w = 650
      gui_h = 270
      gui_h_old = 0
      x = (root.winfo_screenwidth()/2) - (gui_w/2)
      y = (root.winfo_screenheight()/2) - (gui_h/2)
      root.geometry('%dx%d+%d+%d' % (gui_w, gui_h, x, y))
      root.bind('<Configure>', resize)
      root.minsize(width=350, height=315)
      root.maxsize(width=root.winfo_screenwidth(), height=root.winfo_screenheight())


      column_names = ['id', 'name', 'size', 'time']
      column_body = [tk.Listbox(borderwidth=0, highlightthickness=0, exportselection=0, activestyle='none') for i in column_names]
      column_head = [tk.Button(text=i, borderwidth=0.5, relief="ridge", anchor="w") for i in column_names]
      [i.bind("<Motion>", column_drag) for i in column_head]

      column_lead = [False for i in column_names]; column_lead[0] = True
      column_flip = [False for i in column_names]
      column_user = [False for i in column_names]
      column_posx = [0 for i in column_names]

      root.mainloop()


      Error message:



      Fatal Python error: Cannot recover from stack overflow.

      Current thread 0x00001440 (most recent call first):
      File "C:python37libtkinter__init__.py", line 1704 in __call__
      File "C:python37libtkinter__init__.py", line 1177 in update
      File "path.../tst.py", line 42 in refresh_run_display
      File "path.../tst.py", line 14 in column_drag
      Process finished with exit code -1073740791 (0xC0000409)


      I'd like to keep the current format if possible. Please help!







      python python-3.x tkinter multiple-columns






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 10 at 19:01









      Rhys

      1,648122746




      1,648122746






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          I think the column_head[ii].update() is causing this error.



          Before, In testing column_head[ii].winfo_height() would return an incorrect value when asked to return its value in the next line:
          column_head[ii].place(x=ii * 150, y=0, height=20, width=root.winfo_width())



          column_head[ii].update() solved this but apparently now it is not necessary and commenting out all column_head[ii].update() seems to have worked. It was the line called out in the debug






          share|improve this answer






















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53242414%2ftkinter-listboxes-with-resizable-columns-recursion-fatal-error%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            I think the column_head[ii].update() is causing this error.



            Before, In testing column_head[ii].winfo_height() would return an incorrect value when asked to return its value in the next line:
            column_head[ii].place(x=ii * 150, y=0, height=20, width=root.winfo_width())



            column_head[ii].update() solved this but apparently now it is not necessary and commenting out all column_head[ii].update() seems to have worked. It was the line called out in the debug






            share|improve this answer


























              up vote
              0
              down vote













              I think the column_head[ii].update() is causing this error.



              Before, In testing column_head[ii].winfo_height() would return an incorrect value when asked to return its value in the next line:
              column_head[ii].place(x=ii * 150, y=0, height=20, width=root.winfo_width())



              column_head[ii].update() solved this but apparently now it is not necessary and commenting out all column_head[ii].update() seems to have worked. It was the line called out in the debug






              share|improve this answer
























                up vote
                0
                down vote










                up vote
                0
                down vote









                I think the column_head[ii].update() is causing this error.



                Before, In testing column_head[ii].winfo_height() would return an incorrect value when asked to return its value in the next line:
                column_head[ii].place(x=ii * 150, y=0, height=20, width=root.winfo_width())



                column_head[ii].update() solved this but apparently now it is not necessary and commenting out all column_head[ii].update() seems to have worked. It was the line called out in the debug






                share|improve this answer














                I think the column_head[ii].update() is causing this error.



                Before, In testing column_head[ii].winfo_height() would return an incorrect value when asked to return its value in the next line:
                column_head[ii].place(x=ii * 150, y=0, height=20, width=root.winfo_width())



                column_head[ii].update() solved this but apparently now it is not necessary and commenting out all column_head[ii].update() seems to have worked. It was the line called out in the debug







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 11 at 0:06

























                answered Nov 10 at 23:19









                Rhys

                1,648122746




                1,648122746



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53242414%2ftkinter-listboxes-with-resizable-columns-recursion-fatal-error%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    這個網誌中的熱門文章

                    How to read a connectionString WITH PROVIDER in .NET Core?

                    In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

                    Museum of Modern and Contemporary Art of Trento and Rovereto