0
import math
import easygui as eg

eg.msgbox("This program solves quadratic equations Enter the values of a, b and c ")

a=eg.integerbox("enter a") 

when I try to enter a negative number or a number over 99 the integer box wont let me, Is there any way around this

b=eg.integerbox("enter b")

c=eg.integerbox("enter c")


i = b**2-4*a*c 

if d < 0:
    eg.msgbox("There are no real solutions")
elif i == 0:
    x = (-b+math.sqrt(i))/(2*a)

    eg.msgbox("heres your solution: "), x
else:
    x1 = (-b+math.sqrt(i))/(2*a)
    x2 = (-b-math.sqrt(i))/(2*a)
    eg.enterbox(msg="you have 2 solutions", default=(x1,x2))
user2757771
  • 158
  • 7
  • What do you mean by *"wont let me"*? Does it produce an error? Give an unexpected value? – arshajii Sep 07 '13 at 21:07
  • See: http://stackoverflow.com/questions/13366395/python-easygui-integerbox-bound-limits – Sajjan Singh Sep 07 '13 at 21:08
  • @arshajii I'm guessing the `integerbox` simply won'y accept keyboard input if it isn't an "integer". Therefore, there is probably no error given and no value to be unexpected. This is one of the few instances when an OP says "it won't let me" and that is exactly what happens. – SethMMorton Sep 07 '13 at 22:18

1 Answers1

2

Try changing the default parameters of the function integerbox when you call it. Specifically, the one you'll want to change to allow negative numbers is lowerbound. Here is the full definition of integerbox so you can see all the parameters.

integerbox(msg='', title=' ', default='', lowerbound=0, upperbound=99, image=None, root=None, **invalidKeywordArguments)

The minimum value for an integer on any platform can be accessed through the following method:

import sys
a=eg.integerbox(msg='enter a', lowerbound = -sys.maxint - 1)

The upperbound for an int can be accessed through sys.maxint.

Shashank
  • 13,713
  • 5
  • 37
  • 63
  • @SethMMorton Yeah, read: http://docs.python.org/2/library/sys.html#sys.maxint The max int is at least 2**31-1. The max negative int is at most -2**31. – Shashank Sep 07 '13 at 22:20