C:
This is the correct syntax for setting the font when creating a button in tkinter. The font argument allows you to specify the font family, size, and style (in this case, 'Arial', '12' for the size, and 'italic' for the style).
D:
This is another correct way to set the font after the button has already been created. The config() method allows you to modify various properties of a widget, including the font.
config() allows you to set a new value to the property. D correct
The property responsible for storing font information is font.
https://edube.org/learn/pcpp1-4-gui-programming/visiting-widgets-properties-3
However, if you try code from 4 options, only D works correctly:
A, B will raise AttributeError
AttributeError: 'Button' object has no attribute 'setfont'
AttributeError: 'Button' object has no attribute 'ButtonFont'
C has syntax error. C is missing close ")". Also, C is missing "tk.".
If C needs to be correct, it should be:
button = tk.Button(window,font=('Arial', '12', 'italic'))
Since I have to choose 2 answer instead of 1 answer, i prefer CD. Because attribute Error is worse than syntax error.
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
claudiupopa
4 months, 2 weeks agoprabhay786
1 year, 2 months agoMoneybing
1 year, 7 months ago