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
  Tkinter problem DPaul 6 422 May-28-2020, 03:40 PM
Last Post: DPaul
  [Tkinter] Tkinter - I have problem after import varaible or function from aGUI to script johnjh 2 385 Apr-17-2020, 08:12 PM
Last Post: johnjh
  [Tkinter] Problem with tkinter when creating .exe file Jan_97 2 1,102 Feb-27-2020, 05:17 PM
Last Post: Jan_97
  Problem with Submit button Tkinter Reldaing 2 490 Jan-05-2020, 01:58 AM
Last Post: balenaucigasa
  tkinter GUI, problem running seperate files fishglue 17 1,302 Oct-15-2019, 02:56 PM
Last Post: Denni
  [python] [Tkinter] Problem bidding combobox with np.array NEL 3 674 Aug-04-2019, 11:07 AM
Last Post: Yoriz
  Problem with tkinter and string Dule 5 1,153 May-26-2019, 10:57 AM
Last Post: Yoriz
  [Tkinter] Problem with tkinter search widget poopcupine 1 999 Mar-25-2019, 08:24 AM
Last Post: Larz60+
  [Tkinter] tkinter listbox problem edoardo5782 5 3,244 Sep-10-2018, 07:10 PM
Last Post: edoardo5782
  Problem with tkinter sylas 23 26,341 Feb-17-2018, 11:57 PM
Last Post: sparkz_alot

Forum Jump:


Users browsing this thread: 1 Guest(s)