python TK开发界面

-- coding:utf-8 --

from shenzhentong import *
from Tkinter import *

导入tkinter模块的所有内容

class application(Frame):
def init(self, master=None):
Frame.init(self, master)
self.result = StringVar()
self.amount1 = IntVar()
self.amount2 = IntVar()
self.grid()
self.createWidgets()

def createWidgets(self):
    size = {'height':'1', 'width':'8', 'relief':RAISED}
    Button(self, size, text='Perso', height=2, command=self.perso).grid(column=0, row=0,rowspan=2,padx=2)
    Button(self, size, text='Load', command=self.credit).grid(column=1, row=0,padx=2)
    Button(self, size, text='Purchase', command=self.debit).grid(column=1, row=1,padx=2)
    Entry(self, width=8, text=self.amount1).grid(column=2, row=0,padx=2)
    Entry(self, width=8, text=self.amount2).grid(column=2, row=1,padx=2)
    Label(self,height=1,width=2,text='分').grid(column=3, row=0)
    Label(self,height=1,width=2,text='分').grid(column=3, row=1)
    self.amount1.set(10000)
    self.amount2.set(100)
    Label(self,height=6,width=16,textvariable=self.result).grid(column=0, row=3,columnspan=4)

def perso(self):
    card = Card.Card()
    perso(card)
    self.result.set('个人化成功')
    card.Close()

def credit(self):
    card = Card.Card()
    balance = credit(card, self.amount1.get())
    self.result.set('圈存成功\n余额:%.2f元'%(float(balance)/100))
    card.Close()

def debit(self):
    card = Card.Card()
    balance = debit(card, self.amount2.get())
    self.result.set('消费成功\n余额:%.2f元'%(float(balance)/100))
    card.Close()

app = application()
app.mainloop()

1519443934(1).jpg

你可能感兴趣的:(python TK开发界面)