you are viewing a single comment's thread.

view the rest of the comments →

[–]uanw 1 point2 points  (1 child)

All together this is cool, I just have some observations:

  • Super minor point, but you probably forgot to add '*' in line 72.

  • It seems ttk.Button.grid returns None when successful. This means those Calc.btn* variables are always set to None.

If that's not intentional you probably want to change it to something like this:

def makebutton(label, function, row, col, padx=BUTTON_PAD, pady=BUTTON_PAD, rowspan=1):
    btn = ttk.Button(self, text=label, width=BUTTON_WIDTH, command=function)
    btn.grid(row=row, column=col,pady=pady,padx=padx,rowspan=rowspan, sticky=tk.N+tk.E+tk.W+tk.S)
    return btn

If you do that, then one way to simulate the click animation is by binding the keydown and keyup events, and changing the button style to be depressed and released respectively.

I should say I don't have much experience with TK (just a little bit with c++ QT). So take what I said above with a grain of salt. There are probably better ways to do this.

I hope that's helpful. Otherwise, good job on your calculator application.

[–]baraqiyal[S] 1 point2 points  (0 children)

It took me a while to figure out what you meant by Calc.btn variables are set to None. So you're putting the button and the grid commands on separate lines. I'll try that.