Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7836433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T14:08:47+00:00 2026-06-02T14:08:47+00:00

from Tkinter import * import MySQLdb def tran() : first= Tk() label1 = Label(first

  • 0
from Tkinter import *
import MySQLdb

def tran() :
 first= Tk()

 label1 = Label(first ,text="From")
 label1.pack()

 box1=Entry(first )
 box1.pack()

 label2=Label(first ,text="To")
 label2.pack()

 box2=Entry(first )
 box2.pack()

 label3=Label(first ,text="Amt")
 label3.pack()

 box3=Entry(first )
 box3.pack()

 Button1 = Button(first , text="Next", command=func3).pack() 


def func3() :
 conn = MySQLdb.connect (host = "localhost", user = "root", passwd = "natty", db = "dbms")
 cursor=conn.cursor()

 From=int(box1.get().strip())
 To=int(box2.get().strip())
 Amt=int(box3.get().strip())

 cursor.execute ("select bal from account where acc="+str(From)+"")

 a=cursor.fetchone()
 fromval=int(a[0])

 cursor.execute ("select bal from account where acc="+str(To)+"")

 b=cursor.fetchone()
 toval=int(b[0])

 fromval=fromval-Amt
 toval=toval+Amt

 cursor.execute("update account set bal="+str(fromval)+" where acc="+str(From)+"")
 cursor.execute("update account set bal="+str(toval)+" where acc="+str(To)+"")

 cursor.close ()
 conn.close ()

master = Tk()
Button3 = Button(master, text="Transaction", command=tran).pack()
mainloop()

screen shot

The Next button is not working .when i click “Next” button i’m getting the following error:

File "disp.py", line 24, in func3
    From = int (box1.get().strip())
NameError: global name 'box1' is not defined

Should i have to place the button inside the func3

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T14:08:48+00:00Added an answer on June 2, 2026 at 2:08 pm

    Change your code to this:

    from Tkinter import *
    
    import MySQLdb
    
    class App:
    
        def __init__(self, master):
            Button3 = Button(master, text="Transaction", command=self.tran).pack()
    
        def tran(self) :
    
            first = Tk()
    
            label1 = Label(first ,text="From")
    
            label1.pack()
    
            self.box1=Entry(first )
    
            self.box1.pack()
    
            label2=Label(first ,text="To")
    
            label2.pack()
    
            self.box2=Entry(first )
    
            self.box2.pack()
    
    
            label3=Label(first ,text="Amt")
    
            label3.pack()
    
            self.box3=Entry(first )
    
            self.box3.pack()
    
            Button1 = Button(first , text="Next", command=self.func3).pack() 
    
    
        def func3(self) :
    
            conn = MySQLdb.connect (host = "localhost", user = "root", passwd = "natty", db = "dbms")
    
            cursor=conn.cursor()
    
            From=int(self.box1.get().strip())
    
            To=int(self.box2.get().strip())
    
            Amt=int(self.box3.get().strip())
            cursor.execute ("select bal from account where acc="+str(From)+"")
    
            a=cursor.fetchone()
    
            fromval=int(a[0])
    
            cursor.execute ("select bal from account where acc="+str(To)+"")
    
            b=cursor.fetchone()
    
            toval=int(b[0])
    
            fromval=fromval-Amt
    
            toval=toval+Amt
    
            cursor.execute("update account set bal="+str(fromval)+" where acc="+str(From)+"")
    
            cursor.execute("update account set bal="+str(toval)+" where acc="+str(To)+"")
    
            cursor.close ()
    
            conn.close ()
    
    master = Tk()
    
    app = App(master)
    
    master.mainloop()
    

    I think that should work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

from tkinter import * app=Tk() app.title( BRAIN SYNCRONIZATION SOFTWARE ) e1=Entry(app).pack() t1=Text(app).pack() def InputFun():
from Tkinter import * app = Tk() text_field = Entry(app) text_field.pack() app.mainloop() I want
from Tkinter import * class StatusBar(Frame): def __init__(self, master): Frame.__init__(self, master) self.label = Label(self,
from Tkinter import * class Output: def __init__(self,master): self.u=Text(master,width=40) self.u.grid(row=0,column=0) self.v=Button(master,text=Add text,command=Write) self.v.grid(row=1,column=0) def
from Tkinter import * window = Tk() frame=Frame(window) frame.pack() text_area = Text(frame) text_area.pack() text1
from TKinter import * class Ui(Frame): def __init__(self) Frame.__init__(self, None) self.grid() bquit=Button(self, text=Quit, command=self.quit_pressed)
Something like this: from Tkinter import * root = Tk() but = Button(root, text
I've created this simple GUI: from tkinter import * root = Tk() def grabText(event):
here is some code: from Tkinter import * class Main(object): def __init__(self): self.console =
Ok so say I have a basic frame with text widget. from Tkinter import

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.