我使用 tkinter 创建了一个 ATM,它在单击余额按钮时显示当前余额,它添加了不同类别的存入和提取的钱,这些钱从设置为 0 的当前余额和余额中添加或减去
被存储在
class SampleApp(tk.Tk):
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
self.shared_data={'Balance':tk.IntVar()}
剩余余额会显示在屏幕上
class BalancePage(tk.Frame):
global current_balance
controller.shared_data['Balance'].set(current_balance)
balance_label=tk.Label(self,textvariable=controller.shared_data['Balance'],font=('orbitron',13),fg='white',bg='#3d3d5c',anchor='w')
balance_label.pack(fill='x')
我只想在显示的金额前显示一个“$”符号(即为 0 并且想要 $0)请帮助
#WithdrawPage
class WithdrawPage(tk.Frame):
def withdraw(amount):
global current_balance
if amount>current_balance:
messagebox.showwarning('WARNING','Not sufficient funds!')
else:
current_balance -= amount
controller.shared_data['Balance'].set(current_balance)
controller.show_frame('MenuPage')
#DepositPage
class DepositPage(tk.Frame):
def deposit_cash():
global current_balance
current_balance += int(cash.get())
controller.shared_data['Balance'].set(current_balance)
controller.show_frame('MenuPage')
cash.set('')
千巷猫影
慕勒3428872
繁花如伊
相关分类