Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 [Tkinter] Tkinter problem
#1
1.if you just run this, youll have a window to input 'order' and 'Rs'.
2.Enter a number in 'order' and press ok.
3.Change the number in 'order' again and press ok again.
youll know what wrong's with it.

QUESTIONS:

First: how can i cover these elements created by clicking 'ok'?
Second: is there any way that i dont have to have a button but show the elements right after i enter a number in 'order'

Thank you!!!!

import tkinter as tk
R=[]
C=[]
order=0
# GUI
def GUI():
    window=tk.Tk()
    window.title('variable assignment')
    window.geometry('500x600')
    order_label=tk.Label(window,text='order',font=(14))
    order_label.pack()
    order_msgbx=tk.Entry(window,show=None)
    print(type(order))
    order_msgbx.pack()
    R_s_label=tk.Label(window,text='Rs',font=(14))
    R_s_label.pack()
    R_s_msgbx=tk.Entry(window,show=None)
    R_s=R_s_msgbx.get()
    R_s_msgbx.pack()
    R_msgbx=[]
    C_msgbx=[]
    R_label_list=locals()
    C_label_list=locals()

    def RC_button():
        order=int(order_msgbx.get())
        print(order)
        window=tk.Tk()
        if order>0:
            for n in range(order):
                R_label_list['R_label_' + str(n+1)] = tk.Label(window,text='R'+str(n+1),font=(14))
                R_label_list['R_label_' + str(n+1)].pack()
                R_msgbx0=tk.Entry(window,show=None)
                R_msgbx.append(R_msgbx0)
                R_msgbx[n].pack()
                R.append(R_msgbx[n].get)
                C_label_list['C_label_' + str(n+1)] = tk.Label(window,text='C'+str(n+1),font=(14))
                C_label_list['C_label_' + str(n+1)].pack()
                C_msgbx0=tk.Entry(window,show=None)
                C_msgbx.append(C_msgbx0)
                C_msgbx[n].pack()
                C.append(C_msgbx[n].get)
    RC_button=tk.Button(window, text='OK',width=15,height=2,command=RC_button)
    RC_button.pack()
    window.mainloop()
GUI()

Quote
#2
Quote:RC_button=tk.Button(window, text='OK',width=15,height=2,command=RC_button)
this statement calls itself when button pressed.

you need to do some renaming.

calling the function which is named same as button is bad coding, it will recreate widgets each time
and weird things will start at some point.

I strongly suggest taking a good tutorial (at least the parts about buttons)
I'd suggest: https://www.python-course.eu/python_tkinter.php
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Problem with Submit button Tkinter Reldaing 2 133 Jan-05-2020, 01:58 AM
Last Post: balenaucigasa
  tkinter GUI, problem running seperate files fishglue 17 691 Oct-15-2019, 02:56 PM
Last Post: Denni
  [python] [Tkinter] Problem bidding combobox with np.array NEL 3 306 Aug-04-2019, 11:07 AM
Last Post: Yoriz
  Problem with tkinter and string Dule 5 587 May-26-2019, 10:57 AM
Last Post: Yoriz
  [Tkinter] Problem with tkinter search widget poopcupine 1 630 Mar-25-2019, 08:24 AM
Last Post: Larz60+
  [Tkinter] tkinter listbox problem edoardo5782 5 2,495 Sep-10-2018, 07:10 PM
Last Post: edoardo5782
  Problem with tkinter sylas 23 20,870 Feb-17-2018, 11:57 PM
Last Post: sparkz_alot
  [Tkinter] problem with refresh UI in tkinter app Philbot 5 4,169 Feb-06-2018, 01:10 PM
Last Post: Philbot
  Problem with tkinter widget list Larz60+ 2 2,221 Nov-27-2017, 03:36 PM
Last Post: Larz60+

Forum Jump:


Users browsing this thread: 1 Guest(s)