开发者

where is the button widget in pyglet ?

开发者 https://www.devze.com 2023-04-05 22:55 出处:网络
i\'m checking out pyglet, but, funny enough, i can\'t find how to do a s开发者_如何学运维imple button!

i'm checking out pyglet, but, funny enough, i can't find how to do a s开发者_如何学运维imple button!

so

  • what is the standard way to create a standard button?

  • is there a standard way to create a Message-Box? open/save dialogs?

  • or am i missing the point of pyglet? isn't it yet-another gui toolkit for creating (also) forms, windows, buttons, texts, standard widgets, etc. ?

i'm using Python 2.x on a windows PC if that matters.


I didn't use Pyglet yet, but is not a GUI library, it doesn't have to have widgets like buttons, or containers etc. It's a multimedia library like Pygame, it draws stuff on screen, plays sounds, and has some helper functions.

If you want to draw a button on screen, you should first draw a rectangle, print some text in it, and then listen mouse clicks to know if it's clicked on this rectangle.

See PyQT, PyGTK, WxPython for some examples of GUI libraries.


You can see an example of how to create a button and create yet another interface with Pyglet in the script:

http://www.pyglet.org/doc/programming_guide/media_player.py

But this is only an example interface created without complex items.


Current state of affairs 3 years later...

As previously stated Pyglet itself generally provides a lower level api than the UI widget library (e.g. closer to GDI or SDL).

That said there are gui's built on top of pyglet: https://github.com/jorgecarleitao/pyglet-gui https://code.google.com/p/kytten/

Also pyglet 1.2 now has buttons itself (though not much else as far as widgets are concerned).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号