def __init__(self): self.__labels = [] self.__values = [0] * 4 Window.__init__(self, Window.TYPE_DIALOG) self.set_flag(windowflags.EXCLUSIVE, True) self.connect_closed(self.__on_close) self.__hbox = HBox() self.__hbox.set_spacing(12) self.add(self.__hbox) for item in ["h1", "h2", ":", "m1", "m2"]: if (item == ":"): lbl = Label(":", theme.font_sleeptimer_clocksetter, theme.color_mb_text) lbl.set_alignment(lbl.CENTERED) self.__hbox.add(lbl, True) else: vbox = VBox() vbox.set_spacing(12) vbox.set_halign(VBox.HALIGN_CENTER) self.__hbox.add(vbox, True) btn = Button(_UP_ARROW) btn.set_size(80, 80) btn.connect_clicked(self.__on_btn_down, item) vbox.add(btn, False) lbl = Label("0", theme.font_sleeptimer_clocksetter, theme.color_mb_text) lbl.set_alignment(lbl.CENTERED) vbox.add(lbl, True) self.__labels.append(lbl) btn = Button(_DOWN_ARROW) btn.set_size(80, 80) btn.connect_clicked(self.__on_btn_up, item) vbox.add(btn, False)
class DeviceDialog(Widget): def __init__(self, uuid, label): #self.__last_rotate = 0 # throbber pixbuf #self.__throbber = None #self.__throbber_width = 0 #self.__throbber_height = 0 # number of frames in throbber animation #self.__number_of_frames = 0 #self.__current_frame = 0 self.uuid = uuid self.__save_under = Pixmap(None, _WIDTH, _HEIGHT) self.__buffer = Pixmap(None, _WIDTH, _HEIGHT) Widget.__init__(self) self.set_size(_WIDTH, 200) self.__label = Label(label, theme.font_mb_plain, theme.color_mb_panel_text) self.__label.set_alignment(self.__label.CENTERED) self.__label.set_pos(10, 10) self.__label.set_size(_WIDTH - 20, 0) self.add(self.__label) """def set_throbber(self, throbber): self.__throbber = throbber self.__throbber_height = throbber.get_height() self.__throbber_width = self.__throbber_height self.__current_frame = 0 self.__number_of_frames = throbber.get_width() / self.__throbber_width w, h = self.get_size() h = self.__throbber_height + 60 self.set_size(w, h) self.__label.set_pos(10, self.__throbber_height + 20) self.__save_under = Pixmap(None, w, h) self.__buffer = Pixmap(None, w, h)""" """def set_text(self, text): self.__label.set_text(text)""" def render_this(self): parent = self.get_parent() px, py = parent.get_screen_pos() pw, ph = parent.get_size() w, h = self.get_size() screen = self.get_screen() x = (pw - w) / 2 y = (ph - h) / 2 self.set_pos(x, y) x, y = self.get_screen_pos() screen.draw_frame(theme.mb_panel, x, y, w, h, True) self.__save_under.copy_buffer(screen, x, y, 0, 0, w, h) #self.__render_current() """def __render_current(self): x, y = self.get_screen_pos() w, h = self.get_size() screen = self.get_screen() self.__buffer.copy_pixmap(self.__save_under, 0, 0, 0, 0, w, h) if (self.__throbber): tx = (w - self.__throbber_width) / 2 ty = 10 frame_offset = self.__current_frame * self.__throbber_width self.__buffer.draw_subpixbuf(self.__throbber, frame_offset, 0, tx, ty, self.__throbber_width, self.__throbber_height) if (self.may_render()): screen.copy_pixmap(self.__buffer, tx, ty, x + tx, y + ty, self.__throbber_width, self.__throbber_height)""" """def rotate(self): now = time.time() if (now - self.__last_rotate > 0.05): self.__render_current() self.__current_frame += 1 self.__current_frame %= self.__number_of_frames while(gtk.events_pending()): gtk.main_iteration() self.__last_rotate = now #end if""" def set_visible(self, value): if (not value): time.sleep(0.25) self.set_events_blocked(value) Widget.set_visible(self, value)