Clickable Icon in Python GTK -


does know how create custom button custom icon in pygtk? make program in python gtk works similar settings menu or control panel. know pygtk has stock buttons cancel, exit, , ok; i'm unable change labels or icons of buttons.

you can put button on screen, , put image in it.

#!/usr/bin/env python # -*- coding: utf-8 -*- # #  test_icon.py #   #  copyright 2015 john coppens <john@jcoppens.com> #   #  program free software; can redistribute and/or modify #  under terms of gnu general public license published #  free software foundation; either version 2 of license, or #  (at option) later version. #   #  program distributed in hope useful, #  without warranty; without implied warranty of #  merchantability or fitness particular purpose.  see #  gnu general public license more details. #   #  should have received copy of gnu general public license #  along program; if not, write free software #  foundation, inc., 51 franklin street, fifth floor, boston, #  ma 02110-1301, usa. #    import pygtk import gtk  image_file = "/put/an/imagename here"  class mainwindow(gtk.window):     def __init__(self, debug = none):         gtk.window.__init__(self)         self.connect("delete-event", self.on_delete_event)          btn = gtk.button()         img = gtk.image()         img.set_from_file(image_file)         btn.set_image(img)          self.add(btn)         self.show_all()      def on_delete_event(self, win, data):         gtk.main_quit()      def run(self):         gtk.mainloop()  def main():     w = mainwindow()     w.run()     return 0  if __name__ == '__main__':     main() 

the image can of many formats, svg (vector graphics), png, etc.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -