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 toolbar_clicked(obj, item=None):
    win = StandardWindow("toolbar", "Toolbar", autodel=True, size=(320, 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()

    tbl = Table(win,
                size_hint_weight=(0.0, EVAS_HINT_EXPAND),
                size_hint_align=FILL_BOTH)

    tb = Toolbar(win,
                 homogeneous=False,
                 size_hint_weight=(0.0, 0.0),
                 size_hint_align=(EVAS_HINT_FILL, 0.0))

    ph1 = Photo(win,
                size=40,
                file=os.path.join(img_path, "plant_01.jpg"),
                size_hint_weight=EXPAND_BOTH,
                size_hint_align=ALIGN_CENTER)
    tbl.pack(ph1, 0, 0, 1, 1)
    ph1.show()

    ph2 = Photo(win,
                size=80,
                size_hint_weight=EXPAND_BOTH,
                size_hint_align=ALIGN_CENTER)
    tbl.pack(ph2, 1, 0, 1, 1)
    ph2.show()

    ph3 = Photo(win,
                size=40,
                file=os.path.join(img_path, "sky_01.jpg"),
                size_hint_weight=EXPAND_BOTH,
                size_hint_align=ALIGN_CENTER)
    tbl.pack(ph3, 0, 1, 1, 1)
    ph3.show()

    ph4 = Photo(win,
                size=60,
                file=os.path.join(img_path, "sky_02.jpg"),
                size_hint_weight=EXPAND_BOTH,
                size_hint_align=ALIGN_CENTER)
    tbl.pack(ph4, 1, 1, 1, 1)
    ph4.show()

    item = tb.item_append("document-print", "Hello", tb_1)
    item.disabled = True

    item = tb.item_append("clock", "World,", tb_2, ph2)
    item.selected = True

    tb.item_append("folder-new", "here", tb_3, ph4)
    tb.item_append("clock", "comes", tb_4, ph4)
    tb.item_append("folder-new", "python-elementary!", tb_5, ph4)

    item = tb.item_append("clock", "Menu", tb_5, ph4)
    item.menu = True
    tb.menu_parent = win

    menu = item.menu

    menu.item_add(None, "Here", "clock", tb_3, ph4)
    menu_item = menu.item_add(None, "Comes", "refresh", tb_4, ph4)
    menu.item_add(menu_item, "hey ho", "folder-new", tb_4, ph4)
    menu.item_add(None, "python-elementary", "document-print", tb_5, ph4)

    bx.pack_end(tb)
    tb.show()

    bx.pack_end(tbl)
    tbl.show()

    win.show()
Beispiel #3
0
    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 toolbar5_clicked(obj, item=None):
    win = StandardWindow("toolbar5",
                         "Toolbar 5",
                         autodel=True,
                         size=(320, 300))
    win.autodel = True

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

    tbl = Table(win,
                size_hint_weight=(0.0, EVAS_HINT_EXPAND),
                size_hint_align=FILL_BOTH)

    tb = Toolbar(win,
                 homogeneous=False,
                 shrink_mode=ELM_TOOLBAR_SHRINK_MENU,
                 size_hint_weight=(0.0, 0.0),
                 size_hint_align=(EVAS_HINT_FILL, 0.0),
                 select_mode=ELM_OBJECT_SELECT_MODE_NONE)

    ph1 = Photo(win,
                size=40,
                file=os.path.join(img_path, "plant_01.jpg"),
                size_hint_weight=EXPAND_BOTH,
                size_hint_align=ALIGN_CENTER)
    tbl.pack(ph1, 0, 0, 1, 1)
    ph1.show()

    ph2 = Photo(win,
                size=80,
                size_hint_weight=EXPAND_BOTH,
                size_hint_align=ALIGN_CENTER)
    tbl.pack(ph2, 1, 0, 1, 1)
    ph2.show()

    ph3 = Photo(win,
                size=20,
                file=os.path.join(img_path, "sky_01.jpg"),
                size_hint_weight=EXPAND_BOTH,
                size_hint_align=ALIGN_CENTER)
    tbl.pack(ph3, 0, 1, 1, 1)
    ph3.show()

    ph4 = Photo(win,
                size=60,
                file=os.path.join(img_path, "sky_02.jpg"),
                size_hint_weight=EXPAND_BOTH,
                size_hint_align=ALIGN_CENTER)
    tbl.pack(ph4, 1, 1, 1, 1)
    ph4.show()

    tb_it = tb.item_append("document-print", "Hello", tb_1, ph1)
    tb_it.disabled = True
    tb_it.priority = 100

    tb_it = tb.item_append(os.path.join(img_path, "icon_04.png"), "World",
                           tb_2, ph1)
    tb_it.priority = -100

    tb_it = tb.item_append("object-rotate-right", "H", tb_3a, ph4)
    tb_it.state_add("object-rotate-left", "H2", tb_3b, ph4)
    tb_it.priority = 150

    tb_it = tb.item_append("mail-send", "Comes", tb_4a, ph4)
    tb_it.state_add("emptytrash", "Comes2", tb_4a, ph4)
    tb_it.state_add("trashcan_full", "Comes3", tb_4a, ph4)
    tb_it.priority = 0

    tb_it = tb.item_append("clock", "Elementary", tb_5, ph4)
    tb_it.priority = -200

    tb_it = tb.item_append("refresh", "Menu")
    tb_it.menu = True
    tb_it.priority = -9999
    tb.menu_parent = win
    menu = tb_it.menu

    menu.item_add(None, "edit-cut", "Shrink", tb_3, ph4)
    menu_it = menu.item_add(None, "edit-copy", "Mode", tb_4, ph4)
    menu.item_add(menu_it, "edit-paste", "is set to", tb_4, ph4)
    menu.item_add(None, "edit-delete", "Menu", tb_5, ph4)

    bx.pack_end(tb)
    tb.show()

    bx.pack_end(tbl)
    tbl.show()

    win.show()
def toolbar_clicked(obj, item=None):
    win = StandardWindow("toolbar", "Toolbar", autodel=True, size=(320, 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()

    tbl = Table(win, size_hint_weight=(0.0, EVAS_HINT_EXPAND),
        size_hint_align=FILL_BOTH)

    tb = Toolbar(win, homogeneous=False, size_hint_weight=(0.0, 0.0),
        size_hint_align=(EVAS_HINT_FILL, 0.0))

    ph1 = Photo(win, size=40, file=os.path.join(img_path, "plant_01.jpg"),
        size_hint_weight=EXPAND_BOTH, size_hint_align=ALIGN_CENTER)
    tbl.pack(ph1, 0, 0, 1, 1)
    ph1.show()

    ph2 = Photo(win, size=80, size_hint_weight=EXPAND_BOTH,
        size_hint_align=ALIGN_CENTER)
    tbl.pack(ph2, 1, 0, 1, 1)
    ph2.show()

    ph3 = Photo(win, size=40, file=os.path.join(img_path, "sky_01.jpg"),
        size_hint_weight=EXPAND_BOTH, size_hint_align=ALIGN_CENTER)
    tbl.pack(ph3, 0, 1, 1, 1)
    ph3.show()

    ph4 = Photo(win, size=60, file=os.path.join(img_path, "sky_02.jpg"),
        size_hint_weight=EXPAND_BOTH, size_hint_align=ALIGN_CENTER)
    tbl.pack(ph4, 1, 1, 1, 1)
    ph4.show()

    item = tb.item_append("document-print", "Hello", tb_1)
    item.disabled = True

    item = tb.item_append("clock", "World,", tb_2, ph2)
    item.selected = True

    tb.item_append("folder-new", "here", tb_3, ph4)
    tb.item_append("clock", "comes", tb_4, ph4)
    tb.item_append("folder-new", "python-elementary!", tb_5, ph4)

    item = tb.item_append("clock", "Menu", tb_5, ph4)
    item.menu = True
    tb.menu_parent = win

    menu = item.menu

    menu.item_add(None, "Here", "clock", tb_3, ph4)
    menu_item = menu.item_add(None, "Comes", "refresh", tb_4, ph4)
    menu.item_add(menu_item, "hey ho", "folder-new", tb_4, ph4)
    menu.item_add(None, "python-elementary", "document-print", tb_5, ph4)

    bx.pack_end(tb)
    tb.show()

    bx.pack_end(tbl)
    tbl.show()

    win.show()
def toolbar5_clicked(obj, item=None):
    win = StandardWindow("toolbar5", "Toolbar 5", autodel=True, size=(320, 300))
    win.autodel = True

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

    tbl = Table(win, size_hint_weight=(0.0, EVAS_HINT_EXPAND),
        size_hint_align=FILL_BOTH)

    tb = Toolbar(win, homogeneous=False, shrink_mode=ELM_TOOLBAR_SHRINK_MENU,
        size_hint_weight=(0.0, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.0),
        select_mode=ELM_OBJECT_SELECT_MODE_NONE)

    ph1 = Photo(win, size=40, file=os.path.join(img_path, "plant_01.jpg"),
        size_hint_weight=EXPAND_BOTH, size_hint_align=ALIGN_CENTER)
    tbl.pack(ph1, 0, 0, 1, 1)
    ph1.show()

    ph2 = Photo(win, size=80, size_hint_weight=EXPAND_BOTH,
        size_hint_align=ALIGN_CENTER)
    tbl.pack(ph2, 1, 0, 1, 1)
    ph2.show()

    ph3 = Photo(win, size=20, file=os.path.join(img_path, "sky_01.jpg"),
        size_hint_weight=EXPAND_BOTH, size_hint_align=ALIGN_CENTER)
    tbl.pack(ph3, 0, 1, 1, 1)
    ph3.show()

    ph4 = Photo(win, size=60, file=os.path.join(img_path, "sky_02.jpg"),
        size_hint_weight=EXPAND_BOTH, size_hint_align=ALIGN_CENTER)
    tbl.pack(ph4, 1, 1, 1, 1)
    ph4.show()

    tb_it = tb.item_append("document-print", "Hello", tb_1, ph1)
    tb_it.disabled = True
    tb_it.priority = 100

    tb_it = tb.item_append(os.path.join(img_path, "icon_04.png"),
        "World", tb_2, ph1)
    tb_it.priority = -100

    tb_it = tb.item_append("object-rotate-right", "H", tb_3a, ph4)
    tb_it.state_add("object-rotate-left", "H2", tb_3b, ph4)
    tb_it.priority = 150

    tb_it = tb.item_append("mail-send", "Comes", tb_4a, ph4)
    tb_it.state_add("emptytrash", "Comes2", tb_4a, ph4)
    tb_it.state_add("trashcan_full", "Comes3", tb_4a, ph4)
    tb_it.priority = 0

    tb_it = tb.item_append("clock", "Elementary", tb_5, ph4)
    tb_it.priority = -200

    tb_it = tb.item_append("refresh", "Menu")
    tb_it.menu = True
    tb_it.priority = -9999
    tb.menu_parent = win
    menu = tb_it.menu

    menu.item_add(None, "edit-cut", "Shrink", tb_3, ph4)
    menu_it = menu.item_add(None, "edit-copy", "Mode", tb_4, ph4)
    menu.item_add(menu_it, "edit-paste", "is set to", tb_4, ph4)
    menu.item_add(None, "edit-delete", "Menu", tb_5, ph4)

    bx.pack_end(tb)
    tb.show()

    bx.pack_end(tbl)
    tbl.show()

    win.show()
def focus_clicked(obj, item=None):
    win = StandardWindow("focus", "Focus", autodel=True, size=(800,600))
    
    win.focus_highlight_enabled = True

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

    ### Toolbar
    tbar = Toolbar(win, shrink_mode=ELM_TOOLBAR_SHRINK_MENU,
                   size_hint_align=(EVAS_HINT_FILL,0.0))

    tb_it = tbar.item_append("document-print", "Hello", _tb_sel)
    tb_it.disabled = True
    tb_it = tbar.item_append("folder-new", "World", _tb_sel)
    tb_it = tbar.item_append("object-rotate-right", "H", _tb_sel)
    tb_it = tbar.item_append("mail-send", "Comes", _tb_sel)
    tb_it = tbar.item_append("clock", "Elementary", _tb_sel)

    tb_it = tbar.item_append("refresh", "Menu", _tb_sel)
    tb_it.menu = True
    tbar.menu_parent = win
    menu = tb_it.menu

    menu.item_add(None, "Shrink", "edit-cut", _tb_sel)
    menu_it = menu.item_add(None, "Mode", "edit-copy", _tb_sel)
    menu.item_add(menu_it, "is set to", "edit-paste", _tb_sel)
    menu.item_add(menu_it, "or to", "edit-paste", _tb_sel)
    menu.item_add(None, "Menu", "edit-delete", _tb_sel)

    tbx.pack_end(tbar)
    tbar.show()


    mainbx = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH)
    tbx.pack_end(mainbx)
    mainbx.show()

    ## First Col
    bx = Box(win, size_hint_weight=EXPAND_BOTH)
    mainbx.pack_end(bx)
    bx.show()

    lb = Label(win, text="<b>Use Tab or Shift+Tab<br/>or Arrow keys</b>",
                    size_hint_align=FILL_BOTH)
    bx.pack_end(lb)
    lb.show()

    tg = Check(win, style="toggle")
    tg.part_text_set("on", "Yes")
    tg.part_text_set("off", "No")
    bx.pack_end(tg)
    tg.show()
    
    en = Entry(win, scrollable=True, single_line=True, text="This is a single line",
                    size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ)
    bx.pack_end(en)
    en.show()

    #
    bx2 = Box(win, horizontal=True, size_hint_align=FILL_BOTH)
    bx.pack_end(bx2)
    bx2.show()

    for i in range(2):
        bt = Button(win, text="Box", size_hint_align=FILL_BOTH, disabled=(i % 2))
        bx2.pack_end(bt)
        bt.show()

    sc = Scroller(win, bounce=(True,True), content_min_limit=(1,1),
                  size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
    bx2.pack_end(sc)
    sc.show()

    bt = Button(win, text="Scroller", size_hint_align=FILL_BOTH)
    sc.content = bt
    bt.show()

    #
    bt = Button(win, text="Box", size_hint_align=FILL_BOTH)
    bx.pack_end(bt)
    bt.show()

    #
    bx2 = Box(win, horizontal=True, size_hint_align=FILL_BOTH)
    bx.pack_end(bx2)
    bx2.show()
    
    for i in range(2):
        bx3 = Box(win, size_hint_align=FILL_BOTH)
        bx2.pack_end(bx3)
        bx3.show()

        for j in range(3):
            bt = Button(win, text="Box", size_hint_align=FILL_BOTH)
            bx3.pack_end(bt)
            bt.show()
    

    sc = Scroller(win, bounce=(False, True), content_min_limit=(1,0),
                  size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH)
    sc.content_min_limit=(1,1)
    bx2.pack_end(sc)
    sc.show()

    bx3 = Box(win, size_hint_align=FILL_BOTH)
    sc.content = bx3
    bx3.show()

    for i in range(5):
        bt = Button(win, text="BX Scroller", size_hint_align=FILL_BOTH)
        bx3.pack_end(bt)
        bt.show()


    ## Second Col
    ly = Layout(win, size_hint_weight=EXPAND_BOTH)
    ly.file = edj_file, "twolines"
    mainbx.pack_end(ly)
    ly.show()

    bx2 = Box(win, horizontal=True, size_hint_align=FILL_BOTH)
    ly.part_content_set("element1", bx2)
    bx2.show()

    for i in range(3):
        bt = Button(win, text="Layout", size_hint_align=FILL_BOTH)
        bx2.pack_end(bt)
        bt.show()
        bx2.focus_custom_chain_prepend(bt)

    bx2 = Box(win, size_hint_align=FILL_BOTH)
    ly.part_content_set("element2", bx2)
    bx2.show()

    bt = Button(win, text="Disable", size_hint_align=FILL_BOTH)
    bt.callback_clicked_add(lambda b: b.disabled_set(True))
    bx2.pack_end(bt)
    bt.show()
    bx2.focus_custom_chain_prepend(bt)

    bt2 = Button(win, text="Enable", size_hint_align=FILL_BOTH)
    bt2.callback_clicked_add(lambda b, b1: b1.disabled_set(False), bt)
    bx2.pack_end(bt2)
    bt2.show()
    bx2.focus_custom_chain_append(bt2)

    ## Third Col
    bx = Box(win, size_hint_weight=EXPAND_BOTH)
    mainbx.pack_end(bx)
    bx.show()

    fr = Frame(win, text="Frame", )
    bx.pack_end(fr)
    fr.show()

    tb = Table(win, size_hint_weight=EXPAND_BOTH)
    fr.content = tb
    tb.show()

    for j in range(1):
        for i in range(2):
            bt = Button(win, text="Table", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH)
            tb.pack(bt, i, j, 1, 1)
            bt.show()

    #
    fr = Bubble(win, text="Bubble", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH)
    bx.pack_end(fr)
    fr.show()

    tb = Table(win,  size_hint_weight=EXPAND_BOTH)
    fr.content = tb
    tb.show()

    for j in range(2):
        for i in range(1):
            bt = Button(win, text="Table", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH)
            tb.pack(bt, i, j, 1, 1)
            bt.show()


    win.show()
Beispiel #8
0
def focus_clicked(obj, item=None):
    win = StandardWindow("focus", "Focus", autodel=True, size=(800, 600))

    win.focus_highlight_enabled = True

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

    ### Toolbar
    tbar = Toolbar(win,
                   shrink_mode=ELM_TOOLBAR_SHRINK_MENU,
                   size_hint_align=(EVAS_HINT_FILL, 0.0))

    tb_it = tbar.item_append("document-print", "Hello", _tb_sel)
    tb_it.disabled = True
    tb_it = tbar.item_append("folder-new", "World", _tb_sel)
    tb_it = tbar.item_append("object-rotate-right", "H", _tb_sel)
    tb_it = tbar.item_append("mail-send", "Comes", _tb_sel)
    tb_it = tbar.item_append("clock", "Elementary", _tb_sel)

    tb_it = tbar.item_append("refresh", "Menu", _tb_sel)
    tb_it.menu = True
    tbar.menu_parent = win
    menu = tb_it.menu

    menu.item_add(None, "Shrink", "edit-cut", _tb_sel)
    menu_it = menu.item_add(None, "Mode", "edit-copy", _tb_sel)
    menu.item_add(menu_it, "is set to", "edit-paste", _tb_sel)
    menu.item_add(menu_it, "or to", "edit-paste", _tb_sel)
    menu.item_add(None, "Menu", "edit-delete", _tb_sel)

    tbx.pack_end(tbar)
    tbar.show()

    mainbx = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH)
    tbx.pack_end(mainbx)
    mainbx.show()

    ## First Col
    bx = Box(win, size_hint_weight=EXPAND_BOTH)
    mainbx.pack_end(bx)
    bx.show()

    lb = Label(win,
               text="<b>Use Tab or Shift+Tab<br/>or Arrow keys</b>",
               size_hint_align=FILL_BOTH)
    bx.pack_end(lb)
    lb.show()

    tg = Check(win, style="toggle")
    tg.part_text_set("on", "Yes")
    tg.part_text_set("off", "No")
    bx.pack_end(tg)
    tg.show()

    en = Entry(win,
               scrollable=True,
               single_line=True,
               text="This is a single line",
               size_hint_weight=EXPAND_HORIZ,
               size_hint_align=FILL_HORIZ)
    bx.pack_end(en)
    en.show()

    #
    bx2 = Box(win, horizontal=True, size_hint_align=FILL_BOTH)
    bx.pack_end(bx2)
    bx2.show()

    for i in range(2):
        bt = Button(win,
                    text="Box",
                    size_hint_align=FILL_BOTH,
                    disabled=(i % 2))
        bx2.pack_end(bt)
        bt.show()

    sc = Scroller(win,
                  bounce=(True, True),
                  content_min_limit=(1, 1),
                  size_hint_weight=EXPAND_BOTH,
                  size_hint_align=FILL_BOTH)
    bx2.pack_end(sc)
    sc.show()

    bt = Button(win, text="Scroller", size_hint_align=FILL_BOTH)
    sc.content = bt
    bt.show()

    #
    bt = Button(win, text="Box", size_hint_align=FILL_BOTH)
    bx.pack_end(bt)
    bt.show()

    #
    bx2 = Box(win, horizontal=True, size_hint_align=FILL_BOTH)
    bx.pack_end(bx2)
    bx2.show()

    for i in range(2):
        bx3 = Box(win, size_hint_align=FILL_BOTH)
        bx2.pack_end(bx3)
        bx3.show()

        for j in range(3):
            bt = Button(win, text="Box", size_hint_align=FILL_BOTH)
            bx3.pack_end(bt)
            bt.show()

    sc = Scroller(win,
                  bounce=(False, True),
                  content_min_limit=(1, 0),
                  size_hint_align=FILL_BOTH,
                  size_hint_weight=EXPAND_BOTH)
    sc.content_min_limit = (1, 1)
    bx2.pack_end(sc)
    sc.show()

    bx3 = Box(win, size_hint_align=FILL_BOTH)
    sc.content = bx3
    bx3.show()

    for i in range(5):
        bt = Button(win, text="BX Scroller", size_hint_align=FILL_BOTH)
        bx3.pack_end(bt)
        bt.show()

    ## Second Col
    ly = Layout(win, size_hint_weight=EXPAND_BOTH)
    ly.file = edj_file, "twolines"
    mainbx.pack_end(ly)
    ly.show()

    bx2 = Box(win, horizontal=True, size_hint_align=FILL_BOTH)
    ly.part_content_set("element1", bx2)
    bx2.show()

    for i in range(3):
        bt = Button(win, text="Layout", size_hint_align=FILL_BOTH)
        bx2.pack_end(bt)
        bt.show()
        bx2.focus_custom_chain_prepend(bt)

    bx2 = Box(win, size_hint_align=FILL_BOTH)
    ly.part_content_set("element2", bx2)
    bx2.show()

    bt = Button(win, text="Disable", size_hint_align=FILL_BOTH)
    bt.callback_clicked_add(lambda b: b.disabled_set(True))
    bx2.pack_end(bt)
    bt.show()
    bx2.focus_custom_chain_prepend(bt)

    bt2 = Button(win, text="Enable", size_hint_align=FILL_BOTH)
    bt2.callback_clicked_add(lambda b, b1: b1.disabled_set(False), bt)
    bx2.pack_end(bt2)
    bt2.show()
    bx2.focus_custom_chain_append(bt2)

    ## Third Col
    bx = Box(win, size_hint_weight=EXPAND_BOTH)
    mainbx.pack_end(bx)
    bx.show()

    fr = Frame(
        win,
        text="Frame",
    )
    bx.pack_end(fr)
    fr.show()

    tb = Table(win, size_hint_weight=EXPAND_BOTH)
    fr.content = tb
    tb.show()

    for j in range(1):
        for i in range(2):
            bt = Button(win,
                        text="Table",
                        size_hint_align=FILL_BOTH,
                        size_hint_weight=EXPAND_BOTH)
            tb.pack(bt, i, j, 1, 1)
            bt.show()

    #
    fr = Bubble(win,
                text="Bubble",
                size_hint_align=FILL_BOTH,
                size_hint_weight=EXPAND_BOTH)
    bx.pack_end(fr)
    fr.show()

    tb = Table(win, size_hint_weight=EXPAND_BOTH)
    fr.content = tb
    tb.show()

    for j in range(2):
        for i in range(1):
            bt = Button(win,
                        text="Table",
                        size_hint_align=FILL_BOTH,
                        size_hint_weight=EXPAND_BOTH)
            tb.pack(bt, i, j, 1, 1)
            bt.show()

    win.show()