Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

Python calculator

I have been learning and coding in python for a while now and i'm having issues with a small project i'm doing (Basic calculator). I cant seem to figure out how to bind the buttons to functions for example i would like to bind button_plus to the addition function i created earlier. Any tips for helping me out?


Also if anyone has any ideas for other projects after i finish this calculator that would be greatly appreciated :)
Going to be pretty difficult to understand what you're talking about without source code. No idea what your functions look like.
Pseudo-code:

Code
if button_plus.onPressed:
     addition(x,y)
Contact for professional programming services.
unazed#5906
We got QT.

PHP Code

<?php 
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'untitled.ui'
#
# Created: Sat Feb  4 04:33:54 2017
#      by: PyQt4 UI code generator 4.10.4
#
# WARNING! All changes made in this file will be lost!

from PyQt4 import QtCore, QtGui

try:
    
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError
:
    
def _fromUtf8(s):
        return 
s

try:
    
_encoding = QtGui.QApplication.UnicodeUTF8
    def _translate
(context, text, disambig):
        return 
QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
    
def _translate(context, text, disambig):
        return 
QtGui.QApplication.translate(context, text, disambig)

class 
Ui_Dialog(object):
    
def setupUi(self, Dialog):
        
Dialog.setObjectName(_fromUtf8("Dialog"))
        
Dialog.resize(356, 135)
        
self.pushButton = QtGui.QPushButton(Dialog)
        
self.pushButton.setGeometry(QtCore.QRect(220, 50, 111, 51))
        
self.pushButton.setObjectName(_fromUtf8("pushButton"))
        
self.lineEdit = QtGui.QLineEdit(Dialog)
        
self.lineEdit.setGeometry(QtCore.QRect(70, 50, 113, 27))
        
self.lineEdit.setObjectName(_fromUtf8("lineEdit"))
        
self.lineEdit_2 = QtGui.QLineEdit(Dialog)
        
self.lineEdit_2.setGeometry(QtCore.QRect(70, 80, 113, 27))
        
self.lineEdit_2.setObjectName(_fromUtf8("lineEdit_2"))

        
self.retranslateUi(Dialog)
        
QtCore.QObject.connect(self.pushButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.DOSOMETHINGDUDEE)
        
QtCore.QMetaObject.connectSlotsByName(Dialog)

    
def retranslateUi(self, Dialog):
        
Dialog.setWindowTitle(_translate("Dialog", "Dialog", None))
        
self.pushButton.setText(_translate("Dialog", "SUM", None))


    
def DOSOMETHINGDUDEE(self):
        print(
"something")


if 
__name__ == "__main__":
    
import sys
    app 
= QtGui.QApplication(sys.argv)
    
Dialog = QtGui.QDialog()
    
ui = Ui_Dialog()
    
ui.setupUi(Dialog)
    
Dialog.show()
    
sys.exit(app.exec_()) 


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by Bass_ReevesAug 20, 2023 01:44 AM 9 630 Aug 20, 2023 01:44 AM
Last Post: Lucky4L
[Python] by TISADec 2, 2017 09:03 AM 4 237 Dec 2, 2017 09:03 AM
Last Post: Gliese
[Python] by LinxyJun 10, 2017 05:26 PM 1 157 Jun 10, 2017 05:26 PM
Last Post: sepluv