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 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, 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 _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, 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 _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, 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 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()
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 __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()
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()