Не следует запускать более одного экземпляра Tk()
. Вместо этого используйте Toplevel()
. Смотрите пример:
from tkinter import *
root = Tk() # create the window
display = Toplevel(root)
#probability calculations
totalrolls = StringVar()
amountofrolls = 0
def add_num(): # update numbers in gui
global amountofrolls
amountofrolls += 1
totalrolls.set("Amount of rolls made in total: " + str(amountofrolls))
def button_press(): # button functions
add_num()
#string variable
totalrolls.set("Amount of rolls made in total: " + str(amountofrolls))
#modify second window
todennäköisyys = Label(display, text="The quantity of results:")
totalresults = Label (display, textvariable=totalrolls)
todennäköisyys.pack()
totalresults.pack()
# Create button in root window
Button(root, text='Increase number', command=add_num).pack()
#kick off the event loop
root.mainloop()