Пример #1
0
    def __init__(self, parent, session):
        self.session = session
        conf = session.conf
        PreferencesDialog.__init__(self, "General")

        limits = Limits(self, session)
        ports = ListenPorts(self, session)
        pe = EncryptionSettings(self, session)
        dlsel = DataStorageSelector(self, conf)

        pad = Rectangle(self.evas)
        pad.color = 0, 0, 0, 0
        pad.size_hint_min = 0, 10

        sep1 = Separator(self)
        sep1.horizontal = True

        chk1 = Check(self)
        chk1.size_hint_align = 0.0, 0.0
        chk1.text = "Delete original .torrent file when added"
        chk1.state = conf.getboolean("Settings", "delete_original")
        chk1.callback_changed_add(lambda x: conf.set(
            "Settings", "delete_original", str(bool(chk1.state))))

        chk2 = Check(self)
        chk2.size_hint_align = 0.0, 0.0
        chk2.text = "Ask for confirmation on exit"
        chk2.state = conf.getboolean("Settings", "confirmations")
        chk2.callback_changed_add(lambda x: conf.set(
            "Settings", "confirmations", str(bool(chk2.state))))

        sep2 = Separator(self)
        sep2.horizontal = True

        for w in ports, limits, dlsel, pe, pad, sep1, chk1, chk2, sep2:
            w.show()
            self.box.pack_end(w)
    def __init__(self, parent, session):
        self.session = session
        conf = session.conf
        PreferencesDialog.__init__(self, "General")

        limits = Limits(self, session)
        ports = ListenPorts(self, session)
        pe = EncryptionSettings(self, session)
        dlsel = DataStorageSelector(self, conf)

        pad = Rectangle(self.evas)
        pad.color = 0, 0, 0, 0
        pad.size_hint_min = 0, 10

        sep1 = Separator(self)
        sep1.horizontal = True

        chk1 = Check(self)
        chk1.size_hint_align = 0.0, 0.0
        chk1.text = "Delete original .torrent file when added"
        chk1.state = conf.getboolean("Settings", "delete_original")
        chk1.callback_changed_add(lambda x: conf.set("Settings",
            "delete_original", str(bool(chk1.state))))

        chk2 = Check(self)
        chk2.size_hint_align = 0.0, 0.0
        chk2.text = "Ask for confirmation on exit"
        chk2.state = conf.getboolean("Settings", "confirmations")
        chk2.callback_changed_add(lambda x: conf.set("Settings",
            "confirmations", str(bool(chk2.state))))

        sep2 = Separator(self)
        sep2.horizontal = True

        for w in ports, limits, dlsel, pe, pad, sep1, chk1, chk2, sep2:
            w.show()
            self.box.pack_end(w)
