• 公开课 之 心蓝 计算器 (课堂笔记)


    import tkinter as tk

    class ji_suan_qi(tk.Tk):
    def __init__(self):
    super().__init__()
    # 创建控件
    # 结果标签
    self.res_lable = tk.Label( self,font='Times 16 bold',width=20,anchor='e' )

    self.ac_button = tk.Button( self,font='Times 16 bold',text='AC',width=5 )
    self.o_button = tk.Button( self,font='Times 16 bold',text='x',width=5 )
    self.chu_button = tk.Button( self,font='Times 16 bold',text='/',width=5 )
    self.chen_button = tk.Button( self,font='Times 16 bold',text='*',width=5 )

    self.button_7 = tk.Button( self,font='Times 16 bold',text='7',width=5 )
    self.button_8 = tk.Button( self,font='Times 16 bold',text='8',width=5 )
    self.button_9 = tk.Button( self,font='Times 16 bold',text='9',width=5 )
    self.button_jian = tk.Button( self,font='Times 16 bold',text='-',width=5 )

    self.button_4 = tk.Button( self,font='Times 16 bold',text='4',width=5 )
    self.button_5 = tk.Button( self,font='Times 16 bold',text='5',width=5 )
    self.button_6 = tk.Button( self,font='Times 16 bold',text='6',width=5 )
    self.button_jia = tk.Button( self,font='Times 16 bold',text='+',width=5 )

    self.button_1 = tk.Button( self,font='Times 16 bold',text='1',width=5 )
    self.button_2 = tk.Button( self,font='Times 16 bold',text='2',width=5 )
    self.button_3 = tk.Button( self,font='Times 16 bold',text='3',width=5 )
    self.button_denYU = tk.Button( self,font='Times 16 bold',text='=',width=5,height=3 )

    self.button_bai_f_h = tk.Button( self,font='Times 16 bold',text='%',width=5 )
    self.button_0 = tk.Button( self,font='Times 16 bold',text='0',width=5 )
    self.button_dian = tk.Button( self,font='Times 16 bold',text='.',width=5 )

    # 事件绑定
    # self.button_0.bind( '<Button-1>',self.click )
    # self.button_1.bind('<Button-1>', self.click)
    # self.button_2.bind('<Button-1>', self.click)
    # self.button_3.bind('<Button-1>', self.click)
    # self.button_4.bind('<Button-1>', self.click)
    # self.button_5.bind('<Button-1>', self.click)
    # self.button_6.bind('<Button-1>', self.click)
    # self.button_7.bind('<Button-1>', self.click)
    # self.button_8.bind('<Button-1>', self.click)
    # self.button_9.bind('<Button-1>', self.click)

    # 布局
    # 行, 列, 跨 列 跨 行 rowspan
    self.res_lable.grid( row=0,column=0,columnspan=4 )
    self.ac_button.grid( row=1, column=0 )
    self.o_button.grid( row=1, column=1 )
    self.chu_button.grid( row=1, column=2 )
    self.chen_button.grid( row=1, column=3 )

    self.button_7.grid( row=2, column=0 )
    self.button_8.grid( row=2, column=1 )
    self.button_9.grid( row=2, column=2 )
    self.button_jian.grid( row=2, column=3 )

    self.button_4.grid( row=3, column=0 )
    self.button_5.grid( row=3, column=1 )
    self.button_6.grid( row=3, column=2 )
    self.button_jia.grid( row=3, column=3 )

    self.button_1.grid( row=4, column=0 )
    self.button_2.grid( row=4, column=1 )
    self.button_3.grid( row=4, column=2 )
    self.button_denYU.grid( row=4, column=3, rowspan=2 )

    self.button_bai_f_h.grid( row=5, column=0 )
    self.button_0.grid( row=5, column=1 )
    self.button_dian.grid( row=5, column=2 )

    # def click(self,event):


    jsp = ji_suan_qi()
    jsp.mainloop()
  • 相关阅读:
    iOS9 UITableViewCell separatorInset设置为0分割线还是没有顶到头的问题
    facebook登录(集成FBSDKLoginKit) result的isCancelled总是YES token为nil
    Mac OS X 在Finder新建文本文件
    Xcode8 Could not build Objective-C module 'FBSDKCoreKit'
    Multiple methods named 'status' found with mismatched result, parameter type or attributes
    iOS 10 UserNotifications 框架解析
    WKWebView无法(通过URL schemes)跳转到其他App
    WKWebView不显示提示框(Swift)
    Redis 3.2.1集群搭建
    高吞吐量的分布式发布订阅消息系统Kafka-- 管理工具 Kafka Manager
  • 原文地址:https://www.cnblogs.com/gdwz922/p/9129391.html
Copyright © 2020-2023  润新知