Add math calculator to GUI
23 Aug 2021 22:50 #218558
by BigJohnT
Replied by BigJohnT on topic Add math calculator to GUI
For simple math like the OP asked about 567/2 (for example) it seems easier to understand and use the code I posted...
JT
JT
The following user(s) said Thank You: phillc54
Please Log in or Create an account to join the conversation.
25 Aug 2021 07:14 #218682
by anfänger
Replied by anfänger on topic Add math calculator to GUI
For what do you need the calculator?
For setting offsets there is a widget where you can use simple math terms.
For setting offsets there is a widget where you can use simple math terms.
Please Log in or Create an account to join the conversation.
25 Aug 2021 19:51 #218730
by aleksamc
Replied by aleksamc on topic Add math calculator to GUI
I used eval function, it works grate.
Firstly I used BigJohnT solvement. But I saw there a little bit problems, if to write 45/2*3, it will count only first two elements.
Then I started to write code that if I write second time operational char, it make counting of previous.
But I didn't finished it, it somehow worked only for one part of it, as I wrote previusly in my post. I'm not experianced in python, and it tab/spaces logic separation irritates me. I sudied C++ and there is { everythin here } syntax I think very nice. So, pissibly python thought that in the line is and of page and my logic, I don't know.
Then "eval()" solved this problem with easiness.
I use this function only for counting in simple calc to not to count in head, very comfortable, I think.
I almost finished cnc machine for retrofit with MESA and QTpyvcp. When I'll make video, I'll show it at "Show your stuff".
Firstly I used BigJohnT solvement. But I saw there a little bit problems, if to write 45/2*3, it will count only first two elements.
Then I started to write code that if I write second time operational char, it make counting of previous.
But I didn't finished it, it somehow worked only for one part of it, as I wrote previusly in my post. I'm not experianced in python, and it tab/spaces logic separation irritates me. I sudied C++ and there is { everythin here } syntax I think very nice. So, pissibly python thought that in the line is and of page and my logic, I don't know.
Then "eval()" solved this problem with easiness.
I use this function only for counting in simple calc to not to count in head, very comfortable, I think.
I almost finished cnc machine for retrofit with MESA and QTpyvcp. When I'll make video, I'll show it at "Show your stuff".
The following user(s) said Thank You: rodw
Please Log in or Create an account to join the conversation.
25 Aug 2021 21:08 #218734
by rodw
Replied by rodw on topic Add math calculator to GUI
Great it works for you. I'm not so good with Python either. With Python, I always assume the feature I need already exists, so I do a bit of Googling and usually it does. eval was no exception. Years ago I had code for a recursive calculator in C which was neat. I wish I still had it.I used eval function, it works grate.
Firstly I used BigJohnT solvement. But I saw there a little bit problems, if to write 45/2*3, it will count only first two elements.
Then I started to write code that if I write second time operational char, it make counting of previous.
But I didn't finished it, it somehow worked only for one part of it, as I wrote previusly in my post. I'm not experianced in python, and it tab/spaces logic separation irritates me. I sudied C++ and there is { everythin here } syntax I think very nice. So, pissibly python thought that in the line is and of page and my logic, I don't know.
Then "eval()" solved this problem with easiness.
I use this function only for counting in simple calc to not to count in head, very comfortable, I think.
I almost finished cnc machine for retrofit with MESA and QTpyvcp. When I'll make video, I'll show it at "Show your stuff".
Please Log in or Create an account to join the conversation.
Time to create page: 0.082 seconds