示例#1
0
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()
示例#2
0
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()
示例#3
0
文件: ePad.py 项目: nijek/ePad
    def confirmSave(self, ourCallback=None):
        self.confirmPopup = Popup(self.mainWindow,
                                  size_hint_weight=EXPAND_BOTH)
        self.confirmPopup.part_text_set("title,text", "File Unsaved")
        current_file = self.mainEn.file[0]
        current_file = \
            os.path.basename(current_file) if current_file else "Untitled"
        self.confirmPopup.text = "Save changes to '%s'?" % (current_file)
        # 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()
示例#4
0
    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)
示例#5
0
def panes_clicked(obj):
    win = StandardWindow("panes", "Panes test", autodel=True, size=(320, 480))
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    panes = Panes(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
    win.resize_object_add(panes)
    panes.callback_clicked_add(cb_panes, "clicked")
    panes.callback_clicked_double_add(cb_panes, "clicked,double")
    panes.callback_press_add(cb_panes, "press")
    panes.callback_unpress_add(cb_panes, "unpress")
    panes.show()

    bt = Button(win, text="Left")
    panes.part_content_set("left", bt)
    bt.show()

    panes_h = Panes(win,
                    horizontal=True,
                    size_hint_weight=EXPAND_BOTH,
                    size_hint_align=FILL_BOTH)
    panes_h.horizontal = True
    panes.part_content_set("right", panes_h)
    panes_h.show()

    bt = Button(win, text="Up")
    panes_h.part_content_set("left", bt)
    bt.show()

    bt = Button(win, text="Down")
    panes_h.part_content_set("right", bt)
    bt.show()

    win.show()
示例#6
0
文件: ePad.py 项目: rbtylee/ePad
    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()
示例#7
0
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()
示例#8
0
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()
示例#9
0
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 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()
示例#11
0
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()
示例#12
0
def image_clicked(obj):
    win = StandardWindow("image", "Image 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, size_hint_align=FILL_BOTH)
    win.resize_object_add(vbox)
    vbox.show()

    im = Image(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH,
        file=os.path.join(img_path, "logo.png"))
    vbox.pack_end(im)
    im.show()

    sep = Separator(win, horizontal=True)
    vbox.pack_end(sep)
    sep.show()

    hbox = Box(win, layout=ELM_BOX_LAYOUT_FLOW_HORIZONTAL,
        size_hint_align=FILL_BOTH)
    vbox.pack_end(hbox)
    hbox.show()

    for rot in orients:
        b = Button(win, text=rot[0])
        hbox.pack_end(b)
        b.callback_clicked_add(lambda b, y=rot[1]: im.orient_set(y))
        b.show()

    sep = Separator(win, horizontal=True)
    vbox.pack_end(sep)
    sep.show()

    hbox = Box(win, horizontal=True, size_hint_align=FILL_BOTH)
    vbox.pack_end(hbox)
    hbox.show()

    b = Button(win, text="Set remote URL")
    hbox.pack_end(b)
    b.callback_clicked_add(lambda b: im.file_set(remote_url))
    b.show()

    pb = Progressbar(win, size_hint_weight=EXPAND_BOTH,
        size_hint_align=FILL_BOTH)
    hbox.pack_end(pb)
    pb.show()

    im.callback_download_start_add(_cb_im_download_start, pb)
    im.callback_download_done_add(_cb_im_download_done)
    im.callback_download_progress_add(_cb_im_download_progress, pb)
    im.callback_download_error_add(_cb_im_download_error, pb)

    win.show()
示例#13
0
 def __init__(self, canvas, exit_func):
     n = Popup(canvas)
     n.part_text_set("title,text", "Confirm exit")
     n.text = "Are you sure you wish to exit Epour?"
     b = Button(canvas)
     b.text = "Yes"
     b.callback_clicked_add(lambda x: exit_func())
     n.part_content_set("button1", b)
     b = Button(canvas)
     b.text = "No"
     b.callback_clicked_add(lambda x: n.delete())
     n.part_content_set("button2", b)
     n.show()
示例#14
0
    def show_error_msg(self, msg):
        pop = Popup(self, text=msg)
        pop.part_text_set('title,text', _('Error'))

        btn = Button(self, text=_('Continue'))
        btn.callback_clicked_add(lambda b: pop.delete())
        pop.part_content_set('button1', btn)

        btn = Button(self, text=_('Exit'))
        btn.callback_clicked_add(lambda b: self.app.exit())
        pop.part_content_set('button2', btn)

        pop.show()
def page6(bt, nf):
    bt = Button(nf, text="Page 5")
    bt.callback_clicked_add(navi_pop, nf)

    bt2 = Button(nf, text="Page 7")
    bt2.callback_clicked_add(page7, nf)

    content = Photo(nf,
                    file=os.path.join(img_path, "sky_03.jpg"),
                    fill_inside=True,
                    style="shadow")

    item = nf.item_push("Page 6", bt, bt2, content, "overlap")
    item.part_text_set("subtitle", "Overlap style!")
def page7(bt, nf):
    bt = Button(nf, text="Page 6")
    bt.callback_clicked_add(navi_pop, nf)

    bt2 = Button(nf, text="Page 1")
    bt2.callback_clicked_add(lambda x: nf.data["page1"].promote())

    content = Photo(nf,
                    file=os.path.join(img_path, "sky_02.jpg"),
                    fill_inside=True,
                    style="shadow")

    item = nf.item_push("Page 7", bt, bt2, content, "overlap")
    item.part_text_set("subtitle", "Overlap style!")
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)
示例#18
0
def cnp_clicked(obj):
    win = StandardWindow("copypaste", "CopyPaste", autodel=True)
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    gd = Grid(win, size=(100, 100), size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(gd)
    gd.show()

    en = Entry(win, scrollable=True, line_wrap=ELM_WRAP_CHAR,
        size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH,
        text="Elementary provides ")
    gd.pack(en, 10, 10, 60, 30)
    en.show()

    bt = Button(win, text="Copy from left entry")
    bt.callback_clicked_add(bt_copy_clicked, en)
    gd.pack(bt, 70, 10, 22, 30)
    bt.show()

    bt = Button(win, text="Clear clipboard")
    bt.callback_clicked_add(bt_clear_clicked, en)
    gd.pack(bt, 70, 70, 22, 20)
    bt.show()

    en = Entry(win, scrollable=True, line_wrap=ELM_WRAP_CHAR,
        size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH,
        text="rich copying and pasting functionality,")
    gd.pack(en, 10, 40, 60, 30)
    en.show()

    bt = Button(win, text="Paste to left entry")
    bt.callback_clicked_add(bt_paste_clicked, en)
    gd.pack(bt, 70, 40, 22, 30)
    bt.show()

    lb = Label(win, text="<b>Clipboard:</b>", size_hint_weight=(0.0, 0.0),
        size_hint_align=FILL_BOTH)
    gd.pack(lb, 10, 70, 60, 10)
    lb.show()

    global glb
    glb = Label(win, text="", size_hint_weight=(0.0, 0.0),
        size_hint_align=FILL_BOTH)
    gd.pack(glb, 10, 80, 60, 10)
    glb.show()

    win.size = 480, 200
    win.show()
def page5(bt, nf):
    bt = Button(nf, text="Page 4")
    bt.callback_clicked_add(navi_pop, nf)

    bt2 = Button(nf, text="Page 6")
    bt2.callback_clicked_add(page6, nf)

    content = Photo(nf,
                    file=os.path.join(img_path, "sky_01.jpg"),
                    fill_inside=True,
                    style="shadow")

    item = nf.item_insert_after(nf.top_item_get(), "Page 5", bt, bt2, content,
                                "basic")
    item.part_text_set("subtitle", "This page is inserted without transition")
示例#20
0
def cb_popup_center_title_text_2button_restack(li, item, win):
    popup = Popup(win, size_hint_weight=EXPAND_BOTH)
    popup.text = "When you click the 'Restack' button, " \
                 "an image will be located under this popup"
    popup.part_text_set("title,text", "Title")

    bt = Button(win, text="Restack")
    bt.callback_clicked_add(cb_btn_restack, popup)
    popup.part_content_set("button1", bt)

    bt = Button(win, text="Close")
    bt.callback_clicked_add(cb_bnt_close, popup)
    popup.part_content_set("button3", bt)

    popup.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):
        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)
