On 06/09/17 08:09, edmundo pierre via Tutor wrote: > So show us what you did. Its hard to figure out what's > gone wrong when we can't see your code:That is what I did:
> from sympy import*from tkinter import*from sympy import init_printing > root = > Tk()root.geometry("450x350+500+500")root.title("Factorisations/Simplifications")root.configure(background > = "gray")#Difine variablevar1= StringVar()var2 =StringVar()#Create the > function answer > def Answer(): x = symbols("x") A = var1.get() B = factor(A) > Right_insert_top .insert(END,str(B)) As you can see your code is a mess. you need to send in plain text format not HTML, otherwise the mail system mangles everything into an unreadable mess. I'll try to unscramble it as best I can but it would help a lot if in future you can switch to plain text for mails with code. (This is true of most programming mailing lists not just Python) from sympy import* from tkinter import* from sympy import init_printing root =Tk() root.geometry("450x350+500+500") root.title("Factorisations/Simplifications") root.configure(background = "gray") #Difine variable var1= StringVar() var2 =StringVar() #Create the function answer def Answer(): x = symbols("x") A = var1.get() B = factor(A) Right_insert_top .insert(END,str(B)) #Create the function simplification def Simplification(): init_printing() x= symbols("x") D = var2.get() E = expand(D) Right_insert_top .insert(END,str((E)) #Create the Factorisation frame Tops = Frame(root,relief= "sunken")Tops.pack(side = TOP) #Create a Label of the Top Top_Label = Label(Tops,font=("arial",30,"bold"),text = "Factorisations/Simplifications",bd = 10) Top_Label.pack(side = "top",fill =BOTH ) > #Create the left frame <snip left side> #Create a Right side Frame Right = Frame (root,relief= "sunken") Right.pack(side = "right",fill = BOTH) #Create a Frame on the Top right Right_top = Frame (Right,relief= "sunken") Right_top.pack(side = "top") ... #Create a insert text on the screen on the right Right_insert_top = Text( Right_top,font=("arial",10,"bold"),bd= 5) Right_insert_top.pack() Ok, I got bored after this, and we have the basic info we need... We can now see that you are using a Text widget with the Arial font. > I am using Window 7. > I got: x**2+6*x+9, which is Correct. But I do not like the syntax. OK, So all you need to do is write a string formatting function that takes your current output and returns the output you want. You can write and test that in a command line tool which will avoid all the complexity of a GUI. Then plug that into your GUI and insert the output into your Text widget. I don't know sympy but it may have some string formatting functions that you can use. If not you will need to interpret the input string yourself. There are some math expression parsers around on the internet if you search for the,m. You could adapt one of them I'm sure. > I used the Integral as an example of how my answer should look All the mathematical symbols have their own characters. Here is a link to the characters that Arial font supports: http://www.fileformat.info/info/unicode/font/arial_unicode_ms/list.htm You will see the integral variations at U222B-U2233 Use your browser string find tool to find the other operators/symbols. Your formatting function will need to insert the appropriate unicode characters into your output string. > My code run perfectly, you can try. Your code does not run perfectly since it doesn't do what you want! I assume you mean your code doesn't generate any errors. That's a different thing :-) -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor