Python: Tkinter/ttk themed Message Box

后端 未结 3 2046
情歌与酒
情歌与酒 2021-01-02 07:22

I started making a GUI with Tkinter and I added the module tkMessageBox as well. But recently I discovered that importing the module

3条回答
  •  不知归路
    2021-01-02 07:30

    An easier way to get properly themed dialog boxes is by compiling your python scripts into .exe files using pyinstaller. (py2exe might also work, but I haven't used that module in a while and don't plan on going back if I don't have to...)

    Error message when running as a python script:

    Error message when running as an .exe:

    I tried forcing a different theme with ttk.Style().theme_use('clam'), however the dialog boxes don't seem to conform to those themes. It must default to the user's system's style. Still better than the windows 98 feel! for the record, I tested on a computer running windows 7 with Python 2.7.

    EDIT

    It appears you can add a manifest file using the --manifest option in pyinstaller, however it appears that this isn't very applicable anyways since it seems pyinstaller does that for you.

    If you need themed dialog boxes that prompt the user for input, consider using the ttk themed version of tkSimpleDialog called ttkSimpleDialog (link). Full Disclosure: I made the modifications to the original tkSimpleDialog module.

提交回复
热议问题