示例#23
0
def focus3_clicked(obj, item=None):
    win = StandardWindow("focus3", "Focus 3", autodel=True, size=(320, 480))

    win.focus_highlight_enabled = True

    bx = Box(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(bx)
    bx.show()

    en = Entry(win,
               scrollable=True,
               single_line=True,
               text="An entry",
               size_hint_weight=EXPAND_HORIZ,
               size_hint_align=FILL_HORIZ)
    en.callback_focused_add(_focused_cb)
    en.callback_unfocused_add(_unfocused_cb)
    bx.pack_end(en)
    en.show()

    bt = Button(win,
                text="Add",
                focus_allow=False,
                size_hint_weight=EXPAND_HORIZ,
                size_hint_align=FILL_HORIZ)
    bt.callback_clicked_add(_add_cb, win, bx)
    bx.pack_end(bt)
    bt.show()

    bt = Button(win,
                text="Del",
                focus_allow=False,
                size_hint_weight=EXPAND_HORIZ,
                size_hint_align=FILL_HORIZ)
    bt.callback_clicked_add(_del_cb, bx)
    bx.pack_end(bt)
    bt.show()

    bt = Button(win,
                text="hide",
                focus_allow=False,
                size_hint_weight=EXPAND_HORIZ,
                size_hint_align=FILL_HORIZ)
    bt.callback_clicked_add(_hide_cb)
    bx.pack_end(bt)
    bt.show()

    win.show()
示例#24
0
 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, cmd):
     self.cmd = cmd
     self.cmd_exe = None
     
     win = self.win = Window("ecore-ex", ELM_WIN_DIALOG_BASIC)
     win.title = "Ecore Example"
     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.show()
     win.activate()
     
     self.sendEntry = Entry(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
     self.sendEntry.show()
     
     self.sendButton = Button(win, size_hint_weight=EXPAND_HORIZ,
                           size_hint_align=FILL_HORIZ)
     self.sendButton.text = "Send!"
     self.sendButton.callback_pressed_add(self.sendPressed)
     self.sendButton.show()
     
     box = Box(win, size_hint_weight=EXPAND_HORIZ,
                        size_hint_align=FILL_HORIZ)
     box.pack_end(self.sendEntry)
     box.pack_end(self.sendButton)
     box.show()
     
     win.resize_object_add(box)
     
     self.run_command(cmd)
def panel_clicked(obj):
    win = StandardWindow("panel", "Panel test", autodel=True, size=(300, 300))
    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 = Button(win,
                text="HIDE ME :)",
                size_hint_weight=EXPAND_BOTH,
                size_hint_align=FILL_BOTH)
    bt.show()

    panel = Panel(win,
                  orient=ELM_PANEL_ORIENT_LEFT,
                  content=bt,
                  size_hint_weight=EXPAND_VERT,
                  size_hint_align=FILL_VERT_ALIGN_LEFT)

    bx.pack_end(panel)
    panel.show()

    win.show()
示例#27
0
    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
示例#28
0
    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 __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 calendar_clicked(obj, item=None):
    win = StandardWindow("calendar", "Calendar", autodel=True)

    bx = Box(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(bx)
    bx.show()

    bt = Button(bx, text="Next API function")
    bt.callback_clicked_add(api_bt_clicked, api)
    bx.pack_end(bt)
    if api["state"] == API_STATE_LAST:
        bt.disabled = True
    bt.show()

    the_time = datetime(2010, 12, 31)
    cal = Calendar(bx,
                   first_day_of_week=ELM_DAY_MONDAY,
                   size_hint_weight=EXPAND_BOTH,
                   selected_time=the_time,
                   min_max_year=(2010, 2012))
    api["cal"] = cal
    bx.pack_end(cal)
    cal.show()

    win.show()