0

I have this small python tkinter project that basically does two things: It receives data from the tkinter text widget and enters it into the tkinter Radiobutton widget in another window. Everything is working just fine except one issue. It treats everything I enter as one and create only one Radiobutton. I want it to create a new Radiobutton anytime I move to a new line

Here is my code:

  from tkinter import*
  import re
  import tkinter.scrolledtext as src



  root=Tk()
  root.geometry("400x400")
  root.title("Still trying hard!!")
  opt=StringVar()
  db=opt.get()
  var=StringVar()
  var.get()
  Txt_Cont=""
  cont_formater=""
  #FUNCTIONS
  def _Text_Input(a):
  if isinstance(db,str):
    global Txt_Cont
    root1 = Toplevel()
    root1.geometry("400x400+500+200")
    root1.title("DB AND TB WINDOWS")
    cont=Txt_Cont
    Radiobtn=Checkbutton(root1,text=cont, variable=var)
    Radiobtn.deselect()
    Radiobtn.pack()
    root1.mainloop()

def btnfcn():
global Txt_Cont
Txt_Cont = text_box.get("1.0", "end-1c")


text_box = src.ScrolledText(root, width=40, height=10, bd=10, font=('arial', 10, 'bold'), padx=5,        
pady=5)
text_box.pack()
btn = Button(root, text="click me", font=('arial', 10, 'bold'), command=btnfcn)
btn.pack(ipadx=50, pady=(10, 10))
Options = OptionMenu(root, opt, "Databases", "Tables", command=_Text_Input)
Options.pack(ipadx=60)


root.mainloop()

0 Answers0