-1

Im trying to create a python tkinter program for this code:

    from random import *
    from time import *
    from tkinter import *
    MyWindow = Tk()
    MyWindow.title('Fruit Machine')
    money=0
    print("Starting fruit machine simulator!")
    print("Important: Do not enter words or symbols!")
    money = int(input("Enter money for the simulator: "))
    reel=["cherry","bell","lemon","orange","bannana"]
    turn=0

Ive tried using this:

from random import *
from time import *
from tkinter import *
MyWindow = Tk()
MyWindow.title('Fruit Machine')
MyWindow.geometry("1000x1000")
money=0
Heading=StringVar()
Heading1=StringVar()
Heading.set("Starting fruit machine simulator!")
Heading1.set("Important: Do not enter words or symbols!")
TitleText=Label(MyWindow,textvariable=Heading,bg="blue",fg="white",font= 
("Arial",14)).place(x=200,y=200)
TitleText=Label(MyWindow,textvariable=Heading1,bg="blue",fg="white",font= ("Arial",14)).place(x=200,y=230)
Name=StringVar()
InputBox=Entry(MyWindow,textvariable=Name,width="25",font=("Arial",14)).place(x=200,y=260)

def set_money():
    money = InputBox.get()

#b = Button(MyWindow, text="Press Me", command = lambda: setattr(,'money', 7), height=10, width=10, compound=LEFT)
b = Button(MyWindow, text="Press Me", command = set_money, height=10, width=10, compound=LEFT)


b.place(x = 200, y = 280)

mainloop()

MyWindow.mainloop() 

But im getting errors, and it wont run. Can anyone help? It would really make my day! I want to show text in a tkinter window,with a entry box and a button that when clicked updates a vairible.

1 Answers1

-1

When you use textvariable you have to use it

def set_money():
    money = Name.get()
patel
  • 430
  • 1
  • 4
  • 9