classification
Title: Localize tkinter.simpledialog.Default buttons as with file dialogs.
Type: enhancement Stage:
Components: Tkinter Versions: Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: jcrmatos, serhiy.storchaka, terry.reedy
Priority: normal Keywords:

Created on 2017-09-27 17:14 by jcrmatos, last changed 2017-09-30 01:07 by terry.reedy.

Messages (6)
msg303162 - (view) Author: (jcrmatos) * Date: 2017-09-27 17:14
Hello,

tkinter.simpledialog default buttons (not buttonbox) are not localized, unlike all messagebox.

Best regards,

JM
msg303169 - (view) Author: (jcrmatos) * Date: 2017-09-27 19:09
Hello,

Here is some example code:

from tkinter import Label, Tk
from tkinter.simpledialog import Dialog


class CalendarDialog(Dialog):
    def __init__(self, parent, title='', year=0, month=0):
        self.year = year  # type: int
        self.month = month  # type: int

        Dialog.__init__(self, parent, 'Select a date')

    def body(self, parent):
        Label(parent, text='A label').pack()


master = Tk()
result = CalendarDialog(master, year=2017, month=9).result
master.mainloop()


Best regards,

JM
msg303173 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-09-27 19:35
What do you expect and what do you get?
msg303182 - (view) Author: (jcrmatos) * Date: 2017-09-27 21:29
Hello,

I would expect the same behaviour as askopenfilename from tkinter.filedialog where the buttons are localized (in my case in Portuguese).

What I get is the buttons (in tkinter.simpledialog) are always in English.

Best regards,

JM
msg303383 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-09-30 01:04
Tkinter wraps the tcl/tk gui framework.  The file dialogs and messageboxes are provided by tk.  When possible, the file dialogs utilize the native OS file dialogs.  The localization is done the by the OS. If the messageboxes are localized, then I presume the same is true of them also.

tkinter.simpledialog is a tkinter add-on module written in Python, using tk widgets.  SimpleDialog does not have default buttons; they must be supplied in the initialization call.  Dialog does provide default *example* buttons.  The docstring says "override if you do not want the standard buttons".  

Tk does not provide localized [Ok] and [Cancel] buttons.  AFAIK, Python does not provide access to the OS local translations. You will have to provide localization yourself.

A reasonable enhancement request might be to add "ok='OK', cancel='Cancel'" to the signature of Dialog.__init__ so that a user could pass in local translations. These would then be passed on to buttonbox, to be used instead of the current hard-coded strings.
msg303384 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-09-30 01:07
I would make such new paremeters keyword-only.
History
Date User Action Args
2017-09-30 01:07:17terry.reedysetmessages: + msg303384
2017-09-30 01:04:35terry.reedysetnosy: + terry.reedy
title: tkinter.simpledialog default buttons (not buttonbox) are not localized, unlike all messagebox -> Localize tkinter.simpledialog.Default buttons as with file dialogs.
messages: + msg303383

versions: + Python 3.7, - Python 3.5
type: behavior -> enhancement
2017-09-27 21:29:04jcrmatossetmessages: + msg303182
2017-09-27 19:35:09serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg303173
2017-09-27 19:09:21jcrmatossetmessages: + msg303169
2017-09-27 17:14:51jcrmatoscreate