def genlist3_clicked(obj, item=None): win = StandardWindow("Genlist", "Genlist Group test", autodel=True, size=(320, 320)) gl = Genlist(win, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) win.resize_object_add(gl) gl.show() itc_i = GenlistItemClass(item_style="default", text_get_func=gl_text_get, content_get_func=gl_content_get, state_get_func=gl_state_get) itc_g = GenlistItemClass(item_style="group_index", text_get_func=glg_text_get, content_get_func=glg_content_get) for i in range(300): if i % 10 == 0: git = gl.item_append(itc_g, i/10, flags=ELM_GENLIST_ITEM_GROUP) git.select_mode_set(ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) gl.item_append(itc_i, i, git) win.show()
def __init__(self, app): # create the main window StandardWindow.__init__(self, "eepdater", "eepDater - System Updater", autodel=True, size=(320, 320)) self.callback_delete_request_add(lambda o: elementary.exit()) self.app = app icon = Icon(self) icon.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND) icon.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL) icon.standard_set('software-center') icon.show() self.icon_object_set(icon.object_get()) # build the two main boxes self.mainBox = self.buildMainBox() self.loadBox = self.buildLoadBox() # build the information details inwin object self.buildDetailsWin() # the flip object has the load screen on one side and the GUI on the other self.flip = Flip(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.flip.part_content_set("front", self.mainBox) self.flip.part_content_set("back", self.loadBox) self.resize_object_add(self.flip) self.flip.show() # show the window self.show()
def cursor2_clicked(obj, item=None): win = StandardWindow("cursors", "Cursors 2", autodel=True, size=(320, 480)) bx = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(bx) bx.show() tb = Toolbar(win, size_hint_weight=(0.0, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.0)) ti = tb.item_append("folder-new", "Bogosity", None, None) ti.cursor_set("bogosity") ti = tb.item_append("clock", "Unset", None, None) ti.cursor_unset() ti = tb.item_append("document-print", "Xterm", None, None) ti.cursor_set("xterm") bx.pack_end(tb) tb.show() lst = List(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) li = lst.item_append("cursor bogosity") li.cursor_set("bogosity") li = lst.item_append("cursor unset") li.cursor_unset() li = lst.item_append("cursor xterm") li.cursor_set("xterm") bx.pack_end(lst) lst.go() lst.show() win.show()
def __init__(self): StandardWindow.__init__(self, "ex4", "Align Example", size=(300, 200)) self.callback_delete_request_add(lambda o: elm.exit()) ourButton = Button(self) ourButton.size_hint_weight = EXPAND_BOTH ourButton.size_hint_align = (0, 0) ourButton.text = "Button 1" ourButton.show() ourButton2 = Button(self) ourButton2.size_hint_weight = EXPAND_BOTH ourButton2.size_hint_align = FILL_BOTH ourButton2.text = "Button 2" ourButton2.show() ourButton3 = Button(self) ourButton3.size_hint_weight = EXPAND_BOTH ourButton3.size_hint_align = (1, 1) ourButton3.text = "Button 3" ourButton3.show() ourBox = Box(self) ourBox.size_hint_weight = EXPAND_BOTH ourBox.pack_end(ourButton) ourBox.pack_end(ourButton2) ourBox.pack_end(ourButton3) ourBox.show() self.resize_object_add(ourBox)
def __init__(self, repo, win): self.repo = repo self.win = win self.confirmed = False StandardWindow.__init__(self, 'Egitu', 'Egitu', autodel=True) vbox = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.resize_object_add(vbox) vbox.show() # title en = Entry(self, editable=False, text='<title><align=center>Commit changes</align></title>', size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) vbox.pack_end(en) en.show() panes = Panes(self, content_left_size = 0.2, horizontal=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) vbox.pack_end(panes) panes.show() # message entry en = Entry(self, editable=True, scrollable=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) en.part_text_set('guide', 'Enter commit message here') panes.part_content_set("left", en) en.show() self.msg_entry = en # diff entry self.diff_entry = DiffedEntry(self) panes.part_content_set("right", self.diff_entry) self.diff_entry.show() # buttons hbox = Box(self, horizontal=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) vbox.pack_end(hbox) hbox.show() bt = Button(self, text="Cancel") bt.callback_clicked_add(lambda b: self.delete()) hbox.pack_end(bt) bt.show() bt = Button(self, text="Commit") bt.callback_clicked_add(self.commit_button_cb) hbox.pack_end(bt) bt.show() # show the window and give focus to the editable entry self.size = 500, 500 self.show() en.focus = True # load the diff repo.request_diff(self.diff_done_cb, only_staged=True)
def table5_clicked(obj, item=None): win = StandardWindow("table5", "Table 5", autodel=True) tb = Table(win, homogeneous=True, size_hint_weight=EXPAND_BOTH) win.resize_object_add(tb) tb.show() bt = Button(win, text="A", size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) tb.pack(bt, 33, 0, 34, 33) bt.show() bt = Button(win, text="B", size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) tb.pack(bt, 67, 33, 33, 34) bt.show() bt = Button(win, text="C", size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) tb.pack(bt, 33, 67, 34, 33) bt.show() bt = Button(win, text="D", size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) tb.pack(bt, 0, 33, 33, 34) bt.show() bt = Button(win, text="X", size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) tb.pack(bt, 33, 33, 34, 34) bt.show() win.show()
def bubble_clicked(obj, item=None): win = StandardWindow("bubble", "Bubble", autodel=True, size=(320,320)) bx = Box(win) win.resize_object_add(bx) bx.size_hint_weight = EXPAND_BOTH bx.show() # bb 1 ic = Icon(win, file=ic_file, size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1)) lb = Label(win, text="Blah, Blah, Blah") 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() # bb 2 ic = Icon(win, file=ic_file, size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1)) lb = Label(win, text="Blah, Blah, Blah") bb = Bubble(win, text = "Message 2", content = lb, pos = ELM_BUBBLE_POS_TOP_RIGHT, size_hint_weight = EXPAND_BOTH, size_hint_align = FILL_BOTH) bb.part_text_set("info", "Corner: top_right") bb.part_content_set("icon", ic) bx.pack_end(bb) bb.show() # bb 3 ic = Icon(win, file=ic_file, size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1)) lb = Label(win, text="Blah, Blah, Blah") bb = Bubble(win, text = "Message 3", content = ic, pos = ELM_BUBBLE_POS_BOTTOM_LEFT, size_hint_weight = EXPAND_BOTH, size_hint_align = FILL_BOTH) bb.part_text_set("info", "Corner: bottom_left") bx.pack_end(bb) bb.show() # bb 4 ic = Icon(win, file=ic_file, size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1)) lb = Label(win, text="Blah, Blah, Blah") bb = Bubble(win, text = "Message 4", content = lb, pos = ELM_BUBBLE_POS_BOTTOM_RIGHT, size_hint_weight = EXPAND_BOTH, size_hint_align = FILL_BOTH) bb.part_text_set("info", "Corner: bottom_right") bb.part_content_set("icon", ic) bx.pack_end(bb) bb.show() win.show()
def access_clicked(obj, item=None): win = StandardWindow("access", "Access") win.autodel = True win.on_free_add(cleanup_cb) config.access = True bx = Box(win, size_hint_weight=EXPAND_BOTH, homogeneous=True, horizontal=True) win.resize_object_add(bx) bx.show() gl = Genlist(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) bx.pack_end(gl) gl.show() gl.callback_realized_add(_realized) itc1 = GLItC1(item_style="default") itc2 = GLItC2(item_style="full") for i in range(1,9): if i % 4: gl.item_append(itc1, i, None, ELM_GENLIST_ITEM_NONE) else: gl.item_append(itc2, i, None, ELM_GENLIST_ITEM_NONE) itc1.free() itc2.free() win.resize(500, 400) win.show()
def transit2_clicked(obj, item=None): win = StandardWindow("transit2", "Transit 2", autodel=True, size=(400, 400)) bt = Button(win, text="Resizing Effect", pos=(50, 100), size=(100, 50)) bt.show() bt.callback_clicked_add(transit_resizing) win.show()
def transit4_clicked(obj, item=None): win = StandardWindow("transit4", "Transit 4", autodel=True, size=(300, 300)) bt = Button(win, text="Zoom Effect", size=(100, 50), pos=(100, 125)) bt.show() bt.callback_clicked_add(transit_zoom) win.show()
def __init__(self): StandardWindow.__init__(self, "ex1", "Hello Elementary", size=(300, 200)) self.callback_delete_request_add(lambda o: elm.exit()) ourLabel = Label(self) ourLabel.size_hint_weight = EXPAND_BOTH ourLabel.text = "Hello Elementary!" ourLabel.show() self.resize_object_add(ourLabel)
def __init__( self ): win = StandardWindow("Testing", "Elementary Sorted Table") win.callback_delete_request_add(lambda o: elm.exit()) titles = [] for i in range(COLUMNS): titles.append( ("Column " + str(i), True if i != 2 else False) ) slist = SortedList(win, titles=titles, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) for i in range(ROWS): row = [] for j in range(COLUMNS): data = random.randint(0, ROWS*COLUMNS) row.append(data) slist.row_pack(row, sort=False) #slist.sort_by_column(1) slist.show() win.resize_object_add(slist) win.resize(600, 400) win.show()
def layout_clicked(obj): win = StandardWindow("layout", "Layout", autodel=True) win.elm_event_callback_add(_event) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) ly = Layout(win, file=(os.path.join(script_path, "test.edj"), "layout"), size_hint_weight=EXPAND_BOTH) win.resize_object_add(ly) ly.show() bt = Button(win, text="Button 1") ly.part_content_set("element1", bt) bt.elm_event_callback_add(_event) bt.elm_event_callback_del(_event) bt.show() bt = Button(win, text="Button 2") ly.part_content_set("element2", bt) bt.show() bt = Button(win, text="Button 3") ly.part_content_set("element3", bt) bt.show() for o in ly.content_swallow_list_get(): print("Swallowed: " + str(o)) win.show()
def table4_clicked(obj, item=None): win = StandardWindow("table4", "Table 4", autodel=True) tb = Table(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(tb) win.data["tb"] = tb tb.show() bt = Button(win, text="Button 1", size_hint_weight=(0.25, 0.25), size_hint_align=FILL_BOTH) tb.pack(bt, 0, 0, 1, 1) win.data["b1"] = bt bt.callback_clicked_add(my_tb_ch, win) bt.show() bt = Button(win, text="Button 2", size_hint_weight=(0.75, 0.25), size_hint_align=FILL_BOTH) tb.pack(bt, 1, 0, 1, 1) win.data["b2"] = bt bt.callback_clicked_add(my_tb_ch, win) bt.show() bt = Button(win, text="Button 3", size_hint_weight=(0.25, 0.75), size_hint_align=FILL_BOTH) tb.pack(bt, 0, 1, 1, 1) win.data["b3"] = bt bt.callback_clicked_add(my_tb_ch, win) bt.show() win.show()
def list3_clicked(obj, item=None): win = StandardWindow("list-3", "List 3", autodel=True, size=(320, 300)) li = List(win, size_hint_weight=EXPAND_BOTH, mode=ELM_LIST_COMPRESS) win.resize_object_add(li) ic = Icon(win, file=os.path.join(img_path, "logo_small.png")) li.item_append("Hello", ic) ic = Icon(win, file=os.path.join(img_path, "logo_small.png"), resizable=(False, False)) li.item_append("world", ic) ic = Icon(win, standard="edit", resizable=(False, False)) li.item_append(".", ic) ic = Icon(win, standard="delete", resizable=(False, False)) ic2 = Icon(win, standard="clock", resizable=(False, False)) it2 = li.item_append("How", ic, ic2) bx = Box(win, horizontal=True) bx.horizontal_set(True) ic = Icon(win, standard="delete", resizable=(False, False), size_hint_align=ALIGN_CENTER) bx.pack_end(ic) ic.show() ic = Icon(win, file=os.path.join(img_path, "logo_small.png"), resizable=(False, False), size_hint_align=(0.5, 0.0)) bx.pack_end(ic) ic.show() ic = Icon(win, file=os.path.join(img_path, "logo_small.png"), resizable=(False, False), size_hint_align=(0.0, EVAS_HINT_FILL)) bx.pack_end(ic) ic.show() li.item_append("are", bx) li.item_append("you") li.item_append("doing") li.item_append("out") li.item_append("there") li.item_append("today") li.item_append("?") li.item_append("Here") li.item_append("are") li.item_append("some") li.item_append("more") li.item_append("items") li.item_append("Is this label long enough?") it5 = li.item_append("Maybe this one is even longer so we can test long long items.") li.go() li.show() win.show()
def index_clicked(obj): win = StandardWindow("index", "Index test", autodel=True, size=(320, 480)) 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() # index idx = Index(win, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) idx.callback_delay_changed_add(cb_idx_delay_changed) idx.callback_changed_add(cb_idx_changed) idx.callback_selected_add(cb_idx_selected) win.resize_object_add(idx) idx.show() # genlist itc = GenlistItemClass(item_style="default", text_get_func=gl_text_get) # content_get_func=gl_content_get, # state_get_func=gl_state_get) gl = Genlist(win, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) vbox.pack_end(gl) gl.show() for i in 'ABCDEFGHILMNOPQRSTUVZ': for j in 'acegikmo': gl_item = gl.item_append(itc, i + j) if j == 'a': idx_item = idx.item_append(i, cb_idx_item, gl_item) idx_item.data["gl_item"] = gl_item idx.level_go(0) sep = Separator(win, horizontal=True) vbox.pack_end(sep) sep.show() hbox = Box(win, horizontal=True, size_hint_weight=EXPAND_HORIZ) vbox.pack_end(hbox) hbox.show() ck = Check(win, text="autohide_disabled") ck.callback_changed_add(lambda ck: idx.autohide_disabled_set(ck.state)) hbox.pack_end(ck) ck.show() ck = Check(win, text="indicator_disabled") ck.callback_changed_add(lambda ck: idx.indicator_disabled_set(ck.state)) hbox.pack_end(ck) ck.show() ck = Check(win, text="horizontal") ck.callback_changed_add(lambda ck: idx.horizontal_set(ck.state)) hbox.pack_end(ck) ck.show() win.show()
def __init__(self): StandardWindow.__init__(self, "ex12", "Custom Widget", size=(300, 200)) self.callback_delete_request_add(lambda o: elm.exit()) ourPictureFrame = PictureFrame(self) ourPictureFrame.size_hint_weight = EXPAND_BOTH ourPictureFrame.text = "A Custom Picture Frame" ourPictureFrame.file_set("images/logo.png") ourPictureFrame.show() self.resize_object_add(ourPictureFrame)
def __init__(self, app): self.app = app self.branch_selector = None self.caption_label = None self.status_label = None self.graph = None self.diff_view = None StandardWindow.__init__(self, 'egitu', 'Efl GIT gUi - Egitu', size=(1000,600), autodel=True) self.callback_delete_request_add(lambda o: elm.exit())
def __init__(self): StandardWindow.__init__(self, "ex5", "Static Image", size=(300, 200)) self.callback_delete_request_add(lambda o: elm.exit()) ourImage = Image(self) ourImage.size_hint_weight = EXPAND_BOTH ourImage.file_set("images/logo.png") ourImage.tooltip_text_set("A picture!") ourImage.show() self.resize_object_add(ourImage)
def bt_clicked(obj): win = StandardWindow("preload-prescale", "Preload & Prescale", autodel=True, size=(350, 350)) ic = Icon(win, file=os.path.join(img_path, "insanely_huge_test_image.jpg"), size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, resizable=(True, True), aspect_fixed=True, preload_disabled=True, prescale=True) win.resize_object_add(ic) ic.show() win.show()
def entry_clicked(obj, item=None): win = StandardWindow("entry", "Entry", autodel=True) bx = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(bx) bx.show() en = Entry(win, line_wrap=False, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) en.entry_set("This is an entry widget in this window that<br>" "uses markup <b>like this</> for styling and<br>" "formatting <em>like this</>, as well as<br>" "<a href=X><link>links in the text</></a>, so enter text<br>" "in here to edit it. By the way, links are<br>" "called <a href=anc-02>Anchors</a> so you will need<br>" "to refer to them this way.") en.callback_anchor_clicked_add(my_entry_anchor_test, en) bx.pack_end(en) en.show() bx2 = Box(win, horizontal=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) bt = Button(win, text="Clear", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) bt.callback_clicked_add(my_entry_bt_1, en) bx2.pack_end(bt) bt.show() bt = Button(win, text="Print", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) bt.callback_clicked_add(my_entry_bt_2, en) bx2.pack_end(bt) bt.show() bt = Button(win, text="Selection", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) bt.callback_clicked_add(my_entry_bt_3, en) bx2.pack_end(bt) bt.show() bt = Button(win, text="Insert", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) bt.callback_clicked_add(my_entry_bt_4, en) bx2.pack_end(bt) bt.show() bx.pack_end(bx2) bx2.show() en.focus_set(True) win.show()
def conformant_clicked(obj, item=None): win = StandardWindow("conformant", "Conformant", autodel=True, conformant=True, size=(240,240)) conform = Conformant(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(conform) conform.show() bx = Box(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) en = ScrollableEntry(win, single_line=True, bounce=(True, False), text="This is the top entry here", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) en.show() bx.pack_end(en) btn = Button(win, text="Test Conformant", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) bx.pack_end(btn) btn.show() en = ScrollableEntry(win, single_line=True, bounce=(True, False), text="This is the middle entry here", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) en.show() bx.pack_end(en) btn = Button(win, text="Test Conformant", size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) bx.pack_end(btn) btn.show() en = ScrollableEntry(win, bounce=(False, True), size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) en.text = \ "This is a multi-line entry at the bottom<br/>" \ "This can contain more than 1 line of text and be " \ "scrolled around to allow for entering of lots of " \ "content. It is also to test to see that autoscroll " \ "moves to the right part of a larger multi-line " \ "text entry that is inside of a scroller than can be " \ "scrolled around, thus changing the expected position " \ "as well as cursor changes updating auto-scroll when " \ "it is enabled." en.show() bx.pack_end(en) conform.content = bx bx.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 genlist5_clicked(obj, item=None): win = StandardWindow("Genlist", "Genlist iteration test", autodel=True, size=(320, 320)) gl = Genlist(win, homogeneous=True, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) win.resize_object_add(gl) gl.show() itc_i = GenlistItemClass(item_style="default", text_get_func=gl_text_get, content_get_func=gl_content_get, state_get_func=gl_state_get) item_count = 10000 t1 = time.time() for i in range(item_count): GenlistItem(itc_i, i).append_to(gl) t2 = time.time() assert(len(gl) == gl.items_count) t3 = time.time() it = gl.first_item while it: d = it.data it = it.next t4 = time.time() assert(d == item_count-1) t5 = time.time() for it in gl: e = it.data t6 = time.time() assert(e == item_count-1) assert(it in gl) print("Time to add {0} items:".format(item_count)) print(t2-t1) print("Time to iterate item data over {0} items using " "it.next:".format(item_count)) print(t4-t3) print("Time to iterate item data over {0} items using " "a python iterator:".format(item_count)) print(t6-t5) win.show()
def video_clicked(obj): win = StandardWindow("video", "video", autodel=True, size=(800, 600)) win.alpha = True # Needed to turn video fast path on video = Video(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(video) video.show() player = Player(win, content=video) player.show() notify = Notify(win, orient=ELM_NOTIFY_ORIENT_BOTTOM, timeout=3.0) notify.content = player tb = Table(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(tb) bt = FileselectorButton(win, text="Select Video", size_hint_weight=EXPAND_BOTH, size_hint_align=(0.5, 0.1)) bt.callback_file_chosen_add(my_bt_open, video) tb.pack(bt, 0, 0, 1, 1) bt.show() tb.show() video.event_callback_add(EVAS_CALLBACK_MOUSE_MOVE, notify_show, notify) video.event_callback_add(EVAS_CALLBACK_MOUSE_IN, notify_block, notify) video.event_callback_add(EVAS_CALLBACK_MOUSE_OUT, notify_unblock, notify) win.show()
def __init__( self ): win = StandardWindow("Testing", "Elementary Sorted Table") win.callback_delete_request_add(lambda o: elm.exit()) """Build the titles for the table. The titles is a list of tuples with the following format: ( <String - Header Text>, <Bool - Sortable> )""" titles = [] for i in range(COLUMNS): titles.append( ("Column " + str(i), True if i != 2 else False) ) #Create our sorted list object slist = SortedList(win, titles=titles, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) #Populate the rows in our table for i in range(ROWS): #Each row is a list with the number of elements that must equal the number of headers row = [] for j in range(COLUMNS): #Row elements can be ANY elementary object if j == 0: #For the first column in each row, we will create a button that will delete the row when pressed btn = Button(slist, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) btn.text = "Delete row" btn.callback_clicked_add( lambda x, y=row: slist.row_unpack(y, delete=True) ) btn.show() #Add the btn created to our row row.append(btn) else: #For each other row create a label with a random number data = random.randint(0, ROWS*COLUMNS) lb = Label(slist, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) lb.text=str(data) """For integer data we also need to assign value to "sort_data" because otherwise things get sorted as text""" lb.data["sort_data"] = data lb.show() #Append our label to the row row.append(lb) #Add the row into the SortedList slist.row_pack(row, sort=False) #Show the list slist.show() win.resize_object_add(slist) win.resize(600, 400) win.show()
def transit7_clicked(obj, item=None): win = StandardWindow("transit7", "Transit 7", autodel=True, size=(400, 400)) bt = Button(win, text="Front Button - Resizable Flip Effect", pos=(50, 100), size=(250, 30)) bt.show() bt2 = Button(win, text="Back Button - Resizable Flip Effect", pos=(50, 100), size=(300, 200)) win.show() bt.callback_clicked_add(transit_resizable_flip, bt2) bt2.callback_clicked_add(transit_resizable_flip, bt)
def genlist15_clicked(obj, item=None): win = StandardWindow("genlist-decorate-all-mode", "Genlist Decorate All Mode", autodel=True, size=(520, 520)) bx = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(bx) bx.show() gl = Genlist(win, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) gl.show() itc15 = ItemClass15(item_style="default", decorate_all_item_style="edit") itc15.state_get = gl_state_get for i in range(100): ck = Check(gl) data = [i, False] it = GenlistItem(item_class=itc15, item_data=data, parent_item=None, flags=ELM_GENLIST_ITEM_NONE, func=gl15_sel, func_data=data, ).append_to(gl) data.append(it) bx.pack_end(gl) bx.show() bx2 = Box(win, horizontal=True, homogeneous=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) bt = Button(win, text="Decorate All mode", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(gl15_deco_all_mode, gl) bx2.pack_end(bt) bt.show() bt = Button(win, text="Normal mode", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(gl15_normal_mode, gl) bx2.pack_end(bt) bt.show() bx.pack_end(bx2) bx2.show() win.show()
def transit9_clicked(obj, item=None): win = StandardWindow("transit9", "Transit 9", autodel=True, size=(400, 400)) bt = Button(win, text="Chain 1", size=(100, 100), pos=(0, 0)) bt.show() bt2 = Button(win, text="Chain 2", size=(100, 100), pos=(300, 0)) bt2.show() bt3 = Button(win, text="Chain 3", size=(100, 100), pos=(300, 300)) bt3.show() bt4 = Button(win, text="Chain 4", size=(100, 100), pos=(0, 300)) bt4.show() trans = Transit() trans.tween_mode = ELM_TRANSIT_TWEEN_MODE_ACCELERATE trans.effect_translation_add(0, 0, 300, 0) trans.object_add(bt) trans.duration = 1 trans.objects_final_state_keep = True trans.go() trans2 = Transit() trans2.tween_mode = ELM_TRANSIT_TWEEN_MODE_ACCELERATE trans2.effect_translation_add(0, 0, 0, 300) trans2.object_add(bt2) trans2.duration = 1 trans2.objects_final_state_keep = True trans.chain_transit_add(trans2) trans3 = Transit() trans3.tween_mode = ELM_TRANSIT_TWEEN_MODE_ACCELERATE trans3.effect_translation_add(0, 0, -300, 0) trans3.object_add(bt3) trans3.duration = 1 trans3.objects_final_state_keep = True trans2.chain_transit_add(trans3) trans4 = Transit() trans4.tween_mode = ELM_TRANSIT_TWEEN_MODE_ACCELERATE trans4.effect_translation_add(0, 0, 0, -300) trans4.object_add(bt4) trans4.duration = 1 trans4.objects_final_state_keep = True trans3.chain_transit_add(trans4) win.show()
def __init__(self): win = StandardWindow("Testing", "Elementary Embedded Terminal") win.callback_delete_request_add(lambda o: elm.exit()) term = EmbeddedTerminal(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) term.show() win.resize_object_add(term) win.resize(600, 400) win.show()
def focus4_clicked(obj, item=None): win = StandardWindow("focus4", "Focus 4", autodel=True, size=(320, 320)) win.focus_highlight_enabled = True win.focus_highlight_animate = True fr = Frame(win, style="pad_large", size_hint_weight=EXPAND_BOTH) win.resize_object_add(fr) fr.show() # First Example - Using Focus Highlight bx = Box(fr) fr.content = bx bx.show() tg = Check(bx, text="Focus Highlight Enabled (Config)", state=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) tg.callback_changed_add(_highlight_enabled_cb, win) bx.pack_end(tg) tg.show() tg = Check(bx, text="Focus Highlight Animate (Config)", state=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) tg.callback_changed_add(_highlight_animate_cb, win) bx.pack_end(tg) tg.show() tg = Check(bx, text="Focus Highlight Enabled (Win)", state=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) tg.callback_changed_add(_win_highlight_enabled_cb, win) bx.pack_end(tg) tg.show() tg = Check(bx, text="Focus Highlight Animate (Win)", state=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) tg.callback_changed_add(_win_highlight_animate_cb, win) bx.pack_end(tg) tg.show() sp = Separator(win, horizontal=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) bx.pack_end(sp) sp.show() # Second Example - Using Custom Chain lb = Label(bx, text="Custom Chain: Please use tab key to check", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) bx.pack_end(lb) lb.show() bx2 = Box(bx, horizontal=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) bx.pack_end(bx2) bx2.show() bt1 = Button(bx2, text="Button 1", size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) bx2.pack_end(bt1) bt1.show() bt2 = Button(bx2, text="Button 2", size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) bx2.pack_end(bt2) bt2.show() bt3 = Button(bx2, text="Button 3", size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) bx2.pack_end(bt3) bt3.show() bt4 = Button(bx2, text="Button 4", size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) bx2.pack_end(bt4) bt4.show() bx2.focus_custom_chain = [bt2, bt1, bt4, bt3] tg = Check(bx, text="Custom Chain", state=False, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) tg.callback_changed_add(_custom_chain_cb, bx) bx.pack_end(tg) tg.show() win.show()
def focus5_clicked(obj, item=None): theme_overlay_add(os.path.join(script_path, "test_focus_custom.edj")) win = StandardWindow("focus5", "Focus Custom", autodel=True, size=(320, 320)) win.focus_highlight_enabled = True win.focus_highlight_animate = True win.focus_highlight_style = "glow" fr = Frame(win, style="pad_large", size_hint_weight=EXPAND_BOTH) win.resize_object_add(fr) fr.show() bx = Box(fr) fr.content = bx bx.show() chk = Check(bx, text='Enable glow effect on "Glow" Button', state=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) bx.pack_end(chk) chk.show() spinner = Spinner(bx, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) bx.pack_end(spinner) spinner.show() bt = Button(bx, text="Glow Button", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) bt.callback_focused_add(_glow_effect_on_cb, win, chk) bt.callback_unfocused_add(_glow_effect_off_cb, win, chk) bx.pack_end(bt) bt.show() sp = Separator(bx, horizontal=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) bx.pack_end(sp) sp.show() bx2 = Box(bx, horizontal=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) bx.pack_end(bx2) bx2.show() for i in range(1, 5): bt = Button(bx2, text="Button %d" % i, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) bx2.pack_end(bt) bt.show() win.show()
def segment_control_clicked(obj): win = StandardWindow("segment-control", "Segment Control test", autodel=True, size=(320, 280)) 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() # segment 1 seg = SegmentControl(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ) seg.item_add(None, "Only Text") ic = Icon(win, file=os.path.join(img_path, "logo_small.png")) it = seg.item_add(ic) ic = Icon(win) ic = Icon(win, file=os.path.join(img_path, "logo_small.png")) seg.item_add(ic, "Text + Icon") seg.item_add(None, "Seg4") seg.item_add(None, "Seg5") seg.callback_changed_add(cb_seg_changed) it.selected = True vbox.pack_end(seg) seg.show() # segment 2 seg = SegmentControl(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ) seg.item_add(None, "SegmentItem") it = seg.item_add(None, "SegmentItem") seg.item_add(None, "SegmentItem") seg.item_add(None, "SegmentItem") it.selected = True vbox.pack_end(seg) seg.show() # segment 3 seg = SegmentControl(win, size_hint_weight=EXPAND_BOTH, size_hint_align=(0.5, 0.5)) for i in range(3): ic = Icon(win, file=os.path.join(img_path, "logo_small.png")) if i == 1: it = seg.item_add(ic) else: seg.item_add(ic) it.selected = True vbox.pack_end(seg) seg.show() # segment 4 seg = SegmentControl(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ, disabled=True) seg.item_add(None, "Disabled") ic = Icon(win, file=os.path.join(img_path, "logo_small.png")) it = seg.item_add(ic, "Disabled") ic = Icon(win, file=os.path.join(img_path, "logo_small.png")) seg.item_add(ic) it.selected = True vbox.pack_end(seg) seg.show() win.show()
def hoversel_clicked(obj): win = StandardWindow("hoversel", "Hoversel", autodel=True, size=(320, 320)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) bx = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(bx) bx.show() bt = Hoversel(win, hover_parent=win, text="Labels", size_hint_weight=WEIGHT_ZERO, size_hint_align=ALIGN_CENTER) bt.item_add("Item 1") bt.item_add("Item 2") bt.item_add("Item 3") bt.item_add("Item 4 - Long Label Here") bx.pack_end(bt) bt.show() bt = Hoversel(win, hover_parent=win, text="Some Icons", size_hint_weight=WEIGHT_ZERO, size_hint_align=ALIGN_CENTER) bt.item_add("Item 1") bt.item_add("Item 2") bt.item_add("Item 3", "home", ELM_ICON_STANDARD) bt.item_add("Item 4", "close", ELM_ICON_STANDARD) bx.pack_end(bt) bt.show() bt = Hoversel(win, hover_parent=win, text="All Icons", size_hint_weight=WEIGHT_ZERO, size_hint_align=ALIGN_CENTER) bt.item_add("Item 1", "apps", ELM_ICON_STANDARD) bt.item_add("Item 2", "arrow_down", ELM_ICON_STANDARD) bt.item_add("Item 3", "home", ELM_ICON_STANDARD) bt.item_add("Item 4", "close", ELM_ICON_STANDARD) bx.pack_end(bt) bt.show() bt = Hoversel(win, hover_parent=win, text="All Icons", size_hint_weight=WEIGHT_ZERO, size_hint_align=ALIGN_CENTER) bt.item_add("Item 1", "apps", ELM_ICON_STANDARD) bt.item_add("Item 2", os.path.join(img_path, "logo_small.png"), ELM_ICON_FILE) bt.item_add("Item 3", "home", ELM_ICON_STANDARD) bt.item_add("Item 4", "close", ELM_ICON_STANDARD) bx.pack_end(bt) bt.show() bt = Hoversel(win, hover_parent=win, text="Disabled Hoversel", disabled=True, size_hint_weight=WEIGHT_ZERO, size_hint_align=ALIGN_CENTER) bt.item_add("Item 1", "apps", ELM_ICON_STANDARD) bt.item_add("Item 2", "close", ELM_ICON_STANDARD) bx.pack_end(bt) bt.show() ic = Icon(win, file=os.path.join(img_path, "sky_03.jpg")) bt = Hoversel(win, hover_parent=win, text="Icon + Label", content=ic, size_hint_weight=WEIGHT_ZERO, size_hint_align=ALIGN_CENTER) ic.show() bt.item_add("Item 1", "apps", ELM_ICON_STANDARD) bt.item_add("Item 2", "arrow_down", ELM_ICON_STANDARD) bt.item_add("Item 3", "home", ELM_ICON_STANDARD) bt.item_add("Item 4", "close", ELM_ICON_STANDARD) bx.pack_end(bt) bt.show() win.show()
def config_clicked(obj, data=None): siname = "_TestConfigSocketImage_" win = StandardWindow("config", "Configuration", autodel=True, size=(400, 500)) global ad ad = App_Data() win.data["ad"] = ad ad.win = win ad.profiles = elm_conf.profile_list bx = Box(win, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) sc = Scroller(win, content=bx, bounce=(False, True), size_hint_weight=EXPAND_BOTH) win.resize_object_add(sc) fr, bx2 = FRAME(win, bx, "Current window profile") # TODO: Add this code #ee = ecore_evas_ecore_evas_get(evas_object_evas_get(win)); #supported = ecore_evas_window_profile_supported_get(ee); supported = True buf = "Virtual desktop window profile support: <b>{0}</b>".format( "Yes" if supported else "No") lb = LOG(win, buf) bx2.pack_end(lb) lb = LOG(win, "Profile: <b>N/A</b><br/>Available profiles:") bx2.pack_end(lb) win.data["lb"] = lb lb = LOG(win, "<br/>Window profile") bx2.pack_end(lb) ad.curr.rdg = radio_add(win, bx2) bt = Button(win, text="Set") bt.callback_clicked_add(bt_profile_set, win) bx2.pack_end(bt) bt.show() lb = LOG(win, "Window available profiles") bx2.pack_end(lb) ad.curr.cks = check_add(win, bx2) bt = Button(win, text="Set") bt.callback_clicked_add(bt_available_profiles_set, win) bx2.pack_end(bt) bt.show() fr, bx2 = FRAME(win, bx, "Socket") if socket_add(siname): lb = LOG(win, "Starting socket image.") bx2.pack_end(lb) else: lb = LOG( win, "Failed to create socket.<br/>Please check whether another " "test configuration window is<br/>already running and providing " "socket image.") bx2.pack_end(lb) fr, bx2 = FRAME(win, bx, "Plug") if not plug_add(win, bx2, siname): lb = LOG(win, "Failed to connect to server.") bx2.pack_end(lb) fr, bx2 = FRAME(win, bx, "Create new window with profile") lb = LOG(win, "Window profile") bx2.pack_end(lb) ad.new.rdg = radio_add(win, bx2) lb = LOG(win, "Window available profiles") bx2.pack_end(lb) ad.new.cks = check_add(win, bx2) bt = Button(win, text="Create") bt.callback_clicked_add(bt_win_add, win) bx2.pack_end(bt) bt.show() win.callback_profile_changed_add(win_profile_changed_cb) win.callback_delete_request_add(win_del_cb) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) if data: if data.available_profiles: win.available_profiles = data.available_profiles if data.profile: win.profile = data.profile profile_update(win) bx.show() sc.show() win.show()
def entry_scrolled_clicked(obj, item=None): #static Elm_Entry_Filter_Accept_Set digits_filter_data, digits_filter_data2; #static Elm_Entry_Filter_Limit_Size limit_filter_data, limit_filter_data2; win = StandardWindow("entry-scrolled", "Entry Scrolled", autodel=True, size=(320, 300)) bx = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(bx) bx.show() # disabled entry en = ScrollableEntry(win, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ, policy=SCROLL_POLICY_OFF, text="Disabled entry", single_line=True, disabled=True) en.show() bx.pack_end(en) # password entry en = ScrollableEntry(win, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ, policy=SCROLL_POLICY_OFF, password=True, single_line=True, text="Access denied, give up!", disabled=True) en.show() bx.pack_end(en) # multi-line disable entry en = ScrollableEntry(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, policy=SCROLL_POLICY_ON, disabled=True) en.context_menu_item_add("Hello") en.context_menu_item_add("World") en.text = "Multi-line disabled entry widget :)<br/>"\ "We can use markup <b>like this</> for styling and<br/>"\ "formatting <em>like this</>, as well as<br/>"\ "<a href=X><link>links in the text</></a>,"\ "but it won't be editable or clickable." en.show() bx.pack_end(en) sp = Separator(win, horizontal=True) bx.pack_end(sp) sp.show() # Single line selected entry en = ScrollableEntry(win, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ, text="This is a single line", policy=SCROLL_POLICY_OFF, single_line=True) en.select_all() en.show() bx.pack_end(en) # Filter test en = ScrollableEntry(win, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ, text="Filter test", policy=SCROLL_POLICY_OFF, single_line=True) en.show() bx.pack_end(en) en.markup_filter_append(my_filter, "test") # # Only digits entry # en = ScrollableEntry(win) # en.size_hint_weight = EVAS_HINT_EXPAND, 0.0 # en.size_hint_align = EVAS_HINT_FILL, 0.5 # en.text = "01234" # en.scrollbar_policy = ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF # en.single_line = True # en.show() # bx.pack_end(en) # digits_filter_data.accepted = "0123456789" # digits_filter_data.rejected = NULL # en.markup_filter_append(elm_entry_filter_accept_set, digits_filter_data) # # No digits entry # en = ScrollableEntry(win) # en.size_hint_weight = EVAS_HINT_EXPAND, 0.0 # en.size_hint_align = EVAS_HINT_FILL, 0.5 # en.text = "No numbers here" # en.scrollbar_policy = ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF # en.single_line = True # en.show() # bx.pack_end(en) # digits_filter_data2.accepted = NULL # digits_filter_data2.rejected = "0123456789" # en.markup_filter_append(elm_entry_filter_accept_set, digits_filter_data2) # # Size limited entry # en = ScrollableEntry(win) # en.size_hint_weight = EVAS_HINT_EXPAND, 0.0 # en.size_hint_align = EVAS_HINT_FILL, 0.5 # en.text = "Just 20 chars" # en.scrollbar_policy = ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF # en.single_line = True # en.show() # bx.pack_end(en) # limit_filter_data.max_char_count = 20 # limit_filter_data.max_byte_count = 0 # en.markup_filter_append(elm_entry_filter_limit_size, limit_filter_data) # # Byte size limited entry # en = ScrollableEntry(win) # en.size_hint_weight = EVAS_HINT_EXPAND, 0.0 # en.size_hint_align = EVAS_HINT_FILL, 0.5 # en.text = "And now only 30 bytes" # en.policy = ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF # en.single_line = True # en.show() # bx.pack_end(en) # limit_filter_data2.max_char_count = 0 # limit_filter_data2.max_byte_count = 30 # en.markup_filter_append(elm_entry_filter_limit_size, limit_filter_data2) # Single line password entry en_p = ScrollableEntry(win, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ, policy=SCROLL_POLICY_OFF, text="Password here", single_line=True, password=True) en_p.show() bx.pack_end(en_p) # entry with icon/end widgets en = ScrollableEntry(win, policy=SCROLL_POLICY_OFF, single_line=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, text="entry with icon and end objects") bt = Icon(win, standard="home", size_hint_min=(48, 48), color=(128, 0, 0, 128)) bt.show() en.part_content_set("icon", bt) bt = Icon(win, standard="delete", size_hint_min=(48, 48), color=(128, 0, 0, 128)) bt.show() en.part_content_set("end", bt) en.show() bx.pack_end(en) # markup entry en = ScrollableEntry(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, policy=SCROLL_POLICY_ON) en.text = "This is an entry widget in this window that<br/>"\ "uses markup <b>like this</> for styling and<br/>"\ "formatting <em>like this</>, as well as<br/>"\ "<a href=X><link>links in the text</></a>, so enter text<br/>"\ "in here to edit it. By them way, links are<br/>"\ "called <a href=anc-02>Anchors</a> so you will need<br/>"\ "to refer to them this way. At the end here is a really long "\ "line to test line wrapping to see if it works. But just in "\ "case this line is not long enough I will add more here to "\ "really test it out, as Elementary really needs some "\ "good testing to see if entry widgets work as advertised." en.callback_anchor_clicked_add(scrolled_anchor_test, en) en.show() bx.pack_end(en) bx2 = Box(win, horizontal=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) bt = Button(win, text="Clear", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_HORIZ, propagate_events=False, focus_allow=False) bt.callback_clicked_add(scrolled_entry_bt_1, en) bx2.pack_end(bt) bt.show() bt = Button(win, text="Print", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_HORIZ, propagate_events=False, focus_allow=False) bt.callback_clicked_add(scrolled_entry_bt_2, en) bx2.pack_end(bt) bt.show() bt = Button(win, text="Print pwd", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_HORIZ, propagate_events=False, focus_allow=False) bt.callback_clicked_add(scrolled_entry_bt_5, en_p) bx2.pack_end(bt) bt.show() bt = Button(win, text="Selection", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_HORIZ, propagate_events=False, focus_allow=False) bt.callback_clicked_add(scrolled_entry_bt_3, en) bx2.pack_end(bt) bt.show() bt = Button(win, text="Insert", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_HORIZ, propagate_events=False, focus_allow=False) bt.callback_clicked_add(scrolled_entry_bt_4, en) bx2.pack_end(bt) bt.show() bx.pack_end(bx2) bx2.show() win.focus_set(True) win.show()
def focus2_clicked(obj, item=None): win = StandardWindow("focus2", "Focus 2", autodel=True, size=(400, 400)) win.focus_highlight_enabled = True bx = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(bx) bx.show() PARENT = bx en = Entry(PARENT, scrollable=True, single_line=True, text="Entry that should get focus", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) bx.pack_end(en) en.show() bt = Button(PARENT, text="Give focus to entry") bt.callback_clicked_add(_focus_obj, en) bx.pack_end(bt) bt.show() ly = Layout(PARENT, size_hint_weight=EXPAND_BOTH) ly.file = edj_file, "layout" bx.pack_end(ly) ly.show() bt1 = bt = Button(ly, text="Button 1") ly.part_content_set("element1", bt) en1 = Entry(ly, scrollable=True, single_line=True, text="Scrolled Entry that should get focus", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) ly.part_content_set("element2", en1) bt = Button(ly, text="Button 2") ly.part_content_set("element3", bt) bt = Button(PARENT, text="Give focus to layout", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) bt.callback_clicked_add(_focus_obj, ly) bx.pack_end(bt) bt.show() bt = Button(PARENT, text="Give focus to layout part", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) bt.callback_clicked_add(_focus_layout_part, ly) bx.pack_end(bt) bt.show() bt = Button(PARENT, text="Give focus to layout 'Button 1'", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) bt.callback_clicked_add(_focus_obj, bt1) bx.pack_end(bt) bt.show() bt = Button(PARENT, text="Give focus to layout 'Entry'", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) bt.callback_clicked_add(_focus_obj, en1) bx.pack_end(bt) bt.show() bt.focus_next_object_set(en, ELM_FOCUS_DOWN) en.focus_next_object_set(bt, ELM_FOCUS_UP) win.show()
def flip_clicked(obj, item=None): win = StandardWindow("flip", "Flip", autodel=True, size=(320, 320)) box = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(box) box.show() fl = Flip(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) fl.callback_animate_begin_add(my_flip_animate_begin) fl.callback_animate_done_add(my_flip_animate_done) box.pack_end(fl) fl.show() # flip front content o = Background(win, size_hint_weight=EXPAND_BOTH, file=os.path.join(img_path, "sky_01.jpg")) fl.part_content_set("front", o) o.show() # flip back content ly = Layout(win, file=(os.path.join(script_path, "test.edj"), "layout"), size_hint_weight=EXPAND_BOTH) fl.part_content_set("back", ly) ly.show() bt = Button(win, text="Button 1") ly.part_content_set("element1", bt) bt.show() bt = Button(win, text="Button 2") ly.part_content_set("element2", bt) bt.show() bt = Button(win, text="Button 3") ly.part_content_set("element3", bt) bt.show() # flip buttons (first row) hbox = Box(win, size_hint_weight=EXPAND_HORIZ, size_hint_align=(EVAS_HINT_FILL, 0.0), horizontal=True) hbox.show() box.pack_end(hbox) count = 1 for mode in [ELM_FLIP_ROTATE_X_CENTER_AXIS, ELM_FLIP_ROTATE_Y_CENTER_AXIS, ELM_FLIP_ROTATE_XZ_CENTER_AXIS, ELM_FLIP_ROTATE_YZ_CENTER_AXIS]: bt = Button(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, text=str(count)) bt.callback_clicked_add(my_flip_go, fl, mode) hbox.pack_end(bt) bt.show() count += 1 # flip buttons (second row) hbox = Box(win, size_hint_weight=EXPAND_HORIZ, size_hint_align=(EVAS_HINT_FILL, 0.0), horizontal=True) hbox.show() box.pack_end(hbox) for mode in [ELM_FLIP_CUBE_LEFT, ELM_FLIP_CUBE_RIGHT, ELM_FLIP_CUBE_UP, ELM_FLIP_CUBE_DOWN]: bt = Button(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, text=str(count)) bt.callback_clicked_add(my_flip_go, fl, mode) hbox.pack_end(bt) bt.show() count += 1 # flip buttons (third row) hbox = Box(win, size_hint_weight=EXPAND_HORIZ, size_hint_align=(EVAS_HINT_FILL, 0.0), horizontal=True) hbox.show() box.pack_end(hbox) for mode in [ELM_FLIP_PAGE_LEFT, ELM_FLIP_PAGE_RIGHT, ELM_FLIP_PAGE_UP, ELM_FLIP_PAGE_DOWN]: bt = Button(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, text=str(count)) bt.callback_clicked_add(my_flip_go, fl, mode) hbox.pack_end(bt) bt.show() count += 1 win.show()
if __name__ == "__main__": import logging elog = logging.getLogger("efl") elog.addHandler(logging.StreamHandler()) elog.setLevel(logging.WARN) import efl.elementary as elm import efl.evas as evas from efl.elementary.window import StandardWindow from efl.elementary.label import Label evas.init() elm.init() elm.policy_set(elm.ELM_POLICY_QUIT, elm.ELM_POLICY_QUIT_LAST_WINDOW_CLOSED) win = StandardWindow("test", "test", autodel=True) tabs = Tabs(win, size_hint_weight=EXPAND_BOTH, size_hint_fill=FILL_BOTH) def added(tabs, content): print("added", content) def selected(tabs, content): print("selected", content) def deleted(tabs, content): print("deleted", content) tabs.callback_add("tab,added", added) tabs.callback_add("tab,selected", selected) tabs.callback_add("tab,deleted", deleted)
def list3_clicked(obj, item=None): win = StandardWindow("list-3", "List 3", autodel=True, size=(320, 300)) li = List(win, size_hint_weight=EXPAND_BOTH, mode=ELM_LIST_COMPRESS) win.resize_object_add(li) ic = Icon(win, file=os.path.join(img_path, "logo_small.png")) li.item_append("Hello", ic) ic = Icon(win, file=os.path.join(img_path, "logo_small.png"), resizable=(False, False)) li.item_append("world", ic) ic = Icon(win, standard="edit", resizable=(False, False)) li.item_append(".", ic) ic = Icon(win, standard="delete", resizable=(False, False)) ic2 = Icon(win, standard="clock", resizable=(False, False)) it2 = li.item_append("How", ic, ic2) bx = Box(win, horizontal=True) bx.horizontal_set(True) ic = Icon(win, standard="delete", resizable=(False, False), size_hint_align=ALIGN_CENTER) bx.pack_end(ic) ic.show() ic = Icon(win, file=os.path.join(img_path, "logo_small.png"), resizable=(False, False), size_hint_align=(0.5, 0.0)) bx.pack_end(ic) ic.show() ic = Icon(win, file=os.path.join(img_path, "logo_small.png"), resizable=(False, False), size_hint_align=(0.0, EVAS_HINT_FILL)) bx.pack_end(ic) ic.show() li.item_append("are", bx) li.item_append("you") li.item_append("doing") li.item_append("out") li.item_append("there") li.item_append("today") li.item_append("?") li.item_append("Here") li.item_append("are") li.item_append("some") li.item_append("more") li.item_append("items") li.item_append("Is this label long enough?") it5 = li.item_append( "Maybe this one is even longer so we can test long long items.") li.go() li.show() win.show()
def __init__(self, app): self.app = app self.prog_popup = None # the window StandardWindow.__init__(self, 'epack', 'Epack') self.autodel_set(True) self.callback_delete_request_add(lambda o: self.app.exit()) ### main table (inside a padding frame) frame = Frame(self, style='pad_small', size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.resize_object_add(frame) frame.content = table = Table(frame) frame.show() ### header horiz box self.header_box = Box(self, horizontal=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) table.pack(self.header_box, 0, 0, 3, 1) self.header_box.show() # genlist with archive content (inside a small padding frame) frame = Frame(self, style='pad_small', size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) table.pack(frame, 0, 1, 3, 1) self.file_itc = GenlistItemClass(item_style="no_icon", text_get_func=self._gl_file_text_get) self.fold_itc = GenlistItemClass( item_style="one_icon", text_get_func=self._gl_fold_text_get, content_get_func=self._gl_fold_icon_get) self.file_list = Genlist(frame, homogeneous=True) self.file_list.callback_expand_request_add(self._gl_expand_req_cb) self.file_list.callback_contract_request_add(self._gl_contract_req_cb) self.file_list.callback_expanded_add(self._gl_expanded_cb) self.file_list.callback_contracted_add(self._gl_contracted_cb) frame.content = self.file_list frame.show() # rect hack to force a min size on the genlist r = evas.Rectangle(table.evas, size_hint_min=(250, 250), size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) table.pack(r, 0, 1, 3, 1) # FileSelectorButton self.fsb = DestinationButton(app, self) table.pack(self.fsb, 0, 2, 3, 1) self.fsb.show() sep = Separator(table, horizontal=True, size_hint_weight=EXPAND_HORIZ) table.pack(sep, 0, 3, 3, 1) sep.show() # extract button self.extract_btn = Button(table, text=_('Extract')) self.extract_btn.callback_clicked_add(self.extract_btn_cb) table.pack(self.extract_btn, 0, 4, 1, 2) self.extract_btn.show() sep = Separator(table, horizontal=False) table.pack(sep, 1, 4, 1, 2) sep.show() # delete-archive checkbox self.del_chk = Check(table, text=_('Delete archive after extraction'), size_hint_weight=EXPAND_HORIZ, size_hint_align=(0.0, 1.0)) self.del_chk.callback_changed_add(self.del_check_cb) table.pack(self.del_chk, 2, 4, 1, 1) self.del_chk.show() # create-archive-folder checkbox self.create_folder_chk = Check(table, text=_('Create archive folder'), size_hint_weight=EXPAND_HORIZ, size_hint_align=(0.0, 1.0)) table.pack(self.create_folder_chk, 2, 5, 1, 1) self.create_folder_chk.callback_changed_add( lambda c: self.update_fsb_label()) self.create_folder_chk.show() # set the correct ui state self.update_ui() # show the window self.show()
def window_dialog_clicked(obj): win = StandardWindow("window-states", "This is a StandardWindow", autodel=True, size=(800, 600)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) ecore_input.on_mouse_button_down_add(clicked_mouse) windowGrid = Grid(win, size=(100, 100), size_hint_weight=EXPAND_BOTH) win.resize_object_add(windowGrid) windowGrid.show() starterBase = 0 conjectureA = Conjecture(windowGrid, "Calibi") conjectureB = Conjecture(windowGrid, "Yau") while True: try: conjectureA.seed() conjectureB.seed() conjectureA.tune() conjectureB.tune() while (starterBase < conjectureA.ENTROPY_CUTOFF): starterBase = conjectureA.rand() aChallenge = conjectureA.getChallenge(starterBase) bChallenge = conjectureB.getChallenge(starterBase) conjectureA.setBase(bChallenge) conjectureB.setBase(aChallenge) conjectureA.generate() conjectureB.generate() aCarrier = conjectureA.getCarrier(conjectureB.pole) bCarrier = conjectureB.getCarrier(conjectureA.pole) conjectureB.establishListener() conjectureA.establishElement(conjectureB.foundation, conjectureB.channel) conjectureB.establishElement(conjectureA.foundation, conjectureA.channel) conjectureA.syncDynamo() conjectureB.syncDynamo() conjectureA.getManifold(conjectureB.dynamo) conjectureB.getManifold(conjectureA.dynamo) conjectureA.openManifold(aCarrier) conjectureB.openManifold(bCarrier) if conjectureA.validateManifold() and conjectureB.validateManifold( ): break except: continue conjectureA.updateGUIFields() conjectureB.updateGUIFields() conjectureA.initializeGUIEntry() conjectureB.initializeGUIEntry() # win.borderless_set(1) win.show()
def focus_clicked(obj, item=None): win = StandardWindow("focus", "Focus", autodel=True, size=(800, 600)) win.focus_highlight_enabled = True tbx = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(tbx) tbx.show() ### Toolbar tbar = Toolbar(win, shrink_mode=ELM_TOOLBAR_SHRINK_MENU, size_hint_align=(EVAS_HINT_FILL, 0.0)) tb_it = tbar.item_append("document-print", "Hello", _tb_sel) tb_it.disabled = True tb_it = tbar.item_append("folder-new", "World", _tb_sel) tb_it = tbar.item_append("object-rotate-right", "H", _tb_sel) tb_it = tbar.item_append("mail-send", "Comes", _tb_sel) tb_it = tbar.item_append("clock", "Elementary", _tb_sel) tb_it = tbar.item_append("refresh", "Menu", _tb_sel) tb_it.menu = True tbar.menu_parent = win menu = tb_it.menu menu.item_add(None, "Shrink", "edit-cut", _tb_sel) menu_it = menu.item_add(None, "Mode", "edit-copy", _tb_sel) menu.item_add(menu_it, "is set to", "edit-paste", _tb_sel) menu.item_add(menu_it, "or to", "edit-paste", _tb_sel) menu.item_add(None, "Menu", "edit-delete", _tb_sel) tbx.pack_end(tbar) tbar.show() mainbx = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH) tbx.pack_end(mainbx) mainbx.show() ## First Col bx = Box(win, size_hint_weight=EXPAND_BOTH) mainbx.pack_end(bx) bx.show() lb = Label(win, text="<b>Use Tab or Shift+Tab<br/>or Arrow keys</b>", size_hint_align=FILL_BOTH) bx.pack_end(lb) lb.show() tg = Check(win, style="toggle") tg.part_text_set("on", "Yes") tg.part_text_set("off", "No") bx.pack_end(tg) tg.show() en = Entry(win, scrollable=True, single_line=True, text="This is a single line", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) bx.pack_end(en) en.show() # bx2 = Box(win, horizontal=True, size_hint_align=FILL_BOTH) bx.pack_end(bx2) bx2.show() for i in range(2): bt = Button(win, text="Box", size_hint_align=FILL_BOTH, disabled=(i % 2)) bx2.pack_end(bt) bt.show() sc = Scroller(win, bounce=(True, True), content_min_limit=(1, 1), size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) bx2.pack_end(sc) sc.show() bt = Button(win, text="Scroller", size_hint_align=FILL_BOTH) sc.content = bt bt.show() # bt = Button(win, text="Box", size_hint_align=FILL_BOTH) bx.pack_end(bt) bt.show() # bx2 = Box(win, horizontal=True, size_hint_align=FILL_BOTH) bx.pack_end(bx2) bx2.show() for i in range(2): bx3 = Box(win, size_hint_align=FILL_BOTH) bx2.pack_end(bx3) bx3.show() for j in range(3): bt = Button(win, text="Box", size_hint_align=FILL_BOTH) bx3.pack_end(bt) bt.show() sc = Scroller(win, bounce=(False, True), content_min_limit=(1, 0), size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) sc.content_min_limit = (1, 1) bx2.pack_end(sc) sc.show() bx3 = Box(win, size_hint_align=FILL_BOTH) sc.content = bx3 bx3.show() for i in range(5): bt = Button(win, text="BX Scroller", size_hint_align=FILL_BOTH) bx3.pack_end(bt) bt.show() ## Second Col ly = Layout(win, size_hint_weight=EXPAND_BOTH) ly.file = edj_file, "twolines" mainbx.pack_end(ly) ly.show() bx2 = Box(win, horizontal=True, size_hint_align=FILL_BOTH) ly.part_content_set("element1", bx2) bx2.show() for i in range(3): bt = Button(win, text="Layout", size_hint_align=FILL_BOTH) bx2.pack_end(bt) bt.show() bx2.focus_custom_chain_prepend(bt) bx2 = Box(win, size_hint_align=FILL_BOTH) ly.part_content_set("element2", bx2) bx2.show() bt = Button(win, text="Disable", size_hint_align=FILL_BOTH) bt.callback_clicked_add(lambda b: b.disabled_set(True)) bx2.pack_end(bt) bt.show() bx2.focus_custom_chain_prepend(bt) bt2 = Button(win, text="Enable", size_hint_align=FILL_BOTH) bt2.callback_clicked_add(lambda b, b1: b1.disabled_set(False), bt) bx2.pack_end(bt2) bt2.show() bx2.focus_custom_chain_append(bt2) ## Third Col bx = Box(win, size_hint_weight=EXPAND_BOTH) mainbx.pack_end(bx) bx.show() fr = Frame( win, text="Frame", ) bx.pack_end(fr) fr.show() tb = Table(win, size_hint_weight=EXPAND_BOTH) fr.content = tb tb.show() for j in range(1): for i in range(2): bt = Button(win, text="Table", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) tb.pack(bt, i, j, 1, 1) bt.show() # fr = Bubble(win, text="Bubble", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) bx.pack_end(fr) fr.show() tb = Table(win, size_hint_weight=EXPAND_BOTH) fr.content = tb tb.show() for j in range(2): for i in range(1): bt = Button(win, text="Table", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) tb.pack(bt, i, j, 1, 1) bt.show() win.show()
class Application(object): def __init__(self): self.cfg = ConfigOption() self.userid = os.getuid() self.win = None self.bg = None self.main_box = None self.info_frame = None self.lb = None self.ps_list = None self.win = StandardWindow("my app", "eyekill", size=(320, 384)) self.win.title_set("eye kill") self.win.callback_delete_request_add(self.destroy) self.main_box = Box(self.win) self.main_box.size_hint_weight = EXPAND_BOTH self.win.resize_object_add(self.main_box) self.main_box.show() self.info_frame = Frame(self.win) self.info_frame.text_set("Information") self.main_box.pack_end(self.info_frame) self.info_frame.show() self.lb = Label(self.win) self.lb.text_set('<b>Kill process with a double click</b>') self.info_frame.content_set(self.lb) self.lb.show() self.ps_list = List(self.win) self.ps_list.size_hint_weight = EXPAND_BOTH self.ps_list.size_hint_align = FILL_BOTH self.ps_list.callback_clicked_double_add(self.kill_bill) self.update_list() self.main_box.pack_end(self.ps_list) self.ps_list.go() self.ps_list.show() self.win.resize(320, 384) self.win.show() def destroy(self, obj): # FIXME: but here self.cfg.save()??? elementary.exit() def update_list(self): if bool(self.cfg.get_desktop()): for de in self.cfg.get_desktop(): ps = psutil.Process(get_pid_by_name(de)) pl = ps.children() for p in pl: if p.uids().real == self.userid: if p.name not in self.cfg.get_process(): short_info = '%s / %s / %s' % (p.pid, p.name(), p.status()) self.ps_list.item_append(label=short_info, callback=self.update_info, p=p) else: pl = psutil.get_pid_list() for p in pl: p = psutil.Process(p) if p.uids().real == self.userid: if p.name() not in self.cfg.get_process(): short_info = '%s / %s / %s' % (p.pid, p.name(), p.status()) self.ps_list.item_append(label=short_info, callback=self.update_info, p=p) def update_info(self, li, it, p): info = ("PID %i STAT %s TIME %s<br/>MEM %s CPU %s COMMAND %s" % \ (p.pid,\ p.status(),\ p.get_cpu_times().user,\ hbytes(p.get_memory_info().rss),\ p.get_cpu_percent(interval=0),\ p.name())) self.lb.text_set(info) def kill_bill(self, obj, cb_data): bill = cb_data.data_get()[1]['p'].pid print("%s ... Gotcha" % bill) os.kill(bill, signal.SIGTERM) if (os.kill(bill, 0)): os.kill(bill, signal.SIGKILL) item = obj.selected_item_get() item.disabled_set(True)
def slideshow_clicked(obj): win = StandardWindow("slideshow", "Slideshow", autodel=True, size=(500, 400)) ss = Slideshow(win, loop=True, size_hint_weight=EXPAND_BOTH) win.resize_object_add(ss) ss.show() ssc = ssClass() ss.item_add(ssc, os.path.join(img_path, images[0])) ss.item_add(ssc, os.path.join(img_path, images[1])) ss.item_add(ssc, os.path.join(img_path, images[2])) ss.item_add(ssc, os.path.join(img_path, images[3])) ss.item_add(ssc, os.path.join(img_path, images[8])) ss.item_add(ssc, os.path.join(img_path, images[4])) ss.item_add(ssc, os.path.join(img_path, images[5])) ss.item_add(ssc, os.path.join(img_path, images[6])) slide_last_it = ss.item_add(ssc, os.path.join(img_path, images[7])) ss.callback_transition_end_add(slide_transition, slide_last_it) bx = Box(win, horizontal=True) bx.show() no = Notify(win, align=(0.5, 1.0), size_hint_weight=EXPAND_BOTH, timeout=3.0, content=bx) win.resize_object_add(no) bx.event_callback_add(EVAS_CALLBACK_MOUSE_IN, mouse_in, no) bx.event_callback_add(EVAS_CALLBACK_MOUSE_OUT, mouse_out, no) bt = Button(win, text="Previous") bt.callback_clicked_add(previous, ss) bx.pack_end(bt) bt.show() bt = Button(win, text="Next") bt.callback_clicked_add(next, ss) bx.pack_end(bt) bt.show() hv = Hoversel(win, hover_parent=win, text=ss.transitions[0]) bx.pack_end(hv) for transition in ss.transitions: hv.item_add(transition, None, 0, hv_select, ss, transition) hv.item_add("None", None, 0, hv_select, ss, None) hv.show() hv = Hoversel(win, hover_parent=win, text=ss.layout) bx.pack_end(hv) for layout in ss.layouts: hv.item_add(layout, None, 0, layout_select, ss, layout) hv.show() sp = Spinner(win, label_format="%2.0f secs.", step=1, min_max=(1, 30), value=3) sp.callback_changed_add(spin, ss) bx.pack_end(sp) sp.show() bt_start = Button(win, text="Start") bt_stop = Button(win, text="Stop", disabled=True) bt_start.callback_clicked_add(start, ss, sp, bt_start, bt_stop) bx.pack_end(bt_start) bt_start.show() bt_stop.callback_clicked_add(stop, ss, sp, bt_start, bt_stop) bx.pack_end(bt_stop) bt_stop.show() ss.event_callback_add(EVAS_CALLBACK_MOUSE_UP, notify_show, no) ss.event_callback_add(EVAS_CALLBACK_MOUSE_MOVE, notify_show, no) win.show()
def list_clicked(obj, item=None): win = StandardWindow("list", "List", autodel=True, size=(320, 320)) li = List(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(li) ic = Icon(win, file=os.path.join(img_path, "logo_small.png"), resizable=(True, True)) it1 = li.item_append("Hello", ic) ic = Icon(win, file=os.path.join(img_path, "logo_small.png"), resizable=(False, False)) li.item_append("Hello", ic) ic = Icon(win, standard="edit", resizable=(False, False)) ic2 = Icon(win, standard="clock", resizable=(False, False)) li.item_append(".", ic, ic2) ic = Icon(win, standard="delete", resizable=(False, False)) ic2 = Icon(win, standard="clock", resizable=(False, False)) it2 = li.item_append("How", ic, ic2) bx = Box(win, horizontal=True) ic = Icon(win, file=os.path.join(img_path, "logo_small.png"), resizable=(False, False), size_hint_align=ALIGN_CENTER) bx.pack_end(ic) ic.show() ic = Icon(win, file=os.path.join(img_path, "logo_small.png"), resizable=(False, False), size_hint_align=(0.5, 0.0)) bx.pack_end(ic) ic.show() ic = Icon(win, file=os.path.join(img_path, "logo_small.png"), resizable=(False, False), size_hint_align=(0.0, EVAS_HINT_FILL)) bx.pack_end(ic) ic.show() li.item_append("are") li.item_append("you") it3 = li.item_append("doing") li.item_append("out") li.item_append("there") li.item_append("today") li.item_append("?") it4 = li.item_append("Here") li.item_append("are") li.item_append("some") li.item_append("more") li.item_append("items") li.item_append("Is this label long enough?") it5 = li.item_append( "Maybe this one is even longer so we can test long long items.") li.go() li.show() tb2 = Table(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(tb2) bt = Button(win, text="Hello", size_hint_weight=EXPAND_BOTH, size_hint_align=(0.9, 0.5)) bt.callback_clicked_add(my_list_show_it, it1) tb2.pack(bt, 0, 0, 1, 1) bt.show() bt = Button(win, text="How", size_hint_weight=EXPAND_BOTH, size_hint_align=(0.9, 0.5)) bt.callback_clicked_add(my_list_show_it, it2) tb2.pack(bt, 0, 1, 1, 1) bt.show() bt = Button(win, text="doing", size_hint_weight=EXPAND_BOTH, size_hint_align=(0.9, 0.5)) bt.callback_clicked_add(my_list_show_it, it3) tb2.pack(bt, 0, 2, 1, 1) bt.show() bt = Button(win, text="Here", size_hint_weight=EXPAND_BOTH, size_hint_align=(0.9, 0.5)) bt.callback_clicked_add(my_list_show_it, it4) tb2.pack(bt, 0, 3, 1, 1) bt.show() bt = Button(win, text="Maybe this...", size_hint_weight=EXPAND_BOTH, size_hint_align=(0.9, 0.5)) bt.callback_clicked_add(my_list_show_it, it5) tb2.pack(bt, 0, 4, 1, 1) bt.show() tb2.show() win.show()
box.pack_end(rd) rd.show() rd = Radio(win, state_value=ELM_FLIP_INTERACTION_PAGE, text="Page") rd.callback_changed_add(my_cb_radios, fl) rd.group_add(rdg) box.pack_end(rd) rd.show() # window show win.show() if __name__ == "__main__": elementary.init() win = StandardWindow("test", "python-elementary test application", size=(320,520)) win.callback_delete_request_add(lambda o: elementary.exit()) box0 = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(box0) box0.show() lb = Label(win) lb.text_set("Please select a test from the list below<br>" "by clicking the test button to show the<br>" "test window.") lb.show() fr = Frame(win, text="Information", content=lb) box0.pack_end(fr) fr.show()
def flip_interactive_clicked(obj, item=None): win = StandardWindow("flip", "Flip", autodel=True, size=(320, 320)) box = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(box) box.show() # flip object fl = Flip(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, interaction=ELM_FLIP_INTERACTION_NONE) fl.interaction_direction_enabled_set(ELM_FLIP_DIRECTION_UP, True) fl.interaction_direction_enabled_set(ELM_FLIP_DIRECTION_DOWN, True) fl.interaction_direction_enabled_set(ELM_FLIP_DIRECTION_LEFT, True) fl.interaction_direction_enabled_set(ELM_FLIP_DIRECTION_RIGHT, True) fl.interaction_direction_hitsize_set(ELM_FLIP_DIRECTION_UP, 0.25) fl.interaction_direction_hitsize_set(ELM_FLIP_DIRECTION_DOWN, 0.25) fl.interaction_direction_hitsize_set(ELM_FLIP_DIRECTION_LEFT, 0.25) fl.interaction_direction_hitsize_set(ELM_FLIP_DIRECTION_RIGHT, 0.25) fl.callback_animate_begin_add(my_flip_animate_begin) fl.callback_animate_done_add(my_flip_animate_done) box.pack_end(fl) fl.show() # front content (image) o = Background(win, size_hint_weight=EXPAND_BOTH, file=os.path.join(img_path, "sky_01.jpg")) fl.part_content_set("front", o) o.show() # back content (layout) ly = Layout(win, size_hint_weight=EXPAND_BOTH, file=(os.path.join(script_path, "test.edj"), "layout")) fl.part_content_set("back", ly) ly.show() bt = Button(win, text="Button 1") ly.part_content_set("element1", bt) bt.show() bt = Button(win, text="Button 2") ly.part_content_set("element2", bt) bt.show() bt = Button(win, text="Button 3") ly.part_content_set("element3", bt) bt.show() # radio buttons rd = Radio(win, state_value=ELM_FLIP_INTERACTION_NONE, text="None") rd.callback_changed_add(my_cb_radios, fl) box.pack_end(rd) rd.show() rdg = rd rd = Radio(win, state_value=ELM_FLIP_INTERACTION_ROTATE, text="Rotate") rd.callback_changed_add(my_cb_radios, fl) rd.group_add(rdg) box.pack_end(rd) rd.show() rd = Radio(win, state_value=ELM_FLIP_INTERACTION_CUBE, text="Cube") rd.callback_changed_add(my_cb_radios, fl) rd.group_add(rdg) box.pack_end(rd) rd.show() rd = Radio(win, state_value=ELM_FLIP_INTERACTION_PAGE, text="Page") rd.callback_changed_add(my_cb_radios, fl) rd.group_add(rdg) box.pack_end(rd) rd.show() # window show win.show()
class Interface(object): def __init__(self): self.mainWindow = StandardWindow("epad", "Untitled - ePad", size=(600, 400)) self.mainWindow.callback_delete_request_add(self.closeChecks) self.mainWindow.elm_event_callback_add(self.eventsCb) icon = Icon(self.mainWindow) icon.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND) icon.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL) icon.standard_set( 'accessories-text-editor' ) # assumes image icon is in local dir, may need to change later icon.show() self.mainWindow.icon_object_set(icon.object_get()) self.mainBox = Box(self.mainWindow, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.mainBox.show() self.mainTb = Toolbar(self.mainWindow, homogeneous=False, size_hint_weight=(0.0, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.0)) self.mainTb.menu_parent = self.mainWindow self.mainTb.item_append("document-new", "New", self.newPress) self.mainTb.item_append("document-open", "Open", self.openPress) self.mainTb.item_append("document-save", "Save", self.savePress) self.mainTb.item_append("document-save-as", "Save As", self.saveAsPress) # -- Edit Dropdown Menu -- tb_it = self.mainTb.item_append("edit", "Edit") tb_it.menu = True menu = tb_it.menu menu.item_add(None, "Copy", "edit-copy", self.copyPress) menu.item_add(None, "Paste", "edit-paste", self.pastePress) menu.item_add(None, "Cut", "edit-cut", self.cutPress) menu.item_separator_add() menu.item_add(None, "Select All", "edit-select-all", self.selectAllPress) # ----------------------- # self.mainTb.item_append("settings", "Options", self.optionsPress) self.mainTb.item_append("dialog-information", "About", self.aboutPress) self.mainEn = Entry(self.mainWindow, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.mainEn.callback_changed_user_add(self.textEdited) self.mainEn.scrollable_set( True) # creates scrollbars rather than enlarge window self.mainEn.line_wrap_set( False) # does not allow line wrap (can be changed by user) self.mainEn.autosave_set(False) # set to false to reduce disk I/O self.mainEn.elm_event_callback_add(self.eventsCb) self.mainEn.markup_filter_append(self.textFilter) self.mainEn.show() self.mainTb.show() self.mainBox.pack_end(self.mainTb) self.mainBox.pack_end(self.mainEn) #Build our file selector for saving/loading files self.fileBox = Box(self.mainWindow, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.fileBox.show() self.fileLabel = Label(self.mainWindow, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) self.fileLabel.text = "" self.fileLabel.show() self.fileSelector = Fileselector(self.mainWindow, is_save=False, expandable=False, folder_only=False, path=os.getenv("HOME"), size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.fileSelector.callback_done_add(self.fileSelected) #self.fileSelector.callback_selected_add(fs_cb_selected, win) #self.fileSelector.callback_directory_open_add(fs_cb_directory_open, win) self.fileSelector.show() self.fileBox.pack_end(self.fileLabel) self.fileBox.pack_end(self.fileSelector) # the flip object has the file selector on one side and the GUI on the other self.flip = Flip(self.mainWindow, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.flip.part_content_set("front", self.mainBox) self.flip.part_content_set("back", self.fileBox) self.mainWindow.resize_object_add(self.flip) self.flip.show() self.isSaved = True self.isNewFile = False self.confirmPopup = None def newPress(self, obj, it): self.newFile() it.selected_set(False) def openPress(self, obj, it): self.openFile() it.selected_set(False) def savePress(self, obj, it): self.saveFile() it.selected_set(False) def saveAsPress(self, obj, it): self.saveAs() it.selected_set(False) def optionsPress(self, obj, it): it.selected_set(False) def copyPress(self, obj, it): self.mainEn.selection_copy() it.selected_set(False) def pastePress(self, obj, it): self.mainEn.selection_paste() it.selected_set(False) def cutPress(self, obj, it): self.mainEn.selection_cut() it.selected_set(False) def selectAllPress(self, obj, it): self.mainEn.select_all() it.selected_set(False) def textEdited(self, obj): ourFile = self.mainEn.file_get()[0] if ourFile and not self.isNewFile: self.mainWindow.title_set( "*%s - ePad" % self.mainEn.file_get()[0].split("/")[ len(self.mainEn.file_get()[0].split("/")) - 1]) else: self.mainWindow.title_set("*Untitlted - ePad") self.isSaved = False def fileSelected(self, fs, file_selected, onStartup=False): if not onStartup: self.flip.go(ELM_FLIP_INTERACTION_ROTATE) print(file_selected) IsSave = fs.is_save_get() if file_selected: if IsSave: newfile = open(file_selected, 'w') # creates new file tmp_text = self.mainEn.entry_get() newfile.write(tmp_text) newfile.close() self.mainEn.file_set(file_selected, ELM_TEXT_FORMAT_PLAIN_UTF8) self.mainEn.entry_set(tmp_text) self.mainEn.file_save() self.mainWindow.title_set( "%s - ePad" % file_selected.split("/")[len(file_selected.split("/")) - 1]) self.isSaved = True self.isNewFile = False else: try: self.mainEn.file_set(file_selected, ELM_TEXT_FORMAT_PLAIN_UTF8) except RuntimeError: print("Empty file: {0}".format(file_selected)) self.mainWindow.title_set( "%s - ePad" % file_selected.split("/")[len(file_selected.split("/")) - 1]) def aboutPress(self, obj, it): #About popup self.popupAbout = Popup(self.mainWindow, size_hint_weight=EXPAND_BOTH) self.popupAbout.text = "ePad - A simple text editor written in python and elementary<br><br> " \ "By: Jeff Hoogland" bt = Button(self.mainWindow, text="Done") bt.callback_clicked_add(self.aboutClose) self.popupAbout.part_content_set("button1", bt) self.popupAbout.show() it.selected_set(False) def aboutClose(self, bt): self.popupAbout.delete() def newFile(self, obj=None, ignoreSave=False): if self.isSaved == True or ignoreSave == True: trans = Transit() trans.object_add(self.mainEn) trans.auto_reverse = True trans.effect_wipe_add(ELM_TRANSIT_EFFECT_WIPE_TYPE_HIDE, ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT) trans.duration = 0.5 trans.go() time.sleep(0.5) self.mainWindow.title_set("Untitlted - ePad") self.mainEn.delete() self.mainEn = Entry(self.mainWindow, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.mainEn.callback_changed_user_add(self.textEdited) self.mainEn.scrollable_set( True) # creates scrollbars rather than enlarge window self.mainEn.line_wrap_set( False) # does not allow line wrap (can be changed by user) self.mainEn.autosave_set(False) # set to false to reduce disk I/O self.mainEn.elm_event_callback_add(self.eventsCb) self.mainEn.markup_filter_append(self.textFilter) self.mainEn.show() self.mainBox.pack_end(self.mainEn) self.isNewFile = True elif self.confirmPopup == None: self.confirmSave(self.newFile) def openFile(self, obj=None, ignoreSave=False): if self.isSaved == True or ignoreSave == True: self.fileSelector.is_save_set(False) self.fileLabel.text = "<b>Select a text file to open:</b>" self.flip.go(ELM_FLIP_ROTATE_YZ_CENTER_AXIS) elif self.confirmPopup == None: self.confirmSave(self.openFile) def confirmSave(self, ourCallback=None): self.confirmPopup = Popup(self.mainWindow, size_hint_weight=EXPAND_BOTH) self.confirmPopup.part_text_set("title,text", "File Unsaved") if self.mainEn.file_get()[0]: self.confirmPopup.text = "Save changes to '%s'?" % self.mainEn.file_get( )[0].split("/")[len(self.mainEn.file_get()[0].split("/")) - 1] else: self.confirmPopup.text = "Save changes to 'Untitlted'?" # Close without saving button no_btt = Button(self.mainWindow) no_btt.text = "No" no_btt.callback_clicked_add(self.closePopup, self.confirmPopup) if ourCallback is not None: no_btt.callback_clicked_add(ourCallback, True) no_btt.show() # cancel close request cancel_btt = Button(self.mainWindow) cancel_btt.text = "Cancel" cancel_btt.callback_clicked_add(self.closePopup, self.confirmPopup) cancel_btt.show() # Save the file and then close button sav_btt = Button(self.mainWindow) sav_btt.text = "Yes" sav_btt.callback_clicked_add(self.saveFile) sav_btt.callback_clicked_add(self.closePopup, self.confirmPopup) sav_btt.show() # add buttons to popup self.confirmPopup.part_content_set("button1", no_btt) self.confirmPopup.part_content_set("button2", cancel_btt) self.confirmPopup.part_content_set("button3", sav_btt) self.confirmPopup.show() def saveAs(self): self.fileSelector.is_save_set(True) self.fileLabel.text = "<b>Save new file to where:</b>" self.flip.go(ELM_FLIP_ROTATE_XZ_CENTER_AXIS) def saveFile(self, obj=False): if self.mainEn.file_get()[0] == None or self.isNewFile: self.saveAs() else: self.mainEn.file_save() self.mainWindow.title_set( "%s - ePad" % self.mainEn.file_get()[0].split("/")[ len(self.mainEn.file_get()[0].split("/")) - 1]) self.isSaved = True def closeChecks(self, obj): print(self.isSaved) if self.isSaved == False and self.confirmPopup == None: self.confirmSave(self.closeApp) else: self.closeApp() def closePopup(self, bt, confirmPopup): self.confirmPopup.delete() self.confirmPopup = None def closeApp(self, obj=False, trash=False): elementary.exit() def eventsCb(self, obj, src, event_type, event): #print event_type #print event.key #print "Control Key Status: %s" %event.modifier_is_set("Control") #print "Shift Key Status: %s" %event.modifier_is_set("Shift") #print event.modifier_is_set("Alt") if event.modifier_is_set("Control"): if event.key.lower() == "n": self.newFile() elif event.key.lower() == "s" and event.modifier_is_set("Shift"): self.saveAs() elif event.key.lower() == "s": self.saveFile() elif event.key.lower() == "o": self.openFile() def textFilter(self, obj, theText, data): #print theText #Block ctrl+hot keys if theText == "" or theText == "" or theText == "": return None else: return theText def launch(self, startingFile=False): if startingFile: self.fileSelected(self.fileSelector, startingFile, True) self.mainWindow.show()
def bubble_clicked(obj, item=None): win = StandardWindow("bubble", "Bubble", autodel=True, size=(320, 320)) bx = Box(win) win.resize_object_add(bx) bx.size_hint_weight = EXPAND_BOTH bx.show() # bb 1 ic = Icon(win, file=ic_file, size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1)) lb = Label(win, text="Blah, Blah, Blah") 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() # bb 2 ic = Icon(win, file=ic_file, size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1)) lb = Label(win, text="Blah, Blah, Blah") bb = Bubble(win, text="Message 2", content=lb, pos=ELM_BUBBLE_POS_TOP_RIGHT, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) bb.part_text_set("info", "Corner: top_right") bb.part_content_set("icon", ic) bx.pack_end(bb) bb.show() # bb 3 ic = Icon(win, file=ic_file, size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1)) lb = Label(win, text="Blah, Blah, Blah") bb = Bubble(win, text="Message 3", content=ic, pos=ELM_BUBBLE_POS_BOTTOM_LEFT, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) bb.part_text_set("info", "Corner: bottom_left") bx.pack_end(bb) bb.show() # bb 4 ic = Icon(win, file=ic_file, size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1)) lb = Label(win, text="Blah, Blah, Blah") bb = Bubble(win, text="Message 4", content=lb, pos=ELM_BUBBLE_POS_BOTTOM_RIGHT, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) bb.part_text_set("info", "Corner: bottom_right") bb.part_content_set("icon", ic) bx.pack_end(bb) bb.show() win.show()
def __init__(self): self.mainWindow = StandardWindow("epad", "Untitled - ePad", size=(600, 400)) self.mainWindow.callback_delete_request_add(self.closeChecks) self.mainWindow.elm_event_callback_add(self.eventsCb) icon = Icon(self.mainWindow) icon.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND) icon.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL) icon.standard_set( 'accessories-text-editor' ) # assumes image icon is in local dir, may need to change later icon.show() self.mainWindow.icon_object_set(icon.object_get()) self.mainBox = Box(self.mainWindow, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.mainBox.show() self.mainTb = Toolbar(self.mainWindow, homogeneous=False, size_hint_weight=(0.0, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.0)) self.mainTb.menu_parent = self.mainWindow self.mainTb.item_append("document-new", "New", self.newPress) self.mainTb.item_append("document-open", "Open", self.openPress) self.mainTb.item_append("document-save", "Save", self.savePress) self.mainTb.item_append("document-save-as", "Save As", self.saveAsPress) # -- Edit Dropdown Menu -- tb_it = self.mainTb.item_append("edit", "Edit") tb_it.menu = True menu = tb_it.menu menu.item_add(None, "Copy", "edit-copy", self.copyPress) menu.item_add(None, "Paste", "edit-paste", self.pastePress) menu.item_add(None, "Cut", "edit-cut", self.cutPress) menu.item_separator_add() menu.item_add(None, "Select All", "edit-select-all", self.selectAllPress) # ----------------------- # self.mainTb.item_append("settings", "Options", self.optionsPress) self.mainTb.item_append("dialog-information", "About", self.aboutPress) self.mainEn = Entry(self.mainWindow, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.mainEn.callback_changed_user_add(self.textEdited) self.mainEn.scrollable_set( True) # creates scrollbars rather than enlarge window self.mainEn.line_wrap_set( False) # does not allow line wrap (can be changed by user) self.mainEn.autosave_set(False) # set to false to reduce disk I/O self.mainEn.elm_event_callback_add(self.eventsCb) self.mainEn.markup_filter_append(self.textFilter) self.mainEn.show() self.mainTb.show() self.mainBox.pack_end(self.mainTb) self.mainBox.pack_end(self.mainEn) #Build our file selector for saving/loading files self.fileBox = Box(self.mainWindow, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.fileBox.show() self.fileLabel = Label(self.mainWindow, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) self.fileLabel.text = "" self.fileLabel.show() self.fileSelector = Fileselector(self.mainWindow, is_save=False, expandable=False, folder_only=False, path=os.getenv("HOME"), size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.fileSelector.callback_done_add(self.fileSelected) #self.fileSelector.callback_selected_add(fs_cb_selected, win) #self.fileSelector.callback_directory_open_add(fs_cb_directory_open, win) self.fileSelector.show() self.fileBox.pack_end(self.fileLabel) self.fileBox.pack_end(self.fileSelector) # the flip object has the file selector on one side and the GUI on the other self.flip = Flip(self.mainWindow, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.flip.part_content_set("front", self.mainBox) self.flip.part_content_set("back", self.fileBox) self.mainWindow.resize_object_add(self.flip) self.flip.show() self.isSaved = True self.isNewFile = False self.confirmPopup = None
def photocam_clicked(obj): win = StandardWindow("photocam", "Photocam test", autodel=True, size=(600, 600)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) # Photocam widget pc = Photocam(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(pc) pc.show() # table for buttons tb = Table(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(tb) tb.show() # zoom out btn bt = Button(win, text="Z -", size_hint_weight=EXPAND_BOTH, size_hint_align=(0.1, 0.1)) bt.callback_clicked_add(_cb_zoom_out, pc) tb.pack(bt, 0, 0, 1, 1) bt.show() # select file btn bt = FileselectorButton(win, text="Select Photo File", size_hint_weight=EXPAND_BOTH, size_hint_align=(0.5, 0.1)) bt.callback_file_chosen_add(lambda fs, path: pc.file_set(path)) tb.pack(bt, 1, 0, 1, 1) bt.show() # zoom in btn bt = Button(win, text="Z +", size_hint_weight=EXPAND_BOTH, size_hint_align=(0.9, 0.1)) bt.callback_clicked_add(_cb_zoom_in, pc) tb.pack(bt, 2, 0, 1, 1) bt.show() # progressbar for remote loading pb = Progressbar(win, unit_format="loading %.2f %%", size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) tb.pack(pb, 1, 1, 1, 1) # Fit btn bt = Button(win, text="Fit", size_hint_weight=EXPAND_BOTH, size_hint_align=(0.1, 0.9)) bt.callback_clicked_add( lambda b: pc.zoom_mode_set(ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT)) tb.pack(bt, 0, 2, 1, 1) bt.show() # load remote url bt = Button(win, text="Load remote URL (27MB)", size_hint_weight=EXPAND_BOTH, size_hint_align=(0.5, 0.9)) bt.callback_clicked_add(lambda b: pc.file_set(remote_url)) tb.pack(bt, 1, 2, 1, 1) bt.show() pc.callback_download_start_add(_cb_pc_download_start, pb) pc.callback_download_done_add(_cb_pc_download_done, pb) pc.callback_download_progress_add(_cb_pc_download_progress, pb) pc.callback_download_error_add(_cb_pc_download_error, pb) # Fill btn bt = Button(win, text="Fill", size_hint_weight=EXPAND_BOTH, size_hint_align=(0.9, 0.9)) bt.callback_clicked_add( lambda b: pc.zoom_mode_set(ELM_PHOTOCAM_ZOOM_MODE_AUTO_FILL)) tb.pack(bt, 2, 2, 1, 1) bt.show() # show the win win.show()