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 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 __init__(self): win = StandardWindow("Testing", "Elementary Tabbed Widget") # pylint: disable=no-member win.callback_delete_request_add(lambda o: elm.exit()) tabbs = TabbedBox(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) tabbs.close_cb = self.close_checks for i in range(10): lbl = Label(win) lbl.text = "Tab %s" % i lbl.show() tabbs.add(lbl, "Tab %s" % i) tabbs.disable(0) tabbs.disable(3) tabbs.show() win.resize_object_add(tabbs) win.resize(600, 400) win.show()
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 core_evas_smart_clicked(obj, item=None): win = StandardWindow("evassmart", "Evas Smart Object Test", autodel=True) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) box = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) box.show() win.resize_object_add(box) b = Button(win, text="Add one", size_hint_align=(0.0,0.0)) b.callback_clicked_add(btn_add_cb) box.pack_end(b) b.show() b = Button(win, text="Del last", size_hint_align=(0.0,0.0)) b.callback_clicked_add(btn_del_cb) box.pack_end(b) b.show() b = Button(win, text="Hide all", size_hint_align=(0.0,0.0)) b.callback_clicked_add(btn_hide_cb) box.pack_end(b) b.show() b = Button(win, text="Show all", size_hint_align=(0.0,0.0)) b.callback_clicked_add(btn_show_cb) box.pack_end(b) b.show() win.resize(320, 320) win.show()
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 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): win = StandardWindow("Testing", "Elementary Sorted Table") # pylint: disable=no-member 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: # ( <str - 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) label = Label(slist, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) label.text = str(data) # For integer data we also need to assign value to "sort_data" # because otherwise things get sorted as text label.data["sort_data"] = data label.show() # Append our label to the row row.append(label) # 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 __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 __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 __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 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 ): win = StandardWindow("Testing", "Elementary File Selector") win.callback_delete_request_add(lambda o: elm.exit()) self.fs = fs = FileSelector(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) #fs.setMode("Open") fs.show() fs.callback_activated_add(self.showFile) fs.callback_cancel_add(lambda o: elm.exit()) win.resize_object_add(fs) win.resize(600, 400) win.show()
def __init__(self): win = StandardWindow("Testing", "Elementary SearchableList") win.callback_delete_request_add(lambda o: elm.exit()) win.show() ourList = SearchableList(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.keys = ["Jeff", "Kristi", "Jacob", "Declan", "Joris", "Timmy", "Tristam"] for kbl in self.keys: ourList.item_append(kbl) ourList.show() win.resize_object_add(ourList) win.resize(600, 400) win.show()
def __init__( self ): win = StandardWindow("Testing", "Elementary SearchableList") win.callback_delete_request_add(lambda o: elm.exit()) ourList = SearchableList(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.keys = ["Jeff", "Kristi", "Jacob", "Declan", "Joris", "Timmy", "Tristam"] for kbl in self.keys: ourList.item_append(kbl) ourList.show() win.resize_object_add(ourList) win.resize(600, 400) win.show()
def start(): win = StandardWindow("Robot Eyes", "Eyes of the robot", autodel=True) win.callback_delete_request_add(lambda o: elementary.exit()) face = Face(win) draw(win, face) def on_tick(*args, **kargs): draw(win, face) return True Animator(on_tick) win.resize(screenX, screenY) win.show() listener(face)
def inner_window_clicked(obj): win = StandardWindow("inner-window", "InnerWindow test", autodel=True, size=(320, 320)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) lb = Label(win) lb.text_set("This is an \"inwin\" - a window in a<br/>" "window. This is handy for quick popups<br/>" "you want centered, taking over the window<br/>" "until dismissed somehow. Unlike hovers they<br/>" "don't hover over their target.") iw = InnerWindow(win, content=lb) iw.show() win.resize(320, 320) win.show()
def __init__(self): win = StandardWindow("Testing", "Elementary File Selector") # pylint: disable=no-member win.callback_delete_request_add(lambda o: elm.exit()) self.f_selector = f_selector = FileSelector( win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) # f_selector.folderOnlySet(True) f_selector.set_mode("Open") f_selector.show() f_selector.callback_activated_add(self.cb_activated) f_selector.callback_cancel_add(lambda o: elm.exit()) win.resize_object_add(f_selector) win.resize(600, 400) win.show()
def __init__(self): win = StandardWindow("Testing", "Elementary File Selector") win.callback_delete_request_add(lambda o: elm.exit()) self.fs = fs = FileSelector(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) #fs.folderOnlySet(True) fs.setMode("Open") fs.show() fs.callback_activated_add(self.showFile) fs.callback_cancel_add(lambda o: elm.exit()) win.resize_object_add(fs) win.resize(600, 400) win.show()
def __init__( self ): win = StandardWindow("Testing", "Elementary About Dialog") win.callback_delete_request_add(lambda o: elm.exit()) win.show() lbl = Label(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) lbl.text = "This is a parent window for the About Dialog. Close when done." lbl.show() win.resize_object_add(lbl) win.resize(600, 400) win.show() AboutWindow(win, title="About Test", standardicon="dialog-information", \ version="1.0", authors=AUTHORS, \ licen=LICENSE, webaddress="https://github.com/JeffHoogland/python-elm-extensions", \ info=INFO)
def elm_input_events_clicked(obj, item=None): win = StandardWindow("inputevents", "Input Events Test", autodel=True) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) box = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(box) box.show() entry = Entry(win, scrollable=True, size_hint_align=FILL_BOTH, size_hint_weight=(1.0, 0.2)) entry.text = ( "This example will show how Elementary input events are handled. " "Typing in this entry will log in the entry box below all events " "caught by event handlers set to this Entry widget and its parent, " "the Window widget. Key up events are checked for in the callback " "and won't propagate to a parent widget." ) entry.show() log_entry = Entry(win, editable=False, scrollable=True, focus_allow=False, size_hint_align=FILL_BOTH, size_hint_weight=(1.0, 0.8)) log_entry.callback_changed_add(changed_cb) log_entry.show() btn = Button(win, text="Clear log", focus_allow=False) btn.callback_clicked_add(lambda x: setattr(log_entry, "entry", "")) btn.show() box.pack_end(entry) box.pack_end(log_entry) box.pack_end(btn) entry.elm_event_callback_add(events_cb, log_entry) entry.markup_filter_append(filter_cb) win.elm_event_callback_add(events_cb, log_entry) win.resize(640, 480) win.show() entry.focus = True
def __init__( self ): win = StandardWindow("Testing", "Elementary Tabbed Widget") win.callback_delete_request_add(lambda o: elm.exit()) tabbs = TabbedBox(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) tabbs.closeCallback = self.closeChecks for i in range(10): lbl = Label(win) lbl.text = "Tab %s"%i lbl.show() tabbs.addTab(lbl, "Tab %s"%i) tabbs.disableTab(0) tabbs.disableTab(3) tabbs.show() win.resize_object_add(tabbs) win.resize(600, 400) win.show()
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 actionslider_clicked(obj): win = StandardWindow("actionslider", "Actionslider") win.autodel_set(True) 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() acts = Actionslider(win, size_hint_weight=EXPAND_HORIZ, size_hint_align=(EVAS_HINT_FILL, 0.0), indicator_pos=ELM_ACTIONSLIDER_RIGHT, magnet_pos=ELM_ACTIONSLIDER_RIGHT, enabled_pos=(ELM_ACTIONSLIDER_LEFT | ELM_ACTIONSLIDER_RIGHT)) acts.part_text_set("left", "Snooze") acts.part_text_set("center", "") acts.part_text_set("right", "Stop") acts.callback_pos_changed_add(_position_change_magnetic_cb) acts.callback_selected_add(_pos_selected_cb) bx.pack_end(acts) acts.show() acts = Actionslider(win, size_hint_weight=EXPAND_HORIZ, size_hint_align=(EVAS_HINT_FILL, 0.0), indicator_pos=ELM_ACTIONSLIDER_CENTER, magnet_pos=ELM_ACTIONSLIDER_CENTER, enabled_pos=(ELM_ACTIONSLIDER_LEFT | ELM_ACTIONSLIDER_RIGHT)) acts.part_text_set("left", "Snooze") acts.part_text_set("center", "") acts.part_text_set("right", "Stop") acts.callback_selected_add(_pos_selected_cb) bx.pack_end(acts) acts.show() acts = Actionslider( win, style="bar", size_hint_weight=EXPAND_HORIZ, size_hint_align=(EVAS_HINT_FILL, 0.0), indicator_pos=ELM_ACTIONSLIDER_LEFT, magnet_pos=(ELM_ACTIONSLIDER_CENTER | ELM_ACTIONSLIDER_RIGHT), enabled_pos=(ELM_ACTIONSLIDER_CENTER | ELM_ACTIONSLIDER_RIGHT)) acts.part_text_set("left", "") acts.part_text_set("center", "Accept") acts.part_text_set("right", "Reject") acts.callback_selected_add(_pos_selected_cb) bx.pack_end(acts) acts.show() acts = Actionslider(win, style="bar", text="Go", size_hint_weight=EXPAND_HORIZ, size_hint_align=(EVAS_HINT_FILL, 0.0), indicator_pos=ELM_ACTIONSLIDER_LEFT, magnet_pos=ELM_ACTIONSLIDER_LEFT) acts.part_text_set("left", "") acts.part_text_set("center", "Accept") acts.part_text_set("right", "Reject") acts.callback_pos_changed_add(_position_change_magnetic_cb) acts.callback_selected_add(_pos_selected_cb) bx.pack_end(acts) acts.show() acts = Actionslider(win, size_hint_weight=EXPAND_HORIZ, size_hint_align=(EVAS_HINT_FILL, 0.0), indicator_pos=ELM_ACTIONSLIDER_LEFT, magnet_pos=ELM_ACTIONSLIDER_ALL) acts.part_text_set("left", "Left") acts.part_text_set("center", "Center") acts.part_text_set("right", "Right") acts.text_set("Go") acts.callback_selected_add(_pos_selected_cb) bx.pack_end(acts) acts.show() acts = Actionslider(win, size_hint_weight=EXPAND_HORIZ, size_hint_align=(EVAS_HINT_FILL, 0.0), indicator_pos=ELM_ACTIONSLIDER_CENTER, magnet_pos=ELM_ACTIONSLIDER_CENTER) acts.part_text_set("left", "Enable") acts.part_text_set("center", "Magnet") acts.part_text_set("right", "Disable") acts.callback_pos_changed_add(_magnet_enable_disable_cb) acts.callback_selected_add(_pos_selected_cb) bx.pack_end(acts) acts.show() win.resize(320, 400) 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)
en = Entry(win, single_line=True, scrollable=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) en.part_text_set("guide", "Type widget name here to search.") en.callback_changed_add(cb_filter, win) bx1.pack_end(en) en.show() en.focus_set(True) sc = Scroller(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, bounce=(False, True)) sc.show() box0.pack_end(sc) tbx = Box(win, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.0)) sc.content_set(tbx) tbx.show() menu_create(None, win) win.resize(480, 480) win.show() elementary.run() elementary.shutdown()
def main_loop(): win = StandardWindow("WLX42 Eyes", "Eyes of the robot", autodel=True) win.callback_delete_request_add(lambda o: elementary.exit()) bg = Rectangle(win.evas, size = screenSize, color=(0,0,100,255), pos=(0,0)) #bg.clip = Rectangle(win.evas, size = screenSize, color=(0,0,100,255), pos=(0,100) ) bg.show() underlay = Rectangle(win.evas, pos=global_offset, size = screenSize, color=(255,255,255,255)) underlay.show() eyes = Image(win, size = screenSize, pos=global_offset, file=os.path.join(img_path, "oeil-1.png")) #overlay.clip = Image(win, size = screenSize, pos=(0,0), file=os.path.join(img_path, "mb.png")) #overlay.clip.show() eyes.clip = Rectangle(win.evas, size = screenSize, color=(0,0,100,255), pos=(0,0) ) eyes.clip.show() eyes.show() mustache = Image(win, size=screenSize, pos=global_offset, file=os.path.join(img_path, "moustaches.png")) mustache.clip = Rectangle(win.evas, size = screenSize, color=(0,0,100,255), pos=(0,0) ) mustache.clip.show() mustache.stack_above(eyes) mustache.show() bubble_pos = (0,100) bubble_size = (2*106, 2*159) bubble = Image(win, size = bubble_size, pos=bubble_pos, file=os.path.join(img_path, "bulle.png")) bubble.clip = Rectangle(win.evas, size = bubble_size, color=(255,255,255,200), pos=bubble_pos ) bubble.clip.show() bubble.stack_above(eyes) bubble.show() bubble_text_pos=(bubble_pos[0]+10, bubble_pos[1]+10) bubble_text = Text(win.evas, text='', color=(255,255,255,255), pos=bubble_text_pos, size=(180,180)) bubble_text.font_source = font_path bubble_text.font = "FontAwesome", 150 bubble_text.style = EVAS_TEXT_STYLE_SOFT_SHADOW bubble_text.shadow_color = (64,64,64,127) bubble_text.stack_above(bubble) bubble_text.show() # bx = Box(win) # win.resize_object_add(bx) # bx.size_hint_weight = EXPAND_BOTH # bx.show() # lb.show() # lb = Label(win, text="Blah, Blah, Blah") # lb2 = Label(win, text="Tut, Tut, Tut!") # bb = Bubble(win, text = "Message 1", content = lb, # pos = ELM_BUBBLE_POS_TOP_LEFT, size_hint_weight = EXPAND_BOTH, # size_hint_align = FILL_BOTH) # bb.part_text_set("info", "Corner: top_left") # bb.part_content_set("icon", ic) # bx.pack_end(bb) # bb.show() eyeballs = Image(win, size = eyeballs_size, pos=eyeballs_pos, file=os.path.join(img_path, "retine_sim.png")) blink = Image(win, size = screenSize, pos = global_offset, file=os.path.join(img_path, "oeil-11.png")) blink.clip = eyes.clip; dead = Image(win, size = screenSize, pos = global_offset, file=os.path.join(img_path, "oeil-10.png")) #eyes eyeballs.stack_below(eyes) eyeballs.show() def on_tick(*args, **kargs): draw(win, bg, eyeballs, eyes, blink) return True Animator(on_tick) draw(win, bg, eyeballs, eyes, blink) win.resize(screenX, screenY) win.show()
lb = Label(win, text="Filter:") bx1.pack_end(lb) lb.show() en = Entry(win, single_line=True, scrollable=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) en.part_text_set("guide", "Type widget name here to search.") en.callback_changed_add(cb_filter, win) bx1.pack_end(en) en.show() en.focus_set(True) sc = Scroller(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, bounce=(False, True)) sc.show() box0.pack_end(sc) tbx = Box(win, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.0)) sc.content_set(tbx) tbx.show() menu_create(None, win) win.resize(480, 480) win.show() elementary.run() elementary.shutdown()
def actionslider_clicked(obj): win = StandardWindow("actionslider", "Actionslider") win.autodel_set(True) 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() acts = Actionslider(win, size_hint_weight=EXPAND_HORIZ, size_hint_align=(EVAS_HINT_FILL, 0.0), indicator_pos=ELM_ACTIONSLIDER_RIGHT, magnet_pos=ELM_ACTIONSLIDER_RIGHT, enabled_pos=(ELM_ACTIONSLIDER_LEFT | ELM_ACTIONSLIDER_RIGHT)) acts.part_text_set("left", "Snooze") acts.part_text_set("center", "") acts.part_text_set("right", "Stop") acts.callback_pos_changed_add(_position_change_magnetic_cb) acts.callback_selected_add(_pos_selected_cb) bx.pack_end(acts) acts.show() acts = Actionslider(win, size_hint_weight=EXPAND_HORIZ, size_hint_align=(EVAS_HINT_FILL, 0.0), indicator_pos=ELM_ACTIONSLIDER_CENTER, magnet_pos=ELM_ACTIONSLIDER_CENTER, enabled_pos=(ELM_ACTIONSLIDER_LEFT | ELM_ACTIONSLIDER_RIGHT)) acts.part_text_set("left", "Snooze") acts.part_text_set("center", "") acts.part_text_set("right", "Stop") acts.callback_selected_add(_pos_selected_cb) bx.pack_end(acts) acts.show() acts = Actionslider(win, style="bar", size_hint_weight=EXPAND_HORIZ, size_hint_align=(EVAS_HINT_FILL, 0.0), indicator_pos=ELM_ACTIONSLIDER_LEFT, magnet_pos=(ELM_ACTIONSLIDER_CENTER | ELM_ACTIONSLIDER_RIGHT), enabled_pos=(ELM_ACTIONSLIDER_CENTER | ELM_ACTIONSLIDER_RIGHT)) acts.part_text_set("left", "") acts.part_text_set("center", "Accept") acts.part_text_set("right", "Reject") acts.callback_selected_add(_pos_selected_cb) bx.pack_end(acts) acts.show() acts = Actionslider(win, style="bar", text="Go", size_hint_weight=EXPAND_HORIZ, size_hint_align=(EVAS_HINT_FILL, 0.0), indicator_pos=ELM_ACTIONSLIDER_LEFT, magnet_pos=ELM_ACTIONSLIDER_LEFT) acts.part_text_set("left", "") acts.part_text_set("center", "Accept") acts.part_text_set("right", "Reject") acts.callback_pos_changed_add(_position_change_magnetic_cb) acts.callback_selected_add(_pos_selected_cb) bx.pack_end(acts) acts.show() acts = Actionslider(win, size_hint_weight=EXPAND_HORIZ, size_hint_align=(EVAS_HINT_FILL, 0.0), indicator_pos=ELM_ACTIONSLIDER_LEFT, magnet_pos=ELM_ACTIONSLIDER_ALL) acts.part_text_set("left", "Left") acts.part_text_set("center", "Center") acts.part_text_set("right", "Right") acts.text_set("Go"); acts.callback_selected_add(_pos_selected_cb) bx.pack_end(acts) acts.show() acts = Actionslider(win, size_hint_weight=EXPAND_HORIZ, size_hint_align=(EVAS_HINT_FILL, 0.0), indicator_pos=ELM_ACTIONSLIDER_CENTER, magnet_pos=ELM_ACTIONSLIDER_CENTER) acts.part_text_set("left", "Enable") acts.part_text_set("center", "Magnet") acts.part_text_set("right", "Disable") acts.callback_pos_changed_add(_magnet_enable_disable_cb) acts.callback_selected_add(_pos_selected_cb) bx.pack_end(acts) acts.show() win.resize(320, 400) win.show()
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) for i in range(20): lbl = Label(win, text="Tab %s" % i) tabs.append(Tab("Tab %s" % i, lbl)) tabs.show() win.resize_object_add(tabs) win.resize(640, 480) win.show() elm.run() elm.shutdown() evas.shutdown() logging.shutdown()
def evas3d_clicked(obj, item=None): win = StandardWindow("evas3d", "Evas 3d test") win.autodel_set(True) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) cube = Cube(win, 240, 240, 240) vbox = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(vbox) vbox.show() sl = Slider(win, text="Rot X", unit_format="%1.0f units", span_size=360, min_max=(0, 360), size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_BOTH) vbox.pack_end(sl) sl.callback_changed_add(ch_rot_x, cube) sl.show() sl = Slider(win, text="Rot Y", unit_format="%1.0f units", span_size=360, min_max=(0, 360), size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_BOTH) vbox.pack_end(sl) sl.callback_changed_add(ch_rot_y, cube) sl.show() sl = Slider(win, text="Rot Z", unit_format="%1.0f units", span_size=360, min_max=(0, 360), size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_BOTH) vbox.pack_end(sl) sl.callback_changed_add(ch_rot_z, cube) sl.show() sl = Slider(win, text="CX Off", unit_format="%1.0f units", span_size=360, min_max=(-320, 320), value=cube.cxo, size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_BOTH) vbox.pack_end(sl) sl.callback_changed_add(ch_cx, cube) sl.show() sl = Slider(win, text="CY Off", unit_format="%1.0f units", span_size=360, min_max=(-320, 320), value=cube.cyo, size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_BOTH) vbox.pack_end(sl) sl.callback_changed_add(ch_cy, cube) sl.show() sl = Slider(win, text="Foc", unit_format="%1.0f units", span_size=360, min_max=(1, 2000), value=cube.focv, size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_BOTH) vbox.pack_end(sl) sl.callback_changed_add(ch_foc, cube) sl.show() sl = Slider(win, text="Z0", unit_format="%1.0f units", span_size=360, min_max=(-2000, 2000), value=cube.z0v, size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_BOTH) vbox.pack_end(sl) sl.callback_changed_add(ch_z0, cube) sl.show() win.resize(480, 480) cube.update() win.show()
def evas3d_clicked(obj, item=None): win = StandardWindow("evas3d", "Evas 3d test") win.autodel_set(True) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) cube = Cube(win, 240, 240, 240) vbox = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(vbox) vbox.show() sl = Slider(win, text="Rot X", unit_format="%1.0f units", span_size=360, min_max=(0, 360), size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_BOTH) vbox.pack_end(sl) sl.callback_changed_add(ch_rot_x, cube) sl.show() sl = Slider(win, text="Rot Y", unit_format="%1.0f units", span_size=360, min_max=(0, 360), size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_BOTH) vbox.pack_end(sl) sl.callback_changed_add(ch_rot_y, cube) sl.show() sl = Slider(win, text="Rot Z", unit_format="%1.0f units", span_size=360, min_max=(0, 360), size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_BOTH) vbox.pack_end(sl) sl.callback_changed_add(ch_rot_z, cube) sl.show() sl = Slider(win, text="CX Off", unit_format="%1.0f units", span_size=360, min_max=(-320, 320), value=cube.cxo, size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_BOTH) vbox.pack_end(sl) sl.callback_changed_add(ch_cx, cube) sl.show() sl = Slider(win, text="CY Off", unit_format="%1.0f units", span_size=360, min_max=(-320, 320), value=cube.cyo, size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_BOTH) vbox.pack_end(sl) sl.callback_changed_add(ch_cy, cube) sl.show() sl = Slider(win, text="Foc", unit_format="%1.0f units", span_size=360, min_max=(1, 2000), value=cube.focv, size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_BOTH) vbox.pack_end(sl) sl.callback_changed_add(ch_foc, cube) sl.show() sl = Slider(win, text="Z0", unit_format="%1.0f units", span_size=360, min_max=(-2000, 2000), value=cube.z0v, size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_BOTH) vbox.pack_end(sl) sl.callback_changed_add(ch_z0, cube) sl.show() win.resize(480, 480) cube.update() 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)