I made a version based on your code, where I tried to decrease duplicate code, and increase extendability.
The biggest change was putting all the buttons in a 2D list, and rather base the grid position based on that. This makes it easier to move buttons around and add new ones, as you don't have to calculate their grid-position, or update the position of other buttons. It also makes it less prone to mistakes.
The second biggest change was making all the buttons use a single method, which meant I could get rid of a lot of duplicate code, where the only difference was the "command" parameter. I also made it have an optional parameter for width to allow for the "equals button" to use the system too.
Other than that it works exactly the same as your program (other than having equals set self.string with the return value rather than an empty string)
thank you very much. yes, the two main improvements are legitimate ones, easier positioning and a general purpose button function. indeed, a novel view of the affair. just some bits of comments appreciated.
i'll refine and build something on those. else, are you interested in a widget lib collab?
I made a version based on your code, where I tried to decrease duplicate code, and increase extendability.
The biggest change was putting all the buttons in a 2D list, and rather base the grid position based on that. This makes it easier to move buttons around and add new ones, as you don't have to calculate their grid-position, or update the position of other buttons. It also makes it less prone to mistakes.
The second biggest change was making all the buttons use a single method, which meant I could get rid of a lot of duplicate code, where the only difference was the "command" parameter. I also made it have an optional parameter for width to allow for the "equals button" to use the system too.
Other than that it works exactly the same as your program (other than having equals set self.string with the return value rather than an empty string)
thank you very much. yes, the two main improvements are legitimate ones, easier positioning and a general purpose button function. indeed, a novel view of the affair. just some bits of comments appreciated.
i'll refine and build something on those. else, are you interested in a widget lib collab?
sorry but iam a begginer in python and i love your kind of code i want more explanation for this code please
I'm a bit full on projects at the moment, but if you have a git repo or something I can check it out when I have time.
that's the way!
edit: kind of pet project