本文整理汇总了Python中gi.repository.Gtk.ButtonBox方法的典型用法代码示例。如果您正苦于以下问题:Python Gtk.ButtonBox方法的具体用法?Python Gtk.ButtonBox怎么用?Python Gtk.ButtonBox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.Gtk
的用法示例。
在下文中一共展示了Gtk.ButtonBox方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __add_orange_button
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ButtonBox [as 别名]
def __add_orange_button(self, orange_info, kano_button_box):
orange_text = orange_info['name']
orange_return_value = orange_info['return_value']
button_container = Gtk.ButtonBox(spacing=10)
button_container.set_layout(Gtk.ButtonBoxStyle.SPREAD)
self.orange_button = OrangeButton(orange_text)
self.orange_button.connect('button-release-event', self.exit_dialog, orange_return_value)
button_container.pack_start(self.orange_button, False, False, 0)
button_container.pack_start(kano_button_box, False, False, 0)
# The empty label is to centre the kano_button
label = Gtk.Label(" ")
button_container.pack_start(label, False, False, 0)
return button_container
示例2: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ButtonBox [as 别名]
def __init__(self, button1_text, orange_button_text=""):
Gtk.ButtonBox.__init__(self, spacing=10)
self.set_layout(Gtk.ButtonBoxStyle.SPREAD)
self.kano_button = KanoButton(button1_text)
if orange_button_text:
self.orange_button = OrangeButton(orange_button_text)
self.pack_start(self.orange_button, False, False, 0)
self.pack_start(self.kano_button, False, False, 0)
# The empty label is to centre the kano_button
self.label = Gtk.Label(" ")
self.pack_start(self.label, False, False, 0)
else:
self.pack_start(self.kano_button, False, False, 0)
# This is a test class to try out different button functions
示例3: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ButtonBox [as 别名]
def __init__(self, title, description, left_btn_text, right_btn_text, buttons_shown):
Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)
self.title = Heading(title, description)
self.title.container.set_margin_bottom(0)
self.sw = ScrolledWindow()
self.sw.apply_styling_to_widget(wide=False)
self.left_button = KanoButton(left_btn_text, color='orange')
self.right_button = KanoButton(right_btn_text, color='green')
kano_button_box = Gtk.ButtonBox()
kano_button_box.set_layout(Gtk.ButtonBoxStyle.CENTER)
kano_button_box.set_spacing(20)
if buttons_shown == 2:
kano_button_box.pack_start(self.left_button, False, False, 0)
kano_button_box.pack_start(self.right_button, False, False, 0)
self.pack_start(self.title.container, False, False, 0)
self.pack_start(self.sw, True, True, 0)
self.pack_end(kano_button_box, False, False, 0)
示例4: build_gui
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ButtonBox [as 别名]
def build_gui(self):
"""
Build the GUI interface.
"""
self.top = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
self.top.set_border_width(6)
self.entry1 = self.__add_text_view(_("Expression 1"))
self.entry2 = self.__add_text_view(_("Expression 2"))
self.result = self.__add_text_view(_("Result"))
bbox = Gtk.ButtonBox()
apply_button = Gtk.Button(label=_("Calculate"))
apply_button.connect('clicked', self.apply_clicked)
bbox.pack_start(apply_button, False, False, 6)
clear_button = Gtk.Button(label=_("Clear"))
clear_button.connect('clicked', self.clear_clicked)
bbox.pack_start(clear_button, False, False, 6)
self.top.pack_start(bbox, False, False, 6)
self.top.show_all()
self.clear_clicked(None)
return self.top
示例5: __create_gui
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ButtonBox [as 别名]
def __create_gui(self):
"""
Create and display the GUI components of the gramplet.
"""
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
vbox.set_spacing(4)
label = Gtk.Label(_('Enter GOV-id:'))
label.set_halign(Gtk.Align.START)
self.entry = Gtk.Entry()
button_box = Gtk.ButtonBox()
button_box.set_layout(Gtk.ButtonBoxStyle.START)
get = Gtk.Button(label=_('Get Place'))
get.connect("clicked", self.__get_places)
button_box.add(get)
vbox.pack_start(label, False, True, 0)
vbox.pack_start(self.entry, False, True, 0)
vbox.pack_start(button_box, False, True, 0)
return vbox
示例6: _fill_bottom_box
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ButtonBox [as 别名]
def _fill_bottom_box(self, box):
"""
Helper function to fill and box with a buttonbox, featuring
and ok and cancel buttons.
@param box: the Gtk.Box to fill
"""
cancel_button = Gtk.Button()
cancel_button.set_label("Cancel")
cancel_button.connect('clicked', self.on_cancel)
self.ok_button = Gtk.Button()
self.ok_button.set_label("OK")
self.ok_button.connect('clicked', self.on_confirm)
align = Gtk.Alignment.new(0.5, 1, 1, 0)
align.set_padding(0, 10, 0, 0)
buttonbox = Gtk.ButtonBox()
buttonbox.set_layout(Gtk.ButtonBoxStyle.EDGE)
buttonbox.add(cancel_button)
buttonbox.set_child_secondary(cancel_button, False)
buttonbox.add(self.ok_button)
align.add(buttonbox)
box.pack_start(align, True, True, 0)
示例7: _create_refresh_connect_buttons
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ButtonBox [as 别名]
def _create_refresh_connect_buttons(self):
'''Create the buttons used for the refresh button and the
to connect to a network, and pack them into a button box.
Returns the button box.
'''
self._connect_btn = KanoButton(_("CONNECT"))
self._connect_btn.pack_and_align()
self.connect_handler = self._connect_btn.connect(
'clicked', self._first_time_connect
)
self._connect_btn.set_sensitive(False)
self._refresh_btn = self._create_refresh_button()
# For now, show both connect and refresh buttons
buttonbox = Gtk.ButtonBox()
buttonbox.set_layout(Gtk.ButtonBoxStyle.CENTER)
buttonbox.set_spacing(10)
buttonbox.pack_start(self._refresh_btn, False, False, 0)
buttonbox.pack_start(self._connect_btn.align, False, False, 0)
if self._win.is_plug():
self._skip_btn = WhiteButton(_("Skip"))
buttonbox.pack_start(self._skip_btn, False, False, 0)
self._skip_btn.connect('clicked', self.skip)
else:
blank_label = Gtk.Label("")
buttonbox.pack_start(blank_label, False, False, 0)
return buttonbox
# Attached to a callback, hence the extra argument
示例8: __create_gui
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ButtonBox [as 别名]
def __create_gui(self):
"""
Create and display the GUI components of the gramplet.
"""
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
self.model = Gtk.ListStore(object, str, str, str, str)
view = Gtk.TreeView(model=self.model)
renderer = Gtk.CellRendererText()
column = Gtk.TreeViewColumn(_("Source"), renderer, text=1)
view.append_column(column)
renderer = Gtk.CellRendererText()
column = Gtk.TreeViewColumn(_("Role"), renderer, text=2)
view.append_column(column)
renderer = Gtk.CellRendererText()
column = Gtk.TreeViewColumn(_("Date"), renderer, text=3)
view.append_column(column)
renderer = Gtk.CellRendererText()
column = Gtk.TreeViewColumn(_("Place"), renderer, text=4)
view.append_column(column)
view.add_events(Gdk.EventMask.BUTTON_PRESS_MASK)
view.connect("button_press_event", self.__list_clicked)
button_box = Gtk.ButtonBox()
button_box.set_layout(Gtk.ButtonBoxStyle.START)
new = Gtk.Button(label=_('_New'), use_underline=True)
new.connect("clicked", self.__new_form)
button_box.add(new)
edit = Gtk.Button(label=_('_Edit'), use_underline=True)
edit.connect("clicked", self.__edit_form, view.get_selection())
button_box.add(edit)
vbox.pack_start(view, expand=True, fill=True, padding=0)
vbox.pack_end(button_box, expand=False, fill=True, padding=4)
return vbox
示例9: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ButtonBox [as 别名]
def __init__(self, title, description, buttons, is_plug=False, img_path=None):
super(Template, self).__init__(orientation=Gtk.Orientation.VERTICAL)
self._focus_widget = None
heading = Heading(
title,
description,
is_plug,
back_btn=False
)
bbox = Gtk.ButtonBox()
bbox.set_spacing(20)
bbox.set_layout(Gtk.ButtonBoxStyle.CENTER)
bbox.set_margin_right(10)
bbox.set_margin_left(10)
for b in buttons:
label = b["label"]
if not label:
gtk_button = Gtk.Label()
else:
button_type = b["type"]
callback = b["callback"]
if button_type == "KanoButton":
color = b["color"]
gtk_button = KanoButton(label, color=color)
elif button_type == "OrangeButton":
gtk_button = OrangeButton(label)
gtk_button.connect("clicked", callback)
bbox.pack_start(gtk_button, False, False, 0)
if "focus" in b:
self._focus_widget = gtk_button
self.pack_start(heading.container, False, False, 0)
heading.container.set_margin_right(15)
heading.container.set_margin_left(15)
if img_path:
image = Gtk.Image.new_from_file(img_path)
if is_plug:
self.pack_start(image, False, False, 10)
self.pack_start(bbox, False, False, 30)
else:
self.pack_start(image, False, False, 20)
self.pack_end(bbox, False, False, 30)
self.show_all()
示例10: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ButtonBox [as 别名]
def __init__(self, win, original_overscan=None):
OverscanTemplate.__init__(
self,
win,
_("Overscan"),
_("This setting lets you adjust your screen's size."),
original_overscan
)
self.win.change_prev_callback(self.go_to_display)
# Listen for key events
self.key_press_handler = self.win.connect('key-press-event', self.on_key_press)
# slider
self.t_value = Gtk.Label()
self.t_value.get_style_context().add_class('slider_label')
self.t_scale = Gtk.HScale.new_with_range(0, get_overscan_limit(), 1)
self.t_scale.set_value(self.overscan_values['top'])
self.t_scale.set_size_request(400, 30)
self.t_scale.connect('value_changed', self.adjust_all)
self.t_scale.connect('value_changed', self.update_all_values)
self.t_scale.set_draw_value(False)
self.update_all_values(self.t_scale)
box = Gtk.Box()
box.pack_start(self.t_scale, False, False, 5)
box.pack_start(self.t_value, False, False, 5)
box.pack_start(self.reset_button, False, False, 25)
align = Gtk.Alignment(xalign=0.6, xscale=0, yscale=0, yalign=0.5)
align.add(box)
# Advance button
self.advanced_button = OrangeButton()
self.advanced_button.connect('button_press_event', self.go_to_advanced)
self.advanced_button.set_label(_("Advanced"))
button_box = Gtk.ButtonBox()
button_box.set_layout(Gtk.ButtonBoxStyle.SPREAD)
button_box.pack_start(self.advanced_button, False, False, 15)
button_box.pack_start(self.kano_button.align, False, False, 15)
empty_label = Gtk.Label(" ")
button_box.pack_start(empty_label, False, False, 0)
self.pack_start(align, True, True, 0)
self.pack_end(button_box, False, False, 30)
self.win.show_all()
示例11: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ButtonBox [as 别名]
def __init__(self):
self.window = Gtk.Window(Gtk.WindowType.TOPLEVEL, title=_("Ask for permissions"))
self.window.set_transient_for(mainwindow())
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
gtk_version = (Gtk.get_major_version(), Gtk.get_minor_version())
if gtk_version >= (3, 12):
vbox.props.margin_start = 9
vbox.props.margin_end = 9
else:
vbox.props.margin_left = 9
vbox.props.margin_right = 9
vbox.props.margin_bottom = 9
self.window.add(vbox)
uistuff.keepWindowSize("externalsdialog", self.window, (320, 240), uistuff.POSITION_CENTER)
label = Gtk.Label(_("Some PyChess features require further permission in order to download external components"))
vbox.pack_start(label, True, True, 0)
box = Gtk.Box()
check_button = Gtk.CheckButton(_("database querying needs scoutfish"))
check_button.set_active(conf.get("download_scoutfish"))
check_button.connect("toggled", lambda w: conf.set("download_scoutfish", w.get_active()))
box.add(check_button)
link = "https://github.com/pychess/scoutfish"
link_button = Gtk.LinkButton(link, link)
box.add(link_button)
vbox.pack_start(box, False, False, 0)
box = Gtk.Box()
check_button = Gtk.CheckButton(_("database opening tree needs chess_db"))
check_button.set_active(conf.get("download_chess_db"))
check_button.connect("toggled", lambda w: conf.set("download_chess_db", w.get_active()))
box.add(check_button)
link = "https://github.com/pychess/chess_db"
link_button = Gtk.LinkButton(link, link)
box.add(link_button)
vbox.pack_start(box, False, False, 0)
box = Gtk.Box()
check_button = Gtk.CheckButton(_("ICC lag compensation needs timestamp"))
check_button.set_active(conf.get("download_timestamp"))
check_button.connect("toggled", lambda w: conf.set("download_timestamp", w.get_active()))
box.add(check_button)
link = "http://download.chessclub.com/timestamp/"
link_button = Gtk.LinkButton(link, link)
box.add(link_button)
vbox.pack_start(box, False, False, 0)
check_button = Gtk.CheckButton(_("Don't show this dialog on startup."))
check_button.set_active(conf.get("dont_show_externals_at_startup"))
check_button.connect("toggled", lambda w: conf.set("dont_show_externals_at_startup", w.get_active()))
vbox.pack_start(check_button, True, True, 0)
buttonbox = Gtk.ButtonBox()
close_button = Gtk.Button.new_from_stock(Gtk.STOCK_OK)
close_button.connect("clicked", self.on_close_clicked)
self.window.connect("delete_event", lambda w, a: self.window.destroy())
buttonbox.add(close_button)
vbox.pack_start(buttonbox, False, False, 0)
示例12: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ButtonBox [as 别名]
def __init__(self):
Gtk.Window.__init__(self, title='MessageBar Demo')
self.set_default_size(400, 200)
self.connect('destroy', Gtk.main_quit)
style_provider = Gtk.CssProvider()
style_provider.load_from_path(os.path.join('..', "themes/style.css"))
Gtk.StyleContext.add_provider_for_screen(
Gdk.Screen.get_default(), style_provider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
)
self.overlay = Gtk.Overlay()
self.add(self.overlay)
button_box = Gtk.ButtonBox()
button_box.set_halign(Gtk.Align.FILL)
button_box.set_valign(Gtk.Align.END)
button_box.set_layout(Gtk.ButtonBoxStyle.EXPAND)
button_box.set_margin_bottom(5)
# Show info message button
btn = Gtk.Button('Info')
btn.connect('clicked', self.show_info)
button_box.add(btn)
# Show warning message button
btn = Gtk.Button('Warning')
btn.connect('clicked', self.show_warning)
button_box.add(btn)
# Show error message button
btn = Gtk.Button('Error')
btn.connect('clicked', self.show_error)
button_box.add(btn)
# Show question message button
btn = Gtk.Button('Question')
btn.connect('clicked', self.show_question)
button_box.add(btn)
self.overlay.add(button_box)
self.message_bar = MessageBar()
self.overlay.add_overlay(self.message_bar)
self.show_all()
Gtk.main()