0

I have problems by defined functions preforming by themselves, without me pressing the button.

I tried this:

from tkinter import *

root=Tk()

var1=StringVar()
e=Entry(root, width=20, textvariable=var1).grid(row=0,column=0)
a=var1.get()

def commm():
    name=str(var1.get())
    rootnew=Tk()
    rootnew.title(name)
    print(ime)

b=Button(root, text='makeWindow', command=commm()).grid(row=0, column=1)

but it creates two windows instead of one. One containing a Entry and Button and the other is empty.

nbro
  • 15,395
  • 32
  • 113
  • 196

1 Answers1

0

You should not execute Tk twice...

Create Toplevel widget instead.

But please also avoid:

from Tkinter import *

You should use import Tkinter as tk.

nbro
  • 15,395
  • 32
  • 113
  • 196
Jerome Vacher
  • 314
  • 1
  • 7