本文整理汇总了Python中bb.ui.crumbs.progressbar.HobProgressBar.show方法的典型用法代码示例。如果您正苦于以下问题:Python HobProgressBar.show方法的具体用法?Python HobProgressBar.show怎么用?Python HobProgressBar.show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bb.ui.crumbs.progressbar.HobProgressBar
的用法示例。
在下文中一共展示了HobProgressBar.show方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SanityCheckPage
# 需要导入模块: from bb.ui.crumbs.progressbar import HobProgressBar [as 别名]
# 或者: from bb.ui.crumbs.progressbar.HobProgressBar import show [as 别名]
class SanityCheckPage (HobPage):
def __init__(self, builder):
super(SanityCheckPage, self).__init__(builder)
self.running = False
self.create_visual_elements()
self.show_all()
def make_label(self, text, bold=True):
label = gtk.Label()
label.set_alignment(0.0, 0.5)
mark = "<span %s>%s</span>" % (self.span_tag('x-large', 'bold') if bold else self.span_tag('medium'), text)
label.set_markup(mark)
return label
def start(self):
if not self.running:
self.running = True
gobject.timeout_add(100, self.timer_func)
def stop(self):
self.running = False
def is_running(self):
return self.running
def timer_func(self):
self.progress_bar.pulse()
return self.running
def create_visual_elements(self):
# Table'd layout. 'rows' and 'cols' give the table size
rows, cols = 30, 50
self.table = gtk.Table(rows, cols, True)
self.pack_start(self.table, expand=False, fill=False)
sx, sy = 2, 2
# 'info' icon
image = gtk.Image()
image.set_from_file(hic.ICON_INFO_DISPLAY_FILE)
self.table.attach(image, sx, sx + 3, sy, sy + 3 )
image.show()
# 'Checking' message
label = self.make_label('Checking for correct build system setup')
self.table.attach(label, sx + 3, cols, sy, sy + 3, xpadding=5 )
label.show()
# 'Shouldn't take long' message.
label = self.make_label("The check shouldn't take long.", False)
self.table.attach(label, sx + 3, cols, sy + 3, sy + 4, xpadding=5)
label.show()
# Progress bar
self.progress_bar = HobProgressBar()
self.table.attach(self.progress_bar, sx + 3, cols - 3, sy + 5, sy + 7, xpadding=5)
self.progress_bar.show()
# All done
self.table.show()
示例2: DeployImageDialog
# 需要导入模块: from bb.ui.crumbs.progressbar import HobProgressBar [as 别名]
# 或者: from bb.ui.crumbs.progressbar.HobProgressBar import show [as 别名]
class DeployImageDialog (CrumbsDialog):
__dummy_usb__ = "--select a usb drive--"
def __init__(self, title, image_path, parent, flags, buttons=None):
super(DeployImageDialog, self).__init__(title, parent, flags, buttons)
self.image_path = image_path
self.create_visual_elements()
self.connect("response", self.response_cb)
def create_visual_elements(self):
label = gtk.Label()
label.set_alignment(0.0, 0.5)
markup = "<span font_desc='12'>The image to be written into usb drive:</span>"
label.set_markup(markup)
self.vbox.pack_start(label, expand=False, fill=False, padding=2)
scroll = gtk.ScrolledWindow()
scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
scroll.set_shadow_type(gtk.SHADOW_IN)
tv = gtk.TextView()
tv.set_editable(False)
tv.set_wrap_mode(gtk.WRAP_WORD)
tv.set_cursor_visible(False)
buf = gtk.TextBuffer()
buf.set_text(self.image_path)
tv.set_buffer(buf)
scroll.add(tv)
self.vbox.pack_start(scroll, expand=True, fill=True)
self.usb_desc = gtk.Label()
self.usb_desc.set_alignment(0.0, 0.5)
markup = "<span font_desc='12'>You haven't chosen any USB drive.</span>"
self.usb_desc.set_markup(markup)
self.usb_combo = gtk.combo_box_new_text()
self.usb_combo.connect("changed", self.usb_combo_changed_cb)
model = self.usb_combo.get_model()
model.clear()
self.usb_combo.append_text(self.__dummy_usb__)
for usb in self.find_all_usb_devices():
self.usb_combo.append_text("/dev/" + usb)
self.usb_combo.set_active(0)
self.vbox.pack_start(self.usb_combo, expand=True, fill=True)
self.vbox.pack_start(self.usb_desc, expand=False, fill=False, padding=2)
self.progress_bar = HobProgressBar()
self.vbox.pack_start(self.progress_bar, expand=False, fill=False)
separator = gtk.HSeparator()
self.vbox.pack_start(separator, expand=False, fill=True, padding=10)
self.vbox.show_all()
self.progress_bar.hide()
def popen_read(self, cmd):
return os.popen("%s 2>/dev/null" % cmd).read().strip()
def find_all_usb_devices(self):
usb_devs = [ os.readlink(u)
for u in self.popen_read('ls /dev/disk/by-id/usb*').split()
if not re.search(r'part\d+', u) ]
return [ '%s' % u[u.rfind('/')+1:] for u in usb_devs ]
def get_usb_info(self, dev):
return "%s %s" % \
(self.popen_read('cat /sys/class/block/%s/device/vendor' % dev),
self.popen_read('cat /sys/class/block/%s/device/model' % dev))
def usb_combo_changed_cb(self, usb_combo):
combo_item = self.usb_combo.get_active_text()
if not combo_item or combo_item == self.__dummy_usb__:
markup = "<span font_desc='12'>You haven't chosen any USB drive.</span>"
self.usb_desc.set_markup(markup)
else:
markup = "<span font_desc='12'>" + self.get_usb_info(combo_item.lstrip("/dev/")) + "</span>"
self.usb_desc.set_markup(markup)
def response_cb(self, dialog, response_id):
if response_id == gtk.RESPONSE_YES:
combo_item = self.usb_combo.get_active_text()
if combo_item and combo_item != self.__dummy_usb__:
cmdline = bb.ui.crumbs.utils.which_terminal()
if cmdline:
cmdline += "\"sudo dd if=" + self.image_path + " of=" + combo_item + "\""
subprocess.Popen(args=shlex.split(cmdline))
def update_progress_bar(self, title, fraction, status=None):
self.progress_bar.update(fraction)
self.progress_bar.set_title(title)
self.progress_bar.set_rcstyle(status)
def write_file(self, ifile, ofile):
self.progress_bar.reset()
self.progress_bar.show()
f_from = os.open(ifile, os.O_RDONLY)
f_to = os.open(ofile, os.O_WRONLY)
#.........这里部分代码省略.........
示例3: DeployImageDialog
# 需要导入模块: from bb.ui.crumbs.progressbar import HobProgressBar [as 别名]
# 或者: from bb.ui.crumbs.progressbar.HobProgressBar import show [as 别名]
class DeployImageDialog (CrumbsDialog):
__dummy_usb__ = "--select a usb drive--"
def __init__(self, title, image_path, parent, flags, buttons=None, standalone=False):
super(DeployImageDialog, self).__init__(title, parent, flags, buttons)
self.image_path = image_path
self.standalone = standalone
self.create_visual_elements()
self.connect("response", self.response_cb)
def create_visual_elements(self):
self.set_size_request(600, 400)
label = gtk.Label()
label.set_alignment(0.0, 0.5)
markup = "<span font_desc='12'>The image to be written into usb drive:</span>"
label.set_markup(markup)
self.vbox.pack_start(label, expand=False, fill=False, padding=2)
table = gtk.Table(2, 10, False)
table.set_col_spacings(5)
table.set_row_spacings(5)
self.vbox.pack_start(table, expand=True, fill=True)
scroll = gtk.ScrolledWindow()
scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
scroll.set_shadow_type(gtk.SHADOW_IN)
tv = gtk.TextView()
tv.set_editable(False)
tv.set_wrap_mode(gtk.WRAP_WORD)
tv.set_cursor_visible(False)
self.buf = gtk.TextBuffer()
self.buf.set_text(self.image_path)
tv.set_buffer(self.buf)
scroll.add(tv)
table.attach(scroll, 0, 10, 0, 1)
# There are 2 ways to use DeployImageDialog
# One way is that called by HOB when the 'Deploy Image' button is clicked
# The other way is that called by a standalone script.
# Following block of codes handles the latter way. It adds a 'Select Image' button and
# emit a signal when the button is clicked.
if self.standalone:
gobject.signal_new("select_image_clicked", self, gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE, ())
icon = gtk.Image()
pix_buffer = gtk.gdk.pixbuf_new_from_file(hic.ICON_IMAGES_DISPLAY_FILE)
icon.set_from_pixbuf(pix_buffer)
button = gtk.Button("Select Image")
button.set_image(icon)
#button.set_size_request(140, 50)
table.attach(button, 9, 10, 1, 2, gtk.FILL, 0, 0, 0)
button.connect("clicked", self.select_image_button_clicked_cb)
separator = gtk.HSeparator()
self.vbox.pack_start(separator, expand=False, fill=False, padding=10)
self.usb_desc = gtk.Label()
self.usb_desc.set_alignment(0.0, 0.5)
markup = "<span font_desc='12'>You haven't chosen any USB drive.</span>"
self.usb_desc.set_markup(markup)
self.usb_combo = gtk.combo_box_new_text()
self.usb_combo.connect("changed", self.usb_combo_changed_cb)
model = self.usb_combo.get_model()
model.clear()
self.usb_combo.append_text(self.__dummy_usb__)
for usb in self.find_all_usb_devices():
self.usb_combo.append_text("/dev/" + usb)
self.usb_combo.set_active(0)
self.vbox.pack_start(self.usb_combo, expand=False, fill=False)
self.vbox.pack_start(self.usb_desc, expand=False, fill=False, padding=2)
self.progress_bar = HobProgressBar()
self.vbox.pack_start(self.progress_bar, expand=False, fill=False)
separator = gtk.HSeparator()
self.vbox.pack_start(separator, expand=False, fill=True, padding=10)
self.vbox.show_all()
self.progress_bar.hide()
def set_image_text_buffer(self, image_path):
self.buf.set_text(image_path)
def set_image_path(self, image_path):
self.image_path = image_path
def popen_read(self, cmd):
tmpout, errors = bb.process.run("%s" % cmd)
return tmpout.strip()
def find_all_usb_devices(self):
usb_devs = [ os.readlink(u)
for u in glob.glob('/dev/disk/by-id/usb*')
if not re.search(r'part\d+', u) ]
return [ '%s' % u[u.rfind('/')+1:] for u in usb_devs ]
def get_usb_info(self, dev):
#.........这里部分代码省略.........
示例4: DeployImageDialog
# 需要导入模块: from bb.ui.crumbs.progressbar import HobProgressBar [as 别名]
# 或者: from bb.ui.crumbs.progressbar.HobProgressBar import show [as 别名]
class DeployImageDialog (CrumbsDialog):
__dummy_usb__ = "--select a usb drive--"
def __init__(self, builder, title, image, parent, flags, buttons=None, standalone=False):
super(DeployImageDialog, self).__init__(title, parent, flags, buttons)
self.image = image.split("-clanton-")[0]
self.builder = builder
self.standalone = standalone
self.devices = self.find_all_external_devices()
self.create_visual_elements()
self.connect("response", self.response_cb)
def create_visual_elements(self):
if not self.devices:
self.set_size_request(400, 200)
first_column = gtk.HBox(spacing=6)
first_column.set_property("border-width", 6)
first_column.show()
self.vbox.add(first_column)
icon = gtk.Image()
icon_chk = HobIconChecker()
icon.set_from_stock(icon_chk.check_stock_icon(gtk.STOCK_DIALOG_WARNING), gtk.ICON_SIZE_DIALOG)
icon.set_property("xalign", 0.00)
first_column.pack_start(icon, expand=False, fill=True, padding=0)
label = gtk.Label()
label.set_use_markup(True)
label.set_line_wrap(True)
label.set_markup("<span font_desc='17' weight=\'bold\'>No external storage\ndevice found</span>")
label.set_property("xalign", 0.00)
first_column.add(label)
label = gtk.Label()
label.set_use_markup(True)
label.set_line_wrap(True)
label.set_markup("<span font_desc='12'>Insert an SD card or USB drive before\ndeploying your image</span>")
label.set_property("yalign", 0.00)
self.vbox.add(label)
button = self.add_button("OK", gtk.RESPONSE_CANCEL)
HobAltButton.style_button(button)
else:
self.set_size_request(350, 300)
label = gtk.Label()
label.set_alignment(0.0, 0.5)
markup = "<span font_desc='17' weight=\'bold\'>External storage device</span>"
label.set_markup(markup)
self.vbox.pack_start(label, expand=False, fill=False, padding=2)
self.device_vendor = gtk.Label()
self.device_vendor.set_alignment(0.0, 0.5)
vendor = self.get_vendor_info(self.devices[0])
if vendor is None:
vendor = "Not known"
markup = "<span font_desc='12'>Vendor: %s</span>" % vendor
self.device_vendor.set_markup(markup)
self.device_model = gtk.Label()
self.device_model.set_alignment(0.0, 0.5)
model = self.get_model_info(self.devices[0])
if model is None:
model = "Not known"
markup = "<span font_desc='12'>Model: %s</span>" % model
self.device_model.set_markup(markup)
self.device_size = gtk.Label()
self.device_size.set_alignment(0.0, 0.5)
size = float(self.get_size_info(self.devices[0])) * 512 / 1024 / 1024
if size > 1024:
size = size/1024
markup = "<span font_desc='12'>Size: %.2f GB</span>" % size
else:
markup = "<span font_desc='12'>Size: %.2f MB</span>" % size
self.device_size.set_markup(markup)
if len(self.devices) == 1:
label = gtk.Label()
label.set_alignment(0.0, 0.5)
markup = "<span font_desc='12'>/dev/%s</span>" % self.devices[0]
label.set_markup(markup)
self.vbox.pack_start(label, expand=False, fill=False, padding=2)
else:
self.usb_combo = gtk.combo_box_new_text()
self.usb_combo.connect("changed", self.usb_combo_changed_cb)
model = self.usb_combo.get_model()
model.clear()
for usb in self.devices:
self.usb_combo.append_text("/dev/" + usb)
self.usb_combo.set_active(0)
self.vbox.pack_start(self.usb_combo, expand=False, fill=False)
label = gtk.Label()
label.set_alignment(0.0, 0.5)
markup = "<span font_desc='17' weight=\'bold\'>Device details</span>"
label.set_markup(markup)
self.vbox.pack_start(label, expand=False, fill=False, padding=2)
#.........这里部分代码省略.........