本文整理汇总了Python中kano.gtk3.buttons.KanoButton.set_color方法的典型用法代码示例。如果您正苦于以下问题:Python KanoButton.set_color方法的具体用法?Python KanoButton.set_color怎么用?Python KanoButton.set_color使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kano.gtk3.buttons.KanoButton
的用法示例。
在下文中一共展示了KanoButton.set_color方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __generate_buttons
# 需要导入模块: from kano.gtk3.buttons import KanoButton [as 别名]
# 或者: from kano.gtk3.buttons.KanoButton import set_color [as 别名]
def __generate_buttons(self):
self.buttons = []
kano_button_box = Gtk.Box()
for button in self.button_info:
for argument, value in button_defaults.iteritems():
# Use default info if not provided
if argument not in button:
button[argument] = value
# Create default return values for OK and CANCEL buttons
if argument == "return_value":
if hasattr(button, "label"):
if button["label"] == _("OK"):
button["return_value"] = 0
elif button["label"] == _("CANCEL"):
button["return_value"] = 1
if argument == "color":
if button["label"] == _("CANCEL"):
button["color"] = "red"
color = button["color"]
return_value = button["return_value"]
button_name = button["label"]
button = KanoButton(button_name)
button.set_color(color)
button.connect("button-release-event", self.exit_dialog, return_value)
button.connect("key-release-event", self.exit_dialog, return_value)
self.buttons.append(button)
kano_button_box.pack_start(button, False, False, 6)
return kano_button_box
示例2: BluetoothDeviceItem
# 需要导入模块: from kano.gtk3.buttons import KanoButton [as 别名]
# 或者: from kano.gtk3.buttons.KanoButton import set_color [as 别名]
class BluetoothDeviceItem(Gtk.Box):
__gsignals__ = {
'pairing': (GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, ()),
'done-pairing': (GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, ()),
}
def __init__(self, device):
Gtk.Box.__init__(self, hexpand=True)
self.device = device
device_name = device.name
dev_label = Gtk.Label(device_name, hexpand=True)
dev_label.get_style_context().add_class('normal_label')
self.pack_start(dev_label, False, False, 0)
self._pair_button = KanoButton()
self._set_paired_button_state()
self._pair_button.set_margin_top(10)
self._pair_button.set_margin_bottom(10)
self._pair_button.set_margin_left(10)
self._pair_button.set_margin_right(10)
self._pair_button.connect('clicked', self.pair)
self.pack_start(self._pair_button, False, False, 0)
def _set_paired_button_state(self, *dummy_args, **dummy_kwargs):
if not self.device.connected:
label = _("PAIR")
colour = 'green'
else:
label = _("UNPAIR")
colour = 'red'
self._pair_button.set_label(label)
self._pair_button.set_color(colour)
def error(self, err_msg):
KanoDialog(err_msg).run()
def pair(self, *dummy_args, **dummy_kwargs):
def done_pairing():
self._set_paired_button_state()
self.emit('done-pairing')
@queue_cb(callback=done_pairing, gtk=True)
def do_pair():
if not self.device.fuse():
GObject.idle_add(self.error, _("Pairing failed"))
@queue_cb(callback=done_pairing, gtk=True)
def do_unpair():
if not self.device.unfuse():
GObject.idle_add(self.error, _("Unpairing failed"))
self.emit('pairing')
if self.device.connected:
pair_fn = do_unpair
logger.info("Unpairing {}".format(self.device))
else:
pair_fn = do_pair
logger.info("Pairing {}".format(self.device))
pair_thr = threading.Thread(target=pair_fn)
pair_thr.start()
示例3: NetworkScreen
# 需要导入模块: from kano.gtk3.buttons import KanoButton [as 别名]
# 或者: from kano.gtk3.buttons.KanoButton import set_color [as 别名]
#.........这里部分代码省略.........
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
def skip(self, skip_btn=None):
# Exit with an extreme exit code so the init-flow knows the user
# pressed SKIP
sys.exit(100)
def _set_connect_btn_status(self, connect=True):
self._connect_btn.disconnect(self.connect_handler)
if connect:
self.connect_handler = self._connect_btn.connect(
'clicked', self._first_time_connect
)
self._connect_btn.set_color('green')
self._connect_btn.set_label(_("CONNECT"))
else:
self.connect_handler = self._connect_btn.connect(
'clicked', self._launch_disconnect_thread
)
self._connect_btn.set_color('red')
self._connect_btn.set_label(_("DISCONNECT"))
def _launch_disconnect_thread(self, widget=None):
watch_cursor = Gdk.Cursor(Gdk.CursorType.WATCH)
self._win.get_window().set_cursor(watch_cursor)
self._connect_btn.start_spinner()
self._connect_btn.set_sensitive(False)
# Force the spinner to show on the window.
while Gtk.events_pending():
Gtk.main_iteration()
t = threading.Thread(target=self._threaded_disconnect)
t.start()
def _disconnect_screen(self):
self._win.remove_main_widget()
title = _("Disconnect complete.")
description = _("You're now offline")
buttons = [
{
'label': _("CLOSE"),
'type': 'KanoButton',
'color': 'red',
'callback': Gtk.main_quit