• 大小: 27KB
    文件类型: .rar
    金币: 2
    下载: 1 次
    发布日期: 2021-06-06
  • 语言: Python
  • 标签: python  

资源简介

python 简单计算器实现,GUI界面,带上下两种显示,上边显示过程加结果如 1+1=2 ,下边直接显示结果2 带有日历显示,背景图片。鼠标键盘双输入

资源截图

代码片段和文件信息

#! /usr/bin/env python   
# -*- coding: utf-8 -*-
import sysstring
from PyQt4 import QtCoreQtGuiuic
while True:
    try:
        form_class=uic.loadUiType(“music.ui“)[0]
        break

    except SyntaxError:
        print(“ok“)

class mywindowsclass(QtGui.QMainWindowform_class):

    def __init__(selfparent=None):
        QtGui.QMainWindow.__init__(selfparent)
        self.setupUi(self)

        self.sign = ‘‘
        self.num = ‘‘
        self.num1 = ‘‘
        self.result = 0.0

        palette = QtGui.QPalette()
        icon = QtGui.QPixmap(‘34.jpg‘)
        palette.setBrush(self.backgroundRole() QtGui.QBrush(icon))  # 添加背景图片
        self.setPalette(palette)

        exit = QtGui.QAction(QtGui.QIcon(‘icons/exit.png‘) ‘Exit‘ self)       #菜单(退出)
        exit.setShortcut(‘Ctrl+Q‘)
        self.connect(exit QtCore.SIGNAL(‘triggered()‘) QtCore.SLOT(‘close()‘))
        menubar = self.menuBar()
        file = menubar.addMenu(‘&File‘)
        file.addAction(exit)

        self.button_add.clicked.connect(self.add_clicked) 
        self.button_equal.clicked.connect(self.equal_clicked)
        self.button_sub.clicked.connect(self.sub_clicked)
        self.button_mul.clicked.connect(self.mul_clicked)
        self.button_div.clicked.connect(self.div_clicked)
        self.button_cls.clicked.connect(self.cls_clicked)
        
        self.button_one.clicked.connect(self.one_clicked)
        self.button_two.clicked.connect(self.two_clicked)
        self.button_three.clicked.connect(self.three_clicked)
        self.button_four.clicked.connect(self.four_clicked)
        self.button_five.clicked.connect(self.five_clicked)
        self.button_six.clicked.connect(self.six_clicked)
        self.button_seven.clicked.connect(self.seven_clicked)
        self.button_eight.clicked.connect(self.eight_clicked)
        self.button_nine.clicked.connect(self.nine_clicked)
        self.button_zero.clicked.connect(self.zero_clicked)
        

    def add_clicked(self):  
        self.sign=‘+‘
        self.num=self.line_num.text()
        self.line_num.setText(‘‘)

    def sub_clicked(self):
        self.sign=‘-‘
        self.num=self.line_num.text()
        self.line_num.setText(‘‘)

    def mul_clicked(self):
        self.sign=‘*‘
        self.num = self.line_num.text()
        self.line_num.setText(‘‘)

    def div_clicked(self):
        self.sign=‘/‘
        self.num = self.line_num.text()
        self.line_num.setText(‘‘)



    def one_clicked(self):
        self.shu = self.line_num.text()
        self.shu = self.shu + “1“
        self.line_num.setText(self.shu)


    def two_clicked(self):
        self.shu = self.line_num.text()
        self.shu = self.shu + “2“
        self.line_num.setText(self.shu)

    def three_clicked(self):
        self.shu = self.line_num.text()
        self.shu = self.shu + “3“
        self.line_num.setText(self.shu)
    def four_clicked(self):

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      26189  2016-11-24 16:28  计算器\34.jpg

     文件      10552  2018-06-21 17:35  计算器\music.ui

     文件       5089  2018-07-05 16:35  计算器\计算器.py

     目录          0  2018-07-07 11:28  计算器

----------- ---------  ---------- -----  ----

                41830                    4


评论

共有 条评论