#!/usr/bin/python import pygtk pygtk.require("2.0") import gtk import gdl def on_window_delete_event(window, params): layout.save_layout('test') layout.save_to_file('layout.xml') print "Saved layout.xml" win = gtk.Window(gtk.WINDOW_TOPLEVEL) dock = gdl.Dock() #now, this is awful. Why isn't it gdl.Dockbar!? dockbar = dock.bar_new() #Yes! Yet another annoyance! dock.layout_new()!? layout = dock.layout_new() master = dock.props.master master.props.switcher_style = gdl.SWITCHER_STYLE_TABS #the canvas dock canvas = gdl.gdl_dock_item_new_with_stock("canvas", "Canvas", gtk.STOCK_STOP, gdl.DOCK_ITEM_BEH_NORMAL | gdl.DOCK_ITEM_BEH_CANT_ICONIFY | gdl.DOCK_ITEM_BEH_LOCKED) widget = gtk.Label ("This is where you would work and swear at, most of the time") widget.set_size_request(600,300) canvas.add(widget) dock.add_item (canvas, gdl.DOCK_CENTER) canvas.show_all() #Tool box toolbox = gdl.DockItem("toolbox", "Toolbox", gdl.DOCK_ITEM_BEH_NORMAL) #toolbox.set_geometry_hints(base_width=24,base_height=24) #toolbox.set_name("Toolbox") widget = gtk.Label ("This would be the tool box") widget.set_size_request(32,200) toolbox.add(widget) dock.add_item (toolbox, gdl.DOCK_LEFT) toolbox.dock_to(canvas, gdl.DOCK_LEFT, -1) toolbox.show_all() #the color_picker dock color_picker = gdl.DockItem("color_picker", "Color Picker", gdl.DOCK_ITEM_BEH_NORMAL ) hsv = gtk.HSV() #color_picker.set_property("width", 200) color_picker.add(hsv) dock.add_item (color_picker, gdl.DOCK_BOTTOM) color_picker.dock_to(toolbox, gdl.DOCK_BOTTOM, -1) color_picker.show_all() #preview preview = gdl.DockItem("preview", "Preview", gdl.DOCK_ITEM_BEH_NORMAL ) widget = gtk.TreeView () preview.add(widget) dock.add_item (preview, gdl.DOCK_RIGHT) preview.dock_to(canvas, gdl.DOCK_RIGHT, -1) preview.show_all() #palette palette = gdl.DockItem("palette", "Palette", gdl.DOCK_ITEM_BEH_NORMAL ) widget = gtk.TreeView () palette.add(widget) dock.add_item (palette, gdl.DOCK_RIGHT) palette.dock_to(preview, gdl.DOCK_BOTTOM, -1) palette.show_all() #Animations animations = gdl.DockItem("animations", "Animations", gdl.DOCK_ITEM_BEH_NORMAL ) #pr3p3r3 4 Tr33V13w H3ll liststore = gtk.ListStore(str, str) # we'll add some data now - 4 rows with 3 child rows each animations_list = [(gtk.STOCK_DIALOG_WARNING, 'Walk'),(gtk.STOCK_STOP, 'Kill'),(gtk.STOCK_DELETE,'Roundhouse Kick')] for thumbnail, name in animations_list: piter = liststore.append([thumbnail, name]) # create the TreeView using treestore treeview = gtk.TreeView(liststore) # create the TreeViewColumn to display the data tvcolumnthumb = gtk.TreeViewColumn('Thumbnail') tvcolumnname = gtk.TreeViewColumn('Name') # add tvcolumn to treeview treeview.append_column(tvcolumnthumb) treeview.append_column(tvcolumnname) # create a CellRendererText to render the data cell = gtk.CellRendererText() cell.set_property('editable', True) thumbcell = gtk.CellRendererPixbuf() # add the cell to the tvcolumn and allow it to expand tvcolumnthumb.pack_start(thumbcell, True) tvcolumnname.pack_start(cell, True) # set the cell "text" attribute to column 0 - retrieve text # from that column in treestore tvcolumnthumb.add_attribute(thumbcell, 'stock-id', 0) tvcolumnname.add_attribute(cell, 'text', 1) # make it searchable treeview.set_search_column(1) # Allow sorting on the column tvcolumnname.set_sort_column_id(1) # Allow drag and drop reordering of rows treeview.set_reorderable(True) animations.add(treeview) dock.add_item (animations, gdl.DOCK_NONE) animations.dock_to(palette, gdl.DOCK_BOTTOM, -1) animations.show_all() #Layers layers = gdl.DockItem("layers", "Layers", gdl.DOCK_ITEM_BEH_NORMAL ) #pr3p3r3 4 Tr33V13w H3ll liststore = gtk.ListStore(str, str) # we'll add some data now - 4 rows with 3 child rows each layers_list = [(gtk.STOCK_MISSING_IMAGE, 'Hair'),(gtk.STOCK_MISSING_IMAGE, 'Face'),(gtk.STOCK_MISSING_IMAGE,'Third punch')] for thumbnail, name in layers_list: piter = liststore.append([thumbnail, name]) # create the TreeView using treestore treeview = gtk.TreeView(liststore) # create the TreeViewColumn to display the data tvcolumnthumb = gtk.TreeViewColumn('Thumbnail') tvcolumnname = gtk.TreeViewColumn('Name') # add tvcolumn to treeview treeview.append_column(tvcolumnthumb) treeview.append_column(tvcolumnname) # create a CellRendererText to render the data cell = gtk.CellRendererText() cell.set_property('editable', True) thumbcell = gtk.CellRendererPixbuf() # add the cell to the tvcolumn and allow it to expand tvcolumnthumb.pack_start(thumbcell, True) tvcolumnname.pack_start(cell, True) # set the cell "text" attribute to column 0 - retrieve text # from that column in treestore tvcolumnthumb.add_attribute(thumbcell, 'stock-id', 0) tvcolumnname.add_attribute(cell, 'text', 1) # make it searchable treeview.set_search_column(1) # Allow sorting on the column tvcolumnname.set_sort_column_id(1) # Allow drag and drop reordering of rows treeview.set_reorderable(True) layers.add(treeview) dock.add_item (layers, gdl.DOCK_RIGHT) layers.dock_to(animations, gdl.DOCK_BOTTOM, -1) layers.show_all() #the frames dock frames = gdl.DockItem("frames", "Frames", gdl.DOCK_ITEM_BEH_NORMAL ) widget = gtk.Label("Make an educated guess") frames.add(widget) dock.add_item (frames, gdl.DOCK_BOTTOM) frames.dock_to(canvas, gdl.DOCK_BOTTOM, -1) frames.show_all() #load layout from file if layout.load_from_file('layout.xml'): layout.load_layout('test') pass else: print "Couldn't load layout.xml" hbox = gtk.HBox() hbox.pack_start(dockbar,False,False,0) hbox.pack_start(dock) win.add(hbox) win.connect("destroy", gtk.main_quit) win.connect('delete-event', on_window_delete_event) win.set_title("Sprite Hut GUI Prototype") win.show_all() #layout.run_manager() gtk.main()