Commit 048c40ba authored by VIGNET Pierre's avatar VIGNET Pierre

Add images on buttons of the main interface

parent 61ad729e
......@@ -244,43 +244,55 @@ class Charter(object):
but = gtk.Button(label="InputNode (F1)")
self.add_accelerator(but, "F1")
self.add_image(but, "input_node")
c_box.add(but)
self.button_handlers["InputNode"] = (but, -1)
but = gtk.Button(label="SimpleNode (F2)")
self.add_accelerator(but, "F2")
self.add_image(but, "simple_node")
c_box.add(but)
self.button_handlers["SimpleNode"] = (but, -1)
but = gtk.Button(label="PermNode (F3)")
self.add_accelerator(but, "F3")
self.add_image(but, "permanent_node")
c_box.add(but)
self.button_handlers["PermNode"] = (but, -1)
but = gtk.Button(label="StartNode (F4)")
self.add_accelerator(but, "F4")
self.add_image(but, "start_node")
c_box.add(but)
self.button_handlers["StartNode"] = (but, -1)
but = gtk.Button(label="TrapNode (F5)")
self.add_accelerator(but, "F5")
self.add_image(but, "trap_node")
c_box.add(but)
self.button_handlers["TrapNode"] = (but, -1)
but = gtk.Button(label="Transition (F6)")
self.add_accelerator(but, "F6")
self.add_image(but, "transition")
c_box.add(but)
self.button_handlers["Transition"] = (but, -1)
but = gtk.Button(label="Constraints (F7)")
but = gtk.Button(label="View constraints (F7)")
self.add_accelerator(but, "F7")
c_box.add(but)
self.button_handlers["Constraints"] = (but, -1)
# zoom
but = self.wtree.get_widget("zoomp")
image = gtk.Image()
image.set_from_stock(gtk.STOCK_ZOOM_IN, 3)
but.set_image(image)
self.button_handlers["zoom_p"] = (but, -1)
but = self.wtree.get_widget("zoomm")
image = gtk.Image()
image.set_from_stock(gtk.STOCK_ZOOM_OUT, 3)
but.set_image(image)
self.button_handlers["zoom_m"] = (but, -1)
......@@ -337,6 +349,20 @@ class Charter(object):
bhan = but.connect("clicked", self.current_edit_mvc.zoom_minus)
self.button_handlers["zoom_m"] = (but, bhan)
def add_image(self, widget, image_file):
"""Add image to a Button
from http://www.pygtk.org/docs/pygtk/gtk-stock-items.html
"""
image = gtk.Image()
# Get resource
template = pkg_resources.resource_filename(
__name__,
image_file + '.png',
)
image.set_from_file(template)
widget.set_image(image)
def add_accelerator(self, widget, accelerator, signal="activate"):
"""Adds a keyboard shortcut"""
if accelerator is not None:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment