def __init__(self, configuration, channels):
Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)
self.set_homogeneous(False)
self.tool_bar = Gtk.Toolbar()
self.pack_start(self.tool_bar, False, True, 0)
tool = Gtk.ToolButton.new(Gtk.Image.new_from_stock(Gtk.STOCK_ADD, Gtk.IconSize.BUTTON), "Add")
tool.connect("clicked", self.on_add_clicked)
self.tool_bar.insert(tool, -1)
tool = Gtk.ToolButton.new(Gtk.Image.new_from_stock(Gtk.STOCK_DELETE, Gtk.IconSize.BUTTON), "Delete")
tool.connect("clicked", self.on_delete_clicked)
self.tool_bar.insert(tool, -1)
self.content = Gtk.ListBox()
self.scrollTree = Gtk.ScrolledWindow()
self.scrollTree.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
self.scrollTree.add_with_viewport(self.content)
self.scrollTree.set_min_content_height(100)
self.pack_start(self.scrollTree, True, True, 0)
self.configuration = configuration
self.channels = channels
self.sbrick = None
self.functionGroups = []
for group in configuration:
fg = FunctionGroupBox(group, channels)
# self.pack_start(fg, False, True, 0)
self.content.add(fg)
self.functionGroups.append(fg)
python类Toolbar()的实例源码
def __init__(self, configuration, sbrick_communications_store):
Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL, spacing=3, margin=0)
self.set_homogeneous(False)
self.configuration = configuration
self.sbrick_communications_store = sbrick_communications_store
self.tool_bar = Gtk.Toolbar()
self.pack_start(self.tool_bar, False, True, 0)
self.action_play_all = Gtk.ToolButton.new(Gtk.Image.new_from_stock(Gtk.STOCK_MEDIA_PLAY, Gtk.IconSize.BUTTON),
"Play All")
self.action_play_all.connect("clicked", self.on_play_all_clicked)
self.tool_bar.insert(self.action_play_all, -1)
self.action_stop_all = Gtk.ToolButton.new(Gtk.Image.new_from_stock(Gtk.STOCK_MEDIA_STOP, Gtk.IconSize.BUTTON),
"Stop All")
self.action_stop_all.connect("clicked", self.on_stop_all_clicked)
self.tool_bar.insert(self.action_stop_all, -1)
self.content = Gtk.ListBox()
self.scrollTree = Gtk.ScrolledWindow()
self.scrollTree.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
self.scrollTree.add_with_viewport(self.content)
self.scrollTree.set_min_content_height(100)
self.pack_start(self.scrollTree, True, True, 0)
self.sequence_count = 0
if self.configuration is not None:
for sbrick in self.configuration:
stepbox = SequencePlayerBox(sbrick, sbrick_communications_store)
stepbox.connect("sequence_finished", self.on_sequence_finished)
self.content.add(stepbox)
self.sequence_count = self.sequence_count + 1
self.playing = False
self.playing_sequence = None
self.playing_index = -1
def setup_toolbar(self):
self.g_toolbar = Gtk.Toolbar()
self.g_actiongroup.add_actions([
('Add', Gtk.STOCK_ADD, None, None, None, self.on_add_lesson_clicked),
('Remove', Gtk.STOCK_REMOVE, None, None, None, self.on_remove_lesson_clicked),
('Create', Gtk.STOCK_EXECUTE, _("Create Sheet"), None, None, self.on_create_sheet),
('Randomize', None, _("Randomize"), None, None, self.on_randomize),
])
self.g_ui_manager.insert_action_group(self.g_actiongroup, 0)
uixml = """
<ui>
<toolbar name='ExportToolbar'>
<toolitem action='Add'/>
<toolitem action='Remove'/>
<toolitem action='New'/>
<toolitem action='Open'/>
<toolitem action='Save'/>
<toolitem action='SaveAs'/>
<toolitem action='Create'/>
<toolitem action='Randomize'/>
<toolitem action='Close'/>
<toolitem action='Help'/>
</toolbar>
<accelerator action='Close'/>
<accelerator action='New'/>
<accelerator action='Open'/>
<accelerator action='Save'/>
</ui>
"""
self.g_ui_manager.add_ui_from_string(uixml)
self.vbox.pack_start(self.g_ui_manager.get_widget("/ExportToolbar"),
False, False, 0)
self.g_ui_manager.get_widget("/ExportToolbar").set_style(Gtk.ToolbarStyle.BOTH)
def __init__(self, main):
super(LeftButtons,self).__init__(False, 1)
self.main = main
self.prev_size = ()
#################################################################
# Left mini-toolbar
#################################################################
toolbar = Gtk.Toolbar()
toolbar.set_style(Gtk.ToolbarStyle.ICONS)
##################################
# Methods
def create_toolbar_top(self):
toolbar=Gtk.Toolbar()
self.grid.attach(toolbar,0,0,4,1)
##############New_Button#################################################
button_new=Gtk.ToolButton()
button_new.set_icon_name("document-new")
toolbar.insert(button_new,0)
toolbar.insert(Gtk.SeparatorToolItem(),1)
##############Open_Button############################################
button_open=Gtk.ToolButton()
button_open.set_icon_name("document-open")
toolbar.insert(button_open,2)
toolbar.insert(Gtk.SeparatorToolItem(),3)
#############Save_Buton#################################################
button_save=Gtk.ToolButton()
button_save.set_icon_name("document-save")
toolbar.insert(button_save,4)
toolbar.insert(Gtk.SeparatorToolItem(),5)
#########Help_Button#####################################################
button_help=Gtk.ToolButton()
button_help.set_icon_name("help-about")
toolbar.insert(button_help,6)
def _populate_toolbar(self, toolbar, *toolbuttons):
"""
Populate a :class:`Gtk.Toolbar` with several :class:`Gtk.ToolButton`.
.. note:: Tool buttons will be insert into ``toolbar`` following input
arguments order.
"""
for ind, toolbutton in enumerate(toolbuttons):
toolbar.insert(toolbutton, ind)
def __init__(self, section_button):
Gtk.Button.__init__(self)
alignment = Gtk.Alignment.new(0.5, 0.5, 0.0, 1.0)
alignment.set_padding(self.PADDING, self.PADDING,
self.PADDING, self.PADDING)
self.add(alignment)
self.arrow = Gtk.Arrow.new(Gtk.ArrowType.DOWN, Gtk.ShadowType.IN)
alignment.add(self.arrow)
# vars
self.parent_style_type = Gtk.Toolbar
self.section_button = section_button
self.popup = None
self.connect("button-press-event", self.on_button_press)
def __init__(self, section_button):
Gtk.Button.__init__(self)
alignment = Gtk.Alignment.new(0.5, 0.5, 0.0, 1.0)
alignment.set_padding(self.PADDING, self.PADDING,
self.PADDING, self.PADDING)
self.add(alignment)
self.arrow = Gtk.Arrow.new(Gtk.ArrowType.DOWN, Gtk.ShadowType.IN)
alignment.add(self.arrow)
# vars
self.parent_style_type = Gtk.Toolbar
self.section_button = section_button
self.popup = None
self.connect("button-press-event", self.on_button_press)
def __init__(self, configuration):
Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)
self.set_homogeneous(False)
self.sequence_player = None
self.tool_bar = Gtk.Toolbar()
self.pack_start(self.tool_bar, False, True, 0)
self.tool_add = Gtk.ToolButton.new(Gtk.Image.new_from_stock(Gtk.STOCK_ADD, Gtk.IconSize.BUTTON), "Add")
self.tool_add.connect("clicked", self.on_add_clicked)
self.tool_bar.insert(self.tool_add, -1)
self.tool_delete = Gtk.ToolButton.new(Gtk.Image.new_from_stock(Gtk.STOCK_DELETE, Gtk.IconSize.BUTTON), "Delete")
self.tool_delete.connect("clicked", self.on_delete_clicked)
self.tool_bar.insert(self.tool_delete, -1)
self.tool_bar.insert(Gtk.SeparatorToolItem.new(), -1)
self.tool_up = Gtk.ToolButton.new(Gtk.Image.new_from_stock(Gtk.STOCK_GO_UP, Gtk.IconSize.BUTTON), "Add")
self.tool_up.connect("clicked", self.on_up_clicked)
self.tool_bar.insert(self.tool_up, -1)
self.tool_down = Gtk.ToolButton.new(Gtk.Image.new_from_stock(Gtk.STOCK_GO_DOWN, Gtk.IconSize.BUTTON), "Add")
self.tool_down.connect("clicked", self.on_down_clicked)
self.tool_bar.insert(self.tool_down, -1)
self.tool_bar.insert(Gtk.SeparatorToolItem.new(), -1)
self.tool_play = Gtk.ToolButton.new(Gtk.Image.new_from_stock(Gtk.STOCK_MEDIA_PLAY, Gtk.IconSize.BUTTON), "Run")
self.tool_play.connect("clicked", self.on_run_clicked)
self.tool_bar.insert(self.tool_play, -1)
self.enable_tools(True, False)
self.content = Gtk.ListBox()
self.scrollTree = Gtk.ScrolledWindow()
self.scrollTree.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
self.scrollTree.add_with_viewport(self.content)
self.scrollTree.set_min_content_height(100)
self.pack_start(self.scrollTree, True, True, 0)
self.sbrickConfiguration = configuration
self.sbrick = None
self.sequenceSteps = []
if "sequence" in self.sbrickConfiguration:
for step in self.sbrickConfiguration["sequence"]:
stepbox = SequenceStepBox(step, self.sbrickConfiguration["functions"])
self.content.add(stepbox)
self.sequenceSteps.append(stepbox)
else:
self.sbrickConfiguration["sequence"] = []
def __init__(self, view_manager, datadir, db, cache, icons):
Gtk.Toolbar.__init__(self)
context = self.get_style_context()
context.add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR)
# add nav history back/forward buttons...
# note: this is hacky, would be much nicer to make the custom
# self/right buttons in BackForwardButton to be
# Gtk.Activatable/Gtk.Widgets, then wire in the actions using e.g.
# self.navhistory_back_action.connect_proxy(self.back_forward.left),
# but couldn't seem to get this to work..so just wire things up
# directly
vm = get_viewmanager()
self.back_forward = vm.get_global_backforward()
self.back_forward.set_vexpand(False)
self.back_forward.set_valign(Gtk.Align.CENTER)
if self.get_direction() != Gtk.TextDirection.RTL:
_widget_set_margins(self.back_forward,
left=StockEms.MEDIUM,
right=StockEms.MEDIUM + 2)
else:
_widget_set_margins(self.back_forward,
right=StockEms.MEDIUM,
left=StockEms.MEDIUM + 2)
self._insert_as_tool_item(self.back_forward, 0)
# this is what actually draws the All Software, Installed etc buttons
self.view_switcher = ViewSwitcher(view_manager, datadir, db, cache,
icons)
self._insert_as_tool_item(self.view_switcher, 1)
item = Gtk.ToolItem()
item.set_expand(True)
self.insert(item, -1)
#~ self.init_atk_name(self.searchentry, "searchentry")
self.searchentry = vm.get_global_searchentry()
self._insert_as_tool_item(self.searchentry, -1)
# spinner
self.spinner = vm.get_global_spinner()
self.spinner.set_size_request(StockEms.XLARGE, StockEms.XLARGE)
self._insert_as_tool_item(self.spinner, -1)
if self.get_direction() != Gtk.TextDirection.RTL:
_widget_set_margins(self.searchentry, right=StockEms.MEDIUM)
else:
_widget_set_margins(self.searchentry, left=StockEms.MEDIUM)
def __init__(self, view_manager, datadir, db, cache, icons):
Gtk.Toolbar.__init__(self)
context = self.get_style_context()
context.add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR)
# add nav history back/forward buttons...
# note: this is hacky, would be much nicer to make the custom
# self/right buttons in BackForwardButton to be
# Gtk.Activatable/Gtk.Widgets, then wire in the actions using e.g.
# self.navhistory_back_action.connect_proxy(self.back_forward.left),
# but couldn't seem to get this to work..so just wire things up
# directly
vm = get_viewmanager()
self.back_forward = vm.get_global_backforward()
self.back_forward.set_vexpand(False)
self.back_forward.set_valign(Gtk.Align.CENTER)
if self.get_direction() != Gtk.TextDirection.RTL:
_widget_set_margins(self.back_forward,
left=StockEms.MEDIUM,
right=StockEms.MEDIUM + 2)
else:
_widget_set_margins(self.back_forward,
right=StockEms.MEDIUM,
left=StockEms.MEDIUM + 2)
self._insert_as_tool_item(self.back_forward, 0)
# this is what actually draws the All Software, Installed etc buttons
self.view_switcher = ViewSwitcher(view_manager, datadir, db, cache,
icons)
self._insert_as_tool_item(self.view_switcher, 1)
item = Gtk.ToolItem()
item.set_expand(True)
self.insert(item, -1)
#~ self.init_atk_name(self.searchentry, "searchentry")
self.searchentry = vm.get_global_searchentry()
self._insert_as_tool_item(self.searchentry, -1)
# spinner
self.spinner = vm.get_global_spinner()
self.spinner.set_size_request(StockEms.XLARGE, StockEms.XLARGE)
self._insert_as_tool_item(self.spinner, -1)
if self.get_direction() != Gtk.TextDirection.RTL:
_widget_set_margins(self.searchentry, right=StockEms.MEDIUM)
else:
_widget_set_margins(self.searchentry, left=StockEms.MEDIUM)