本文整理汇总了Python中kano.gtk3.buttons.OrangeButton.set_label方法的典型用法代码示例。如果您正苦于以下问题:Python OrangeButton.set_label方法的具体用法?Python OrangeButton.set_label怎么用?Python OrangeButton.set_label使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kano.gtk3.buttons.OrangeButton
的用法示例。
在下文中一共展示了OrangeButton.set_label方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PageControl
# 需要导入模块: from kano.gtk3.buttons import OrangeButton [as 别名]
# 或者: from kano.gtk3.buttons.OrangeButton import set_label [as 别名]
class PageControl(Gtk.Alignment):
__gsignals__ = {
'back-button-clicked': (GObject.SIGNAL_RUN_FIRST, None, ()),
'next-button-clicked': (GObject.SIGNAL_RUN_FIRST, None, ())
}
def __init__(self,
num_of_pages=3,
selected_page=1,
back_text=_("BACK"),
next_text=_("NEXT")):
Gtk.Alignment.__init__(self, xalign=0.5, xscale=0)
self.num_of_pages = num_of_pages
self.selected = selected_page
self._box = Gtk.Box()
self.add(self._box)
# The back button has subtly different styling to the next button
# When the back button is disabled, it goes invisible, while
# the NEXT button goes grey.
self._back_button = OrangeButton(back_text)
self._back_button.connect('clicked', self.back_button_clicked)
attach_cursor_events(self._back_button)
self._next_button = OrangeButton(next_text)
self._next_button.connect('clicked', self.next_button_clicked)
attach_cursor_events(self._next_button)
self.dot_box = Gtk.Box()
self._create_progress_dots(self.selected)
self._box.pack_start(self._back_button, False, False, 40)
self._box.pack_start(self.dot_box, False, False, 0)
self._box.pack_start(self._next_button, False, False, 40)
if self.selected == 1:
self._back_button.set_sensitive(False)
if self.selected == self.num_of_pages:
self._next_button.set_sensitive(False)
# self.connect('next-button-clicked', self.select_dot)
# self.connect('back-button-clicked', self.select_dot)
@property
def back_button(self):
return self._back_button
@property
def next_button(self):
return self._next_button
def disable_buttons(self):
self._next_button.set_sensitive(False)
self._back_button.set_sensitive(False)
def enable_buttons(self):
self._next_button.set_sensitive(True)
self._back_button.set_sensitive(True)
def enable_next(self):
self._next_button.set_sensitive(True)
def enable_back(self):
self._back_button.set_sensitive(True)
def disable_next(self):
self._next_button.set_sensitive(False)
def disable_back(self):
self._back_button.set_sensitive(False)
def set_back_button_text(self, text):
self._back_button.set_label(text)
def set_next_button_text(self, text):
self._next_button.set_label(text)
def get_back_button(self):
return self._back_button
def get_next_button(self):
return self._next_button
# TODO: these are expanding to fill the parent container.
def _create_progress_dots(self, index):
'''Index is a number from1 to 3, and represents which is
the selected dot (i.e selected page number)
'''
logger.debug("Creating dots")
for child in self.dot_box.get_children():
self.dot_box.remove(child)
for i in range(self.num_of_pages):
if i + 1 == index:
dot = self.selected_dot()
dot.set_margin_left(3)
#.........这里部分代码省略.........
示例2: SetSimpleOverscan
# 需要导入模块: from kano.gtk3.buttons import OrangeButton [as 别名]
# 或者: from kano.gtk3.buttons.OrangeButton import set_label [as 别名]
class SetSimpleOverscan(OverscanTemplate):
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, 100, 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()
def reset(self, widget=None, event=None):
# Restore overscan if any
if self.original_overscan != self.overscan_values:
set_overscan_status(self.original_overscan)
self.t_scale.set_value(self.original_overscan['top'])
def go_to_advanced(self, event=None, arg=None):
# Remove key press handler from screen
self.win.disconnect(self.key_press_handler)
self.win.clear_win()
SetAdvancedOverscan(self.win, self.original_overscan)
def on_key_press(self, widget, event):
# Right arrow (65363)
if not hasattr(event, 'keyval') or event.keyval == Gdk.KEY_Right:
self.overscan_values['top'] += 1
self.overscan_values['bottom'] += 1
self.overscan_values['left'] += 1
self.overscan_values['right'] += 1
set_overscan_status(self.overscan_values)
self.t_scale.set_value(self.overscan_values['top'])
return
# Left arrow (65361)
if not hasattr(event, 'keyval') or event.keyval == Gdk.KEY_Left:
self.overscan_values['top'] -= 1
self.overscan_values['bottom'] -= 1
self.overscan_values['left'] -= 1
self.overscan_values['right'] -= 1
set_overscan_status(self.overscan_values)
self.t_scale.set_value(self.overscan_values['top'])
return
def update_all_values(self, widget):
new_value = str(int(widget.get_value()))
self.t_value.set_text(new_value)