Пример #3
0
def colorselector_clicked(obj):
    win = StandardWindow("colorselector",
                         "ColorSelector test",
                         autodel=True,
                         size=(350, 350))
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

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

    re = Rectangle(win.evas)
    re.size_hint_min = (1, 100)
    re.show()

    fr = Frame(win,
               text="Color View",
               content=re,
               size_hint_weight=EXPAND_HORIZ,
               size_hint_align=FILL_BOTH)
    vbox.pack_end(fr)
    fr.show()

    cs = Colorselector(win,
                       size_hint_weight=EXPAND_BOTH,
                       size_hint_align=FILL_BOTH,
                       color=(255, 160, 132, 255))
    cs.callback_changed_add(cb_cs_changed, re)
    cs.callback_color_item_selected_add(cb_cs_item_sel, re)
    cs.callback_color_item_longpressed_add(cb_cs_item_lp, re)
    cs.show()

    fr = Frame(win,
               text="Color Selector",
               content=cs,
               size_hint_weight=EXPAND_BOTH,
               size_hint_align=FILL_BOTH)
    vbox.pack_end(fr)
    fr.show()

    re.color = cs.color
    cs.palette_color_add(255, 90, 18, 255)
    cs.palette_color_add(255, 213, 0, 255)
    cs.palette_color_add(146, 255, 11, 255)
    cs.palette_color_add(9, 186, 10, 255)
    cs.palette_color_add(86, 201, 242, 255)
    cs.palette_color_add(18, 83, 128, 255)
    cs.palette_color_add(140, 53, 238, 255)
    cs.palette_color_add(255, 145, 145, 255)
    cs.palette_color_add(255, 59, 119, 255)
    cs.palette_color_add(133, 100, 69, 255)
    cs.palette_color_add(255, 255, 119, 255)
    cs.palette_color_add(133, 100, 255, 255)

    last_item = cs.palette_items_get()[-1]
    last_item.color = (255, 0, 0, 255)

    hbox = Box(win,
               horizontal=True,
               size_hint_align=FILL_AND_ALIGN_TOP,
               size_hint_weight=EXPAND_HORIZ)
    vbox.pack_end(hbox)
    hbox.show()

    bt = Button(win,
                text="Palette",
                size_hint_align=FILL_AND_ALIGN_TOP,
                size_hint_weight=EXPAND_HORIZ)
    bt.callback_clicked_add(lambda btn: cs.mode_set(ELM_COLORSELECTOR_PALETTE))
    hbox.pack_end(bt)
    bt.show()

    bt = Button(win,
                text="Components",
                size_hint_align=FILL_AND_ALIGN_TOP,
                size_hint_weight=EXPAND_HORIZ)
    bt.callback_clicked_add(
        lambda btn: cs.mode_set(ELM_COLORSELECTOR_COMPONENTS))
    hbox.pack_end(bt)
    bt.show()

    bt = Button(win,
                text="Both",
                size_hint_align=FILL_AND_ALIGN_TOP,
                size_hint_weight=EXPAND_HORIZ)
    bt.callback_clicked_add(lambda btn: cs.mode_set(ELM_COLORSELECTOR_BOTH))
    hbox.pack_end(bt)
    bt.show()

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

    bt = Button(win,
                text="palette items",
                size_hint_align=FILL_BOTH,
                size_hint_weight=EXPAND_HORIZ)
    bt.callback_clicked_add(palette_items, cs)
    hbox.pack_end(bt)
    bt.show()

    bt = Button(win,
                text="palette selected item",
                size_hint_align=FILL_BOTH,
                size_hint_weight=EXPAND_HORIZ)
    bt.callback_clicked_add(selected_item_get, cs)
    hbox.pack_end(bt)
    bt.show()

    win.show()
def mapbuf_clicked(obj, item=None):
    global mb_list

    win = Window("mapbuf", ELM_WIN_BASIC, title="Mapbuf test", autodel=True,
        size=(480, 600))
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    bg = Background(win, file=os.path.join(img_path, "sky_04.jpg"),
        size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(bg)
    bg.show()

    vbox = Box(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
    win.resize_object_add(vbox)
    vbox.show()

    # launcher
    sc = Scroller(win, bounce=(True, False), policy=SCROLL_POLICY_OFF,
        size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH)
    vbox.pack_end(sc)

    bx = Box(win, horizontal=True, homogeneous=True)
    bx.show()

    for k in range(8):
        tb = Table(win, size_hint_align=ALIGN_CENTER,
            size_hint_weight=(0.0, 0.0))
        tb.show()

        pad = Rectangle(win.evas, color=(255, 255, 0, 255))
        pad.size_hint_min = (464, 4)
        pad.size_hint_weight = (0.0, 0.0)
        pad.size_hint_align = (EVAS_HINT_FILL, EVAS_HINT_FILL)
        pad.show()
        tb.pack(pad, 1, 0, 5, 1)

        pad = Rectangle(win.evas, color=(255, 255, 0, 255))
        pad.size_hint_min = (464, 4)
        pad.size_hint_weight = (0.0, 0.0)
        pad.size_hint_align = (EVAS_HINT_FILL, EVAS_HINT_FILL)
        pad.show()
        tb.pack(pad, 1, 11, 5, 1)

        pad = Rectangle(win.evas, color=(255, 255, 0, 255))
        pad.size_hint_min = (4, 4)
        pad.size_hint_weight = (0.0, 0.0)
        pad.size_hint_align = (EVAS_HINT_FILL, EVAS_HINT_FILL)
        pad.show()
        tb.pack(pad, 0, 1, 1, 10)

        pad = Rectangle(win.evas, color=(255, 255, 0, 255))
        pad.size_hint_min = (4, 4)
        pad.size_hint_weight = (0.0, 0.0)
        pad.size_hint_align = (EVAS_HINT_FILL, EVAS_HINT_FILL)
        pad.show()
        tb.pack(pad, 6, 1, 1, 10)

        mb = Mapbuf(win, content=tb)
        mb.point_color_set(k % 4, 255, 0, 0, 255)
        mb_list.append(mb)
        bx.pack_end(mb)
        mb.show()

        n = m = 0
        for j in range(5):
            for i in range(5):
                ic = Icon(win, scale=0.5,
                    file=os.path.join(img_path, "icon_%02d.png" % (n)),
                    resizable=(False, False), size_hint_weight=EXPAND_BOTH,
                    size_hint_align=ALIGN_CENTER)
                tb.pack(ic, 1 + i, 1 + (j * 2), 1, 1)
                ic.show()

                lb = Label(win, style="marker", text=names[m])
                tb.pack(lb, 1 + i, 1 + (j * 2) + 1, 1, 1)
                lb.show()

                n = n + 1 if n < 23 else 0
                m = m + 1 if m < 15 else 0

    sc.content = bx
    sc.page_relative_set(1.0, 1.0)
    sc.show()

    # controls
    hbox = Box(win, horizontal=True, homogeneous=True,
        size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ)
    vbox.pack_start(hbox)
    hbox.show()

    ck = Check(win, text="Map", state=False)
    ck.callback_changed_add(cb_ck_map)
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="Alpha", state=True)
    ck.callback_changed_add(cb_ck_alpha)
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="Smooth", state=True)
    ck.callback_changed_add(cb_ck_smooth)
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="FS", state=False)
    ck.callback_changed_add(cb_ck_fs, win)
    hbox.pack_end(ck)
    ck.show()

    bt = Button(win, text="Close", size_hint_align=FILL_BOTH,
        size_hint_weight=EXPAND_HORIZ)
    bt.callback_clicked_add(cb_btn_close, win)
    hbox.pack_end(bt)
    bt.show()

    win.show()
