def __init__(self): StandardWindow.__init__(self, "ex7", "Naviframe", size=(300, 200)) self.callback_delete_request_add(lambda o: elm.exit()) staticImage = staticImage = Image(self) staticImage.size_hint_weight = EXPAND_BOTH staticImage.file_set("images/logo.png") staticImage.tooltip_text_set("A picture!") staticImage.show() ourLabel = ourLabel = Label(self) ourLabel.size_hint_weight = EXPAND_BOTH ourLabel.text = "Hey look some text!" ourLabel.show() self.nf = Naviframe(self) self.nf.size_hint_weight = EXPAND_BOTH self.nf.size_hint_align = FILL_BOTH self.nf.show() buttonOne = Button(self) buttonOne.size_hint_weight = EXPAND_BOTH buttonOne.text = "Show image" buttonOne.callback_clicked_add(self.buttonPressed, staticImage) buttonOne.show() buttonTwo = Button(self) buttonTwo.size_hint_weight = EXPAND_BOTH buttonTwo.text = "Show label" buttonTwo.callback_clicked_add(self.buttonPressed, ourLabel) buttonTwo.show() buttonBox = Box(self) buttonBox.size_hint_weight = EXPAND_HORIZ buttonBox.horizontal_set(True) buttonBox.pack_end(buttonOne) buttonBox.pack_end(buttonTwo) buttonBox.show() mainBox = Box(self) mainBox.size_hint_weight = EXPAND_BOTH mainBox.pack_end(self.nf) mainBox.pack_end(buttonBox) mainBox.show() self.nf.item_simple_push(staticImage) self.resize_object_add(mainBox)
def __init__(self, parent, session): Frame.__init__(self, parent) self.session = session self.size_hint_align = FILL_HORIZ self.text = "Listen port (range)" port = session.listen_port() b = Box(parent) b.size_hint_weight = EXPAND_HORIZ lp = self.lp = RangeSpinners( parent, low=session.conf.getint("Settings", "listen_low"), high=session.conf.getint("Settings", "listen_high"), minim=0, maxim=65535) lp.show() b.pack_end(lp) save = Button(parent) save.text = "Apply" save.callback_clicked_add(self.save_cb) save.show() b.pack_end(save) b.show() self.content = b
def __init__(self): StandardWindow.__init__(self, "ex8", "ElmEx - Button and Popup", size=(300, 200)) self.callback_delete_request_add(lambda o: elm.exit()) ourButton = StandardButton(self, "Show Popup", "start-here", self.buttonPressed) ourButton.size_hint_weight = EXPAND_HORIZ ourButton.size_hint_align = FILL_BOTH ourButton.show() ourButton2 = StandardButton(self, "Show About", "dialog-information", self.button2Pressed) ourButton2.size_hint_weight = EXPAND_HORIZ ourButton2.size_hint_align = FILL_BOTH ourButton2.show() mainBox = Box(self) mainBox.size_hint_weight = EXPAND_BOTH mainBox.size_hint_align = FILL_BOTH mainBox.pack_end(ourButton) mainBox.pack_end(ourButton2) mainBox.show() self.resize_object_add(mainBox)
def __init__(self): StandardWindow.__init__(self, "ex2", "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() ourButton = Button(self) ourButton.size_hint_weight = EXPAND_BOTH ourButton.text = "Goodbye Elementary" ourButton.callback_clicked_add(self.buttonPressed) ourButton.show() ourBox = Box(self) ourBox.size_hint_weight = EXPAND_BOTH ourBox.pack_end(ourLabel) ourBox.pack_end(ourButton) ourBox.show() self.resize_object_add(ourBox)
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, parent, session): Frame.__init__(self, parent) self.session = session self.size_hint_align = FILL_HORIZ self.text = "Listen port (range)" port = session.listen_port() b = Box(parent) b.size_hint_weight = EXPAND_HORIZ lp = self.lp = RangeSpinners( parent, low = session.conf.getint("Settings", "listen_low"), high = session.conf.getint("Settings", "listen_high"), minim = 0, maxim = 65535) lp.show() b.pack_end(lp) save = Button(parent) save.text = "Apply" save.callback_clicked_add(self.save_cb) save.show() b.pack_end(save) b.show() self.content = b
def transit_clicked(obj, item=None): win = StandardWindow("transit", "Transit") win.autodel = True bx = Box(win) bx.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND win.resize_object_add(bx) bx.size_hint_min = 318, 318 bx.show() ic = Image(win, file=os.path.join(img_path, "icon_11.png"), size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1)) bt = Button(win, text="ImageAnimation Effect") bt.part_content_set("icon", ic) bx.pack_end(bt) bt.show() ic.show() bt.callback_clicked_add(transit_image_animation, ic) bt = Button(win, text="Color, Rotation and Translation") bx.pack_end(bt) bt.show() bt.callback_clicked_add(transit_rotation_translation_color) bt = Button(win, text="Wipe Effect") bx.pack_end(bt) bt.show() bt.callback_clicked_add(transit_wipe) win.show()
def buildSubs(self): self.subWin = Window("lifetracker", ELM_WIN_DIALOG_BASIC, self, size=(300, 300)) self.subWin.title = "Life Tracker Assignment" bg = Background(self.subWin, size_hint_weight=EXPAND_BOTH) bg.show() self.subWin.resize_object_add(bg) self.subWin.callback_delete_request_add(lambda o: elm.exit()) self.ourWin = Window("lifetracker", ELM_WIN_DIALOG_BASIC, self, size=(300, 300)) self.ourWin.title = "Life Tracker Key Strokes" bg = Background(self.ourWin, size_hint_weight=EXPAND_BOTH) bg.show() self.ourWin.resize_object_add(bg) self.ourWin.callback_delete_request_add(lambda o: elm.exit()) self.ourWin.elm_event_callback_add(self.eventsCb) self.ourLife = ourLabel = Entry(self.ourWin, editable=False) ourLabel.size_hint_weight = EXPAND_BOTH ourLabel.size_hint_align = FILL_BOTH ourLabel.text_style_user_push("DEFAULT='font_size=20'") ourLabel.text = "Up and Down for Their Life, Left and Right for Mine" ourLabel.show() self.ourEntry = ourEntry = Entry(self.subWin) ourEntry.size_hint_weight = EXPAND_HORIZ ourEntry.size_hint_align = (-1, 0) ourEntry.single_line_set(True) ourEntry.text_style_user_push("DEFAULT='font_size=50'") ourEntry.callback_activated_add(self.ourLifeUpdate) ourEntry.text = "20" ourEntry.show() self.theirEntry = theirEntry = Entry(self.subWin) theirEntry.size_hint_weight = EXPAND_HORIZ theirEntry.size_hint_align = (-1, 0) theirEntry.single_line_set(True) theirEntry.text_style_user_push("DEFAULT='font_size=50'") theirEntry.callback_activated_add(self.theirLifeUpdate) theirEntry.text = "20" theirEntry.show() resetBtn = Button(self.subWin) resetBtn.text = "Reset life totals" resetBtn.callback_pressed_add(self.resetLifeTotals) resetBtn.show() entryBox = Box(self.subWin) entryBox.size_hint_weight = EXPAND_HORIZ entryBox.pack_end(ourEntry) entryBox.pack_end(theirEntry) entryBox.pack_end(resetBtn) entryBox.show() self.ourWin.resize_object_add(ourLabel) self.subWin.resize_object_add(entryBox) self.ourWin.show() self.subWin.show() self.ourWin.center(True, True) self.subWin.center(True, True)
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 store_clicked(obj): win = StandardWindow("store", "Store") win.autodel = True if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) bx = Box(win) bx.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND win.resize_object_add(bx) bx.show() gl = Genlist(win) gl.mode = ELM_LIST_COMPRESS gl.callback_selected_add(st_selected) gl.callback_clicked_double_add(st_double_clicked) gl.callback_longpressed_add(st_longpress) gl.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND gl.size_hint_align = EVAS_HINT_FILL, EVAS_HINT_FILL bx.pack_end(gl) gl.show() itc1 = GenlistItemClass() itc1.item_style = "message" st = Store() st.fs_list_func_set(st_store_list) st.fetch_func_set(st_store_fetch) #st.fetch_thread = False #st.unfetch_func_set(st_store_unfetch) st.items_sorted = False st.target_genlist = gl st.filesystem_directory = "." win.size = 480, 800 win.show()
def select_torrent(self): sel = Fileselector(self.win) sel.expandable = False sel.path_set(os.path.expanduser("~")) sel.size_hint_weight_set(1.0, 1.0) sel.size_hint_align_set(-1.0, -1.0) sel.show() sf = Frame(self.win) sf.size_hint_weight_set(1.0, 1.0) sf.size_hint_align_set(-1.0, -1.0) sf.text = "Select torrent file" sf.content = sel sf.show() magnet = Entry(self.win) magnet.single_line = True magnet.scrollable = True if hasattr(magnet, "cnp_selection_get"): magnet.cnp_selection_get(ELM_SEL_TYPE_CLIPBOARD, ELM_SEL_FORMAT_TEXT) else: import pyperclip t = pyperclip.paste() if t is not None and t.startswith("magnet:"): magnet.entry = t magnet.show() mf = Frame(self.win) mf.size_hint_weight_set(1.0, 0.0) mf.size_hint_align_set(-1.0, 0.0) mf.text = "Or enter magnet URI here" mf.content = magnet mf.show() mbtn = Button(self.win) mbtn.text = "Done" mbtn.show() mbox = Box(self.win) mbox.size_hint_weight_set(1.0, 0.0) mbox.size_hint_align_set(-1.0, 0.0) mbox.horizontal = True mbox.pack_end(mf) mbox.pack_end(mbtn) mbox.show() box = Box(self.win) box.size_hint_weight = (1.0, 1.0) box.size_hint_align = (-1.0, -1.0) box.pack_end(sf) box.pack_end(mbox) box.show() inwin = InnerWindow(self.win) inwin.content = box sel.callback_done_add(self.add_torrent_cb) sel.callback_done_add(lambda x, y: inwin.delete()) mbtn.callback_clicked_add(self.add_magnet_uri_cb, magnet) mbtn.callback_clicked_add(lambda x: inwin.delete()) inwin.activate()
def theme_clicked(obj, data=None): win = StandardWindow("config", "Theme", autodel=True, size=(400, 200)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) box = Box(win) box.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND box.show() win.resize_object_add(box) bt = Button(win, text="A button with a custom style") bt.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND bt.style = "my_custom_style" bt.show() box.pack_end(bt) bt = Button(win, text="A button with default style") bt.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND bt.show() box.pack_end(bt) sep = Separator(win, horizontal=True) sep.show() box.pack_end(sep) hbox = Box(win, horizontal=True) hbox.show() box.pack_end(hbox) bt = Button(win, text="Add Extension") bt.callback_clicked_add(add_ext_clicked_cb) bt.show() hbox.pack_end(bt) bt = Button(win, text="Remove Extension") bt.callback_clicked_add(del_ext_clicked_cb) bt.show() hbox.pack_end(bt) bt = Button(win, text="Add Overlay") bt.callback_clicked_add(add_ovr_clicked_cb) bt.show() hbox.pack_end(bt) bt = Button(win, text="Remove Overlay") bt.callback_clicked_add(del_ovr_clicked_cb) bt.show() hbox.pack_end(bt) win.show()
def theme_clicked(obj, data=None): win = StandardWindow("config", "Theme", autodel=True, size=(400,200)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) box = Box(win) box.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND box.show() win.resize_object_add(box) bt = Button(win, text = "A button with a custom style") bt.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND bt.style = "my_custom_style" bt.show() box.pack_end(bt) bt = Button(win, text = "A button with default style") bt.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND bt.show() box.pack_end(bt) sep = Separator(win, horizontal=True) sep.show() box.pack_end(sep) hbox = Box(win, horizontal=True) hbox.show() box.pack_end(hbox) bt = Button(win, text = "Add Extension") bt.callback_clicked_add(add_ext_clicked_cb) bt.show() hbox.pack_end(bt) bt = Button(win, text = "Remove Extension") bt.callback_clicked_add(del_ext_clicked_cb) bt.show() hbox.pack_end(bt) bt = Button(win, text = "Add Overlay") bt.callback_clicked_add(add_ovr_clicked_cb) bt.show() hbox.pack_end(bt) bt = Button(win, text = "Remove Overlay") bt.callback_clicked_add(del_ovr_clicked_cb) bt.show() hbox.pack_end(bt) win.show()
def __init__(self): StandardWindow.__init__(self, "ex6", "Selected Image", size=(300, 200)) self.callback_delete_request_add(lambda o: elm.exit()) self.ourImage = ourImage = Image(self) ourImage.size_hint_weight = EXPAND_BOTH ourImage.size_hint_align = FILL_BOTH ourImage.file_set("images/logo.png") ourImage.tooltip_text_set("A picture!") ourImage.show() ourButton = FileselectorButton(self) ourButton.size_hint_weight = EXPAND_HORIZ ourButton.text = "Select new Image" ourButton.callback_file_chosen_add(self.fileSelected) ourButton.show() ourBox = Box(self) ourBox.size_hint_weight = EXPAND_BOTH ourBox.pack_end(ourImage) ourBox.pack_end(ourButton) ourBox.show() self.resize_object_add(ourBox)
def __init__(self, parent, method): StandardWindow.__init__(self, "espionage", "Method", autodel=True) self._method = method self._param_entry = None self._return_entry = None # content is vbox (with surrounding pad frame) pad = Frame(self, style='pad_medium') pad.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND pad.size_hint_align = EVAS_HINT_FILL, EVAS_HINT_FILL self.resize_object_add(pad) pad.show() vbox = Box(self) vbox.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND vbox.size_hint_align = EVAS_HINT_FILL, EVAS_HINT_FILL pad.content = vbox vbox.show() # title f = "font_size=16 align=0.5 font_weight=Bold" en = Entry(self, text='<font %s>%s()</>' % (f, method.name)) en.size_hint_weight = EVAS_HINT_EXPAND, 0.0 en.size_hint_align = EVAS_HINT_FILL, 0.0 en.editable = False vbox.pack_end(en) en.show() # params label + entry if len(method.params) > 0: label = Entry(self, editable=False) label.size_hint_weight = EVAS_HINT_EXPAND, 0.0 label.size_hint_align = EVAS_HINT_FILL, 0.0 pars = colored_params(method.params, omit_braces=True) label.text = 'Params: %s' % (pars if method.params else 'None') vbox.pack_end(label) label.show() en = Entry(self, editable=True, scrollable=True, single_line=True) en.size_hint_weight = EVAS_HINT_EXPAND, 0.0 en.size_hint_align = EVAS_HINT_FILL, 0.0 self._param_entry = en vbox.pack_end(en) en.show() # returns label + entry label = Entry(self, editable=False) label.size_hint_weight = EVAS_HINT_EXPAND, 0.0 label.size_hint_align = EVAS_HINT_FILL, 0.0 rets = colored_params(method.returns, omit_braces=True) label.text = 'Returns: %s' % (rets if method.returns else 'None') vbox.pack_end(label) label.show() en = Entry(self, editable=False, scrollable=True) en.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND en.size_hint_align = EVAS_HINT_FILL, EVAS_HINT_FILL self._return_entry = en vbox.pack_end(en) en.show() # pretty print check button def pretty_output_clicked_cb(chk): options.pretty_output = chk.state ch = Check(self) ch.size_hint_align = 0.0, 0.5 ch.text = "Prettify output (loosing type infos)" ch.state = options.pretty_output ch.callback_changed_add(pretty_output_clicked_cb) ch.show() vbox.pack_end(ch) sep = Separator(self, horizontal=True) vbox.pack_end(sep) sep.show() # buttons hbox = Box(self, horizontal=True) hbox.size_hint_weight = EVAS_HINT_EXPAND, 0.0 hbox.size_hint_align = EVAS_HINT_FILL, 0.5 vbox.pack_end(hbox) hbox.show() btn = Button(self) btn.text = 'Close' btn.callback_clicked_add(lambda b: self.delete()) hbox.pack_end(btn) btn.show() btn = Button(self) btn.text = 'Clear output' btn.callback_clicked_add(lambda b: self._return_entry.entry_set('')) hbox.pack_end(btn) btn.show() btn = Button(self) btn.text = 'Run method' btn.callback_clicked_add(self.run_clicked_cb) hbox.pack_end(btn) btn.show() # show the window self.resize(300, 300) self.show()
def map_clicked(obj): win = StandardWindow("map", "Map test", autodel=True, size=(600, 600)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) vbox = Box(win) vbox.size_hint_weight = EXPAND_BOTH vbox.size_hint_align = FILL_BOTH win.resize_object_add(vbox) vbox.show() map_obj = Map(win, zoom=2) map_obj.size_hint_weight = EXPAND_BOTH map_obj.size_hint_align = FILL_BOTH map_obj.callback_tile_load_add(cb_map_load) map_obj.callback_tile_loaded_add(cb_map_load) map_obj.event_callback_add(EVAS_CALLBACK_MOUSE_DOWN, cb_map_mouse_down) vbox.pack_end(map_obj) map_obj.show() ### lb = Label(win, text="load_status: 0 / 0") vbox.pack_end(lb) lb.show() map_obj.data["lb_load_status"] = lb ### hbox = Box(win, horizontal=True) hbox.size_hint_weight = EXPAND_HORIZ hbox.size_hint_align = FILL_HORIZ vbox.pack_end(hbox) hbox.show() bt = Button(win, text="Goto") bt.callback_clicked_add(cb_btn_goto, map_obj) hbox.pack_end(bt) bt.show() bt = Button(win, text="Zoom +") bt.callback_clicked_add(cb_btn_zoom, map_obj, 1) hbox.pack_end(bt) bt.show() bt = Button(win, text="Zoom -") bt.callback_clicked_add(cb_btn_zoom, map_obj, -1) hbox.pack_end(bt) bt.show() sl = Slider(win, text="Rotation:", min_max=(0, 360), value=0, indicator_format="%3.0f") sl.callback_changed_add(cb_slider_rot, map_obj) hbox.pack_end(sl) sl.show() src_type = ELM_MAP_SOURCE_TYPE_TILE ho = Hoversel(win, hover_parent=win, text="Tiles: %s" % (map_obj.source_get(src_type))) for src in map_obj.sources_get(src_type): ho.item_add(src) ho.callback_selected_add(cb_hovsel_selected, map_obj, src_type, "Tiles") hbox.pack_end(ho) ho.show() ### hbox = Box(win, horizontal=True) hbox.size_hint_weight = EXPAND_HORIZ hbox.size_hint_align = FILL_HORIZ vbox.pack_end(hbox) hbox.show() ck = Check(win, text="wheel_disabled") ck.callback_changed_add(lambda bt: map_obj.wheel_disabled_set(bt.state)) hbox.pack_end(ck) ck.show() ck = Check(win, text="paused") ck.callback_changed_add(lambda bt: map_obj.paused_set(bt.state)) hbox.pack_end(ck) ck.show() ck = Check(win, text="hide overlays") ck.callback_changed_add(cb_chk_overlays_hidden, map_obj) hbox.pack_end(ck) ck.show() ck = Check(win, text="pause overlays") ck.callback_changed_add(cb_chk_overlays_paused, map_obj) hbox.pack_end(ck) ck.show() ### sp = Separator(win, horizontal=True) sp.show() vbox.pack_end(sp) hbox = Box(win, horizontal=True) hbox.size_hint_weight = EXPAND_HORIZ hbox.size_hint_align = FILL_HORIZ vbox.pack_end(hbox) hbox.show() src_type = ELM_MAP_SOURCE_TYPE_ROUTE ho = Hoversel(win, hover_parent=win, text="Routes: %s" % (map_obj.source_get(src_type))) for src in map_obj.sources_get(src_type): ho.item_add(src) ho.callback_selected_add(cb_hovsel_selected, map_obj, src_type, "Routes") hbox.pack_end(ho) ho.show() lb = Label(win, text="Set Start and End point to calculate route") hbox.pack_end(lb) lb.show() map_obj.data["lb_distance"] = lb bt = Button(win, text="Calc route") bt.callback_clicked_add(cb_btn_calc_route, map_obj) hbox.pack_end(bt) bt.show() ### sp = Separator(win, horizontal=True) sp.show() vbox.pack_end(sp) hbox = Box(win, horizontal=True) hbox.size_hint_weight = EXPAND_HORIZ hbox.size_hint_align = FILL_HORIZ vbox.pack_end(hbox) hbox.show() src_type = ELM_MAP_SOURCE_TYPE_NAME ho = Hoversel(win, hover_parent=win, text="Names: %s" % (map_obj.source_get(src_type))) for src in map_obj.sources_get(src_type): ho.item_add(src) ho.callback_selected_add(cb_hovsel_selected, map_obj, src_type, "Names") hbox.pack_end(ho) ho.show() en = Entry(win, scrollable=True, text="type an address here") en.size_hint_weight = EXPAND_BOTH en.size_hint_align = FILL_BOTH en.single_line = True hbox.pack_end(en) en.show() bt = Button(win, text="Search address") bt.callback_clicked_add(cb_btn_search_name, map_obj, en) hbox.pack_end(bt) bt.show() bt = Button(win, text="Search start point") bt.callback_clicked_add(cb_btn_search_region, map_obj, en) hbox.pack_end(bt) bt.show() print_map_info(map_obj) win.show()
def __init__(self): StandardWindow.__init__(self, "espionage", "EFL DBus Spy - Espionage") self.autodel_set(True) self.callback_delete_request_add(lambda o: elm.exit()) box = Box(self) self.resize_object_add(box) box.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND box.show() tb = Table(self) box.pack_end(tb) tb.show() lb = Label(self, text="Connect to:", scale=1.3) tb.pack(lb, 0, 0, 1, 2) lb.show() flip = FlipSelector(self, scale=1.3) flip.item_append("Session Bus", self.flip_selected_cb, session_bus) flip.item_append("System Bus", self.flip_selected_cb, system_bus) tb.pack(flip, 1, 0, 1, 2) flip.show() chk = Check(self, text="Show private services") chk.size_hint_align = 0.0, 1.0 chk.state = options.show_private_stuff chk.callback_changed_add(self.show_private_cb) tb.pack(chk, 2, 0, 1, 1) chk.show() chk = Check(self, text="Show DBus introspectables") chk.size_hint_align = 0.0, 0.0 chk.state = options.show_introspect_stuff chk.callback_changed_add(self.show_introspectables_cb) tb.pack(chk, 2, 1, 1, 1) chk.show() vpanes = Panes(self, horizontal=True) vpanes.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND vpanes.size_hint_align = EVAS_HINT_FILL, EVAS_HINT_FILL vpanes.content_left_size = 2.0 / 3 box.pack_end(vpanes) vpanes.show() hpanes = Panes(self) hpanes.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND hpanes.size_hint_align = EVAS_HINT_FILL, EVAS_HINT_FILL hpanes.content_left_size = 1.0 / 3 vpanes.part_content_set("left", hpanes) self.panes = hpanes hpanes.show() self.names_list = NamesList(self) hpanes.part_content_set("left", self.names_list) self.detail_list = DetailList(self) hpanes.part_content_set("right", self.detail_list) self.sigs_receiver = SignalReceiver(self) vpanes.part_content_set("right", self.sigs_receiver) self.resize(700, 500) self.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, parent, h): if not h.is_valid(): Information(parent.win, "Invalid torrent handle.") return if not h.has_metadata(): Information(parent.win, "Torrent contains no metadata.") return i = h.get_torrent_info() InnerWindow.__init__(self, parent.win) box = Box(self) box.size_hint_align = -1.0, -1.0 box.size_hint_weight = 1.0, 1.0 tname = Label(self) tname.size_hint_align = -1.0, 0.5 tname.line_wrap = ELM_WRAP_CHAR tname.ellipsis = True tname.text = "{}".format(cgi.escape(i.name())) tname.show() box.pack_end(tname) for func in i.comment, i.creation_date, i.creator: try: w = func() except Exception as e: log.debug(e) else: if w: f = Frame(self) f.size_hint_align = -1.0, 0.0 f.text = func.__name__.replace("_", " ").capitalize() l = Label(self) l.ellipsis = True l.text = cgi.escape(str(w)) l.show() f.content = l f.show() box.pack_end(f) tpriv = Check(self) tpriv.size_hint_align = 0.0, 0.0 tpriv.text = "Private" tpriv.tooltip_text_set("Whether this torrent is private.<br> \ i.e., it should not be distributed on the trackerless network<br> \ (the kademlia DHT).") tpriv.disabled = True tpriv.state = i.priv() magnet_uri = lt.make_magnet_uri(h) f = Frame(self) f.size_hint_align = -1.0, 0.0 f.text = "Magnet URI" me_box = Box(self) me_box.horizontal = True me = Entry(self) me.size_hint_align = -1.0, 0.0 me.size_hint_weight = 1.0, 0.0 #me.editable = False me.entry = magnet_uri me_box.pack_end(me) me.show() me_btn = Button(self) me_btn.text = "Copy" if hasattr(me, "cnp_selection_set"): me_btn.callback_clicked_add( lambda x: me.top_widget.cnp_selection_set( ELM_SEL_TYPE_CLIPBOARD, ELM_SEL_FORMAT_TEXT, me.text)) else: import pyperclip me_btn.callback_clicked_add(lambda x: pyperclip.copy(magnet_uri)) me_btn.show() me_box.pack_end(me_btn) me_box.show() f.content = me_box f.show() box.pack_end(f) fl_btn = Button(self) fl_btn.text = "Files ->" fl_btn.callback_clicked_add(self.file_list_cb, h) xbtn = Button(self) xbtn.text_set("Close") xbtn.callback_clicked_add(lambda x: self.delete()) for w in tpriv, fl_btn, xbtn: w.show() box.pack_end(w) box.show() nf = self.nf = Naviframe(self) nf.item_simple_push(box) self.content_set(nf) self.activate()
def __init__(self, parent, session): self.parent = parent self.session = session elm_conf = Configuration() scale = elm_conf.scale self.log = logging.getLogger("epour.gui") self.torrentitems = {} win = self.win = StandardWindow("epour", "Epour") win.callback_delete_request_add(lambda x: elm.exit()) win.screen_constrain = True win.size = 480 * scale, 400 * scale mbox = Box(win) mbox.size_hint_weight = 1.0, 1.0 win.resize_object_add(mbox) mbox.show() tb = Toolbar(win) tb.homogeneous = False tb.shrink_mode = ELM_TOOLBAR_SHRINK_NONE tb.select_mode = ELM_OBJECT_SELECT_MODE_NONE tb.size_hint_align = -1.0, 0.0 tb.menu_parent = win item = tb.item_append("document-new", "Add torrent", lambda t,i: self.select_torrent()) def pause_session(it): self.session.pause() it.state_set(it.state_next()) def resume_session(it): session.resume() del it.state item = tb.item_append("media-playback-pause", "Pause Session", lambda tb, it: pause_session(it)) item.state_add("media-playback-start", "Resume Session", lambda tb, it: resume_session(it)) item = tb.item_append("preferences-system", "Preferences") item.menu = True item.menu.item_add(None, "General", "preferences-system", lambda o,i: PreferencesGeneral(self, self.session)) item.menu.item_add(None, "Proxy", "preferences-system", lambda o,i: PreferencesProxy(self, self.session)) item.menu.item_add(None, "Session", "preferences-system", lambda o,i: PreferencesSession(self, self.session)) item = tb.item_append("application-exit", "Exit", lambda tb, it: elm.exit()) mbox.pack_start(tb) tb.show() self.tlist = tlist = Genlist(win) tlist.select_mode = ELM_OBJECT_SELECT_MODE_NONE tlist.mode = ELM_LIST_COMPRESS tlist.callback_activated_add(self.item_activated_cb) tlist.homogeneous = True tlist.size_hint_weight = 1.0, 1.0 tlist.size_hint_align = -1.0, -1.0 tlist.show() mbox.pack_end(tlist) pad = Rectangle(win.evas) pad.size_hint_weight = 1.0, 1.0 p = Panel(win) p.color = 200,200,200,200 p.size_hint_weight = 1.0, 1.0 p.size_hint_align = -1.0, -1.0 p.orient = ELM_PANEL_ORIENT_BOTTOM p.content = SessionStatus(win, session) p.hidden = True p.show() topbox = Box(win) topbox.horizontal = True topbox.size_hint_weight = 1.0, 1.0 win.resize_object_add(topbox) topbox.pack_end(pad) topbox.pack_end(p) topbox.stack_above(mbox) topbox.show() session.alert_manager.callback_add( "torrent_added_alert", self.torrent_added_cb) session.alert_manager.callback_add( "torrent_removed_alert", self.torrent_removed_cb) for a_name in "torrent_paused_alert", "torrent_resumed_alert": session.alert_manager.callback_add(a_name, self.update_icon) session.alert_manager.callback_add( "state_changed_alert", self.state_changed_cb) Timer(15.0, lambda: session.alert_manager.callback_add( "torrent_finished_alert", self.torrent_finished_cb))
def __init__(self, command=None, win=None, start_callback=None, end_callback=None, *args, **kwargs): if not win: nowindow = True win = self.win = Window("esudo", ELM_WIN_DIALOG_BASIC) win.title = "eSudo" win.borderless = True win.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND win.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL win.resize(300, 200) win.callback_delete_request_add(lambda o: elementary.exit()) win.layer_set(11) #~ win.fullscreen = True win.show() win.activate() bg = Background(win) bg.size_hint_weight = 1.0, 1.0 win.resize_object_add(bg) bg.show() self.embedded = False else: nowindow = False self.embedded = True self.cmd = command self.start_cb = start_callback if callable(start_callback) else None self.end_cb = end_callback if callable(end_callback) else None self.args = args self.kwargs = kwargs #--------eSudo Window bz = Box(win) if nowindow: bz.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0 else: bz.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND bz.size_hint_align = evas.EVAS_HINT_FILL, 0.0 bz.show() if nowindow: lbl = Label(win) lbl.style = "marker" lbl.color = 170, 170, 170, 255 lbl.size_hint_align = 0.5, 0.0 lbl.scale = 2.0 lbl.text = "<b>eSudo</b>" bz.pack_end(lbl) lbl.show() sep = Separator(win) sep.horizontal = True bz.pack_end(sep) sep.show() fr = Frame(win) fr.text = "Command:" fr.size_hint_align = evas.EVAS_HINT_FILL, 0.0 bz.pack_end(fr) fr.show() if nowindow: sep = Separator(win) sep.horizontal = True bz.pack_end(sep) sep.show() self.cmdline = cmdline = Entry(win) cmdline.elm_event_callback_add(self.entry_event) cmdline.single_line = True if self.cmd: cmdline.text = self.cmd cmdline.editable = False fr.content = cmdline cmdline.scrollable_set(True) cmdline.show() if nowindow: fr = Frame(win) fr.text = "Password:"******"<b>Password:</b>" lb.size_hint_align = 0.0, 0.5 bz1.pack_end(lb) lb.show() en = self.en = Entry(win) en.name = "password" en.elm_event_callback_add(self.entry_event) en.single_line = True en.password = True en.show() if nowindow: fr.content = en else: bz1.pack_end(en) sep = Separator(win) sep.horizontal = True bz.pack_end(sep) sep.show() btnb = Box(win) btnb.horizontal = True btnb.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0 btnb.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL bz.pack_end(btnb) btnb.show() bt = Button(win) bt.text = "Cancel" bt.callback_clicked_add(self.esudo_cancel, en) bt.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL bt.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0 btnb.pack_end(bt) bt.show() bt = Button(win) bt.text = "OK" bt.callback_clicked_add(self.password_check, en) bt.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL bt.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0 btnb.pack_end(bt) bt.show() self.iw = iw = InnerWindow(win) iw.content = bz iw.show() iw.activate() if self.cmd: en.focus = True
def __init__(self, parent, session): self.parent = parent self.session = session elm_conf = Configuration() scale = elm_conf.scale self.log = logging.getLogger("epour.gui") self.torrentitems = {} win = self.win = StandardWindow("epour", "Epour") win.callback_delete_request_add(lambda x: elm.exit()) win.screen_constrain = True win.size = 480 * scale, 400 * scale mbox = Box(win) mbox.size_hint_weight = 1.0, 1.0 win.resize_object_add(mbox) mbox.show() tb = Toolbar(win) tb.homogeneous = False tb.shrink_mode = ELM_TOOLBAR_SHRINK_NONE tb.select_mode = ELM_OBJECT_SELECT_MODE_NONE tb.size_hint_align = -1.0, 0.0 tb.menu_parent = win item = tb.item_append("document-new", "Add torrent", lambda t, i: self.select_torrent()) def pause_session(it): self.session.pause() it.state_set(it.state_next()) def resume_session(it): session.resume() del it.state item = tb.item_append("media-playback-pause", "Pause Session", lambda tb, it: pause_session(it)) item.state_add("media-playback-start", "Resume Session", lambda tb, it: resume_session(it)) item = tb.item_append("preferences-system", "Preferences") item.menu = True item.menu.item_add(None, "General", "preferences-system", lambda o, i: PreferencesGeneral(self, self.session)) item.menu.item_add(None, "Proxy", "preferences-system", lambda o, i: PreferencesProxy(self, self.session)) item.menu.item_add(None, "Session", "preferences-system", lambda o, i: PreferencesSession(self, self.session)) item = tb.item_append("application-exit", "Exit", lambda tb, it: elm.exit()) mbox.pack_start(tb) tb.show() self.tlist = tlist = Genlist(win) tlist.select_mode = ELM_OBJECT_SELECT_MODE_NONE tlist.mode = ELM_LIST_COMPRESS tlist.callback_activated_add(self.item_activated_cb) tlist.homogeneous = True tlist.size_hint_weight = 1.0, 1.0 tlist.size_hint_align = -1.0, -1.0 tlist.show() mbox.pack_end(tlist) pad = Rectangle(win.evas) pad.size_hint_weight = 1.0, 1.0 p = Panel(win) p.color = 200, 200, 200, 200 p.size_hint_weight = 1.0, 1.0 p.size_hint_align = -1.0, -1.0 p.orient = ELM_PANEL_ORIENT_BOTTOM p.content = SessionStatus(win, session) p.hidden = True p.show() topbox = Box(win) topbox.horizontal = True topbox.size_hint_weight = 1.0, 1.0 win.resize_object_add(topbox) topbox.pack_end(pad) topbox.pack_end(p) topbox.stack_above(mbox) topbox.show() session.alert_manager.callback_add("torrent_added_alert", self.torrent_added_cb) session.alert_manager.callback_add("torrent_removed_alert", self.torrent_removed_cb) for a_name in "torrent_paused_alert", "torrent_resumed_alert": session.alert_manager.callback_add(a_name, self.update_icon) session.alert_manager.callback_add("state_changed_alert", self.state_changed_cb) Timer( 15.0, lambda: session.alert_manager.callback_add( "torrent_finished_alert", self.torrent_finished_cb))