def __init__(self, parent, doc_path, page_num, w, h, zoom=1.0): self.doc_path = doc_path self.page_num = page_num self.in_viewport = False evas = parent.evas super(Page, self).__init__(evas, self.SMART, parent=parent) self.page_num_label = Label(parent, text=str(page_num + 1)) self.bg = Rectangle(evas, color=(255, 255, 255, 255)) self.member_add(self.bg) self.bg.show() self.orig_w = float(w) self.orig_h = float(h) w = float(w) * zoom h = float(h) * zoom self.pv_img = FilledImage(evas, load_dpi=1, load_size=(w / 2, h / 2)) self.member_add(self.pv_img) self.pv_img.on_image_preloaded_add(self.pv_preloaded) self.hq_img = FilledImage(evas, load_dpi=1, load_size=(w * 2, h * 2)) self.member_add(self.hq_img) self.hq_img.on_image_preloaded_add(self.hq_preloaded, self.pv_img) self.size_hint_min = w, h self.pass_events = True
def __init__(self, parent, color, tag_name): elm.Frame.__init__(self, parent, style='pad_small', propagate_events=False) self._rect = Rectangle(self.evas, color=color) self._rect.on_mouse_down_add(lambda o, i: self._popup_build()) self.content = self._rect self._tag_name = tag_name
def core_evas_canvas_callbacks_clicked(obj, item=None): win = StandardWindow("evascanvascbs", "Evas canvas callbacks", autodel=True, size=(320, 320)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) text = Text(win.evas, text="Events printed on console", size=(300, 30), color=(0, 0, 0, 255)) text.font_set("Sans", 12) text.pos = (10, 10) text.show() canvas = win.evas_get() canvas.event_callback_add(EVAS_CALLBACK_CANVAS_FOCUS_IN, events_cb1, "EVAS_CALLBACK_CANVAS_FOCUS_IN") canvas.event_callback_add(EVAS_CALLBACK_CANVAS_FOCUS_OUT, events_cb1, "EVAS_CALLBACK_CANVAS_FOCUS_OUT") canvas.event_callback_add(EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN, events_cb2, "EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN") canvas.event_callback_add(EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT, events_cb2, "EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT") canvas.event_callback_add(EVAS_CALLBACK_RENDER_FLUSH_PRE, events_cb1, "EVAS_CALLBACK_RENDER_FLUSH_PRE") canvas.event_callback_add(EVAS_CALLBACK_RENDER_FLUSH_POST, events_cb1, "EVAS_CALLBACK_RENDER_FLUSH_POST") canvas.event_callback_add(EVAS_CALLBACK_RENDER_PRE, events_cb1, "EVAS_CALLBACK_RENDER_PRE") canvas.event_callback_add(EVAS_CALLBACK_RENDER_POST, events_cb1, "EVAS_CALLBACK_RENDER_POST") r2 = Rectangle(win.evas, size=(120, 70), color=(0, 100, 0, 100), pos=(70, 70)) r2.show() hbox = Box(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, horizontal=True) win.resize_object_add(hbox) hbox.show() b = Button(win, text="del cbs", size_hint_align=(0.5, 1.0)) hbox.pack_end(b) b.callback_clicked_add(btn_del_cbs_cb) b.show() win.show()
def __init__(self, win): global screen_size, global_offset self.win = win SmartObject.__init__(self, win.evas) self.bg = Rectangle( win.evas, pos=TOP_LEFT, size=screen_size, color=BLUE) self.bg.layer = 0 self.member_add(self.bg) self.eyes = Eyes(win) self.eyes.layer = 1 self.eyes.move(global_offset[0], global_offset[1]) self.eyes.stack_above(self.bg) self.member_add(self.eyes) self.mustache = Mustache(win, ( global_offset[0] + 200, global_offset[1] + 380 ) ) #print "mustache.move to", (global_offset[0] + 200, global_offset[1] + 380) #self.mustache.move( global_offset[0] + 200, global_offset[1] + 380 ) self.mustache.layer = 5 self.mustache.stack_above(self.eyes) self.member_add(self.mustache) self.color_set(*BLUE) self.standard() self.eyes.eyeballs.move(0,0) self.show() self.anim_standard() self.bubbles={}
def __init__(self, parent, color, tag_name): elm.Frame.__init__(self, parent, style='pad_small', propagate_events=False) self._rect = Rectangle(self.evas, color=color) self._rect.on_mouse_down_add(lambda o,i: self._popup_build()) self.content = self._rect self._tag_name = tag_name
def _file_change(self): # hack to make popup respect min_size rect = Rectangle(self.parent.evas, size_hint_min=(400, 400)) tb = elm.Table(self.parent) tb.pack(rect, 0, 0, 1, 1) # show the fileselector inside a popup popup = elm.Popup(self.top_widget, content=tb) popup.part_text_set('title,text', 'Choose the Todo.txt file to use') popup.show() # the fileselector widget fs = elm.Fileselector(popup, is_save=False, expandable=False, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) fs.callback_activated_add(self._file_change_done, popup) fs.callback_done_add(self._file_change_done, popup) try: fs.selected = options.txt_file except: fs.path = os.path.expanduser('~') fs.show() tb.pack(fs, 0, 0, 1, 1)
def __init__(self, parent, doc_path, page_num, w, h, zoom=1.0): self.doc_path = doc_path self.page_num = page_num self.in_viewport = False evas = parent.evas super(Page, self).__init__(evas, self.SMART, parent=parent) self.page_num_label = Label(parent, text=str(page_num + 1)) self.bg = Rectangle(evas, color=(255, 255, 255, 255)) self.member_add(self.bg) self.bg.show() self.orig_w = float(w) self.orig_h = float(h) w = float(w) * zoom h = float(h) * zoom self.pv_img = FilledImage(evas, load_dpi=1, load_size=(w/2, h/2)) self.member_add(self.pv_img) self.pv_img.on_image_preloaded_add(self.pv_preloaded) self.hq_img = FilledImage(evas, load_dpi=1, load_size=(w*2, h*2)) self.member_add(self.hq_img) self.hq_img.on_image_preloaded_add(self.hq_preloaded, self.pv_img) self.size_hint_min = w, h self.pass_events = True
def core_evas_canvas_callbacks_clicked(obj, item=None): win = StandardWindow("evascanvascbs", "Evas canvas callbacks", autodel=True, size=(320,320)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) text = Text(win.evas, text="Events printed on console", size=(300, 30), color=(0,0,0,255)) text.font_set("Sans", 12) text.pos = (10, 10) text.show() canvas = win.evas_get() canvas.event_callback_add(EVAS_CALLBACK_CANVAS_FOCUS_IN, events_cb1, "EVAS_CALLBACK_CANVAS_FOCUS_IN") canvas.event_callback_add(EVAS_CALLBACK_CANVAS_FOCUS_OUT, events_cb1, "EVAS_CALLBACK_CANVAS_FOCUS_OUT") canvas.event_callback_add(EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN, events_cb2, "EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN") canvas.event_callback_add(EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT, events_cb2, "EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT") canvas.event_callback_add(EVAS_CALLBACK_RENDER_FLUSH_PRE, events_cb1, "EVAS_CALLBACK_RENDER_FLUSH_PRE") canvas.event_callback_add(EVAS_CALLBACK_RENDER_FLUSH_POST, events_cb1, "EVAS_CALLBACK_RENDER_FLUSH_POST") canvas.event_callback_add(EVAS_CALLBACK_RENDER_PRE, events_cb1, "EVAS_CALLBACK_RENDER_PRE") canvas.event_callback_add(EVAS_CALLBACK_RENDER_POST, events_cb1, "EVAS_CALLBACK_RENDER_POST") r2 = Rectangle(win.evas, size=(120,70), color=(0,100,0,100), pos=(70,70)) r2.show() hbox = Box(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, horizontal=True) win.resize_object_add(hbox) hbox.show() b = Button(win, text="del cbs", size_hint_align=(0.5, 1.0)) hbox.pack_end(b) b.callback_clicked_add(btn_del_cbs_cb) b.show() win.show()
class ColorRect(elm.Frame): def __init__(self, parent, color, tag_name): elm.Frame.__init__(self, parent, style='pad_small', propagate_events=False) self._rect = Rectangle(self.evas, color=color) self._rect.on_mouse_down_add(lambda o, i: self._popup_build()) self.content = self._rect self._tag_name = tag_name def _popup_build(self): popup = elm.Popup(self.top_widget) popup.part_text_set('title,text', 'Choose the color for %s' % self._tag_name) popup.callback_block_clicked_add(lambda p: popup.delete()) cs = elm.Colorselector(popup, color=self._rect.color) cs.callback_changed_add(lambda s: setattr(rect, 'color', cs.color)) popup.content = cs rect = Rectangle(popup.evas, color=self._rect.color) frame = elm.Frame(popup, style='pad_small', content=rect) popup.part_content_set('button1', frame) bt = elm.Button(popup, text='Accept') bt.callback_clicked_add(self._popup_accept_cb, popup, cs) popup.part_content_set('button2', bt) bt = elm.Button(popup, text='Cancel') bt.callback_clicked_add(lambda b: popup.delete()) popup.part_content_set('button3', bt) popup.show() def _popup_accept_cb(self, obj, popup, colorselector): self._rect.color = colorselector.color options.tag_colors[self._tag_name] = self._rect.color popup.delete()
class ColorRect(elm.Frame): def __init__(self, parent, color, tag_name): elm.Frame.__init__(self, parent, style='pad_small', propagate_events=False) self._rect = Rectangle(self.evas, color=color) self._rect.on_mouse_down_add(lambda o,i: self._popup_build()) self.content = self._rect self._tag_name = tag_name def _popup_build(self): popup = elm.Popup(self.top_widget) popup.part_text_set('title,text', 'Choose the color for %s' % self._tag_name) popup.callback_block_clicked_add(lambda p: popup.delete()) cs = elm.Colorselector(popup, color=self._rect.color) cs.callback_changed_add(lambda s: setattr(rect, 'color', cs.color)) popup.content = cs rect = Rectangle(popup.evas, color=self._rect.color) frame = elm.Frame(popup, style='pad_small', content=rect) popup.part_content_set('button1', frame) bt = elm.Button(popup, text='Accept') bt.callback_clicked_add(self._popup_accept_cb, popup, cs) popup.part_content_set('button2', bt) bt = elm.Button(popup, text='Cancel') bt.callback_clicked_add(lambda b: popup.delete()) popup.part_content_set('button3', bt) popup.show() def _popup_accept_cb(self, obj, popup, colorselector): self._rect.color = colorselector.color options.tag_colors[self._tag_name] = self._rect.color popup.delete()
def __init__(self, parent, session): self.session = session conf = session.conf PreferencesDialog.__init__(self, "General") limits = Limits(self, session) ports = ListenPorts(self, session) pe = EncryptionSettings(self, session) dlsel = DataStorageSelector(self, conf) pad = Rectangle(self.evas) pad.color = 0, 0, 0, 0 pad.size_hint_min = 0, 10 sep1 = Separator(self) sep1.horizontal = True chk1 = Check(self) chk1.size_hint_align = 0.0, 0.0 chk1.text = "Delete original .torrent file when added" chk1.state = conf.getboolean("Settings", "delete_original") chk1.callback_changed_add(lambda x: conf.set("Settings", "delete_original", str(bool(chk1.state)))) chk2 = Check(self) chk2.size_hint_align = 0.0, 0.0 chk2.text = "Ask for confirmation on exit" chk2.state = conf.getboolean("Settings", "confirmations") chk2.callback_changed_add(lambda x: conf.set("Settings", "confirmations", str(bool(chk2.state)))) sep2 = Separator(self) sep2.horizontal = True for w in ports, limits, dlsel, pe, pad, sep1, chk1, chk2, sep2: w.show() self.box.pack_end(w)
def __init__(self, parent, session): self.session = session conf = session.conf PreferencesDialog.__init__(self, "General") limits = Limits(self, session) ports = ListenPorts(self, session) pe = EncryptionSettings(self, session) dlsel = DataStorageSelector(self, conf) pad = Rectangle(self.evas) pad.color = 0, 0, 0, 0 pad.size_hint_min = 0, 10 sep1 = Separator(self) sep1.horizontal = True chk1 = Check(self) chk1.size_hint_align = 0.0, 0.0 chk1.text = "Delete original .torrent file when added" chk1.state = conf.getboolean("Settings", "delete_original") chk1.callback_changed_add(lambda x: conf.set( "Settings", "delete_original", str(bool(chk1.state)))) chk2 = Check(self) chk2.size_hint_align = 0.0, 0.0 chk2.text = "Ask for confirmation on exit" chk2.state = conf.getboolean("Settings", "confirmations") chk2.callback_changed_add(lambda x: conf.set( "Settings", "confirmations", str(bool(chk2.state)))) sep2 = Separator(self) sep2.horizontal = True for w in ports, limits, dlsel, pe, pad, sep1, chk1, chk2, sep2: w.show() self.box.pack_end(w)
def core_evas_objects_clicked(obj, item=None): win = StandardWindow("evasobjects", "Evas Objects Test", autodel=True) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) rect = Rectangle(win.evas, size=(120,70), color=(0,100,0,100), pos=(70,70)) rect.show() line = Line(win.evas, start=(20,40), end=(200,100), color=(255,0,0,255)) line.show() text = Text(win.evas, text="Evas Text Object", size=(300, 30), color=(0,0,0,255)) text.font_set("Sans", 16) text.pos = (40, 20) text.show() poly = Polygon(win.evas, color=(200, 0, 200, 200)) poly.point_add(10,100) poly.point_add(100,120) poly.point_add(20,30) poly.show() win.resize(320, 320) win.show()
def _popup_build(self): popup = elm.Popup(self.top_widget) popup.part_text_set('title,text', 'Choose the color for %s' % self._tag_name) popup.callback_block_clicked_add(lambda p: popup.delete()) cs = elm.Colorselector(popup, color=self._rect.color) cs.callback_changed_add(lambda s: setattr(rect, 'color', cs.color)) popup.content = cs rect = Rectangle(popup.evas, color=self._rect.color) frame = elm.Frame(popup, style='pad_small', content=rect) popup.part_content_set('button1', frame) bt = elm.Button(popup, text='Accept') bt.callback_clicked_add(self._popup_accept_cb, popup, cs) popup.part_content_set('button2', bt) bt = elm.Button(popup, text='Cancel') bt.callback_clicked_add(lambda b: popup.delete()) popup.part_content_set('button3', bt) popup.show()
def __init__(self, parent, min_size=(0,0)): Table.__init__(self, parent, size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH) self._entry = Entry(self, scrollable=True, editable=False, line_wrap=ELM_WRAP_NONE, size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH) self._wheel = Progressbar(self, style='wheel', pulse_mode=True, size_hint_expand=EXPAND_BOTH) self._rect = Rectangle(self.evas, size_hint_min=min_size, size_hint_expand=EXPAND_BOTH, color=(0,0,0,0)) self.pack(self._entry, 0, 0, 1, 1) self.pack(self._rect, 0, 0, 1, 1) self.pack(self._wheel, 0, 0, 1, 1) self._last_was_carriage = False self._entry.show() self._rect.show() self.show()
def __init__(self, win): global screen_size, global_offset SmartObject.__init__(self, win.evas) self.name = "eyes" eye_size = screen_size self.origin = eye_pos = global_offset # white underlay behind eyes self.underlay = Rectangle(win.evas, pos=TOP_LEFT, size=eye_size, color=WHITE) self.underlay.layer = 0 self.member_add(self.underlay) # eyeballs self.eyeballs = EyeBalls(win, self) #self.eyeballs.layer = 2 self.member_add(self.eyeballs) #self.eyeballs.stack_above(self.underlay) # first load images to retrieve eye size self.images = [Image(win, pos=TOP_LEFT, size=eye_size, file=os.path.join(img_path, 'oeil-' + str(i) + '.png')) for i in range(1, 12)] # print "eyes image list", self.images self.eyes = self.images[0] for i in range(0, 11): self.member_add(self.images[i]) self.images[i].layer = 3 self.images[i].stack_above(self.underlay) self.images[i].stack_above(self.eyeballs) Transformable.__init__(self, self.eyes) self.clip_set(Rectangle(win.evas, pos=TOP_LEFT, size=eye_size, color=BLUE)) self.show()
def menu_clicked(obj): win = StandardWindow("menu", "Menu test", autodel=True, size=(350, 200)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) rect = Rectangle(win.evas_get(), color=(0, 0, 0, 0)) win.resize_object_add(rect) rect.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND rect.show() menu = Menu(win) item = menu.item_add(None, "first item", "clock") item = menu.item_add(None, "second item", "mail-send") menu_populate_1(menu, item) menu.item_add(item, "sub menu", "refresh") rect.event_callback_add(EVAS_CALLBACK_MOUSE_DOWN, menu_show, menu) win.show()
class CommandOutputEntry(Table): def __init__(self, parent, min_size=(0,0)): Table.__init__(self, parent, size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH) self._entry = Entry(self, scrollable=True, editable=False, line_wrap=ELM_WRAP_NONE, size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH) self._wheel = Progressbar(self, style='wheel', pulse_mode=True, size_hint_expand=EXPAND_BOTH) self._rect = Rectangle(self.evas, size_hint_min=min_size, size_hint_expand=EXPAND_BOTH, color=(0,0,0,0)) self.pack(self._entry, 0, 0, 1, 1) self.pack(self._rect, 0, 0, 1, 1) self.pack(self._wheel, 0, 0, 1, 1) self._last_was_carriage = False self._entry.show() self._rect.show() self.show() @property def text(self): return self._entry.text @text.setter def text(self, text): self._entry.text = text def pulse_start(self): self._rect.repeat_events = False self._wheel.pulse(True) self._wheel.show() def pulse_stop(self): self._rect.repeat_events = True self._wheel.pulse(False) self._wheel.hide() def successfull(self): self._entry.entry_append('<success>Operation successfully completed.</success><br>') def failure(self): self._entry.entry_append('<failure>Error! Something goes wrong.</failure><br>') def error_set(self, text): self._entry.text = '<failure>Error:</failure><br>%s' % text def append_raw(self, line, sep=None): if self._last_was_carriage is True: self._entry.cursor_selection_begin() self._entry.cursor_line_end_set() self._entry.cursor_selection_end() self._entry.entry_insert('') if sep == '\n': self._entry.entry_append(line + '<br>') self._entry.cursor_end_set() self._last_was_carriage = False elif sep == '\r': self._entry.entry_append(line) self._last_was_carriage = True else: self._entry.entry_append(line) self._last_was_carriage = False
def main_loop(): win = StandardWindow("WLX42 Eyes", "Eyes of the robot", autodel=True) win.callback_delete_request_add(lambda o: elementary.exit()) bg = Rectangle(win.evas, size = screenSize, color=(0,0,100,255), pos=(0,0)) #bg.clip = Rectangle(win.evas, size = screenSize, color=(0,0,100,255), pos=(0,100) ) bg.show() underlay = Rectangle(win.evas, pos=global_offset, size = screenSize, color=(255,255,255,255)) underlay.show() eyes = Image(win, size = screenSize, pos=global_offset, file=os.path.join(img_path, "oeil-1.png")) #overlay.clip = Image(win, size = screenSize, pos=(0,0), file=os.path.join(img_path, "mb.png")) #overlay.clip.show() eyes.clip = Rectangle(win.evas, size = screenSize, color=(0,0,100,255), pos=(0,0) ) eyes.clip.show() eyes.show() mustache = Image(win, size=screenSize, pos=global_offset, file=os.path.join(img_path, "moustaches.png")) mustache.clip = Rectangle(win.evas, size = screenSize, color=(0,0,100,255), pos=(0,0) ) mustache.clip.show() mustache.stack_above(eyes) mustache.show() bubble_pos = (0,100) bubble_size = (2*106, 2*159) bubble = Image(win, size = bubble_size, pos=bubble_pos, file=os.path.join(img_path, "bulle.png")) bubble.clip = Rectangle(win.evas, size = bubble_size, color=(255,255,255,200), pos=bubble_pos ) bubble.clip.show() bubble.stack_above(eyes) bubble.show() bubble_text_pos=(bubble_pos[0]+10, bubble_pos[1]+10) bubble_text = Text(win.evas, text='', color=(255,255,255,255), pos=bubble_text_pos, size=(180,180)) bubble_text.font_source = font_path bubble_text.font = "FontAwesome", 150 bubble_text.style = EVAS_TEXT_STYLE_SOFT_SHADOW bubble_text.shadow_color = (64,64,64,127) bubble_text.stack_above(bubble) bubble_text.show() # bx = Box(win) # win.resize_object_add(bx) # bx.size_hint_weight = EXPAND_BOTH # bx.show() # lb.show() # lb = Label(win, text="Blah, Blah, Blah") # lb2 = Label(win, text="Tut, Tut, Tut!") # bb = Bubble(win, text = "Message 1", content = lb, # pos = ELM_BUBBLE_POS_TOP_LEFT, size_hint_weight = EXPAND_BOTH, # size_hint_align = FILL_BOTH) # bb.part_text_set("info", "Corner: top_left") # bb.part_content_set("icon", ic) # bx.pack_end(bb) # bb.show() eyeballs = Image(win, size = eyeballs_size, pos=eyeballs_pos, file=os.path.join(img_path, "retine_sim.png")) blink = Image(win, size = screenSize, pos = global_offset, file=os.path.join(img_path, "oeil-11.png")) blink.clip = eyes.clip; dead = Image(win, size = screenSize, pos = global_offset, file=os.path.join(img_path, "oeil-10.png")) #eyes eyeballs.stack_below(eyes) eyeballs.show() def on_tick(*args, **kargs): draw(win, bg, eyeballs, eyes, blink) return True Animator(on_tick) draw(win, bg, eyeballs, eyes, blink) win.resize(screenX, screenY) win.show()
def colorselector_clicked(obj): win = StandardWindow("colorselector", "ColorSelector test", autodel=True, size=(350, 350)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) vbox = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(vbox) vbox.show() re = Rectangle(win.evas) re.size_hint_min = (1, 100) re.show() fr = Frame(win, text="Color View", content=re, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) vbox.pack_end(fr) fr.show() cs = Colorselector(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, color=(255, 160, 132, 255)) cs.callback_changed_add(cb_cs_changed, re) cs.callback_color_item_selected_add(cb_cs_item_sel, re) cs.callback_color_item_longpressed_add(cb_cs_item_lp, re) cs.show() fr = Frame(win, text="Color Selector", content=cs, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) vbox.pack_end(fr) fr.show() re.color = cs.color cs.palette_color_add(255, 90, 18, 255) cs.palette_color_add(255, 213, 0, 255) cs.palette_color_add(146, 255, 11, 255) cs.palette_color_add(9, 186, 10, 255) cs.palette_color_add(86, 201, 242, 255) cs.palette_color_add(18, 83, 128, 255) cs.palette_color_add(140, 53, 238, 255) cs.palette_color_add(255, 145, 145, 255) cs.palette_color_add(255, 59, 119, 255) cs.palette_color_add(133, 100, 69, 255) cs.palette_color_add(255, 255, 119, 255) cs.palette_color_add(133, 100, 255, 255) last_item = cs.palette_items_get()[-1] last_item.color = (255, 0, 0, 255) hbox = Box(win, horizontal=True, size_hint_align=FILL_AND_ALIGN_TOP, size_hint_weight=EXPAND_HORIZ) vbox.pack_end(hbox) hbox.show() bt = Button(win, text="Palette", size_hint_align=FILL_AND_ALIGN_TOP, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(lambda btn: cs.mode_set(ELM_COLORSELECTOR_PALETTE)) hbox.pack_end(bt) bt.show() bt = Button(win, text="Components", size_hint_align=FILL_AND_ALIGN_TOP, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add( lambda btn: cs.mode_set(ELM_COLORSELECTOR_COMPONENTS)) hbox.pack_end(bt) bt.show() bt = Button(win, text="Both", size_hint_align=FILL_AND_ALIGN_TOP, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(lambda btn: cs.mode_set(ELM_COLORSELECTOR_BOTH)) hbox.pack_end(bt) bt.show() hbox = Box(win, horizontal=True, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_HORIZ) vbox.pack_end(hbox) hbox.show() bt = Button(win, text="palette items", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(palette_items, cs) hbox.pack_end(bt) bt.show() bt = Button(win, text="palette selected item", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(selected_item_get, cs) hbox.pack_end(bt) bt.show() win.show()
def colorselector_clicked(obj): win = StandardWindow("colorselector", "ColorSelector test", autodel=True, size=(350,350)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) vbox = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(vbox) vbox.show() re = Rectangle(win.evas) re.size_hint_min = (1, 100) re.show() fr = Frame(win, text="Color View", content=re, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) vbox.pack_end(fr) fr.show() cs = Colorselector(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, color=(255, 160, 132, 255)) cs.callback_changed_add(cb_cs_changed, re) cs.callback_color_item_selected_add(cb_cs_item_sel, re) cs.callback_color_item_longpressed_add(cb_cs_item_lp, re) cs.show() fr = Frame(win, text="Color Selector", content=cs, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) vbox.pack_end(fr) fr.show() re.color = cs.color cs.palette_color_add(255, 90, 18, 255) cs.palette_color_add(255, 213, 0, 255) cs.palette_color_add(146, 255, 11, 255) cs.palette_color_add(9, 186, 10, 255) cs.palette_color_add(86, 201, 242, 255) cs.palette_color_add(18, 83, 128, 255) cs.palette_color_add(140, 53, 238, 255) cs.palette_color_add(255, 145, 145, 255) cs.palette_color_add(255, 59, 119, 255) cs.palette_color_add(133, 100, 69, 255) cs.palette_color_add(255, 255, 119, 255) cs.palette_color_add(133, 100, 255, 255) last_item = cs.palette_items_get()[-1] last_item.color = (255, 0, 0, 255) hbox = Box(win, horizontal=True, size_hint_align=FILL_AND_ALIGN_TOP, size_hint_weight=EXPAND_HORIZ) vbox.pack_end(hbox) hbox.show() bt = Button(win, text="Palette", size_hint_align=FILL_AND_ALIGN_TOP, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(lambda btn: cs.mode_set(ELM_COLORSELECTOR_PALETTE)) hbox.pack_end(bt) bt.show() bt = Button(win, text="Components", size_hint_align=FILL_AND_ALIGN_TOP, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(lambda btn: cs.mode_set(ELM_COLORSELECTOR_COMPONENTS)) hbox.pack_end(bt) bt.show() bt = Button(win, text="Both", size_hint_align=FILL_AND_ALIGN_TOP, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(lambda btn: cs.mode_set(ELM_COLORSELECTOR_BOTH)) hbox.pack_end(bt) bt.show() hbox = Box(win, horizontal=True, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_HORIZ) vbox.pack_end(hbox) hbox.show() bt = Button(win, text="palette items", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(palette_items, cs) hbox.pack_end(bt) bt.show() bt = Button(win, text="palette selected item", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(selected_item_get, cs) hbox.pack_end(bt) bt.show() win.show()
def genlist_clicked(obj, item=None): win = StandardWindow("Genlist", "Genlist test", autodel=True) bx = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(bx) bx.show() gl = Genlist(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) gl.callback_selected_add(_gl_selected, "arg1", "arg2", kwarg1="kwarg1", kwarg2="kwarg2") gl.callback_clicked_double_add(_gl_clicked_double, "arg1", "arg2", kwarg1="kwarg1", kwarg2="kwarg2") gl.callback_longpressed_add(_gl_longpressed, "arg1", "arg2", kwarg1="kwarg1", kwarg2="kwarg2") bx.pack_end(gl) gl.show() over = Rectangle(win.evas_get()) over.color_set(0, 0, 0, 0) over.event_callback_add(evas.EVAS_CALLBACK_MOUSE_DOWN, _gl_over_click, gl) over.repeat_events_set(True) over.show() over.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND) win.resize_object_add(over) vbx = Box(win, horizontal=True) bx.pack_end(vbx) vbx.show() itc1 = GenlistItemClass(item_style="default", text_get_func=gl_text_get, content_get_func=gl_content_get, state_get_func=gl_state_get) bt_50 = Button(win, text="Go to 50") vbx.pack_end(bt_50) bt_50.show() bt_1500 = Button(win, text="Go to 1500") vbx.pack_end(bt_1500) bt_1500.show() for i in range(0, 2000): gli = gl.item_append(itc1, i, func=gl_item_sel) if i == 50: bt_50._callback_add("clicked", lambda bt, it: it.bring_in(), gli) elif i == 1500: bt_1500._callback_add("clicked", lambda bt, it: it.bring_in(), gli) win.resize(480, 800) win.show()
def __init__(self, parent, session): self.parent = parent self.session = session elm_conf = Configuration() scale = elm_conf.scale self.log = logging.getLogger("epour.gui") self.torrentitems = {} win = self.win = StandardWindow("epour", "Epour") win.callback_delete_request_add(lambda x: elm.exit()) win.screen_constrain = True win.size = 480 * scale, 400 * scale mbox = Box(win) mbox.size_hint_weight = 1.0, 1.0 win.resize_object_add(mbox) mbox.show() tb = Toolbar(win) tb.homogeneous = False tb.shrink_mode = ELM_TOOLBAR_SHRINK_NONE tb.select_mode = ELM_OBJECT_SELECT_MODE_NONE tb.size_hint_align = -1.0, 0.0 tb.menu_parent = win item = tb.item_append("document-new", "Add torrent", lambda t,i: self.select_torrent()) def pause_session(it): self.session.pause() it.state_set(it.state_next()) def resume_session(it): session.resume() del it.state item = tb.item_append("media-playback-pause", "Pause Session", lambda tb, it: pause_session(it)) item.state_add("media-playback-start", "Resume Session", lambda tb, it: resume_session(it)) item = tb.item_append("preferences-system", "Preferences") item.menu = True item.menu.item_add(None, "General", "preferences-system", lambda o,i: PreferencesGeneral(self, self.session)) item.menu.item_add(None, "Proxy", "preferences-system", lambda o,i: PreferencesProxy(self, self.session)) item.menu.item_add(None, "Session", "preferences-system", lambda o,i: PreferencesSession(self, self.session)) item = tb.item_append("application-exit", "Exit", lambda tb, it: elm.exit()) mbox.pack_start(tb) tb.show() self.tlist = tlist = Genlist(win) tlist.select_mode = ELM_OBJECT_SELECT_MODE_NONE tlist.mode = ELM_LIST_COMPRESS tlist.callback_activated_add(self.item_activated_cb) tlist.homogeneous = True tlist.size_hint_weight = 1.0, 1.0 tlist.size_hint_align = -1.0, -1.0 tlist.show() mbox.pack_end(tlist) pad = Rectangle(win.evas) pad.size_hint_weight = 1.0, 1.0 p = Panel(win) p.color = 200,200,200,200 p.size_hint_weight = 1.0, 1.0 p.size_hint_align = -1.0, -1.0 p.orient = ELM_PANEL_ORIENT_BOTTOM p.content = SessionStatus(win, session) p.hidden = True p.show() topbox = Box(win) topbox.horizontal = True topbox.size_hint_weight = 1.0, 1.0 win.resize_object_add(topbox) topbox.pack_end(pad) topbox.pack_end(p) topbox.stack_above(mbox) topbox.show() session.alert_manager.callback_add( "torrent_added_alert", self.torrent_added_cb) session.alert_manager.callback_add( "torrent_removed_alert", self.torrent_removed_cb) for a_name in "torrent_paused_alert", "torrent_resumed_alert": session.alert_manager.callback_add(a_name, self.update_icon) session.alert_manager.callback_add( "state_changed_alert", self.state_changed_cb) Timer(15.0, lambda: session.alert_manager.callback_add( "torrent_finished_alert", self.torrent_finished_cb))
class Page(SmartObject): SMART = PageSmart() SIZE_MIN = 50 def __init__(self, parent, doc_path, page_num, w, h, zoom=1.0): self.doc_path = doc_path self.page_num = page_num self.in_viewport = False evas = parent.evas super(Page, self).__init__(evas, self.SMART, parent=parent) self.page_num_label = Label(parent, text=str(page_num + 1)) self.bg = Rectangle(evas, color=(255, 255, 255, 255)) self.member_add(self.bg) self.bg.show() self.orig_w = float(w) self.orig_h = float(h) w = float(w) * zoom h = float(h) * zoom self.pv_img = FilledImage(evas, load_dpi=1, load_size=(w/2, h/2)) self.member_add(self.pv_img) self.pv_img.on_image_preloaded_add(self.pv_preloaded) self.hq_img = FilledImage(evas, load_dpi=1, load_size=(w*2, h*2)) self.member_add(self.hq_img) self.hq_img.on_image_preloaded_add(self.hq_preloaded, self.pv_img) self.size_hint_min = w, h self.pass_events = True def zoom_set(self, value): old_size = self.size_hint_min new_size = [(i * value) for i in (self.orig_w, self.orig_h)] if ( (old_size[0] >= self.SIZE_MIN or old_size[1] >= self.SIZE_MIN) and (new_size[0] < self.SIZE_MIN or new_size[1] < self.SIZE_MIN)): return self.pv_img.load_size = [ (i * value / 2) for i in (self.orig_w, self.orig_h) ] self.hq_img.load_size = [ (i * value * 2) for i in (self.orig_w, self.orig_h) ] self.size_hint_min = new_size def hq_preloaded(self, hq_img, pv_img): log.debug("preloaded hq %d", self.page_num) pv_img.hide() hq_img.show() def pv_preloaded(self, pv_img): log.debug("preloaded pv %d", self.page_num) pv_img.show() for img in (self.hq_img,): img.file = (self.doc_path, str(self.page_num)) img.preload() log.debug("preloading hq %d", self.page_num)
def grid_clicked(obj): win = StandardWindow("grid", "Grid test", autodel=True, size=(480, 480)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) gd = Grid(win, size=(100, 100), size_hint_weight=EXPAND_BOTH) win.resize_object_add(gd) gd.show() en = Entry(win, scrollable=True, text="Entry text 2", single_line=True) gd.pack(en, 60, 20, 30, 10) en.show() bt = Button(win, text="Next API function", disabled=True) gd.pack(bt, 30, 0, 40, 10) bt.disabled = True bt.show() bt = Button(win, text="Button") gd.pack(bt, 0, 0, 20, 20) bt.show() bt = Button(win, text="Button") gd.pack(bt, 10, 10, 40, 20) bt.show() bt = Button(win, text="Button") gd.pack(bt, 10, 30, 20, 50) bt.show() bt = Button(win, text="Button") gd.pack(bt, 80, 80, 20, 20) bt.show() bt = Button(win, text="Change") bt.callback_clicked_add(cb_change) gd.pack(bt, 40, 40, 20, 20) bt.show() re = Rectangle(win.evas, color=(128, 0, 0, 128)) gd.pack(re, 40, 70, 20, 10) re.show() re = Rectangle(win.evas, color=(0, 128, 0, 128)) gd.pack(re, 60, 70, 10, 10) re.show() re = Rectangle(win.evas, color=(0, 0, 128, 128)) gd.pack(re, 40, 80, 10, 10) re.show() re = Rectangle(win.evas, color=(128, 0, 128, 128)) gd.pack(re, 50, 80, 10, 10) re.show() re = Rectangle(win.evas, color=(128, 64, 0, 128)) gd.pack(re, 60, 80, 10, 10) re.show() win.show()
def __init__(self, parent, session): self.parent = parent self.session = session elm_conf = Configuration() scale = elm_conf.scale self.log = logging.getLogger("epour.gui") self.torrentitems = {} win = self.win = StandardWindow("epour", "Epour") win.callback_delete_request_add(lambda x: elm.exit()) win.screen_constrain = True win.size = 480 * scale, 400 * scale mbox = Box(win) mbox.size_hint_weight = 1.0, 1.0 win.resize_object_add(mbox) mbox.show() tb = Toolbar(win) tb.homogeneous = False tb.shrink_mode = ELM_TOOLBAR_SHRINK_NONE tb.select_mode = ELM_OBJECT_SELECT_MODE_NONE tb.size_hint_align = -1.0, 0.0 tb.menu_parent = win item = tb.item_append("document-new", "Add torrent", lambda t, i: self.select_torrent()) def pause_session(it): self.session.pause() it.state_set(it.state_next()) def resume_session(it): session.resume() del it.state item = tb.item_append("media-playback-pause", "Pause Session", lambda tb, it: pause_session(it)) item.state_add("media-playback-start", "Resume Session", lambda tb, it: resume_session(it)) item = tb.item_append("preferences-system", "Preferences") item.menu = True item.menu.item_add(None, "General", "preferences-system", lambda o, i: PreferencesGeneral(self, self.session)) item.menu.item_add(None, "Proxy", "preferences-system", lambda o, i: PreferencesProxy(self, self.session)) item.menu.item_add(None, "Session", "preferences-system", lambda o, i: PreferencesSession(self, self.session)) item = tb.item_append("application-exit", "Exit", lambda tb, it: elm.exit()) mbox.pack_start(tb) tb.show() self.tlist = tlist = Genlist(win) tlist.select_mode = ELM_OBJECT_SELECT_MODE_NONE tlist.mode = ELM_LIST_COMPRESS tlist.callback_activated_add(self.item_activated_cb) tlist.homogeneous = True tlist.size_hint_weight = 1.0, 1.0 tlist.size_hint_align = -1.0, -1.0 tlist.show() mbox.pack_end(tlist) pad = Rectangle(win.evas) pad.size_hint_weight = 1.0, 1.0 p = Panel(win) p.color = 200, 200, 200, 200 p.size_hint_weight = 1.0, 1.0 p.size_hint_align = -1.0, -1.0 p.orient = ELM_PANEL_ORIENT_BOTTOM p.content = SessionStatus(win, session) p.hidden = True p.show() topbox = Box(win) topbox.horizontal = True topbox.size_hint_weight = 1.0, 1.0 win.resize_object_add(topbox) topbox.pack_end(pad) topbox.pack_end(p) topbox.stack_above(mbox) topbox.show() session.alert_manager.callback_add("torrent_added_alert", self.torrent_added_cb) session.alert_manager.callback_add("torrent_removed_alert", self.torrent_removed_cb) for a_name in "torrent_paused_alert", "torrent_resumed_alert": session.alert_manager.callback_add(a_name, self.update_icon) session.alert_manager.callback_add("state_changed_alert", self.state_changed_cb) Timer( 15.0, lambda: session.alert_manager.callback_add( "torrent_finished_alert", self.torrent_finished_cb))
def core_evas_object_callbacks_clicked(obj, item=None): win = StandardWindow("evas3d", "Evas object callbacks", autodel=True, size=(320,320)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) text = Text(win.evas, text="Events printed on console", size=(300, 30), color=(0,0,0,255)) text.font_set("Sans", 12) text.pos = (10, 10) text.show() r = Rectangle(win.evas, size=(100,100), color=(100,0,0,200), pos=(50,50)) r.event_callback_add(EVAS_CALLBACK_MOUSE_IN, events_cb2, "EVAS_CALLBACK_MOUSE_IN") r.event_callback_add(EVAS_CALLBACK_MOUSE_OUT, events_cb2, "EVAS_CALLBACK_MOUSE_OUT") r.event_callback_add(EVAS_CALLBACK_MOUSE_DOWN, events_cb2, "EVAS_CALLBACK_MOUSE_DOWN") r.event_callback_add(EVAS_CALLBACK_MOUSE_UP, events_cb2, "EVAS_CALLBACK_MOUSE_UP") r.event_callback_add(EVAS_CALLBACK_MOUSE_MOVE, events_cb2, "EVAS_CALLBACK_MOUSE_MOVE") r.event_callback_add(EVAS_CALLBACK_MOUSE_WHEEL, events_cb2, "EVAS_CALLBACK_MOUSE_WHEEL") r.event_callback_add(EVAS_CALLBACK_MULTI_DOWN, events_cb2, "EVAS_CALLBACK_MULTI_DOWN") r.event_callback_add(EVAS_CALLBACK_MULTI_UP, events_cb2, "EVAS_CALLBACK_MULTI_UP") r.event_callback_add(EVAS_CALLBACK_MULTI_MOVE, events_cb2, "EVAS_CALLBACK_MULTI_MOVE") r.event_callback_add(EVAS_CALLBACK_FREE, events_cb1, "EVAS_CALLBACK_FREE") r.event_callback_add(EVAS_CALLBACK_KEY_DOWN, events_cb2, "EVAS_CALLBACK_KEY_DOWN") r.event_callback_add(EVAS_CALLBACK_KEY_UP, events_cb2, "EVAS_CALLBACK_KEY_UP") r.event_callback_add(EVAS_CALLBACK_FOCUS_IN, events_cb2, "EVAS_CALLBACK_FOCUS_IN") r.event_callback_add(EVAS_CALLBACK_FOCUS_OUT, events_cb2, "EVAS_CALLBACK_FOCUS_OUT") r.event_callback_add(EVAS_CALLBACK_SHOW, events_cb1, "EVAS_CALLBACK_SHOW") r.event_callback_add(EVAS_CALLBACK_HIDE, events_cb1, "EVAS_CALLBACK_HIDE") r.event_callback_add(EVAS_CALLBACK_MOVE, events_cb1, "EVAS_CALLBACK_MOVE") r.event_callback_add(EVAS_CALLBACK_RESIZE, events_cb1, "EVAS_CALLBACK_RESIZE") r.event_callback_add(EVAS_CALLBACK_RESTACK, events_cb1, "EVAS_CALLBACK_RESTACK") r.event_callback_add(EVAS_CALLBACK_DEL, events_cb1, "EVAS_CALLBACK_DEL") r.event_callback_add(EVAS_CALLBACK_HOLD, events_cb1, "EVAS_CALLBACK_HOLD") r.event_callback_add(EVAS_CALLBACK_CHANGED_SIZE_HINTS, events_cb1, "EVAS_CALLBACK_CHANGED_SIZE_HINTS") r.event_callback_add(EVAS_CALLBACK_IMAGE_PRELOADED, events_cb1, "EVAS_CALLBACK_IMAGE_PRELOADED") r.event_callback_add(EVAS_CALLBACK_IMAGE_UNLOADED, events_cb1, "EVAS_CALLBACK_IMAGE_UNLOADED") ## r.event_callback_add(EVAS_CALLBACK_CANVAS_FOCUS_IN, events_cb1, "EVAS_CALLBACK_CANVAS_FOCUS_IN") ## r.event_callback_add(EVAS_CALLBACK_CANVAS_FOCUS_OUT, events_cb1, "") ## r.event_callback_add(EVAS_CALLBACK_RENDER_FLUSH_PRE, events_cb1, "") ## r.event_callback_add(EVAS_CALLBACK_RENDER_FLUSH_POST, events_cb1, "") ## r.event_callback_add(EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN, events_cb1, "") ## r.event_callback_add(EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT, events_cb1, "") ## r.event_callback_add(EVAS_CALLBACK_RENDER_PRE, events_cb1, "") ## r.event_callback_add(EVAS_CALLBACK_RENDER_POST, events_cb1, "") #? r.event_callback_add(EVAS_CALLBACK_IMAGE_RESIZE, events_cb1, "") #? r.event_callback_add(EVAS_CALLBACK_DEVICE_CHANGED, events_cb1, "") r.show() r2 = Rectangle(win.evas, size=(120,70), color=(0,100,0,100), pos=(70,70)) r2.show() hbox = Box(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, horizontal=True) win.resize_object_add(hbox) hbox.show() b = Button(win, text="show / hide", size_hint_align=(0.5, 1.0)) hbox.pack_end(b) b.callback_clicked_add(lambda b, r: r.hide() if r.visible else r.show(), r) b.show() b = Button(win, text="move", size_hint_align=(0.5, 1.0)) hbox.pack_end(b) b.callback_clicked_add(lambda b, t: r.pos_set(r.pos[0] + 1, r.pos[1]), r) b.show() b = Button(win, text="resize", size_hint_align=(0.5, 1.0)) hbox.pack_end(b) b.callback_clicked_add(lambda b, r: r.size_set(r.size[0] + 1, r.size[1] + 1), r) b.show() b = Button(win, text="delete", size_hint_align=(0.5, 1.0)) hbox.pack_end(b) b.callback_clicked_add(lambda b, r: r.delete(), r) b.show() b = Button(win, text="raise", size_hint_align=(0.5, 1.0)) hbox.pack_end(b) b.callback_clicked_add(lambda b, r: r.raise_(), r) b.show() b = Button(win, text="hints", size_hint_align=(0.5, 1.0)) hbox.pack_end(b) b.callback_clicked_add(lambda b, r: r.size_hint_align_set(0.0, 0.0), r) b.show() b = Button(win, text="del cbs", size_hint_align=(0.5, 1.0)) hbox.pack_end(b) b.callback_clicked_add(btn_del_cbs_cb, r) b.show() win.show()
class Page(SmartObject): SMART = PageSmart() SIZE_MIN = 50 def __init__(self, parent, doc_path, page_num, w, h, zoom=1.0): self.doc_path = doc_path self.page_num = page_num self.in_viewport = False evas = parent.evas super(Page, self).__init__(evas, self.SMART, parent=parent) self.page_num_label = Label(parent, text=str(page_num + 1)) self.bg = Rectangle(evas, color=(255, 255, 255, 255)) self.member_add(self.bg) self.bg.show() self.orig_w = float(w) self.orig_h = float(h) w = float(w) * zoom h = float(h) * zoom self.pv_img = FilledImage(evas, load_dpi=1, load_size=(w / 2, h / 2)) self.member_add(self.pv_img) self.pv_img.on_image_preloaded_add(self.pv_preloaded) self.hq_img = FilledImage(evas, load_dpi=1, load_size=(w * 2, h * 2)) self.member_add(self.hq_img) self.hq_img.on_image_preloaded_add(self.hq_preloaded, self.pv_img) self.size_hint_min = w, h self.pass_events = True def zoom_set(self, value): old_size = self.size_hint_min new_size = [(i * value) for i in (self.orig_w, self.orig_h)] if ((old_size[0] >= self.SIZE_MIN or old_size[1] >= self.SIZE_MIN) and (new_size[0] < self.SIZE_MIN or new_size[1] < self.SIZE_MIN)): return self.pv_img.load_size = [(i * value / 2) for i in (self.orig_w, self.orig_h)] self.hq_img.load_size = [(i * value * 2) for i in (self.orig_w, self.orig_h)] self.size_hint_min = new_size def hq_preloaded(self, hq_img, pv_img): log.debug("preloaded hq %d", self.page_num) pv_img.hide() hq_img.show() def pv_preloaded(self, pv_img): log.debug("preloaded pv %d", self.page_num) pv_img.show() for img in (self.hq_img, ): img.file = (self.doc_path, str(self.page_num)) img.preload() log.debug("preloading hq %d", self.page_num)
def core_evas_object_callbacks_clicked(obj, item=None): win = StandardWindow("evas3d", "Evas object callbacks", autodel=True, size=(320, 320)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) text = Text(win.evas, text="Events printed on console", size=(300, 30), color=(0, 0, 0, 255)) text.font_set("Sans", 12) text.pos = (10, 10) text.show() r = Rectangle(win.evas, size=(100, 100), color=(100, 0, 0, 200), pos=(50, 50)) r.event_callback_add(EVAS_CALLBACK_MOUSE_IN, events_cb2, "EVAS_CALLBACK_MOUSE_IN") r.event_callback_add(EVAS_CALLBACK_MOUSE_OUT, events_cb2, "EVAS_CALLBACK_MOUSE_OUT") r.event_callback_add(EVAS_CALLBACK_MOUSE_DOWN, events_cb2, "EVAS_CALLBACK_MOUSE_DOWN") r.event_callback_add(EVAS_CALLBACK_MOUSE_UP, events_cb2, "EVAS_CALLBACK_MOUSE_UP") r.event_callback_add(EVAS_CALLBACK_MOUSE_MOVE, events_cb2, "EVAS_CALLBACK_MOUSE_MOVE") r.event_callback_add(EVAS_CALLBACK_MOUSE_WHEEL, events_cb2, "EVAS_CALLBACK_MOUSE_WHEEL") r.event_callback_add(EVAS_CALLBACK_MULTI_DOWN, events_cb2, "EVAS_CALLBACK_MULTI_DOWN") r.event_callback_add(EVAS_CALLBACK_MULTI_UP, events_cb2, "EVAS_CALLBACK_MULTI_UP") r.event_callback_add(EVAS_CALLBACK_MULTI_MOVE, events_cb2, "EVAS_CALLBACK_MULTI_MOVE") r.event_callback_add(EVAS_CALLBACK_FREE, events_cb1, "EVAS_CALLBACK_FREE") r.event_callback_add(EVAS_CALLBACK_KEY_DOWN, events_cb2, "EVAS_CALLBACK_KEY_DOWN") r.event_callback_add(EVAS_CALLBACK_KEY_UP, events_cb2, "EVAS_CALLBACK_KEY_UP") r.event_callback_add(EVAS_CALLBACK_FOCUS_IN, events_cb2, "EVAS_CALLBACK_FOCUS_IN") r.event_callback_add(EVAS_CALLBACK_FOCUS_OUT, events_cb2, "EVAS_CALLBACK_FOCUS_OUT") r.event_callback_add(EVAS_CALLBACK_SHOW, events_cb1, "EVAS_CALLBACK_SHOW") r.event_callback_add(EVAS_CALLBACK_HIDE, events_cb1, "EVAS_CALLBACK_HIDE") r.event_callback_add(EVAS_CALLBACK_MOVE, events_cb1, "EVAS_CALLBACK_MOVE") r.event_callback_add(EVAS_CALLBACK_RESIZE, events_cb1, "EVAS_CALLBACK_RESIZE") r.event_callback_add(EVAS_CALLBACK_RESTACK, events_cb1, "EVAS_CALLBACK_RESTACK") r.event_callback_add(EVAS_CALLBACK_DEL, events_cb1, "EVAS_CALLBACK_DEL") r.event_callback_add(EVAS_CALLBACK_HOLD, events_cb1, "EVAS_CALLBACK_HOLD") r.event_callback_add(EVAS_CALLBACK_CHANGED_SIZE_HINTS, events_cb1, "EVAS_CALLBACK_CHANGED_SIZE_HINTS") r.event_callback_add(EVAS_CALLBACK_IMAGE_PRELOADED, events_cb1, "EVAS_CALLBACK_IMAGE_PRELOADED") r.event_callback_add(EVAS_CALLBACK_IMAGE_UNLOADED, events_cb1, "EVAS_CALLBACK_IMAGE_UNLOADED") ## r.event_callback_add(EVAS_CALLBACK_CANVAS_FOCUS_IN, events_cb1, "EVAS_CALLBACK_CANVAS_FOCUS_IN") ## r.event_callback_add(EVAS_CALLBACK_CANVAS_FOCUS_OUT, events_cb1, "") ## r.event_callback_add(EVAS_CALLBACK_RENDER_FLUSH_PRE, events_cb1, "") ## r.event_callback_add(EVAS_CALLBACK_RENDER_FLUSH_POST, events_cb1, "") ## r.event_callback_add(EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN, events_cb1, "") ## r.event_callback_add(EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT, events_cb1, "") ## r.event_callback_add(EVAS_CALLBACK_RENDER_PRE, events_cb1, "") ## r.event_callback_add(EVAS_CALLBACK_RENDER_POST, events_cb1, "") #? r.event_callback_add(EVAS_CALLBACK_IMAGE_RESIZE, events_cb1, "") #? r.event_callback_add(EVAS_CALLBACK_DEVICE_CHANGED, events_cb1, "") r.show() r2 = Rectangle(win.evas, size=(120, 70), color=(0, 100, 0, 100), pos=(70, 70)) r2.show() hbox = Box(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, horizontal=True) win.resize_object_add(hbox) hbox.show() b = Button(win, text="show / hide", size_hint_align=(0.5, 1.0)) hbox.pack_end(b) b.callback_clicked_add(lambda b, r: r.hide() if r.visible else r.show(), r) b.show() b = Button(win, text="move", size_hint_align=(0.5, 1.0)) hbox.pack_end(b) b.callback_clicked_add(lambda b, t: r.pos_set(r.pos[0] + 1, r.pos[1]), r) b.show() b = Button(win, text="resize", size_hint_align=(0.5, 1.0)) hbox.pack_end(b) b.callback_clicked_add( lambda b, r: r.size_set(r.size[0] + 1, r.size[1] + 1), r) b.show() b = Button(win, text="delete", size_hint_align=(0.5, 1.0)) hbox.pack_end(b) b.callback_clicked_add(lambda b, r: r.delete(), r) b.show() b = Button(win, text="raise", size_hint_align=(0.5, 1.0)) hbox.pack_end(b) b.callback_clicked_add(lambda b, r: r.raise_(), r) b.show() b = Button(win, text="hints", size_hint_align=(0.5, 1.0)) hbox.pack_end(b) b.callback_clicked_add(lambda b, r: r.size_hint_align_set(0.0, 0.0), r) b.show() b = Button(win, text="del cbs", size_hint_align=(0.5, 1.0)) hbox.pack_end(b) b.callback_clicked_add(btn_del_cbs_cb, r) b.show() win.show()
class Face(SmartObject): def __init__(self, win): global screen_size, global_offset self.win = win SmartObject.__init__(self, win.evas) self.bg = Rectangle( win.evas, pos=TOP_LEFT, size=screen_size, color=BLUE) self.bg.layer = 0 self.member_add(self.bg) self.eyes = Eyes(win) self.eyes.layer = 1 self.eyes.move(global_offset[0], global_offset[1]) self.eyes.stack_above(self.bg) self.member_add(self.eyes) self.mustache = Mustache(win, ( global_offset[0] + 200, global_offset[1] + 380 ) ) #print "mustache.move to", (global_offset[0] + 200, global_offset[1] + 380) #self.mustache.move( global_offset[0] + 200, global_offset[1] + 380 ) self.mustache.layer = 5 self.mustache.stack_above(self.eyes) self.member_add(self.mustache) self.color_set(*BLUE) self.standard() self.eyes.eyeballs.move(0,0) self.show() self.anim_standard() self.bubbles={} #self.anim_sleep() #print "bg", self.bg #print "eyes", self.eyes def show(self): self.bg.show() self.eyes.show() self.mustache.show() def hide(self): self.bg.hide() self.eyes.hide() self.mustache.hide() def color_set(self, r, g, b, a): color = (r, g, b, a) self.bg.color = color self.eyes.color_set(r, g, b, a) def color_get(self): return self.bg.color def change_eyes(self, id): self.eyes.change(id % 11) def change_mustache(self, id): self.mustache.change(id % 2) def noop(self): return True def add_bubble(self, name, content=None, ratio=1.0, pos=(20,40)): bubble=Bubble(self.win) bubble.name=name bubble.pos=pos if content: bubble.add(content) bubble.show() self.bubbles[name]=bubble return bubble def show_qr_bubble(self): if not self.bubbles.get("qr"): bubble_text = Text(self.win.evas, text='?', color=WHITE) bubble_text.font_source = font_path bubble_text.font = "FontAwesome", 130 bubble_text.style = EVAS_TEXT_STYLE_SOFT_SHADOW bubble_text.shadow_color = (64,64,64,127) self.add_bubble("qr", bubble_text) self.bubbles["qr"].content.move_relative(0,-20) else: self.bubbles.get("qr").show() def show_tv_bubble(self): if not self.bubbles.get("tv"): bubble_image = Image(self.win, pos=(30,20), size=(160,80), file=os.path.join(img_path, "tv.png")) self.add_bubble("tv", bubble_image) else: self.bubbles.get("tv").show() def show_bubble(self, key): if self.bubbles.get(key): self.bubbles[key].show() def hide_bubble(self, key): if self.bubbles.get(key): self.bubbles[key].hide() def hide_all_bubbles(self): for key in self.bubbles: print "hiding bubble", key self.bubbles[key].hide() #del self.bubbles[key] # Face States def standard(self, awaken=True): self.awaken = awaken self.eyes.change(0) self.eyes.move_origin() self.color_set(*BLUE) return True def dead(self, awaken=False): self.awaken = awaken self.eyes.change(11) self.eyes.move_origin() self.color_set(*RED) return True def tired(self, awaken=True): self.awaken = awaken self.eyes.change(6) #self.color_set(*dark_blue) self.eyes.move_origin() return True def sleep(self, awaken=False): self.awaken = awaken self.eyes.change(10) self.eyes.move_origin() return True def intrigued(self, awaken=True): self.awaken = awaken self.eyes.change(7) self.eyes.move_origin() return True def astonished(self, awaken=True): self.awaken = awaken self.eyes.change(8) self.eyes.move_origin() return True def grumpy(self, awaken=True): self.awaken = awaken self.eyes.change(8) self.eyes.move_origin() return True # Face Animations (default for animating at ~ 30fps) def anim_standard(self, blink_max_delay=250.0/30.0, blink_min_delay=50.0/30.0, cb=lambda: None): self.animation="standard" self.eyes.change(0) def set_color(rgba): (r, g, b, a) = rgba self.color_set(r,g,b,a) return True animation_arrays( from_to(self.color, BLUE, 10, set_color)) def on_timer(): if self.animation == "standard": self.anim_blink() #self.anim_flash() interval = blink_min_delay + (random()* (blink_max_delay-blink_min_delay)) Timer(interval, on_timer) return False on_timer() def anim_tired(self, cb=lambda: None): self.animation="tired" def cycle(cb): def check(): if self.animation=="tired": self.anim_tired() return True else: cb() return False return check def on_timer_set_awaken(): if self.animation == "tired": self.anim_blink() self.anim_flash(lighten(BLUE, 0.1), 20, lambda: self.anim_colorize(darken(BLUE, 0.02), 20 ) ) #self.anim_flash() interval = 1 + (random()* 2) Timer(interval, on_timer_set_tired) return False def on_timer_set_tired(): if self.animation == "tired": self.tired() self.anim_colorize(darken(BLUE, 0.05), 180) #self.anim_flash() interval = 1 + (random()* 4) Timer(interval, on_timer_set_asleep) return False def on_timer_set_asleep(): if self.animation == "tired": self.sleep() self.anim_colorize(darken(BLUE, 0.1), 180) interval = 1 + (random()* 2) Timer(interval, on_timer_set_awaken) return False on_timer_set_tired() #animation_queue(self.standard, self.noop, self.noop # , self.tired, self.noop, self.noop, self.noop, self.noop # , self.standard, self.noop, self.noop, self.tired # , self.noop, self.noop, self.noop, self.noop # , cycle(cb)) def anim_blink(self, cb=lambda: None): #self.animation="standard" animation_queue( self.tired, self.noop, self.noop, self.noop, self.noop, self.sleep, self.noop, self.noop, self.noop, self.noop, self.standard, cb) def anim_sleep(self, cb=lambda: None): self.animation="sleep" def step(x,y,color): def move(): if self.animation=="sleep": self.eyes.move_relative(x,y) self.color_set(*color) return True else: self.eyes.move_origin() return move def cycle(cb): def check(): if self.animation=="sleep": self.anim_sleep() return True else: self.eyes.move_origin() cb() return False return check animation_queue( self.sleep , step(0, -2, darken(BLUE,0.002*5)), self.noop, self.noop, self.noop, self.noop, self.noop , step(0, -5, darken(BLUE,0.007*5)), self.noop, self.noop, self.noop, self.noop, self.noop , step(0, -10, darken(BLUE,0.017*5)), self.noop, self.noop, self.noop, self.noop, self.noop , step(0, -10, darken(BLUE,0.027*5)), self.noop, self.noop, self.noop, self.noop, self.noop , step(0, -5, darken(BLUE,0.032*5)), self.noop, self.noop, self.noop, self.noop, self.noop , step(0, -2, darken(BLUE,0.034*5)), self.noop, self.noop, self.noop, self.noop, self.noop, self.noop, self.noop , step(0, 2, darken(BLUE,0.032*5)), self.noop, self.noop, self.noop, self.noop, self.noop , step(0, 5, darken(BLUE,0.027*5)), self.noop, self.noop, self.noop, self.noop, self.noop , step(0, 10, darken(BLUE,0.017*5)), self.noop, self.noop, self.noop, self.noop, self.noop , step(0, 10, darken(BLUE,0.007*5)), self.noop, self.noop, self.noop, self.noop, self.noop , step(0, 5, darken(BLUE,0.002*5)), self.noop, self.noop, self.noop, self.noop, self.noop , step(0, 2, BLUE), self.noop, self.noop, self.noop, self.noop, self.noop, self.noop, self.noop #, self.anim_flash , cycle(cb)) def anim_colorize(self, color=YELLOW, quantity_of_ticks=10, cb=lambda: None): print "colorize original color", self.color, "destination color", color def set_color(rgba): (r, g, b, a) = rgba self.color_set(r,g,b,a) return True animation_arrays( from_to(self.color, color, quantity_of_ticks, set_color) , [cb]) def anim_flash(self, color=YELLOW, quantity_of_ticks=10, cb=lambda: None): print "flash original color", self.color, "destination color", color def set_color(rgba): (r, g, b, a) = rgba self.color_set(r,g,b,a) return True animation_arrays( from_to(self.color, color, quantity_of_ticks, set_color) , from_to(color, self.color, quantity_of_ticks, set_color) , [cb]) def anim_eyeballs(self, coords, quantity_of_ticks=3, cb=lambda: None): print "original eyeball pos", self.eyes.eyes.pos dest_pos=(coords.x, coords.y) print "destination eyeball pos", dest_pos animation_arrays( timing.linear_tuple_number( self.eyes.eyeballs.eyeballs.pos, dest_pos , quantity_of_ticks), [cb]) def anim_eyes_zoom(self, animation="eyeballs_zoom", quantity_of_ticks=20, cb=lambda: None): max_zoom=1.5 min_zoom=1.0 delta = 4.0/(quantity_of_ticks) #print 'delta', delta def scaler(start, stop, ratio): #print "scaler", start, stop, ratio def scale(): if self.animation == animation: self.eyes.smooth = False self.eyes.map.smooth = False self.eyes.scale( sinusoidal_number (start, stop, ratio) ) return True else: self.eyes.scale( 1.0 ) self.eyes.smooth = True self.eyes.map.smooth = True cb() return False return scale def cycle(cb): def check(): #print "should display again if current animation is alarma:", self.animation if self.animation == animation: self.anim_eyes_zoom(animation, quantity_of_ticks, cb) return True else: cb() return False return check animation_arrays( [ scaler(1.0, max_zoom, ratio) for ratio in np.arange( 0.0, 1.0 +delta/2, delta )] , [scaler(max_zoom, min_zoom, ratio) for ratio in np.arange( 0.0, 1.0 +delta/2, delta/2 )] , [scaler(min_zoom, 1.0, ratio) for ratio in np.arange( 0.0, 1.0 +delta/2, delta )] , [cycle(cb)] ) def anim_mustache_dance(self, animation="mustache", quantity_of_ticks=30, cb=lambda: None): dest_angle=22.0 delta = 4.0/(quantity_of_ticks) #print 'delta', delta def rotator(start, stop, ratio): #print "rotator", start, stop, ratio def rotate(): if self.animation == animation: self.mustache.smooth = False self.mustache.rotate( sinusoidal_number (start, stop, ratio) ) return True else: self.mustache.rotate( 0 ) self.mustache.smooth = True cb() return False return rotate def cycle(cb): def check(): #print "should display again if current animation is alarma:", self.animation if self.animation == animation: self.anim_mustache_dance(animation, quantity_of_ticks, cb) return True else: self.mustache.rotate( 0 ) self.mustache.smooth = True cb() return False return check animation_arrays( [ rotator(0, dest_angle, ratio) for ratio in np.arange( 0.0, 1.0 +delta/2, delta )] , [rotator(-dest_angle, dest_angle, ratio) for ratio in np.arange( 1.0, -1.0 +delta/2, -delta/2 )] , [rotator(0, dest_angle, ratio) for ratio in np.arange( -1.0, 0.0 +delta/2, delta )] , [cycle(cb)] ) def anim_alarm(self, cb=lambda: None): #print "alarm !" self.animation="alarm" ref_color = lighten(BLUE, 0.1) def cycle(cb): def check(): #print "should display again if current animation is alarma:", self.animation if self.animation == "alarm": self.anim_alarm() return True else: cb() return False return check def color_rotate(variation): mixed=rotate_hue(ref_color, variation) def colorize(): if self.animation == "alarm": self.color_set(*mixed) return True elif self.animation == "mustache": self.standard() return True else: self.standard() cb() return False return colorize hues = [ color_rotate(variation) for variation in np.arange(0, 1.001, 0.05) ] animation_arrays( hues, [cycle(cb)])
def mapbuf_clicked(obj, item=None): global mb_list win = Window("mapbuf", ELM_WIN_BASIC, title="Mapbuf test", autodel=True, size=(480, 600)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) bg = Background(win, file=os.path.join(img_path, "sky_04.jpg"), size_hint_weight=EXPAND_BOTH) win.resize_object_add(bg) bg.show() vbox = Box(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) win.resize_object_add(vbox) vbox.show() # launcher sc = Scroller(win, bounce=(True, False), policy=SCROLL_POLICY_OFF, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) vbox.pack_end(sc) bx = Box(win, horizontal=True, homogeneous=True) bx.show() for k in range(8): tb = Table(win, size_hint_align=ALIGN_CENTER, size_hint_weight=(0.0, 0.0)) tb.show() pad = Rectangle(win.evas, color=(255, 255, 0, 255)) pad.size_hint_min = (464, 4) pad.size_hint_weight = (0.0, 0.0) pad.size_hint_align = (EVAS_HINT_FILL, EVAS_HINT_FILL) pad.show() tb.pack(pad, 1, 0, 5, 1) pad = Rectangle(win.evas, color=(255, 255, 0, 255)) pad.size_hint_min = (464, 4) pad.size_hint_weight = (0.0, 0.0) pad.size_hint_align = (EVAS_HINT_FILL, EVAS_HINT_FILL) pad.show() tb.pack(pad, 1, 11, 5, 1) pad = Rectangle(win.evas, color=(255, 255, 0, 255)) pad.size_hint_min = (4, 4) pad.size_hint_weight = (0.0, 0.0) pad.size_hint_align = (EVAS_HINT_FILL, EVAS_HINT_FILL) pad.show() tb.pack(pad, 0, 1, 1, 10) pad = Rectangle(win.evas, color=(255, 255, 0, 255)) pad.size_hint_min = (4, 4) pad.size_hint_weight = (0.0, 0.0) pad.size_hint_align = (EVAS_HINT_FILL, EVAS_HINT_FILL) pad.show() tb.pack(pad, 6, 1, 1, 10) mb = Mapbuf(win, content=tb) mb.point_color_set(k % 4, 255, 0, 0, 255) mb_list.append(mb) bx.pack_end(mb) mb.show() n = m = 0 for j in range(5): for i in range(5): ic = Icon(win, scale=0.5, file=os.path.join(img_path, "icon_%02d.png" % (n)), resizable=(False, False), size_hint_weight=EXPAND_BOTH, size_hint_align=ALIGN_CENTER) tb.pack(ic, 1 + i, 1 + (j * 2), 1, 1) ic.show() lb = Label(win, style="marker", text=names[m]) tb.pack(lb, 1 + i, 1 + (j * 2) + 1, 1, 1) lb.show() n = n + 1 if n < 23 else 0 m = m + 1 if m < 15 else 0 sc.content = bx sc.page_relative_set(1.0, 1.0) sc.show() # controls hbox = Box(win, horizontal=True, homogeneous=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) vbox.pack_start(hbox) hbox.show() ck = Check(win, text="Map", state=False) ck.callback_changed_add(cb_ck_map) hbox.pack_end(ck) ck.show() ck = Check(win, text="Alpha", state=True) ck.callback_changed_add(cb_ck_alpha) hbox.pack_end(ck) ck.show() ck = Check(win, text="Smooth", state=True) ck.callback_changed_add(cb_ck_smooth) hbox.pack_end(ck) ck.show() ck = Check(win, text="FS", state=False) ck.callback_changed_add(cb_ck_fs, win) hbox.pack_end(ck) ck.show() bt = Button(win, text="Close", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(cb_btn_close, win) hbox.pack_end(bt) bt.show() win.show()
def label_clicked(obj): win = StandardWindow("label", "Label test", autodel=True, size=(280, 400)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) vbox = Box(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) win.resize_object_add(vbox) vbox.show() lb = Label(win, "<b>This is a small label</b>", size_hint_align=(0.0, 0.5)) vbox.pack_end(lb) lb.show() lb = Label(win, size_hint_align=(0.0, 0.5)) lb.text = "This is a larger label with newlines<br/>" \ "to make it bigger, bit it won't expand or wrap<br/>" \ "just be a block of text that can't change its<br/>" \ "formatting as it's fixed based on text<br/>" vbox.pack_end(lb) lb.show() lb = Label(win, line_wrap=ELM_WRAP_CHAR, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) lb.text = "<b>This is more text designed to line-wrap here as " \ "This object is resized horizontally. As it is " \ "resized vertically though, nothing should change. " \ "The amount of space allocated vertically should " \ "change as horizontal size changes.</b>" vbox.pack_end(lb) lb.show() lb = Label(win, text="This small label set to wrap", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) vbox.pack_end(lb) lb.show() sp = Separator(win, horizontal=True) vbox.pack_end(sp) sp.show() gd = Grid(win, size=(100, 100), size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) vbox.pack_end(gd) gd.show() lb = Label(win, text="Test Label Ellipsis:", size_hint_align=(0.0, 0.5)) gd.pack(lb, 5, 5, 90, 15) lb.show() rect = Rectangle(win.evas, color=(255, 125, 125, 255)) gd.pack(rect, 5, 15, 90, 15) rect.show() lb = Label(win, ellipsis=True, size_hint_align=(0.0, 0.5)) lb.text = "This is a label set to ellipsis. " \ "If set ellipsis to true and the text doesn't fit " \ "in the label an ellipsis(\"...\") will be shown " \ "at the end of the widget." gd.pack(lb, 5, 15, 90, 15) lb.show() lb = Label(win, text="Test Label Slide:", size_hint_align=(0.0, 0.5)) gd.pack(lb, 5, 30, 90, 15) lb.show() rect = Rectangle(win.evas, color=(255, 125, 125, 255)) gd.pack(rect, 5, 40, 90, 15) rect.show() lb = Label(win, slide_mode=ELM_LABEL_SLIDE_MODE_AUTO, style="slide_short", size_hint_align=(0.0, 0.5), slide_duration=15) lb.text = "This is a label set to slide. " \ "If set slide to true the text of the label " \ "will slide/scroll through the length of label." \ "This only works with the themes \"slide_short\", " \ "\"slide_long\" and \"slide_bounce\"." gd.pack(lb, 5, 40, 90, 15) lb.show() rd = Radio(win, state_value=1, text="slide_short") gd.pack(rd, 5, 55, 30, 15) rd.callback_changed_add(cb_slide_radio, lb) rd.show() rdg = rd rd = Radio(win, state_value=2, text="slide_long") rd.group_add(rdg) gd.pack(rd, 35, 55, 30, 15) rd.callback_changed_add(cb_slide_radio, lb) rd.show() rd = Radio(win, state_value=3, text="slide_bounce") rd.group_add(rdg) gd.pack(rd, 65, 55, 30, 15) rd.callback_changed_add(cb_slide_radio, lb) rd.show() sl_dur = Slider(win, text="Slide Duration", unit_format="%1.1f secs", min_max=(1, 40), value=15, size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ) sl_dur.callback_changed_add(cb_slider_duration, lb) gd.pack(sl_dur, 5, 70, 90, 15) sl_dur.show() sl_spd = Slider(win, text="Slide Speed", unit_format="%1.1f px/sec", min_max=(10, 300), value=10, size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ) sl_spd.callback_changed_add(cb_slider_speed, lb) gd.pack(sl_spd, 5, 80, 90, 15) sl_spd.show() lb.data["slider_duration"] = sl_dur lb.data["slider_speed"] = sl_spd win.show()
class Eyes(Transformable): def __init__(self, win): global screen_size, global_offset SmartObject.__init__(self, win.evas) self.name = "eyes" eye_size = screen_size self.origin = eye_pos = global_offset # white underlay behind eyes self.underlay = Rectangle(win.evas, pos=TOP_LEFT, size=eye_size, color=WHITE) self.underlay.layer = 0 self.member_add(self.underlay) # eyeballs self.eyeballs = EyeBalls(win, self) #self.eyeballs.layer = 2 self.member_add(self.eyeballs) #self.eyeballs.stack_above(self.underlay) # first load images to retrieve eye size self.images = [Image(win, pos=TOP_LEFT, size=eye_size, file=os.path.join(img_path, 'oeil-' + str(i) + '.png')) for i in range(1, 12)] # print "eyes image list", self.images self.eyes = self.images[0] for i in range(0, 11): self.member_add(self.images[i]) self.images[i].layer = 3 self.images[i].stack_above(self.underlay) self.images[i].stack_above(self.eyeballs) Transformable.__init__(self, self.eyes) self.clip_set(Rectangle(win.evas, pos=TOP_LEFT, size=eye_size, color=BLUE)) self.show() # print "eyes underlay", self.underlay # print "eyes current image", self.eyes # print "eyes clip", self.clip def show(self): self.underlay.show() self.eyes.show() self.clipper.show() self.eyeballs.show() def hide(self): self.clipper.hide() self.eyeballs.hide() def clip_set(self, clipper): self.clipper = clipper # self.underlay.clip=clipper for i in range(0, 11): self.images[i].clip = clipper # self.eyes.clip=clipper def move_origin(self): self.move(*self.origin) def color_set(self, r, g, b, a): color = (r, g, b, a) self.clipper.color = color def color_get(self): return self.clipper.color def change(self, id): # print "changing eyes to", id self.eyes.hide() # print "old eyes hidden", self.eyes self.eyes = self.images[id] self.transformable_set(self.eyes) # print "new eyes still hidden", self.eyes self.eyes.show()