Tuesday 15 July 2014

user interface - Python GUI Calculator he lp needed -


I am new to GI-CREATION to create python and I was trying to make a calculator.
So far I have designed and made it possible that when a key displays its label then on the text entry box, but I can not do this, for example when 789x789 is typed So the result of this will be the text-entry-box.

I think this is what you want

  class calc: numbers = [] operators = [] ... def pressed (self, widget): # This function makes it possible that the label of the button is displayed in the text box when that button is pressed Num = Self.textbox.get_text () pnum = widget.get_label () result = "" if "pnum" in 1234567890: self.textbox.set_text (num + pnum) return elif pnum == "x": add self.numbers (Floats (num) self.operators.append (operator.mul) elif pnum == "+": self.numbers.append (float (num) self.operators.append (operator.add) elif pnum == " - ": self.numbers.append (float (num)) self.operato Rs.append (operator.sub) elif pnum == "/": self.numbers.append (num) self.operators apend (operator. Div) alip pnum == "sqrt": self.numbers.append ( Float (num) ** 0.5) elif pnum == "=": op.php (op) for self.operators in op: self.numbers.insert (0, op (self.numbers.pop (0 ), Self.numbers.pop (0) results = str (self.numbers [0]) self.textbox.set_text (results)    

No comments:

Post a Comment