What's the simplest cross-platform way to pop up graphical dialogs in Python?

后端 未结 10 2211
一生所求
一生所求 2020-12-13 04:15

I want the simplest possible way to pop up simple dialogs in Python scripts. Ideally, the solution would:

  • Work on Windows, OS X, Gnome, KDE
  • Look like
10条回答
  •  半阙折子戏
    2020-12-13 04:50

    pyglet is another alternative, though it may not be the simplest. that being said, it's cross-platform and only depends on python, so there's no external dependencies. that fact alone can be reason enough to use it over others.

    and all it can handle multimedia pretty easily as well, pretty handy if you want to display an image or video or something.

    the example below is from the documentation...

    #!/usr/bin/python
    import pyglet
    window = pyglet.window.Window()
    label = pyglet.text.Label('Hello, world',
                          font_name='Times New Roman',
                          font_size=36,
                          x=window.width/2, y=window.height/2,
                          anchor_x='center', anchor_y='center')
    
    @window.event
    def on_draw():
        window.clear()
        label.draw()
    
    pyglet.app.run()
    

提交回复
热议问题