def _on_add_di_button_clicked(self, button): examples = [('calc', 'calculator', '#!/usr/bin/env python\n\nprint \'Hello!\''), ('file-manager', 'Hi!', 'Hello!'), ('fonts', 'ABC', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'), ('style', 'abc', 'abcdefghijklmnopqrstuvwxyz'), ('web-browser', 'browser', '0123456789'), ('date', 'today', '9876543210')] for i in range(random.randrange(1, 10, 1)): icon_name, tooltip_text, text = random.choice(examples) # Create a TextView and set some example text scrolledwindow = gtk.ScrolledWindow() scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) textview = gtk.TextView() textview.get_buffer().set_text(text) scrolledwindow.add(textview) # Create a DockItem and add our TextView di = DockItem(icon_name=icon_name, title='New %s' % self.file_counter, title_tooltip_text=tooltip_text) di.add(scrolledwindow) di.show_all() # Add out DockItem to the DockGroup self.dg.add(di) # Increment file counter self.file_counter += 1
def _add_dockitems(self, dockgroup): examples = [(gtk.STOCK_EXECUTE, 'calculator', '#!/usr/bin/env python\n\nprint \'Hello!\''), (gtk.STOCK_OPEN, 'Hi!', 'Hello!'), (gtk.STOCK_FILE, 'ABC', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'), (gtk.STOCK_FIND, 'abc', 'abcdefghijklmnopqrstuvwxyz'), (gtk.STOCK_HARDDISK, 'browser', '0123456789'), (gtk.STOCK_HOME, 'today', '9876543210'), gtk.Notebook] for i in [1]: # range(random.randrange(1, 10, 1)): example = random.choice(examples) if example is gtk.Notebook: child = gtk.Notebook() child.append_page(gtk.Button('Click me'), gtk.Label('New %s' % self.file_counter)) stock_id = '' tooltip_text = 'notebook' else: stock_id, tooltip_text, text = example child = self._create_content(text) child.set_name(stock_id) # Create a DockItem and add our TextView di = DockItem(title='New %s' % self.file_counter, title_tooltip_text=tooltip_text, stock_id=stock_id) def on_close(item): print 'close:', item di.connect('close', on_close) di.add(child) di.show_all() # Add out DockItem to the DockGroup dockgroup.add(di) # Increment file counter self.file_counter += 1