def colorselector_clicked(obj):
    win = StandardWindow("colorselector", "ColorSelector test",
        autodel=True, size=(350,350))
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

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

    re = Rectangle(win.evas)
    re.size_hint_min = (1, 100)
    re.show()

    fr = Frame(win, text="Color View", content=re,
        size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
    vbox.pack_end(fr)
    fr.show()

    cs = Colorselector(win, size_hint_weight=EXPAND_BOTH,
        size_hint_align=FILL_BOTH, color=(255, 160, 132, 255))
    cs.callback_changed_add(cb_cs_changed, re)
    cs.callback_color_item_selected_add(cb_cs_item_sel, re)
    cs.callback_color_item_longpressed_add(cb_cs_item_lp, re)
    cs.show()

    fr = Frame(win, text="Color Selector", content=cs,
        size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
    vbox.pack_end(fr)
    fr.show()

    re.color = cs.color
    cs.palette_color_add(255, 90, 18, 255)
    cs.palette_color_add(255, 213, 0, 255)
    cs.palette_color_add(146, 255, 11, 255)
    cs.palette_color_add(9, 186, 10, 255)
    cs.palette_color_add(86, 201, 242, 255)
    cs.palette_color_add(18, 83, 128, 255)
    cs.palette_color_add(140, 53, 238, 255)
    cs.palette_color_add(255, 145, 145, 255)
    cs.palette_color_add(255, 59, 119, 255)
    cs.palette_color_add(133, 100, 69, 255)
    cs.palette_color_add(255, 255, 119, 255)
    cs.palette_color_add(133, 100, 255, 255)

    last_item = cs.palette_items_get()[-1]
    last_item.color = (255, 0, 0, 255)

    hbox = Box(win, horizontal=True, size_hint_align=FILL_AND_ALIGN_TOP,
        size_hint_weight=EXPAND_HORIZ)
    vbox.pack_end(hbox)
    hbox.show()

    bt = Button(win, text="Palette", size_hint_align=FILL_AND_ALIGN_TOP,
        size_hint_weight=EXPAND_HORIZ)
    bt.callback_clicked_add(lambda btn: cs.mode_set(ELM_COLORSELECTOR_PALETTE))
    hbox.pack_end(bt)
    bt.show()

    bt = Button(win, text="Components", size_hint_align=FILL_AND_ALIGN_TOP,
        size_hint_weight=EXPAND_HORIZ)
    bt.callback_clicked_add(lambda btn: cs.mode_set(ELM_COLORSELECTOR_COMPONENTS))
    hbox.pack_end(bt)
    bt.show()

    bt = Button(win, text="Both", size_hint_align=FILL_AND_ALIGN_TOP,
        size_hint_weight=EXPAND_HORIZ)
    bt.callback_clicked_add(lambda btn: cs.mode_set(ELM_COLORSELECTOR_BOTH))
    hbox.pack_end(bt)
    bt.show()

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

    bt = Button(win, text="palette items", size_hint_align=FILL_BOTH,
        size_hint_weight=EXPAND_HORIZ)
    bt.callback_clicked_add(palette_items, cs)
    hbox.pack_end(bt)
    bt.show()
    
    bt = Button(win, text="palette selected item", size_hint_align=FILL_BOTH,
        size_hint_weight=EXPAND_HORIZ)
    bt.callback_clicked_add(selected_item_get, cs)
    hbox.pack_end(bt)
    bt.show()

    win.show()
def mapbuf_clicked(obj, item=None):
    global mb_list

    win = Window("mapbuf",
                 ELM_WIN_BASIC,
                 title="Mapbuf test",
                 autodel=True,
                 size=(480, 600))
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    bg = Background(win,
                    file=os.path.join(img_path, "sky_04.jpg"),
                    size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(bg)
    bg.show()

    vbox = Box(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
    win.resize_object_add(vbox)
    vbox.show()

    # launcher
    sc = Scroller(win,
                  bounce=(True, False),
                  policy=SCROLL_POLICY_OFF,
                  size_hint_align=FILL_BOTH,
                  size_hint_weight=EXPAND_BOTH)
    vbox.pack_end(sc)

    bx = Box(win, horizontal=True, homogeneous=True)
    bx.show()

    for k in range(8):
        tb = Table(win,
                   size_hint_align=ALIGN_CENTER,
                   size_hint_weight=(0.0, 0.0))
        tb.show()

        pad = Rectangle(win.evas, color=(255, 255, 0, 255))
        pad.size_hint_min = (464, 4)
        pad.size_hint_weight = (0.0, 0.0)
        pad.size_hint_align = (EVAS_HINT_FILL, EVAS_HINT_FILL)
        pad.show()
        tb.pack(pad, 1, 0, 5, 1)

        pad = Rectangle(win.evas, color=(255, 255, 0, 255))
        pad.size_hint_min = (464, 4)
        pad.size_hint_weight = (0.0, 0.0)
        pad.size_hint_align = (EVAS_HINT_FILL, EVAS_HINT_FILL)
        pad.show()
        tb.pack(pad, 1, 11, 5, 1)

        pad = Rectangle(win.evas, color=(255, 255, 0, 255))
        pad.size_hint_min = (4, 4)
        pad.size_hint_weight = (0.0, 0.0)
        pad.size_hint_align = (EVAS_HINT_FILL, EVAS_HINT_FILL)
        pad.show()
        tb.pack(pad, 0, 1, 1, 10)

        pad = Rectangle(win.evas, color=(255, 255, 0, 255))
        pad.size_hint_min = (4, 4)
        pad.size_hint_weight = (0.0, 0.0)
        pad.size_hint_align = (EVAS_HINT_FILL, EVAS_HINT_FILL)
        pad.show()
        tb.pack(pad, 6, 1, 1, 10)

        mb = Mapbuf(win, content=tb)
        mb.point_color_set(k % 4, 255, 0, 0, 255)
        mb_list.append(mb)
        bx.pack_end(mb)
        mb.show()

        n = m = 0
        for j in range(5):
            for i in range(5):
                ic = Icon(win,
                          scale=0.5,
                          file=os.path.join(img_path, "icon_%02d.png" % (n)),
                          resizable=(False, False),
                          size_hint_weight=EXPAND_BOTH,
                          size_hint_align=ALIGN_CENTER)
                tb.pack(ic, 1 + i, 1 + (j * 2), 1, 1)
                ic.show()

                lb = Label(win, style="marker", text=names[m])
                tb.pack(lb, 1 + i, 1 + (j * 2) + 1, 1, 1)
                lb.show()

                n = n + 1 if n < 23 else 0
                m = m + 1 if m < 15 else 0

    sc.content = bx
    sc.page_relative_set(1.0, 1.0)
    sc.show()

    # controls
    hbox = Box(win,
               horizontal=True,
               homogeneous=True,
               size_hint_weight=EXPAND_HORIZ,
               size_hint_align=FILL_HORIZ)
    vbox.pack_start(hbox)
    hbox.show()

    ck = Check(win, text="Map", state=False)
    ck.callback_changed_add(cb_ck_map)
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="Alpha", state=True)
    ck.callback_changed_add(cb_ck_alpha)
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="Smooth", state=True)
    ck.callback_changed_add(cb_ck_smooth)
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="FS", state=False)
    ck.callback_changed_add(cb_ck_fs, win)
    hbox.pack_end(ck)
    ck.show()

    bt = Button(win,
                text="Close",
                size_hint_align=FILL_BOTH,
                size_hint_weight=EXPAND_HORIZ)
    bt.callback_clicked_add(cb_btn_close, win)
    hbox.pack_end(bt)
    bt.show()

    win.show()