コード例 #1
0
def thumb_clicked(obj):
    if not elementary.need_ethumb():
        print("Ethumb not available!")
        return

    images = ("panel_01.jpg", "plant_01.jpg", "rock_01.jpg", "rock_02.jpg",
              "sky_01.jpg", "sky_02.jpg", "sky_03.jpg", "sky_04.jpg",
              "wood_01.jpg", "mystrale.jpg", "mystrale_2.jpg")

    win = StandardWindow("thumb", "Thumb", autodel=True, size=(600, 600))
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    tb = Table(win, size_hint_weight=EXPAND_BOTH)

    n = 0
    for j in range(12):
        for i in range(12):
            n = (n + 1) % 11
            th = Thumb(win,
                       file=os.path.join(img_path, images[n]),
                       size_hint_weight=EXPAND_BOTH,
                       size_hint_align=FILL_BOTH,
                       editable=True)
            tb.pack(th, i, j, 1, 1)
            th.show()

    sc = Scroller(win, size_hint_weight=EXPAND_BOTH, content=tb)
    win.resize_object_add(sc)

    tb.show()
    sc.show()

    win.show()
コード例 #2
0
ファイル: utils.py プロジェクト: DaveMDS/egitu
    def __init__(self, cmd, exec_cb):
        DialogWindow.__init__(self, _app_instance.win, 'egitu-review',
                              'Git Command Review', autodel=True, size=(300,50))

        # main table (inside a padding frame)
        fr = Frame(self, style='default', text='Command to execute',
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        self.resize_object_add(fr)
        fr.show()

        tb = Table(self, padding=(6,6),
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        fr.content = tb
        tb.show()

        # cmd entry
        en = Entry(self, single_line=True, scrollable=True, 
                   text=utf8_to_markup(cmd),
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        tb.pack(en, 0, 0, 2, 1)
        en.show()

        # buttons
        bt = Button(self, text='Close', size_hint_expand=EXPAND_HORIZ, size_hint_fill=FILL_HORIZ)
        bt.callback_clicked_add(lambda b: self.delete())
        tb.pack(bt, 0, 1, 1, 1)
        bt.show()

        bt = Button(self, text='Execute', size_hint_expand=EXPAND_HORIZ, size_hint_fill=FILL_HORIZ)
        bt.callback_clicked_add(self._exec_clicked_cb, en, exec_cb)
        tb.pack(bt, 1, 1, 1, 1)
        bt.show()

        #
        self.show()
コード例 #3
0
def video_clicked(obj):
    win = StandardWindow("video", "video", autodel=True, size=(800, 600))
    win.alpha = True  # Needed to turn video fast path on

    video = Video(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(video)
    video.show()

    player = Player(win, content=video)
    player.show()

    notify = Notify(win, orient=ELM_NOTIFY_ORIENT_BOTTOM, timeout=3.0)
    notify.content = player

    tb = Table(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(tb)

    bt = FileselectorButton(win,
                            text="Select Video",
                            size_hint_weight=EXPAND_BOTH,
                            size_hint_align=(0.5, 0.1))
    bt.callback_file_chosen_add(my_bt_open, video)
    tb.pack(bt, 0, 0, 1, 1)
    bt.show()

    tb.show()

    video.event_callback_add(EVAS_CALLBACK_MOUSE_MOVE, notify_show, notify)
    video.event_callback_add(EVAS_CALLBACK_MOUSE_IN, notify_block, notify)
    video.event_callback_add(EVAS_CALLBACK_MOUSE_OUT, notify_unblock, notify)

    win.show()
コード例 #4
0
def video_clicked(obj):
    win = StandardWindow("video", "video", autodel=True, size=(800, 600))
    win.alpha = True # Needed to turn video fast path on

    video = Video(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(video)
    video.show()

    player = Player(win, content=video)
    player.show()

    notify = Notify(win, orient=ELM_NOTIFY_ORIENT_BOTTOM, timeout=3.0)
    notify.content = player

    tb = Table(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(tb)

    bt = FileselectorButton(win, text="Select Video",
        size_hint_weight=EXPAND_BOTH, size_hint_align=(0.5, 0.1))
    bt.callback_file_chosen_add(my_bt_open, video)
    tb.pack(bt, 0, 0, 1, 1)
    bt.show()

    tb.show()

    video.event_callback_add(EVAS_CALLBACK_MOUSE_MOVE, notify_show, notify)
    video.event_callback_add(EVAS_CALLBACK_MOUSE_IN, notify_block, notify)
    video.event_callback_add(EVAS_CALLBACK_MOUSE_OUT, notify_unblock, notify)

    win.show()
コード例 #5
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()
コード例 #6
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()
コード例 #7
0
def photo_clicked(obj):
    win = StandardWindow("photo", "Photo test", autodel=True, size=(300, 300))
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    elementary.need_ethumb()

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

    sc = Scroller(win, size_hint_weight=EXPAND_BOTH, content=tb)
    win.resize_object_add(sc)
    sc.show()

    n = 0
    for j in range(12):
        for i in range(12):
            ph = Photo(win, aspect_fixed=False, size=80, editable=True,
                size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
            name = os.path.join(img_path, images[n])
            n += 1
            if n >= 9: n = 0
            if n == 8:
                ph.thumb = name
            else:
                ph.file = name
            if n in [2, 3]:
                ph.fill_inside = True
                ph.style = "shadow"

            tb.pack(ph, i, j, 1, 1)
            ph.show()

    win.show()
コード例 #8
0
ファイル: ePad.py プロジェクト: emctoo/ePad
    def fileExists(self, filePath):

        self.confirmPopup = Popup(self.mainWindow,
                                  size_hint_weight=EXPAND_BOTH)

        # Add a table to hold dialog image and text to Popup
        tb = Table(self.confirmPopup, size_hint_weight=EXPAND_BOTH)
        self.confirmPopup.part_content_set("default", tb)
        tb.show()

        # Add dialog-error Image to table
        need_ethumb()
        icon = Icon(self.confirmPopup, thumb='True')
        icon.standard_set('dialog-question')
        # Using gksudo or sudo fails to load Image here
        #   unless options specify using preserving their existing environment.
        #   may also fail to load other icons but does not raise an exception
        #   in that situation.
        # Works fine using eSudo as a gksudo alternative,
        #   other alternatives not tested
        try:
            dialogImage = Image(self.confirmPopup,
                                size_hint_weight=EXPAND_HORIZ,
                                size_hint_align=FILL_BOTH,
                                file=icon.file_get())
            tb.pack(dialogImage, 0, 0, 1, 1)
            dialogImage.show()
        except RuntimeError:
            # An error message is displayed for this same error
            #   when aboutWin is initialized so no need to redisplay.
            pass
        # Add dialog text to table
        dialogLabel = Label(self.confirmPopup, line_wrap=ELM_WRAP_WORD,
                            size_hint_weight=EXPAND_HORIZ,
                            size_hint_align=FILL_BOTH)
        current_file = os.path.basename(filePath)
        dialogLabel.text = "'%s' already exists. Overwrite?<br><br>" \
                           % (current_file)
        tb.pack(dialogLabel, 1, 0, 1, 1)
        dialogLabel.show()

        # Close without saving button
        no_btt = Button(self.mainWindow)
        no_btt.text = "No"
        no_btt.callback_clicked_add(self.closePopup, self.confirmPopup)
        no_btt.show()
        # Save the file and then close button
        sav_btt = Button(self.mainWindow)
        sav_btt.text = "Yes"
        sav_btt.callback_clicked_add(self.doSelected)
        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("button3", sav_btt)
        self.confirmPopup.show()
コード例 #9
0
ファイル: remotes.py プロジェクト: druonysus/egitu
    def __init__(self, parent, repo):
        self.repo = repo

        Popup.__init__(self, parent)
        self.part_text_set("title,text", "Add remote")

        tb = Table(self, padding=(3, 3), size_hint_expand=EXPAND_BOTH)
        self.content = tb
        tb.show()

        # name
        lb = Label(tb, text="Name")
        tb.pack(lb, 0, 0, 1, 1)
        lb.show()

        en = Entry(
            tb, editable=True, single_line=True, scrollable=True, size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH
        )
        en.part_text_set("guide", "Name for the new remote")
        en.callback_changed_user_add(lambda e: self.err_unset())
        tb.pack(en, 1, 0, 1, 1)
        en.show()
        self.name_entry = en

        # url
        lb = Label(tb, text="URL")
        tb.pack(lb, 0, 1, 1, 1)
        lb.show()

        en = Entry(
            tb, editable=True, single_line=True, scrollable=True, size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH
        )
        en.part_text_set("guide", "git://git.example.com/repo.git")
        en.callback_changed_user_add(lambda e: self.err_unset())
        tb.pack(en, 1, 1, 1, 1)
        en.show()
        self.url_entry = en

        # error label
        lb = Label(tb, text="", size_hint_expand=EXPAND_HORIZ)
        tb.pack(lb, 0, 2, 2, 1)
        lb.show()
        self.error_label = lb

        # buttons
        bt = Button(self, text="Cancel")
        bt.callback_clicked_add(lambda b: self.delete())
        self.part_content_set("button1", bt)
        bt.show()

        bt = Button(self, text="Add remote")
        bt.callback_clicked_add(self._add_btn_cb)
        self.part_content_set("button2", bt)
        bt.show()

        self.show()
コード例 #10
0
ファイル: StandardPopup.py プロジェクト: R0bur/bodhi5packages
    def __init__(self, ourParent, ourMsg, ourIcon=None, *args, **kwargs):
        Popup.__init__(self, ourParent, *args, **kwargs)
        self.callback_block_clicked_add(lambda obj: self.delete())

        # Add a table to hold dialog image and text to Popup
        tb = Table(self, size_hint_weight=EXPAND_BOTH)
        self.part_content_set("default", tb)
        tb.show()

        # Add dialog-error Image to table
        need_ethumb()
        icon = Icon(self, thumb='True')
        icon.standard_set(ourIcon)
        # Using gksudo or sudo fails to load Image here
        #   unless options specify using preserving their existing environment.
        #   may also fail to load other icons but does not raise an exception
        #   in that situation.
        # Works fine using eSudo as a gksudo alternative,
        #   other alternatives not tested
        try:
            dialogImage = Image(self,
                                size_hint_weight=EXPAND_HORIZ,
                                size_hint_align=FILL_BOTH,
                                file=icon.file_get())
            tb.pack(dialogImage, 0, 0, 1, 1)
            dialogImage.show()
        except RuntimeError:
            # An error message is displayed for this same error
            #   when aboutWin is initialized so no need to redisplay.
            pass
        # Add dialog text to table
        dialogLabel = Label(self,
                            line_wrap=ELM_WRAP_WORD,
                            size_hint_weight=EXPAND_HORIZ,
                            size_hint_align=FILL_BOTH)
        dialogLabel.text = ourMsg
        tb.pack(dialogLabel, 1, 0, 1, 1)
        dialogLabel.show()

        # Ok Button
        ok_btt = Button(self)
        ok_btt.text = "Ok"
        ok_btt.callback_clicked_add(lambda obj: self.delete())
        ok_btt.show()

        # add button to popup
        self.part_content_set("button3", ok_btt)
コード例 #11
0
ファイル: ePad.py プロジェクト: emctoo/ePad
def errorPopup(window, errorMsg):
    errorPopup = Popup(window, size_hint_weight=EXPAND_BOTH)
    errorPopup.callback_block_clicked_add(lambda obj: errorPopup.delete())

    # Add a table to hold dialog image and text to Popup
    tb = Table(errorPopup, size_hint_weight=EXPAND_BOTH)
    errorPopup.part_content_set("default", tb)
    tb.show()

    # Add dialog-error Image to table
    need_ethumb()
    icon = Icon(errorPopup, thumb='True')
    icon.standard_set('dialog-warning')
    # Using gksudo or sudo fails to load Image here
    #   unless options specify using preserving their existing environment.
    #   may also fail to load other icons but does not raise an exception
    #   in that situation.
    # Works fine using eSudo as a gksudo alternative,
    #   other alternatives not tested
    try:
        dialogImage = Image(errorPopup,
                            size_hint_weight=EXPAND_HORIZ,
                            size_hint_align=FILL_BOTH,
                            file=icon.file_get())
        tb.pack(dialogImage, 0, 0, 1, 1)
        dialogImage.show()
    except RuntimeError:
        # An error message is displayed for this same error
        #   when aboutWin is initialized so no need to redisplay.
        pass
    # Add dialog text to table
    dialogLabel = Label(errorPopup, line_wrap=ELM_WRAP_WORD,
                        size_hint_weight=EXPAND_HORIZ,
                        size_hint_align=FILL_BOTH)
    dialogLabel.text = errorMsg
    tb.pack(dialogLabel, 1, 0, 1, 1)
    dialogLabel.show()

    # Ok Button
    ok_btt = Button(errorPopup)
    ok_btt.text = "Ok"
    ok_btt.callback_clicked_add(lambda obj: errorPopup.delete())
    ok_btt.show()

    # add button to popup
    errorPopup.part_content_set("button3", ok_btt)
    errorPopup.show()
コード例 #12
0
def thumb_clicked(obj):
    if not elementary.need_ethumb():
        print("Ethumb not available!")
        return

    images = (
        "panel_01.jpg",
        "plant_01.jpg",
        "rock_01.jpg",
        "rock_02.jpg",
        "sky_01.jpg",
        "sky_02.jpg",
        "sky_03.jpg",
        "sky_04.jpg",
        "wood_01.jpg",
        "mystrale.jpg",
        "mystrale_2.jpg"
    )

    win = StandardWindow("thumb", "Thumb", autodel=True, size=(600, 600))
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    tb = Table(win, size_hint_weight=EXPAND_BOTH)

    n = 0
    for j in range(12):
        for i in range(12):
            n = (n + 1) % 11
            th = Thumb(win, file=os.path.join(img_path, images[n]),
                size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH,
                editable=True)
            tb.pack(th, i, j, 1, 1)
            th.show()

    sc = Scroller(win, size_hint_weight=EXPAND_BOTH, content=tb)
    win.resize_object_add(sc)

    tb.show()
    sc.show()

    win.show()
コード例 #13
0
def table_clicked(obj, item=None):
    win = StandardWindow("table", "Table", autodel=True)

    tb = Table(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(tb)
    tb.show()

    bt = Button(win, text="Button 1", size_hint_weight=EXPAND_BOTH,
        size_hint_align=FILL_BOTH)
    tb.pack(bt, 0, 0, 1, 1)
    bt.show()

    bt = Button(win, text="Button 2", size_hint_weight=EXPAND_BOTH,
        size_hint_align=FILL_BOTH)
    tb.pack(bt, 1, 0, 1, 1)
    bt.show()

    bt = Button(win, text="Button 3", size_hint_weight=EXPAND_BOTH,
        size_hint_align=FILL_BOTH)
    tb.pack(bt, 2, 0, 1, 1)
    bt.show()

    bt = Button(win, text="Button 4", size_hint_weight=EXPAND_BOTH,
        size_hint_align=FILL_BOTH)
    tb.pack(bt, 0, 1, 2, 1)
    bt.show()

    bt = Button(win, text="Button 5", size_hint_weight=EXPAND_BOTH,
        size_hint_align=FILL_BOTH)
    tb.pack(bt, 2, 1, 1, 3)
    bt.show()

    bt = Button(win, text="Button 6", size_hint_weight=EXPAND_BOTH,
        size_hint_align=FILL_BOTH)
    tb.pack(bt, 0, 2, 2, 2)
    bt.show()

    win.show()
コード例 #14
0
def table2_clicked(obj, item=None):
    win = StandardWindow("table2", "Table Homogeneous", 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, 1, 1, 2, 2)
    bt.show()

    bt = Button(win, text="Blah blah blah", size_hint_weight=EXPAND_BOTH,
        size_hint_align=FILL_BOTH)
    tb.pack(bt, 3, 0, 2, 3)
    bt.show()

    bt = Button(win, text="Hallow", size_hint_weight=EXPAND_BOTH,
        size_hint_align=FILL_BOTH)
    tb.pack(bt, 0, 3, 10, 1)
    bt.show()

    bt = Button(win, text="B", size_hint_weight=EXPAND_BOTH,
        size_hint_align=FILL_BOTH)
    tb.pack(bt, 2, 5, 2, 1)
    bt.show()

    bt = Button(win, text="C", size_hint_weight=EXPAND_BOTH,
        size_hint_align=FILL_BOTH)
    tb.pack(bt, 8, 8, 1, 1)
    bt.show()

    bt = Button(win, text="Wide", size_hint_weight=EXPAND_BOTH,
        size_hint_align=FILL_BOTH)
    tb.pack(bt, 1, 7, 7, 2)
    bt.show()

    win.show()
コード例 #15
0
def photo_clicked(obj):
    win = StandardWindow("photo", "Photo test", autodel=True, size=(300, 300))
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    elementary.need_ethumb()

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

    sc = Scroller(win, size_hint_weight=EXPAND_BOTH, content=tb)
    win.resize_object_add(sc)
    sc.show()

    n = 0
    for j in range(12):
        for i in range(12):
            ph = Photo(win,
                       aspect_fixed=False,
                       size=80,
                       editable=True,
                       size_hint_weight=EXPAND_BOTH,
                       size_hint_align=FILL_BOTH)
            name = os.path.join(img_path, images[n])
            n += 1
            if n >= 9: n = 0
            if n == 8:
                ph.thumb = name
            else:
                ph.file = name
            if n in [2, 3]:
                ph.fill_inside = True
                ph.style = "shadow"

            tb.pack(ph, i, j, 1, 1)
            ph.show()

    win.show()
コード例 #16
0
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()
コード例 #17
0
def scroller_clicked(obj):
    win = StandardWindow("scroller", "Scroller", autodel=True, size=(320, 320))
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    tb = Table(win, size_hint_weight=EXPAND_BOTH)

    img = ["panel_01.jpg",
           "plant_01.jpg",
           "rock_01.jpg",
           "rock_02.jpg",
           "sky_01.jpg",
           "sky_02.jpg",
           "sky_03.jpg",
           "sky_04.jpg",
           "wood_01.jpg"]

    n = 0
    for j in range(12):
        for i in range(12):
            bg2 = Background(win, file=os.path.join(img_path, img[n]),
                size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH,
                size_hint_min=(318, 318))

            n = n + 1
            if n >= 9:
                n = 0
            tb.pack(bg2, i, j, 1, 1)
            bg2.show()

    sc = Scroller(win, size_hint_weight=EXPAND_BOTH, content=tb,
        page_relative=(1.0, 1.0))
    sc.callback_edge_top_add(cb_edges, "top")
    sc.callback_edge_bottom_add(cb_edges, "bottom")
    sc.callback_edge_left_add(cb_edges, "left")
    sc.callback_edge_right_add(cb_edges, "right")
    sc.callback_scroll_drag_start_add(cb_drags, "start")
    sc.callback_scroll_drag_stop_add(cb_drags, "stop")
    sc.callback_scroll_anim_start_add(cb_anims, "start")
    sc.callback_scroll_anim_stop_add(cb_anims, "stop")
    win.resize_object_add(sc)

    tb.show()

    sc.show()

    tb2 = Table(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(tb2)

    bt = Button(win, text="to 300 300", size_hint_weight=EXPAND_BOTH,
        size_hint_align=(0.1, 0.1))
    bt.callback_clicked_add(my_scroller_go_300_300, sc)
    tb2.pack(bt, 0, 0, 1, 1)
    bt.show()

    bt = Button(win, text="to 900 300", size_hint_weight=EXPAND_BOTH,
        size_hint_align=(0.9, 0.1))
    bt.callback_clicked_add(my_scroller_go_900_300, sc)
    tb2.pack(bt, 1, 0, 1, 1)
    bt.show()

    bt = Button(win, text="to 300 900", size_hint_weight=EXPAND_BOTH,
        size_hint_align=(0.1, 0.9))
    bt.callback_clicked_add(my_scroller_go_300_900, sc)
    tb2.pack(bt, 0, 1, 1, 1)
    bt.show()

    bt = Button(win, text="to 900 900", size_hint_weight=EXPAND_BOTH,
        size_hint_align=(0.9, 0.9))
    bt.callback_clicked_add(my_scroller_go_900_900, sc)
    tb2.pack(bt, 1, 1, 1, 1)
    bt.show()

    tb2.show()

    win.show()
コード例 #18
0
ファイル: utils.py プロジェクト: DaveMDS/egitu
class ComboBox(Entry):
    def __init__(self, parent, text=None, icon=None):
        Entry.__init__(self, parent, scrollable=True, single_line=True,
                       size_hint_expand=EXPAND_BOTH,
                       size_hint_fill=FILL_BOTH)
        self.show()
        if text: self.text = text
        if icon: self.icon = icon

        ic = SafeIcon(self, 'go-down')
        ic.size_hint_min = 16, 16 # TODO file a bug for elm on phab
        ic.callback_clicked_add(self.activate)
        self.part_content_set('end', ic)

        self._itc = GenlistItemClass(item_style='default',
                                     text_get_func=self._gl_text_get,
                                     content_get_func=self._gl_content_get)
        self._list = Genlist(self)
        self._list.callback_selected_add(self._list_selected_cb)

        self._hover = Hover(self.parent, target=self)

        self._bg = Background(self, size_hint_expand=EXPAND_BOTH, 
                        size_hint_fill=FILL_BOTH)

        fr = Frame(self, style='pad_medium',
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        fr.content = self._list
        fr.show()

        self._table = Table(self, size_hint_expand=EXPAND_BOTH, 
                      size_hint_fill=FILL_BOTH)
        self._table.pack(self._bg, 0, 0, 1, 1)
        self._table.pack(fr, 0, 0, 1, 1)

        self._selected_func = None

    def callback_selected_add(self, func):
        self._selected_func = func

    @property
    def icon(self):
        return self.part_content_get('icon')
    @icon.setter
    def icon(self, icon):
        icon.size_hint_min = 16, 16 # TODO file a bug for elm on phab
        self.part_content_set('icon', icon)

    @property
    def guide(self):
        self.part_text_get('guide')
    @guide.setter
    def guide(self, text):
        self.part_text_set('guide', text)
    
    def item_append(self, label=None, icon=None, end=None):
        item_data = (label, icon, end)
        self._list.item_append(self._itc, item_data)

    def clear(self):
        self._list.clear()

    def activate(self, source=None):
        self.focus = False # :/

        # TODO calculate this based on _list and parent size
        # print(self._list.size)
        # print(self._list.geometry)
        self._bg.size_hint_min = 0, 200
        loc = self._hover.best_content_location_get(ELM_HOVER_AXIS_VERTICAL)
        self._hover.part_content_set(loc, self._table)
        self._hover.show()
        self._table.show()
        self._bg.show()
        self._list.show()
    
    def dismiss(self):
        self._hover.dismiss()

    def _list_selected_cb(self, gl, item):
        label, icon, end = item.data
        self.text = label
        if icon:
            self.icon = SafeIcon(self, icon)
        item.selected = False
        self.dismiss()
        if callable(self._selected_func):
            self._selected_func(self)

    def _gl_text_get(self, gl, part, item_data):
        label, icon, end = item_data
        return label

    def _gl_content_get(self, gl, part, item_data):
        label, icon, end = item_data
        if icon and part == 'elm.swallow.icon':
            return SafeIcon(gl, icon)
        elif end and part == 'elm.swallow.end':
            return SafeIcon(gl, end)
コード例 #19
0
ファイル: pushpull.py プロジェクト: druonysus/egitu
    def __init__(self, parent, app, title, icon_name):
        self.app = app

        Popup.__init__(self, parent)
        self.part_text_set('title,text', title)
        self.part_content_set('title,icon', Icon(self, standard=icon_name))
        
        # TODO padding should be (4,4) but it seems buggy for the big entry
        tb = Table(self, padding=(0,4), size_hint_expand=EXPAND_BOTH)
        self.content = tb
        tb.show()
        self.table = tb

        # sep
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_BOTH)
        tb.pack(sep, 0, 0, 2, 1)
        sep.show()

        # remote
        lb = Label(tb, text='Remote', size_hint_align=(0.0, 0.5))
        tb.pack(lb, 0, 1, 1, 1)
        lb.show()

        cb = ComboBox(self, icon=Icon(self, standard='git-remote'))
        cb.callback_selected_add(self.rbranch_populate)
        for remote in app.repo.remotes:
            cb.item_append(remote.name, 'git-remote')
        tb.pack(cb, 1, 1, 1, 1)
        cb.show()
        self.remote_combo = cb

        # remote branch
        lb = Label(tb, text='Remote branch', size_hint_align=(0.0, 0.5))
        tb.pack(lb, 0, 2, 1, 1)
        lb.show()

        cb = ComboBox(self, icon=Icon(cb, standard='git-branch'))
        tb.pack(cb, 1, 2, 1, 1)
        cb.show()
        self.rbranch_combo = cb

        # local branch
        lb = Label(tb, text='Local branch', size_hint_align=(0.0, 0.5))
        tb.pack(lb, 0, 3, 1, 1)
        lb.show()

        en = Entry(tb, disabled=True, single_line=True, scrollable=True,
                   text=app.repo.status.current_branch.name,
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        tb.pack(en, 1, 3, 1, 1)
        en.show()
        self.lbranch_entry = en

        # output entry
        en = CommandOutputEntry(self, min_size=(400, 150))
        tb.pack(en, 0, 4, 2, 1)
        en.show()
        self.output_entry = en

        # sep
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_BOTH)
        tb.pack(sep, 0, 5, 2, 1)
        sep.show()

        # buttons
        bt = Button(self, text='Close')
        bt.callback_clicked_add(lambda b: self.delete())
        self.part_content_set('button1', bt)
        bt.show()
        self.close_btn = bt

        bt = Button(self, text='Action')
        bt.callback_clicked_add(self._action_btn_cb)
        self.part_content_set('button2', bt)
        bt.show()
        self.action_btn = bt

        self.autopopulate()
        self.show()
コード例 #20
0
def photocam_clicked(obj):
    win = StandardWindow("photocam", "Photocam test", autodel=True,
        size=(600, 600))
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    # Photocam widget
    pc = Photocam(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(pc)
    pc.show()

    # table for buttons
    tb = Table(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(tb)
    tb.show()

    # zoom out btn
    bt = Button(win, text="Z -", size_hint_weight=EXPAND_BOTH,
        size_hint_align=(0.1, 0.1))
    bt.callback_clicked_add(_cb_zoom_out, pc)
    tb.pack(bt, 0, 0, 1, 1)
    bt.show()

    # select file btn
    bt = FileselectorButton(win, text="Select Photo File",
        size_hint_weight=EXPAND_BOTH, size_hint_align=(0.5, 0.1))
    bt.callback_file_chosen_add(lambda fs, path: pc.file_set(path))
    tb.pack(bt, 1, 0, 1, 1)
    bt.show()

    # zoom in btn
    bt = Button(win, text="Z +", size_hint_weight=EXPAND_BOTH,
        size_hint_align=(0.9, 0.1))
    bt.callback_clicked_add(_cb_zoom_in, pc)
    tb.pack(bt, 2, 0, 1, 1)
    bt.show()

    # progressbar for remote loading
    pb = Progressbar(win, unit_format="loading %.2f %%",
        size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
    tb.pack(pb, 1, 1, 1, 1)

    # Fit btn
    bt = Button(win, text="Fit", size_hint_weight=EXPAND_BOTH,
        size_hint_align=(0.1, 0.9))
    bt.callback_clicked_add(lambda b: pc.zoom_mode_set(ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT))
    tb.pack(bt, 0, 2, 1, 1)
    bt.show()

    # load remote url
    bt = Button(win, text="Load remote URL (27MB)",
        size_hint_weight=EXPAND_BOTH, size_hint_align=(0.5, 0.9))
    bt.callback_clicked_add(lambda b: pc.file_set(remote_url))
    tb.pack(bt, 1, 2, 1, 1)
    bt.show()

    pc.callback_download_start_add(_cb_pc_download_start, pb)
    pc.callback_download_done_add(_cb_pc_download_done, pb)
    pc.callback_download_progress_add(_cb_pc_download_progress, pb)
    pc.callback_download_error_add(_cb_pc_download_error, pb)

    # Fill btn
    bt = Button(win, text="Fill", size_hint_weight=EXPAND_BOTH,
        size_hint_align=(0.9, 0.9))
    bt.callback_clicked_add(lambda b: pc.zoom_mode_set(ELM_PHOTOCAM_ZOOM_MODE_AUTO_FILL))
    tb.pack(bt, 2, 2, 1, 1)
    bt.show()

    # show the win
    win.show()
コード例 #21
0
def gengrid_clicked(obj):

    global item_count
    item_count = 25

    win = StandardWindow("gengrid", "Gengrid", autodel=True, size=(480, 800))
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    tb = Table(win, homogeneous=False, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(tb)
    tb.show()

    # gengrid
    itc = GengridItemClass(item_style="default",
                                       text_get_func=gg_text_get,
                                       content_get_func=gg_content_get,
                                       state_get_func=gg_state_get,
                                       del_func=gg_del)
    gg = ScrollableGengrid(win, size_hint_weight=EXPAND_BOTH,
        size_hint_align=FILL_BOTH, horizontal=False, bounce=(False, True),
        item_size=(80, 80), align=(0.5, 0.0))
    tb.pack(gg, 0, 0, 6, 1)
    gg.callback_selected_add(gg_sel)
    gg.callback_unselected_add(gg_unsel)
    gg.callback_clicked_double_add(gg_clicked_double)
    gg.show()

    # add the first items
    for i in range(item_count):
        gg.item_append(itc, i, None)

    # multi select
    def multi_select_changed(bt, gg):
        gg.multi_select_set(bt.state)
        print((gg.multi_select))

    bt = Check(win, text="MultiSelect", state=gg.multi_select)
    bt.callback_changed_add(multi_select_changed, gg)
    tb.pack(bt, 0, 1, 1, 1)
    bt.show()

    # horizontal
    def horizontal_changed(bt, gg):
        gg.horizontal_set(bt.state)

    bt = Check(win, text="Horizontal")
    bt.callback_changed_add(horizontal_changed, gg)
    tb.pack(bt, 1, 1, 1, 1)
    bt.show()

    # bounce h
    def bounce_h_changed(bt, gg):
        (h_bounce, v_bounce) = gg.bounce_get()
        gg.bounce_set(bt.state, v_bounce)
        print((gg.bounce_get()))

    bt = Check(win, text="BounceH")
    h_bounce = gg.bounce[0]
    bt.state = h_bounce
    bt.callback_changed_add(bounce_h_changed, gg)
    tb.pack(bt, 4, 1, 1, 1)
    bt.show()

    # bounce v
    def bounce_v_changed(bt, gg):
        (h_bounce, v_bounce) = gg.bounce_get()
        gg.bounce_set(h_bounce, bt.state)
        print((gg.bounce_get()))

    bt = Check(win, text="BounceV")
    v_bounce = gg.bounce[1]
    bt.state = v_bounce
    bt.callback_changed_add(bounce_v_changed, gg)
    tb.pack(bt, 5, 1, 1, 1)
    bt.show()

    # item size
    def item_size_w_changed(sl, gg):
        (w, h) = gg.item_size_get()
        gg.item_size_set(sl.value, h)
        print((gg.item_size_get()))

    def item_size_h_changed(sl, gg):
        (w, h) = gg.item_size_get()
        gg.item_size_set(w, sl.value)
        print((gg.item_size_get()))

    (w, h) = gg.item_size
    sl = Slider(win, text="ItemSizeW", min_max=(0, 500),
        indicator_format="%.0f", unit_format="%.0f", span_size=100, value=w)
    sl.callback_changed_add(item_size_w_changed, gg)
    tb.pack(sl, 0, 2, 2, 1)
    sl.show()

    sl = Slider(win, text="ItemSizeH", min_max=(0, 500),
        indicator_format="%.0f", unit_format="%.0f", span_size=100, value=h)
    sl.callback_changed_add(item_size_h_changed, gg)
    tb.pack(sl, 0, 3, 2, 1)
    sl.show()

    # align
    def alignx_changed(sl, gg):
        (ax, ay) = gg.align
        gg.align = sl.value, ay
        print(gg.align)

    def aligny_changed(sl, gg):
        (ax, ay) = gg.align
        gg.align = ax, sl.value
        print(gg.align)

    (ax, ay) = gg.align

    sl = Slider(win, text="AlignX", min_max=(0.0, 1.0),
        indicator_format="%.2f", unit_format="%.2f", span_size=100, value=ax)
    sl.callback_changed_add(alignx_changed, gg)
    tb.pack(sl, 0, 4, 2, 1)
    sl.show()

    sl = Slider(win, text="AlignY", min_max=(0.0, 1.0),
        indicator_format="%.2f", unit_format="%.2f", span_size=100, value=ay)
    sl.callback_changed_add(aligny_changed, gg)
    tb.pack(sl, 0, 5, 2, 1)
    sl.show()

    # select first
    def select_first_clicked(bt, gg):
        ggi = gg.first_item
        if ggi:
            ggi.selected = not ggi.selected

    bt = Button(win, size_hint_align=FILL_HORIZ, text="Select first")
    bt.callback_clicked_add(select_first_clicked, gg)
    tb.pack(bt, 2, 2, 1, 1)
    bt.show()

    # select last
    def select_last_clicked(bt, gg):
        ggi = gg.last_item
        if ggi:
            ggi.selected = not ggi.selected

    bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0), text="Select last")
    bt.callback_clicked_add(select_last_clicked, gg)
    tb.pack(bt, 3, 2, 1, 1)
    bt.show()

    # selection del
    def seldel_clicked(bt, gg):
        for ggi in gg.selected_items_get():
            ggi.delete()

    bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0), text="Sel del")
    bt.callback_clicked_add(seldel_clicked, gg)
    tb.pack(bt, 4, 2, 1, 1)
    bt.show()

    # clear
    def clear_clicked(bt, gg):
        global item_count
        item_count = 0
        gg.clear()

    bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0), text="Clear")
    bt.callback_clicked_add(clear_clicked, gg)
    tb.pack(bt, 5, 2, 1, 1)
    bt.show()

    # show first/last
    def show_clicked(bt, gg, first):
        ggi = gg.first_item if first else gg.last_item
        if ggi:
            ggi.show()

    bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0), text="Show first")
    bt.callback_clicked_add(show_clicked, gg, True)
    tb.pack(bt, 2, 3, 1, 1)
    bt.show()

    bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0), text="Show last")
    bt.callback_clicked_add(show_clicked, gg, False)
    tb.pack(bt, 3, 3, 1, 1)
    bt.show()

    # bring-in first/last
    def bring_in_clicked(bt, gg, first):
        ggi = gg.first_item if first else gg.last_item
        if ggi:
            ggi.bring_in()

    bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0), text="BringIn first")
    bt.callback_clicked_add(bring_in_clicked, gg, True)
    tb.pack(bt, 4, 3, 1, 1)
    bt.show()

    bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0), text="BringIn last")
    bt.callback_clicked_add(bring_in_clicked, gg, False)
    tb.pack(bt, 5, 3, 1, 1)
    bt.show()

    # append
    def append_clicked(bt, gg, n):
        global item_count
        while n:
            item_count += 1
            gg.item_append(itc, item_count, None)
            n -= 1

    bt = Button(win, size_hint_align=FILL_HORIZ, text="Append 1")
    bt.callback_clicked_add(append_clicked, gg, 1)
    tb.pack(bt, 2, 4, 1, 1)
    bt.show()

    bt = Button(win, size_hint_align=FILL_HORIZ, text="Append 100")
    bt.callback_clicked_add(append_clicked, gg, 100)
    tb.pack(bt, 3, 4, 1, 1)
    bt.show()

    bt = Button(win, size_hint_align=FILL_HORIZ, text="Append 1000")
    bt.callback_clicked_add(append_clicked, gg, 1000)
    tb.pack(bt, 4, 4, 1, 1)
    bt.show()

    bt = Button(win, size_hint_align=FILL_HORIZ, text="Append 10000 :)")
    bt.callback_clicked_add(append_clicked, gg, 10000)
    tb.pack(bt, 5, 4, 1, 1)
    bt.show()

    # prepend
    def prepend_clicked(bt, gg):
        global item_count
        item_count += 1
        gg.item_prepend(itc, item_count)

    bt = Button(win, size_hint_align=FILL_HORIZ, text="Prepend")
    bt.callback_clicked_add(prepend_clicked, gg)
    tb.pack(bt, 2, 5, 1, 1)
    bt.show()

    # insert_before
    def ins_before_clicked(bt, gg):
        global item_count
        item_count += 1
        before = gg.selected_item_get()
        if before:
            gg.item_insert_before(itc, item_count, before)
        else:
            print("nothing selected")

    bt = Button(win, size_hint_align=FILL_HORIZ, text="Ins before")
    bt.callback_clicked_add(ins_before_clicked, gg)
    tb.pack(bt, 3, 5, 1, 1)
    bt.show()

    # insert_after
    def ins_after_clicked(bt, gg):
        global item_count
        item_count += 1
        after = gg.selected_item_get()
        if after:
            gg.item_insert_after(itc, item_count, after)
        else:
            print("nothing selected")

    bt = Button(win, size_hint_align=FILL_HORIZ, text="Ins after")
    bt.callback_clicked_add(ins_after_clicked, gg)
    tb.pack(bt, 4, 5, 1, 1)
    bt.show()

    print(gg)

    win.show()
コード例 #22
0
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()
コード例 #23
0
class ConjectureGUI(object):
    def __init__(self, windowGrid, name):
        offset = 0
        if (name == 'Yau'):
            offset = 50

        self.BaseBox = Box(windowGrid,
                           size_hint_weight=(EVAS_HINT_EXPAND,
                                             EVAS_HINT_EXPAND),
                           size_hint_align=(EVAS_HINT_FILL, EVAS_HINT_FILL))
        windowGrid.pack(self.BaseBox, offset, 0, 50, 100)
        self.BaseBox.show()

        self.frame = Frame(self.BaseBox,
                           size_hint_weight=(EVAS_HINT_EXPAND,
                                             EVAS_HINT_EXPAND),
                           size_hint_align=(EVAS_HINT_FILL, EVAS_HINT_FILL),
                           text=name)
        self.BaseBox.pack_end(self.frame)
        self.frame.show()

        self.FrameBox = Box(self.BaseBox,
                            size_hint_weight=(EVAS_HINT_EXPAND,
                                              EVAS_HINT_EXPAND),
                            size_hint_align=(EVAS_HINT_FILL, EVAS_HINT_FILL))
        self.frame.content_set(self.FrameBox)
        self.FrameBox.show()

        self.FrameCheck = Check(self.BaseBox,
                                size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                size_hint_align=(EVAS_HINT_FILL, 0.5),
                                text="{0} Frame Check".format(name))
        self.FrameBox.pack_end(self.FrameCheck)
        self.FrameCheck.show()

        self.FrameSeparator = Separator(self.BaseBox,
                                        horizontal=True,
                                        size_hint_weight=(EVAS_HINT_EXPAND,
                                                          0.0),
                                        size_hint_align=(EVAS_HINT_FILL, 0.5))
        self.FrameBox.pack_end(self.FrameSeparator)
        self.FrameSeparator.show()

        self.FrameScroller = Scroller(
            self.BaseBox,
            content_min_limit=(True, False),
            size_hint_weight=(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND),
            size_hint_align=(EVAS_HINT_FILL, EVAS_HINT_FILL),
            scrollbar_policy=(ELM_SCROLLER_POLICY_OFF,
                              ELM_SCROLLER_POLICY_OFF))
        self.FrameBox.pack_end(self.FrameScroller)
        self.FrameScroller.show()

        self.FrameTable = Table(self.BaseBox,
                                size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                size_hint_align=(EVAS_HINT_FILL, 0.0))
        self.FrameScroller.content_set(self.FrameTable)
        self.FrameTable.show()

        self.BaseLabel = Label(self.FrameTable,
                               size_hint_weight=(0.0, 0.0),
                               size_hint_align=(0.0, 0.5),
                               text="Base:")
        self.FrameTable.pack(self.BaseLabel, 0, 0, 1, 1)
        self.BaseLabel.show()

        self.BaseEntry = Entry(self.FrameTable,
                               size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                               size_hint_align=(EVAS_HINT_FILL, 0.5),
                               single_line=True,
                               scrollable=True,
                               text="")
        self.FrameTable.pack(self.BaseEntry, 1, 0, 1, 1)
        self.BaseEntry.show()

        self.SecretLabel = Label(self.FrameTable,
                                 size_hint_weight=(0.0, 0.0),
                                 size_hint_align=(0.0, 0.5),
                                 text="Secret:")
        self.FrameTable.pack(self.SecretLabel, 2, 0, 1, 1)
        self.SecretLabel.show()

        self.SecretEntry = Entry(self.FrameTable,
                                 size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                 size_hint_align=(EVAS_HINT_FILL, 0.5),
                                 single_line=True,
                                 scrollable=True,
                                 text="")
        self.FrameTable.pack(self.SecretEntry, 3, 0, 1, 1)
        self.SecretEntry.show()

        self.SignalLabel = Label(self.FrameTable,
                                 size_hint_weight=(0.0, 0.0),
                                 size_hint_align=(0.0, 0.5),
                                 text="Signal:")
        self.FrameTable.pack(self.SignalLabel, 4, 0, 1, 1)
        self.SignalLabel.show()

        self.SignalEntry = Entry(self.FrameTable,
                                 size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                 size_hint_align=(EVAS_HINT_FILL, 0.5),
                                 single_line=True,
                                 scrollable=True,
                                 text="")
        self.FrameTable.pack(self.SignalEntry, 5, 0, 1, 1)
        self.SignalEntry.show()

        self.ChannelLabel = Label(self.FrameTable,
                                  size_hint_weight=(0.0, 0.0),
                                  size_hint_align=(0.0, 0.5),
                                  text="Channel:")
        self.FrameTable.pack(self.ChannelLabel, 0, 1, 1, 1)
        self.ChannelLabel.show()

        self.ChannelEntry = Entry(self.FrameTable,
                                  size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                  size_hint_align=(EVAS_HINT_FILL, 0.5),
                                  single_line=True,
                                  scrollable=True,
                                  text="")
        self.FrameTable.pack(self.ChannelEntry, 1, 1, 1, 1)
        self.ChannelEntry.show()

        self.PoleLabel = Label(self.FrameTable,
                               size_hint_weight=(0.0, 0.0),
                               size_hint_align=(0.0, 0.5),
                               text="Pole:")
        self.FrameTable.pack(self.PoleLabel, 2, 1, 1, 1)
        self.PoleLabel.show()

        self.PoleEntry = Entry(self.FrameTable,
                               size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                               size_hint_align=(EVAS_HINT_FILL, 0.5),
                               single_line=True,
                               scrollable=True,
                               text="")
        self.FrameTable.pack(self.PoleEntry, 3, 1, 1, 1)
        self.PoleEntry.show()

        self.IdentityLabel = Label(self.FrameTable,
                                   size_hint_weight=(0.0, 0.0),
                                   size_hint_align=(0.0, 0.5),
                                   text="Identity:")
        self.FrameTable.pack(self.IdentityLabel, 4, 1, 1, 1)
        self.IdentityLabel.show()

        self.IdentityEntry = Entry(self.FrameTable,
                                   size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                   size_hint_align=(EVAS_HINT_FILL, 0.5),
                                   single_line=True,
                                   scrollable=True,
                                   text="")
        self.FrameTable.pack(self.IdentityEntry, 5, 1, 1, 1)
        self.IdentityEntry.show()

        self.FoundationLabel = Label(self.FrameTable,
                                     size_hint_weight=(0.0, 0.0),
                                     size_hint_align=(0.0, 0.5),
                                     text="Foundation:")
        self.FrameTable.pack(self.FoundationLabel, 0, 2, 1, 1)
        self.FoundationLabel.show()

        self.FoundationEntry = Entry(self.FrameTable,
                                     size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                     size_hint_align=(EVAS_HINT_FILL, 0.5),
                                     single_line=True,
                                     scrollable=True,
                                     text="")
        self.FrameTable.pack(self.FoundationEntry, 1, 2, 1, 1)
        self.FoundationEntry.show()

        self.ElementLabel = Label(self.FrameTable,
                                  size_hint_weight=(0.0, 0.0),
                                  size_hint_align=(0.0, 0.5),
                                  text="Element:")
        self.FrameTable.pack(self.ElementLabel, 2, 2, 1, 1)
        self.ElementLabel.show()

        self.ElementEntry = Entry(self.FrameTable,
                                  size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                  size_hint_align=(EVAS_HINT_FILL, 0.5),
                                  single_line=True,
                                  scrollable=True,
                                  text="")
        self.FrameTable.pack(self.ElementEntry, 3, 2, 1, 1)
        self.ElementEntry.show()

        self.DynamoLabel = Label(self.FrameTable,
                                 size_hint_weight=(0.0, 0.0),
                                 size_hint_align=(0.0, 0.5),
                                 text="Dynamo:")
        self.FrameTable.pack(self.DynamoLabel, 4, 2, 1, 1)
        self.DynamoLabel.show()

        self.DynamoEntry = Entry(self.FrameTable,
                                 size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                 size_hint_align=(EVAS_HINT_FILL, 0.5),
                                 single_line=True,
                                 scrollable=True,
                                 text="")
        self.FrameTable.pack(self.DynamoEntry, 5, 2, 1, 1)
        self.DynamoEntry.show()

        self.ManifoldLabel = Label(self.FrameTable,
                                   size_hint_weight=(0.0, 0.0),
                                   size_hint_align=(0.0, 0.5),
                                   text="Manifold:")
        self.FrameTable.pack(self.ManifoldLabel, 0, 3, 1, 1)
        self.ManifoldLabel.show()

        self.ManifoldEntry = Entry(self.FrameTable,
                                   size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                   size_hint_align=(EVAS_HINT_FILL, 0.5),
                                   single_line=True,
                                   scrollable=True,
                                   text="")
        self.FrameTable.pack(self.ManifoldEntry, 1, 3, 1, 1)
        self.ManifoldEntry.show()

        self.RingLabel = Label(self.FrameTable,
                               size_hint_weight=(0.0, 0.0),
                               size_hint_align=(0.0, 0.5),
                               text="Ring:")
        self.FrameTable.pack(self.RingLabel, 2, 3, 1, 1)
        self.RingLabel.show()

        self.RingEntry = Entry(self.FrameTable,
                               size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                               size_hint_align=(EVAS_HINT_FILL, 0.5),
                               single_line=True,
                               scrollable=True,
                               text="")
        self.FrameTable.pack(self.RingEntry, 3, 3, 1, 1)
        self.RingEntry.show()

        self.BarnLabel = Label(self.FrameTable,
                               size_hint_weight=(0.0, 0.0),
                               size_hint_align=(0.0, 0.5),
                               text="Barn:")
        self.FrameTable.pack(self.BarnLabel, 4, 3, 1, 1)
        self.BarnLabel.show()

        self.BarnEntry = Entry(self.FrameTable,
                               size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                               size_hint_align=(EVAS_HINT_FILL, 0.5),
                               single_line=True,
                               scrollable=True,
                               text="")
        self.FrameTable.pack(self.BarnEntry, 5, 3, 1, 1)
        self.BarnEntry.show()

        self.VoltpereLabel = Label(self.FrameTable,
                                   size_hint_weight=(0.0, 0.0),
                                   size_hint_align=(0.0, 0.5),
                                   text="Voltpere:")
        self.FrameTable.pack(self.VoltpereLabel, 0, 4, 1, 1)
        self.VoltpereLabel.show()

        self.VoltpereEntry = Entry(self.FrameTable,
                                   size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                   size_hint_align=(EVAS_HINT_FILL, 0.5),
                                   single_line=True,
                                   scrollable=True,
                                   text="")
        self.FrameTable.pack(self.VoltpereEntry, 1, 4, 5, 1)
        self.VoltpereEntry.show()

        self.AmpereLabel = Label(self.FrameTable,
                                 size_hint_weight=(0.0, 0.0),
                                 size_hint_align=(0.0, 0.5),
                                 text="Ampere:")
        self.FrameTable.pack(self.AmpereLabel, 0, 5, 1, 1)
        self.AmpereLabel.show()

        self.AmpereEntry = Entry(self.FrameTable,
                                 size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                 size_hint_align=(EVAS_HINT_FILL, 0.5),
                                 single_line=True,
                                 scrollable=True,
                                 text="")
        self.FrameTable.pack(self.AmpereEntry, 1, 5, 2, 1)
        self.AmpereEntry.show()

        self.HenryLabel = Label(self.FrameTable,
                                size_hint_weight=(0.0, 0.0),
                                size_hint_align=(0.0, 0.5),
                                text="Henry:")
        self.FrameTable.pack(self.HenryLabel, 0, 6, 1, 1)
        self.HenryLabel.show()

        self.HenryEntry = Entry(self.FrameTable,
                                size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                size_hint_align=(EVAS_HINT_FILL, 0.5),
                                single_line=True,
                                scrollable=True,
                                text="")
        self.FrameTable.pack(self.HenryEntry, 1, 6, 2, 1)
        self.HenryEntry.show()

        self.MaxwellLabel = Label(self.FrameTable,
                                  size_hint_weight=(0.0, 0.0),
                                  size_hint_align=(0.0, 0.5),
                                  text="Maxwell:")
        self.FrameTable.pack(self.MaxwellLabel, 0, 7, 1, 1)
        self.MaxwellLabel.show()

        self.MaxwellEntry = Entry(self.FrameTable,
                                  size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                  size_hint_align=(EVAS_HINT_FILL, 0.5),
                                  single_line=True,
                                  scrollable=True,
                                  text="")
        self.FrameTable.pack(self.MaxwellEntry, 1, 7, 2, 1)
        self.MaxwellEntry.show()

        self.FermatLabel = Label(self.FrameTable,
                                 size_hint_weight=(0.0, 0.0),
                                 size_hint_align=(0.0, 0.5),
                                 text="Fermat:")
        self.FrameTable.pack(self.FermatLabel, 0, 8, 1, 1)
        self.FermatLabel.show()

        self.FermatEntry = Entry(self.FrameTable,
                                 size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                 size_hint_align=(EVAS_HINT_FILL, 0.5),
                                 single_line=True,
                                 scrollable=True,
                                 text="")
        self.FrameTable.pack(self.FermatEntry, 1, 8, 2, 1)
        self.FermatEntry.show()

        self.PropelButton = Button(self.FrameTable,
                                   size_hint_weight=(0.0, 0.0),
                                   size_hint_align=(0.0, 0.5),
                                   text="Propel")
        self.FrameTable.pack(self.PropelButton, 4, 8, 1, 1)
        self.PropelButton.show()
        self.PropelButton.callback_clicked_add(self.propelClicked)

    def propelClicked(self, obj):
        print("clicked")
コード例 #24
0
def notify_clicked(obj=None):
    win = StandardWindow("notify", "Notify", autodel=True, size=(400,400))
    if obj is None:
        win.callback_delete_request_add(lambda x: elementary.exit())
    win.show()

    tb = Table(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(tb)
    tb.show()

    # Notify top
    bx = Box(win, horizontal=True)
    bx.show()

    notify = Notify(win, size_hint_weight=EXPAND_BOTH, align=(0.5, 0.0),
        content=bx)

    lb = Label(win, text="This position is the default.")
    bx.pack_end(lb)
    lb.show()

    bt = Button(win, text="Close")
    bt.callback_clicked_add(lambda x, y=notify: y.hide())
    bx.pack_end(bt)
    bt.show()

    bt = Button(win, size_hint_align=FILL_BOTH, text="Top")
    bt.callback_clicked_add(lambda x, y=notify: y.show())
    tb.pack(bt, 2, 1, 1, 1)
    bt.show()

    # Notify bottom
    bx = Box(win, horizontal=True)
    bx.show()

    notify = Notify(win, allow_events=False, size_hint_weight=EXPAND_BOTH,
        align=(0.5, 1.0), timeout=(5.0), content=bx)

    notify.callback_timeout_add(lambda x: setattr(x, "timeout", 2.0))
    notify.callback_block_clicked_add(
        lambda x: print("Notify block area clicked!!"))

    lb = Label(win)
    lb.text = (
        "Bottom position. This notify uses a timeout of 5 sec.<br/>"
        "<b>The events outside the window are blocked.</b>"
        )
    bx.pack_end(lb)
    lb.show()

    bt = Button(win, text="Close")
    bt.callback_clicked_add(lambda x, y=notify: y.hide())
    bx.pack_end(bt)
    bt.show()

    bt = Button(win, size_hint_align=FILL_BOTH, text="Bottom")
    bt.callback_clicked_add(lambda x, y=notify: y.show())
    tb.pack(bt, 2, 3, 1, 1)
    bt.show()

    # Notify left
    bx = Box(win, horizontal=True)
    bx.show()

    notify = Notify(win, size_hint_weight=EXPAND_BOTH, align=(0.0, 0.5),
        timeout=10.0, content=bx)
    notify.callback_timeout_add(lambda x: print("Notify timed out!"))

    lb = Label(win)
    lb.text = "Left position. This notify uses a timeout of 10 sec."
    bx.pack_end(lb)
    lb.show()

    bt = Button(win, text="Close")
    bt.callback_clicked_add(lambda x, y=notify: y.hide())
    bx.pack_end(bt)
    bt.show()

    bt = Button(win, size_hint_align=FILL_BOTH, text="Left")
    bt.callback_clicked_add(lambda x, y=notify: y.show())
    tb.pack(bt, 1, 2, 1, 1)
    bt.show()

    # Notify center
    bx = Box(win, horizontal=True)
    bx.show()

    notify = Notify(win, size_hint_weight=EXPAND_BOTH, align=(0.5, 0.5),
        timeout=10.0, content=bx)
    notify.callback_timeout_add(lambda x: print("Notify timed out!"))

    lb = Label(win)
    lb.text = "Center position. This notify uses a timeout of 10 sec."
    bx.pack_end(lb)
    lb.show()

    bt = Button(win, text="Close")
    bt.callback_clicked_add(lambda x, y=notify: y.hide())
    bx.pack_end(bt)
    bt.show()

    bt = Button(win, size_hint_align=FILL_BOTH, text="Center")
    bt.callback_clicked_add(lambda x, y=notify: y.show())
    tb.pack(bt, 2, 2, 1, 1)
    bt.show()

    # Notify right
    bx = Box(win, horizontal=True)
    bx.show()

    notify = Notify(win, size_hint_weight=EXPAND_BOTH, align=(1.0, 0.5),
        content=bx)

    lb = Label(win, text="Right position.")
    bx.pack_end(lb)
    lb.show()

    bt = Button(win, text="Close")
    bt.callback_clicked_add(lambda x, y=notify: y.hide())
    bx.pack_end(bt)
    bt.show()

    bt = Button(win, size_hint_align=FILL_BOTH, text="Right")
    bt.callback_clicked_add(lambda x, y=notify: y.show())
    tb.pack(bt, 3, 2, 1, 1)
    bt.show()

    # Notify top left
    bx = Box(win, horizontal=True)
    bx.show()

    notify = Notify(win, size_hint_weight=EXPAND_BOTH, align=(0.0, 0.0),
        content=bx)

    lb = Label(win, text="Top Left position.")
    bx.pack_end(lb)
    lb.show()

    bt = Button(win, text="Close")
    bt.callback_clicked_add(lambda x, y=notify: y.hide())
    bx.pack_end(bt)
    bt.show()

    bt = Button(win, size_hint_align=FILL_BOTH, text="Top Left")
    bt.callback_clicked_add(lambda x, y=notify: y.show())
    tb.pack(bt, 1, 1, 1, 1)
    bt.show()

    # Notify top right
    bx = Box(win, horizontal=True)
    bx.show()

    notify = Notify(win, size_hint_weight=EXPAND_BOTH, align=(1.0, 0.0),
        content=bx)

    lb = Label(win, text="Top Right position.")
    bx.pack_end(lb)
    lb.show()

    bt = Button(win, text="Close")
    bt.callback_clicked_add(lambda x, y=notify: y.hide())
    bx.pack_end(bt)
    bt.show()

    bt = Button(win, size_hint_align=FILL_BOTH, text="Top Right")
    bt.callback_clicked_add(lambda x, y=notify: y.show())
    tb.pack(bt, 3, 1, 1, 1)
    bt.show()

    # Notify bottom left
    bx = Box(win, horizontal=True)
    bx.show()

    notify = Notify(win, size_hint_weight=EXPAND_BOTH, align=(0.0, 1.0),
        content=bx)

    lb = Label(win, text="Bottom Left position.")
    bx.pack_end(lb)
    lb.show()

    bt = Button(win, text="Close")
    bt.callback_clicked_add(lambda x, y=notify: y.hide())
    bx.pack_end(bt)
    bt.show()

    bt = Button(win, size_hint_align=FILL_BOTH, text="Bottom Left")
    bt.callback_clicked_add(lambda x, y=notify: y.show())
    tb.pack(bt, 1, 3, 1, 1)
    bt.show()

    # Notify bottom right
    bx = Box(win, horizontal=True)
    bx.show()

    notify = Notify(win, size_hint_weight=EXPAND_BOTH, align=(1.0, 1.0),
        content=bx)

    lb = Label(win, text="Bottom Right position.")
    bx.pack_end(lb)
    lb.show()

    bt = Button(win, text="Close in 2s")
    bt.callback_clicked_add(lambda x, y=notify: setattr(y, "timeout", 2.0))
    bx.pack_end(bt)
    bt.show()

    bt = Button(win, size_hint_align=FILL_BOTH, text="Bottom Right")
    bt.callback_clicked_add(lambda x, y=notify: y.show())
    tb.pack(bt, 3, 3, 1, 1)
    bt.show()

    # Notify top fill
    bx = Box(win, horizontal=True)
    bx.show()

    notify = Notify(win, size_hint_weight=EXPAND_BOTH,
        align=(ELM_NOTIFY_ALIGN_FILL, 0.0), timeout=5.0, content=bx)

    lb = Label(win)
    lb.text = (
        "Fill top. This notify fills horizontal area.<br/>"
        "<b>notify.align = (ELM_NOTIFY_ALIGN_FILL, 0.0)</b>"
        )
    bx.pack_end(lb)
    lb.show()

    bt = Button(win, text="Close")
    bt.callback_clicked_add(lambda x, y=notify: y.hide())
    bx.pack_end(bt)
    bt.show()

    bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0.5), text="Top fill")
    bt.callback_clicked_add(lambda x, y=notify: y.show())
    tb.pack(bt, 1, 0, 3, 1)
    bt.show()

    # Notify bottom fill
    bx = Box(win, horizontal=True)
    bx.show()

    notify = Notify(win, size_hint_weight=EXPAND_BOTH,
        align=(ELM_NOTIFY_ALIGN_FILL, 1.0), timeout=5.0, content=bx)

    lb = Label(win, size_hint_weight=EXPAND_BOTH, size_hint_align=(0.0, 0.5))
    lb.text = (
        "Fill Bottom. This notify fills horizontal area.<br/>"
        "<b>notify.align = (ELM_NOTIFY_ALIGN_FILL, 1.0)</b>"
        )
    bx.pack_end(lb)
    lb.show()

    bt = Button(win, text="Close")
    bt.callback_clicked_add(lambda x, y=notify: y.hide())
    bx.pack_end(bt)
    bt.show()

    bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0.5), text="Bottom fill")
    bt.callback_clicked_add(lambda x, y=notify: y.show())
    tb.pack(bt, 1, 4, 3, 1)
    bt.show()

    # Notify left fill
    bx = Box(win)
    bx.show()

    notify = Notify(win, size_hint_weight=EXPAND_BOTH,
        align=(0.0, ELM_NOTIFY_ALIGN_FILL), timeout=5.0, content=bx)

    lb = Label(win, text="Left fill.")
    bx.pack_end(lb)
    lb.show()

    bt = Button(win, text="Close")
    bt.callback_clicked_add(lambda x, y=notify: y.hide())
    bx.pack_end(bt)
    bt.show()

    bt = Button(win, size_hint_align=(0.5, EVAS_HINT_FILL), text="Left fill")
    bt.callback_clicked_add(lambda x, y=notify: y.show())
    tb.pack(bt, 0, 1, 1, 3)
    bt.show()

    # Notify right fill
    bx = Box(win)
    bx.show()

    notify = Notify(win, size_hint_weight=EXPAND_BOTH,
        align=(1.0, ELM_NOTIFY_ALIGN_FILL), timeout=5.0, content=bx)

    lb = Label(win)
    lb.text = "Right fill."
    bx.pack_end(lb)
    lb.show()

    bt = Button(win, text="Close")
    bt.callback_clicked_add(lambda x, y=notify: y.hide())
    bx.pack_end(bt)
    bt.show()

    bt = Button(win, size_hint_align=(0.5, EVAS_HINT_FILL), text="Right fill")
    bt.callback_clicked_add(lambda x, y=notify: y.show())
    tb.pack(bt, 4, 1, 1, 3)
    bt.show()
コード例 #25
0
def notify_clicked(obj=None):
    win = StandardWindow("notify", "Notify", autodel=True, size=(400, 400))
    if obj is None:
        win.callback_delete_request_add(lambda x: elementary.exit())
    win.show()

    tb = Table(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(tb)
    tb.show()

    # Notify top
    bx = Box(win, horizontal=True)
    bx.show()

    notify = Notify(win,
                    size_hint_weight=EXPAND_BOTH,
                    align=(0.5, 0.0),
                    content=bx)

    lb = Label(win, text="This position is the default.")
    bx.pack_end(lb)
    lb.show()

    bt = Button(win, text="Close")
    bt.callback_clicked_add(lambda x, y=notify: y.hide())
    bx.pack_end(bt)
    bt.show()

    bt = Button(win, size_hint_align=FILL_BOTH, text="Top")
    bt.callback_clicked_add(lambda x, y=notify: y.show())
    tb.pack(bt, 2, 1, 1, 1)
    bt.show()

    # Notify bottom
    bx = Box(win, horizontal=True)
    bx.show()

    notify = Notify(win,
                    allow_events=False,
                    size_hint_weight=EXPAND_BOTH,
                    align=(0.5, 1.0),
                    timeout=(5.0),
                    content=bx)

    notify.callback_timeout_add(lambda x: setattr(x, "timeout", 2.0))
    notify.callback_block_clicked_add(
        lambda x: print("Notify block area clicked!!"))

    lb = Label(win)
    lb.text = ("Bottom position. This notify uses a timeout of 5 sec.<br/>"
               "<b>The events outside the window are blocked.</b>")
    bx.pack_end(lb)
    lb.show()

    bt = Button(win, text="Close")
    bt.callback_clicked_add(lambda x, y=notify: y.hide())
    bx.pack_end(bt)
    bt.show()

    bt = Button(win, size_hint_align=FILL_BOTH, text="Bottom")
    bt.callback_clicked_add(lambda x, y=notify: y.show())
    tb.pack(bt, 2, 3, 1, 1)
    bt.show()

    # Notify left
    bx = Box(win, horizontal=True)
    bx.show()

    notify = Notify(win,
                    size_hint_weight=EXPAND_BOTH,
                    align=(0.0, 0.5),
                    timeout=10.0,
                    content=bx)
    notify.callback_timeout_add(lambda x: print("Notify timed out!"))

    lb = Label(win)
    lb.text = "Left position. This notify uses a timeout of 10 sec."
    bx.pack_end(lb)
    lb.show()

    bt = Button(win, text="Close")
    bt.callback_clicked_add(lambda x, y=notify: y.hide())
    bx.pack_end(bt)
    bt.show()

    bt = Button(win, size_hint_align=FILL_BOTH, text="Left")
    bt.callback_clicked_add(lambda x, y=notify: y.show())
    tb.pack(bt, 1, 2, 1, 1)
    bt.show()

    # Notify center
    bx = Box(win, horizontal=True)
    bx.show()

    notify = Notify(win,
                    size_hint_weight=EXPAND_BOTH,
                    align=(0.5, 0.5),
                    timeout=10.0,
                    content=bx)
    notify.callback_timeout_add(lambda x: print("Notify timed out!"))

    lb = Label(win)
    lb.text = "Center position. This notify uses a timeout of 10 sec."
    bx.pack_end(lb)
    lb.show()

    bt = Button(win, text="Close")
    bt.callback_clicked_add(lambda x, y=notify: y.hide())
    bx.pack_end(bt)
    bt.show()

    bt = Button(win, size_hint_align=FILL_BOTH, text="Center")
    bt.callback_clicked_add(lambda x, y=notify: y.show())
    tb.pack(bt, 2, 2, 1, 1)
    bt.show()

    # Notify right
    bx = Box(win, horizontal=True)
    bx.show()

    notify = Notify(win,
                    size_hint_weight=EXPAND_BOTH,
                    align=(1.0, 0.5),
                    content=bx)

    lb = Label(win, text="Right position.")
    bx.pack_end(lb)
    lb.show()

    bt = Button(win, text="Close")
    bt.callback_clicked_add(lambda x, y=notify: y.hide())
    bx.pack_end(bt)
    bt.show()

    bt = Button(win, size_hint_align=FILL_BOTH, text="Right")
    bt.callback_clicked_add(lambda x, y=notify: y.show())
    tb.pack(bt, 3, 2, 1, 1)
    bt.show()

    # Notify top left
    bx = Box(win, horizontal=True)
    bx.show()

    notify = Notify(win,
                    size_hint_weight=EXPAND_BOTH,
                    align=(0.0, 0.0),
                    content=bx)

    lb = Label(win, text="Top Left position.")
    bx.pack_end(lb)
    lb.show()

    bt = Button(win, text="Close")
    bt.callback_clicked_add(lambda x, y=notify: y.hide())
    bx.pack_end(bt)
    bt.show()

    bt = Button(win, size_hint_align=FILL_BOTH, text="Top Left")
    bt.callback_clicked_add(lambda x, y=notify: y.show())
    tb.pack(bt, 1, 1, 1, 1)
    bt.show()

    # Notify top right
    bx = Box(win, horizontal=True)
    bx.show()

    notify = Notify(win,
                    size_hint_weight=EXPAND_BOTH,
                    align=(1.0, 0.0),
                    content=bx)

    lb = Label(win, text="Top Right position.")
    bx.pack_end(lb)
    lb.show()

    bt = Button(win, text="Close")
    bt.callback_clicked_add(lambda x, y=notify: y.hide())
    bx.pack_end(bt)
    bt.show()

    bt = Button(win, size_hint_align=FILL_BOTH, text="Top Right")
    bt.callback_clicked_add(lambda x, y=notify: y.show())
    tb.pack(bt, 3, 1, 1, 1)
    bt.show()

    # Notify bottom left
    bx = Box(win, horizontal=True)
    bx.show()

    notify = Notify(win,
                    size_hint_weight=EXPAND_BOTH,
                    align=(0.0, 1.0),
                    content=bx)

    lb = Label(win, text="Bottom Left position.")
    bx.pack_end(lb)
    lb.show()

    bt = Button(win, text="Close")
    bt.callback_clicked_add(lambda x, y=notify: y.hide())
    bx.pack_end(bt)
    bt.show()

    bt = Button(win, size_hint_align=FILL_BOTH, text="Bottom Left")
    bt.callback_clicked_add(lambda x, y=notify: y.show())
    tb.pack(bt, 1, 3, 1, 1)
    bt.show()

    # Notify bottom right
    bx = Box(win, horizontal=True)
    bx.show()

    notify = Notify(win,
                    size_hint_weight=EXPAND_BOTH,
                    align=(1.0, 1.0),
                    content=bx)

    lb = Label(win, text="Bottom Right position.")
    bx.pack_end(lb)
    lb.show()

    bt = Button(win, text="Close in 2s")
    bt.callback_clicked_add(lambda x, y=notify: setattr(y, "timeout", 2.0))
    bx.pack_end(bt)
    bt.show()

    bt = Button(win, size_hint_align=FILL_BOTH, text="Bottom Right")
    bt.callback_clicked_add(lambda x, y=notify: y.show())
    tb.pack(bt, 3, 3, 1, 1)
    bt.show()

    # Notify top fill
    bx = Box(win, horizontal=True)
    bx.show()

    notify = Notify(win,
                    size_hint_weight=EXPAND_BOTH,
                    align=(ELM_NOTIFY_ALIGN_FILL, 0.0),
                    timeout=5.0,
                    content=bx)

    lb = Label(win)
    lb.text = ("Fill top. This notify fills horizontal area.<br/>"
               "<b>notify.align = (ELM_NOTIFY_ALIGN_FILL, 0.0)</b>")
    bx.pack_end(lb)
    lb.show()

    bt = Button(win, text="Close")
    bt.callback_clicked_add(lambda x, y=notify: y.hide())
    bx.pack_end(bt)
    bt.show()

    bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0.5), text="Top fill")
    bt.callback_clicked_add(lambda x, y=notify: y.show())
    tb.pack(bt, 1, 0, 3, 1)
    bt.show()

    # Notify bottom fill
    bx = Box(win, horizontal=True)
    bx.show()

    notify = Notify(win,
                    size_hint_weight=EXPAND_BOTH,
                    align=(ELM_NOTIFY_ALIGN_FILL, 1.0),
                    timeout=5.0,
                    content=bx)

    lb = Label(win, size_hint_weight=EXPAND_BOTH, size_hint_align=(0.0, 0.5))
    lb.text = ("Fill Bottom. This notify fills horizontal area.<br/>"
               "<b>notify.align = (ELM_NOTIFY_ALIGN_FILL, 1.0)</b>")
    bx.pack_end(lb)
    lb.show()

    bt = Button(win, text="Close")
    bt.callback_clicked_add(lambda x, y=notify: y.hide())
    bx.pack_end(bt)
    bt.show()

    bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0.5), text="Bottom fill")
    bt.callback_clicked_add(lambda x, y=notify: y.show())
    tb.pack(bt, 1, 4, 3, 1)
    bt.show()

    # Notify left fill
    bx = Box(win)
    bx.show()

    notify = Notify(win,
                    size_hint_weight=EXPAND_BOTH,
                    align=(0.0, ELM_NOTIFY_ALIGN_FILL),
                    timeout=5.0,
                    content=bx)

    lb = Label(win, text="Left fill.")
    bx.pack_end(lb)
    lb.show()

    bt = Button(win, text="Close")
    bt.callback_clicked_add(lambda x, y=notify: y.hide())
    bx.pack_end(bt)
    bt.show()

    bt = Button(win, size_hint_align=(0.5, EVAS_HINT_FILL), text="Left fill")
    bt.callback_clicked_add(lambda x, y=notify: y.show())
    tb.pack(bt, 0, 1, 1, 3)
    bt.show()

    # Notify right fill
    bx = Box(win)
    bx.show()

    notify = Notify(win,
                    size_hint_weight=EXPAND_BOTH,
                    align=(1.0, ELM_NOTIFY_ALIGN_FILL),
                    timeout=5.0,
                    content=bx)

    lb = Label(win)
    lb.text = "Right fill."
    bx.pack_end(lb)
    lb.show()

    bt = Button(win, text="Close")
    bt.callback_clicked_add(lambda x, y=notify: y.hide())
    bx.pack_end(bt)
    bt.show()

    bt = Button(win, size_hint_align=(0.5, EVAS_HINT_FILL), text="Right fill")
    bt.callback_clicked_add(lambda x, y=notify: y.show())
    tb.pack(bt, 4, 1, 1, 3)
    bt.show()
コード例 #26
0
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()
コード例 #27
0
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()
コード例 #28
0
    def __init__(self, parent, title, rfunc, wfunc):
        Frame.__init__(self, parent)
        self.size_hint_weight = EXPAND_HORIZ
        self.size_hint_align = FILL_HORIZ
        self.text = title

        t = Table(self, homogeneous=True, padding=(3, 3))
        t.size_hint_weight = EXPAND_HORIZ
        t.size_hint_align = FILL_HORIZ
        t.show()

        l = Label(self, text="Proxy type")
        l.size_hint_align = 0.0, 0.5
        l.show()
        ptype = Hoversel(parent)
        ptype.size_hint_align = -1.0, 0.5
        ptype.text = rfunc().type.name
        for n in self.proxy_types.iterkeys():
            ptype.item_add(n, callback=lambda x, y, z=n: ptype.text_set(z))
        ptype.show()
        t.pack(l, 0, 0, 1, 1)
        t.pack(ptype, 1, 0, 1, 1)

        l = Label(self, text="Hostname")
        l.size_hint_align = 0.0, 0.5
        l.show()
        phost = Entry(parent)
        phost.size_hint_weight = EXPAND_HORIZ
        phost.size_hint_align = FILL_HORIZ
        phost.single_line = True
        phost.scrollable = True
        phost.entry = rfunc().hostname
        phost.show()
        t.pack(l, 0, 1, 1, 1)
        t.pack(phost, 1, 1, 1, 1)

        l = Label(self, text="Port")
        l.size_hint_align = 0.0, 0.5
        l.show()
        pport = Spinner(parent)
        pport.size_hint_align = -1.0, 0.5
        pport.min_max = 0, 65535
        pport.value = rfunc().port
        pport.show()
        t.pack(l, 0, 2, 1, 1)
        t.pack(pport, 1, 2, 1, 1)

        l = Label(self, text="Username")
        l.size_hint_align = 0.0, 0.5
        l.show()
        puser = Entry(parent)
        puser.size_hint_weight = EXPAND_HORIZ
        puser.size_hint_align = FILL_HORIZ
        puser.single_line = True
        puser.scrollable = True
        puser.entry = rfunc().username
        puser.show()
        t.pack(l, 0, 3, 1, 1)
        t.pack(puser, 1, 3, 1, 1)

        l = Label(self, text="Password")
        l.size_hint_align = 0.0, 0.5
        l.show()
        ppass = Entry(parent)
        ppass.size_hint_weight = EXPAND_HORIZ
        ppass.size_hint_align = FILL_HORIZ
        ppass.single_line = True
        ppass.scrollable = True
        ppass.password = True
        ppass.entry = rfunc().password
        ppass.show()
        t.pack(l, 0, 4, 1, 1)
        t.pack(ppass, 1, 4, 1, 1)

        entries = [ptype, phost, pport, puser, ppass]

        save = Button(parent, text="Apply")
        save.callback_clicked_add(self.save_conf, wfunc, entries)
        save.show()
        t.pack(save, 0, 5, 2, 1)

        self.content = t
コード例 #29
0
    def __init__(self, parent, session):
        PreferencesDialog.__init__(self, "Session")

        # TODO: Construct and populate this with an Idler

        self.session = session

        widgets = {}

        elm_conf = Configuration()

        s = session.settings()

        t = Table(self,
                  padding=(5, 5),
                  homogeneous=True,
                  size_hint_align=FILL_BOTH)
        self.box.pack_end(t)
        t.show()

        i = 0

        INT_MIN = -2147483648
        INT_MAX = 2147483647

        scale = elm_conf.scale

        for k in dir(s):
            if k.startswith("__"): continue
            try:
                a = getattr(s, k)
                if isinstance(a, lt.disk_cache_algo_t):
                    w = Spinner(t)
                    w.size_hint_align = FILL_HORIZ
                    # XXX: lt-rb python bindings don't have all values.
                    w.min_max = 0, 2  #len(lt.disk_cache_algo_t.values.keys())
                    for name, val in lt.disk_cache_algo_t.names.items():
                        w.special_value_add(val, name)
                    w.value = a
                elif isinstance(a, bool):
                    w = Check(t)
                    w.size_hint_align = 1.0, 0.0
                    w.style = "toggle"
                    w.state = a
                elif isinstance(a, int):
                    w = Spinner(t)
                    w.size_hint_align = FILL_HORIZ
                    w.min_max = INT_MIN, INT_MAX
                    w.value = a
                elif isinstance(a, float):
                    w = Slider(t)
                    w.size_hint_align = FILL_HORIZ
                    w.size_hint_weight = EXPAND_HORIZ
                    w.unit_format = "%1.2f"
                    if k.startswith("peer_turnover"):
                        w.min_max = 0.0, 1.0
                    else:
                        w.min_max = 0.0, 20.0
                    w.value = a
                elif k == "peer_tos":
                    # XXX: This is an int pair in libtorrent,
                    #      which doesn't have a python equivalent.
                    continue
                elif k == "user_agent":
                    w = Entry(t)
                    w.size_hint_align = 1.0, 0.0
                    w.size_hint_weight = EXPAND_HORIZ
                    w.single_line = True
                    w.editable = False
                    w.entry = cgi.escape(a)
                else:
                    w = Entry(t)
                    w.part_text_set("guide", "Enter here")
                    w.size_hint_align = FILL_HORIZ
                    w.size_hint_weight = EXPAND_HORIZ
                    w.single_line = True
                    w.entry = cgi.escape(a)
                l = Label(t)
                l.text = k.replace("_", " ").capitalize()
                l.size_hint_align = 0.0, 0.0
                l.size_hint_weight = EXPAND_HORIZ
                l.show()
                t.pack(l, 0, i, 1, 1)
                #w.size_hint_min = scale * 150, scale * 25
                t.pack(w, 1, i, 1, 1)
                w.show()
                widgets[k] = w
                i += 1
            except TypeError:
                pass  #print("Error {}".format(k))

        save_btn = Button(self)
        save_btn.text = "Apply session settings"
        save_btn.callback_clicked_add(self.apply_settings, widgets, session)
        save_btn.show()
        self.box.pack_end(save_btn)
コード例 #30
0
ファイル: gui.py プロジェクト: DaveMDS/egitu
    def __init__(self, parent, app):
        self.app = app

        Popup.__init__(self, parent)

        # title
        self.part_text_set('title,text', 'Clone')
        self.part_content_set('title,icon', SafeIcon(self, 'egitu'))

        # main table
        tb = Table(self, padding=(0,4),
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        self.content = tb
        tb.show()

        # sep
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_HORIZ)
        tb.pack(sep, 0, 0, 2, 1)
        sep.show()

        # url
        en = Entry(self, single_line=True, scrollable=True,
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        en.part_text_set('guide', 'Path or URL to clone')
        tb.pack(en, 0, 1, 2, 1)
        en.show()
        self.url_entry = en

        # parent folder
        en = Entry(self, single_line=True, scrollable=True,
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        en.part_text_set('guide', 'Parent folder to clone into')
        tb.pack(en, 0, 2, 1, 1)
        en.show()

        bt = Button(self, text='', content=SafeIcon(self, 'folder'))
        bt.callback_clicked_add(self._folder_clicked_cb)
        tb.pack(bt, 1, 2, 1, 1)
        bt.show()
        self.folder_entry = en

        # shallow check
        ck = Check(self, text='Shallow (no history and no branches, faster)',
                   size_hint_expand=EXPAND_BOTH, size_hint_align=(0.0,0.5))
        tb.pack(ck, 0, 3, 2, 1)
        ck.show()
        self.shallow_check = ck

        # output entry
        en = CommandOutputEntry(self, min_size=(400, 150))
        tb.pack(en, 0, 4, 2, 1)
        en.show()
        self.output_entry = en

        # sep
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_HORIZ)
        tb.pack(sep, 0, 5, 2, 1)
        sep.show()

        # bottons
        bt = Button(self, text='Close')
        bt.callback_clicked_add(lambda b: self.delete())
        self.part_content_set('button1', bt)
        bt.show()
        self.close_btn = bt

        bt = Button(self, text='Clone')
        bt.callback_clicked_add(self._clone_clicked_cb)
        self.part_content_set('button2', bt)
        bt.show()
        self.clone_btn = bt

        #
        self.show()
コード例 #31
0
ファイル: tags.py プロジェクト: druonysus/egitu
    def __init__(self, parent, app):
        self.app = app

        Popup.__init__(self, parent)
        self.part_text_set('title,text', 'Create tag')
        self.part_content_set('title,icon', Icon(self, standard='git-tag'))

        # main vertical box
        tb = Table(self, padding=(4,4),
                    size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        self.content = tb
        tb.show()

        # sep
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_BOTH)
        tb.pack(sep, 0, 0, 2, 1)
        sep.show()

        # tag name
        en = Entry(self, single_line=True, scrollable=True,
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        en.part_text_set('guide', 'Type the tag name, ex: v1.15.0')
        en.callback_changed_user_add(self._something_changed_cb)
        tb.pack(en, 0, 1, 2, 1)
        en.show()
        self.name_entry  = en

        # annotated or light
        rdg = Radio(self, state_value=1, value=1, text='Annotated',
                    size_hint_expand=EXPAND_BOTH)
        rdg.callback_changed_add(self._annotated_radio_changed_cb)
        rdg.callback_changed_add(self._something_changed_cb)
        tb.pack(rdg, 0, 2, 1, 1)
        rdg.show()
        self.annotated_radio  = rdg

        rd = Radio(self, state_value=0, text='Lightweight',
                   size_hint_expand=EXPAND_BOTH)
        rd.callback_changed_add(self._annotated_radio_changed_cb)
        rd.callback_changed_add(self._something_changed_cb)
        rd.group_add(rdg)
        tb.pack(rd, 1, 2, 1, 1)
        rd.show()

        # message entry
        en = Entry(self, scrollable=True,
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        en.part_text_set('guide', 'Type a message for the tag')
        en.callback_changed_user_add(self._something_changed_cb)

        r = Rectangle(self.evas, size_hint_min=(200,150),
                      size_hint_expand=EXPAND_BOTH)
        tb.pack(r, 0, 3, 2, 1)
        tb.pack(en, 0, 3, 2, 1)
        en.show()
        self.msg_entry  = en

        # buttons
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_BOTH)
        tb.pack(sep, 0, 4, 2, 1)
        sep.show()

        bt = Button(self, text='Cancel')
        bt.callback_clicked_add(lambda b: self.delete())
        self.part_content_set('button1', bt)
        bt.show()

        bt = Button(self, text='Create', disabled=True,
                    content=Icon(self, standard='git-tag'))
        bt.callback_clicked_add(self._create_clicked_cb)
        self.part_content_set('button2', bt)
        bt.show()
        self.create_btn = bt

        #
        self.name_entry.focus = True
        self.show()
コード例 #32
0
def list_clicked(obj, item=None):
    win = StandardWindow("list", "List", autodel=True, size=(320, 320))

    li = List(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(li)

    ic = Icon(win,
              file=os.path.join(img_path, "logo_small.png"),
              resizable=(True, True))
    it1 = li.item_append("Hello", ic)
    ic = Icon(win,
              file=os.path.join(img_path, "logo_small.png"),
              resizable=(False, False))
    li.item_append("Hello", ic)
    ic = Icon(win, standard="edit", resizable=(False, False))
    ic2 = Icon(win, standard="clock", resizable=(False, False))
    li.item_append(".", ic, ic2)

    ic = Icon(win, standard="delete", resizable=(False, False))
    ic2 = Icon(win, standard="clock", resizable=(False, False))
    it2 = li.item_append("How", ic, ic2)

    bx = Box(win, horizontal=True)

    ic = Icon(win,
              file=os.path.join(img_path, "logo_small.png"),
              resizable=(False, False),
              size_hint_align=ALIGN_CENTER)
    bx.pack_end(ic)
    ic.show()

    ic = Icon(win,
              file=os.path.join(img_path, "logo_small.png"),
              resizable=(False, False),
              size_hint_align=(0.5, 0.0))
    bx.pack_end(ic)
    ic.show()

    ic = Icon(win,
              file=os.path.join(img_path, "logo_small.png"),
              resizable=(False, False),
              size_hint_align=(0.0, EVAS_HINT_FILL))
    bx.pack_end(ic)
    ic.show()
    li.item_append("are")

    li.item_append("you")
    it3 = li.item_append("doing")
    li.item_append("out")
    li.item_append("there")
    li.item_append("today")
    li.item_append("?")
    it4 = li.item_append("Here")
    li.item_append("are")
    li.item_append("some")
    li.item_append("more")
    li.item_append("items")
    li.item_append("Is this label long enough?")
    it5 = li.item_append(
        "Maybe this one is even longer so we can test long long items.")

    li.go()

    li.show()

    tb2 = Table(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(tb2)

    bt = Button(win,
                text="Hello",
                size_hint_weight=EXPAND_BOTH,
                size_hint_align=(0.9, 0.5))
    bt.callback_clicked_add(my_list_show_it, it1)
    tb2.pack(bt, 0, 0, 1, 1)
    bt.show()

    bt = Button(win,
                text="How",
                size_hint_weight=EXPAND_BOTH,
                size_hint_align=(0.9, 0.5))
    bt.callback_clicked_add(my_list_show_it, it2)
    tb2.pack(bt, 0, 1, 1, 1)
    bt.show()

    bt = Button(win,
                text="doing",
                size_hint_weight=EXPAND_BOTH,
                size_hint_align=(0.9, 0.5))
    bt.callback_clicked_add(my_list_show_it, it3)
    tb2.pack(bt, 0, 2, 1, 1)
    bt.show()

    bt = Button(win,
                text="Here",
                size_hint_weight=EXPAND_BOTH,
                size_hint_align=(0.9, 0.5))
    bt.callback_clicked_add(my_list_show_it, it4)
    tb2.pack(bt, 0, 3, 1, 1)
    bt.show()

    bt = Button(win,
                text="Maybe this...",
                size_hint_weight=EXPAND_BOTH,
                size_hint_align=(0.9, 0.5))
    bt.callback_clicked_add(my_list_show_it, it5)
    tb2.pack(bt, 0, 4, 1, 1)
    bt.show()

    tb2.show()

    win.show()
コード例 #33
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()
コード例 #34
0
ファイル: stash.py プロジェクト: DaveMDS/egitu
    def __init__(self, parent, app, stash=None):
        self.app = app
        self.stash = stash or app.repo.stash[0]
        self.idx = parseint(stash.ref) if stash else 0

        DialogWindow.__init__(self, app.win, 'egitu-stash', 'stash',
                              size=(500,500), autodel=True)

        # main vertical box (inside a padding frame)
        vbox = Box(self, padding=(0, 6), size_hint_weight=EXPAND_BOTH,
                   size_hint_align=FILL_BOTH)
        fr = Frame(self, style='pad_medium', size_hint_weight=EXPAND_BOTH)
        self.resize_object_add(fr)
        fr.content = vbox
        fr.show()
        vbox.show()

        # header horizontal box
        hbox = Box(self, horizontal=True,
                   size_hint_expand=EXPAND_HORIZ, size_hint_fill=FILL_HORIZ)
        vbox.pack_end(hbox)
        hbox.show()

        # title
        en = Entry(self, editable=False, scrollable=False,
                    size_hint_expand=EXPAND_HORIZ, size_hint_align=(-1,0.0))
        hbox.pack_end(en)
        en.show()
        self.title_entry = en

        # header separator
        sep = Separator(self)
        hbox.pack_end(sep)
        sep.show()

        # navigation table
        tb = Table(self, size_hint_align=(0.5,0.0))
        hbox.pack_end(tb)
        tb.show()

        lb = Label(self)
        tb.pack(lb, 0, 0, 2, 1)
        lb.show()
        self.nav_label = lb

        ic = SafeIcon(self, 'go-previous')
        bt = Button(self, text='Prev', content=ic)
        bt.callback_clicked_add(self._prev_clicked_cb)
        tb.pack(bt, 0, 1, 1, 1)
        bt.show()
        self.prev_btn = bt

        ic = SafeIcon(self, 'go-next')
        bt = Button(self, text='Next', content=ic)
        bt.callback_clicked_add(self._next_clicked_cb)
        tb.pack(bt, 1, 1, 1, 1)
        bt.show()
        self.next_btn = bt

        # diff entry
        self.diff_entry = DiffedEntry(self)
        vbox.pack_end(self.diff_entry)
        self.diff_entry.show()

        # buttons
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_HORIZ)
        vbox.pack_end(sep)
        sep.show()

        hbox = Box(self, horizontal=True,
                   size_hint_expand=EXPAND_HORIZ, size_hint_fill=FILL_BOTH)
        vbox.pack_end(hbox)
        hbox.show()

        bt = Button(self, text='Apply')
        bt.callback_clicked_add(self._apply_clicked_cb)
        hbox.pack_end(bt)
        bt.show()

        bt = Button(self, text='Pop (apply & delete)')
        bt.callback_clicked_add(self._pop_clicked_cb)
        hbox.pack_end(bt)
        bt.show()

        bt = Button(self, text='Branch & Delete',
                    content=SafeIcon(self, 'git-branch'))
        bt.callback_clicked_add(self._branch_clicked_cb)
        hbox.pack_end(bt)
        bt.show()

        bt = Button(self, text='Delete',
                    content=SafeIcon(self, 'user-trash'))
        bt.callback_clicked_add(self._drop_clicked_cb)
        hbox.pack_end(bt)
        bt.show()

        sep = Separator(self, size_hint_expand=EXPAND_HORIZ)
        hbox.pack_end(sep)

        bt = Button(self, text='Close')
        bt.callback_clicked_add(lambda b: self.delete())
        hbox.pack_end(bt)
        bt.show()

        # request the diff and show the dialog
        self.update(self.idx)
        self.show()
コード例 #35
0
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()
コード例 #36
0
    def __init__(self, parent, title, rfunc, wfunc):
        Frame.__init__(self, parent)
        self.size_hint_weight = EXPAND_HORIZ
        self.size_hint_align = FILL_HORIZ
        self.text = title

        t = Table(self, homogeneous=True, padding=(3,3))
        t.size_hint_weight = EXPAND_HORIZ
        t.size_hint_align = FILL_HORIZ
        t.show()

        l = Label(self, text="Proxy type")
        l.size_hint_align = 0.0, 0.5
        l.show()
        ptype = Hoversel(parent)
        ptype.size_hint_align = -1.0, 0.5
        ptype.text = rfunc().type.name
        for n in self.proxy_types.iterkeys():
            ptype.item_add(n, callback=lambda x, y, z=n: ptype.text_set(z))
        ptype.show()
        t.pack(l, 0, 0, 1, 1)
        t.pack(ptype, 1, 0, 1, 1)

        l = Label(self, text="Hostname")
        l.size_hint_align = 0.0, 0.5
        l.show()
        phost = Entry(parent)
        phost.size_hint_weight = EXPAND_HORIZ
        phost.size_hint_align = FILL_HORIZ
        phost.single_line = True
        phost.scrollable = True
        phost.entry = rfunc().hostname
        phost.show()
        t.pack(l, 0, 1, 1, 1)
        t.pack(phost, 1, 1, 1, 1)

        l = Label(self, text="Port")
        l.size_hint_align = 0.0, 0.5
        l.show()
        pport = Spinner(parent)
        pport.size_hint_align = -1.0, 0.5
        pport.min_max = 0, 65535
        pport.value = rfunc().port
        pport.show()
        t.pack(l, 0, 2, 1, 1)
        t.pack(pport, 1, 2, 1, 1)

        l = Label(self, text="Username")
        l.size_hint_align = 0.0, 0.5
        l.show()
        puser = Entry(parent)
        puser.size_hint_weight = EXPAND_HORIZ
        puser.size_hint_align = FILL_HORIZ
        puser.single_line = True
        puser.scrollable = True
        puser.entry = rfunc().username
        puser.show()
        t.pack(l, 0, 3, 1, 1)
        t.pack(puser, 1, 3, 1, 1)

        l = Label(self, text="Password")
        l.size_hint_align = 0.0, 0.5
        l.show()
        ppass = Entry(parent)
        ppass.size_hint_weight = EXPAND_HORIZ
        ppass.size_hint_align = FILL_HORIZ
        ppass.single_line = True
        ppass.scrollable = True
        ppass.password = True
        ppass.entry = rfunc().password
        ppass.show()
        t.pack(l, 0, 4, 1, 1)
        t.pack(ppass, 1, 4, 1, 1)

        entries = [ptype, phost, pport, puser, ppass]

        save = Button(parent, text="Apply")
        save.callback_clicked_add(self.save_conf, wfunc, entries)
        save.show()
        t.pack(save, 0, 5, 2, 1)

        self.content = t
コード例 #37
0
ファイル: gui.py プロジェクト: lonid/epack
    def __init__(self, app):
        self.app = app
        self.prog_popup = None

        # the window
        StandardWindow.__init__(self, 'epack', 'Epack')
        self.autodel_set(True)
        self.callback_delete_request_add(lambda o: self.app.exit())

        # main vertical box
        vbox = Box(self, size_hint_weight=EXPAND_BOTH)
        self.resize_object_add(vbox)
        vbox.show()

        ### header horiz box (inside a padding frame)
        frame = Frame(self, style='pad_medium',
                      size_hint_weight=EXPAND_HORIZ,
                      size_hint_align=FILL_HORIZ)
        vbox.pack_end(frame)
        frame.show()

        self.header_box = Box(self, horizontal=True,
                              size_hint_weight=EXPAND_HORIZ,
                              size_hint_align=FILL_HORIZ)
        frame.content = self.header_box
        self.header_box.show()

        # genlist with archive content
        self.file_itc = GenlistItemClass(item_style="no_icon",
                                         text_get_func=gl_file_text_get)
        self.fold_itc = GenlistItemClass(item_style="one_icon",
                                         text_get_func=gl_fold_text_get,
                                         content_get_func=gl_fold_icon_get)
        self.file_list = Genlist(self, homogeneous=True,
                                 size_hint_weight=EXPAND_BOTH,
                                 size_hint_align=FILL_BOTH)
        self.file_list.callback_expand_request_add(self._gl_expand_req_cb)
        self.file_list.callback_contract_request_add(self._gl_contract_req_cb)
        self.file_list.callback_expanded_add(self._gl_expanded_cb)
        self.file_list.callback_contracted_add(self._gl_contracted_cb)
        vbox.pack_end(self.file_list)
        self.file_list.show()

        ### footer table (inside a padding frame)
        frame = Frame(self, style='pad_medium',
                      size_hint_weight=EXPAND_HORIZ,
                      size_hint_align=FILL_HORIZ)
        vbox.pack_end(frame)
        frame.show()

        table = Table(frame)
        frame.content = table
        table.show()

        # FileSelectorButton
        self.fsb = DestinationButton(app, self)
        table.pack(self.fsb, 0, 0, 3, 1)
        self.fsb.show()

        sep = Separator(table, horizontal=True,
                        size_hint_weight=EXPAND_HORIZ)
        table.pack(sep, 0, 1, 3, 1)
        sep.show()

        # extract button
        self.extract_btn = Button(table, text=_('Extract'))
        self.extract_btn.callback_clicked_add(self.extract_btn_cb)
        table.pack(self.extract_btn, 0, 2, 1, 2)
        self.extract_btn.show()

        sep = Separator(table, horizontal=False)
        table.pack(sep, 1, 2, 1, 2)
        sep.show()

        # delete-archive checkbox
        self.del_chk = Check(table, text=_('Delete archive after extraction'),
                             size_hint_weight=EXPAND_HORIZ,
                             size_hint_align=(0.0, 1.0))
        self.del_chk.callback_changed_add(self.del_check_cb)
        table.pack(self.del_chk, 2, 2, 1, 1)
        self.del_chk.show()

        # create-archive-folder checkbox
        self.create_folder_chk = Check(table, text=_('Create archive folder'),
                                       size_hint_weight=EXPAND_HORIZ,
                                       size_hint_align=(0.0, 1.0))
        table.pack(self.create_folder_chk, 2, 3, 1, 1)
        self.create_folder_chk.callback_changed_add(
                               lambda c: self.update_fsb_label())
        self.create_folder_chk.show()

        # set the correct ui state
        self.update_ui()

        # show the window
        self.resize(300, 380)
        self.show()
コード例 #38
0
    def __init__(self, parent, session):
        PreferencesDialog.__init__(self, "Session")

        # TODO: Construct and populate this with an Idler

        self.session = session

        widgets = {}

        elm_conf = Configuration()

        s = session.settings()

        t = Table(self, padding=(5,5), homogeneous=True,
            size_hint_align=FILL_BOTH)
        self.box.pack_end(t)
        t.show()

        i = 0

        INT_MIN = -2147483648
        INT_MAX =  2147483647

        scale = elm_conf.scale

        for k in dir(s):
            if k.startswith("__"): continue
            try:
                a = getattr(s, k)
                if isinstance(a, lt.disk_cache_algo_t):
                    w = Spinner(t)
                    w.size_hint_align = FILL_HORIZ
                    # XXX: lt-rb python bindings don't have all values.
                    w.min_max = 0, 2 #len(lt.disk_cache_algo_t.values.keys())
                    for name, val in lt.disk_cache_algo_t.names.items():
                        w.special_value_add(val, name)
                    w.value = a
                elif isinstance(a, bool):
                    w = Check(t)
                    w.size_hint_align = 1.0, 0.0
                    w.style = "toggle"
                    w.state = a
                elif isinstance(a, int):
                    w = Spinner(t)
                    w.size_hint_align = FILL_HORIZ
                    w.min_max = INT_MIN, INT_MAX
                    w.value = a
                elif isinstance(a, float):
                    w = Slider(t)
                    w.size_hint_align = FILL_HORIZ
                    w.size_hint_weight = EXPAND_HORIZ
                    w.unit_format = "%1.2f"
                    if k.startswith("peer_turnover"):
                        w.min_max = 0.0, 1.0
                    else:
                        w.min_max = 0.0, 20.0
                    w.value = a
                elif k == "peer_tos":
                    # XXX: This is an int pair in libtorrent,
                    #      which doesn't have a python equivalent.
                    continue
                elif k == "user_agent":
                    w = Entry(t)
                    w.size_hint_align = 1.0, 0.0
                    w.size_hint_weight = EXPAND_HORIZ
                    w.single_line = True
                    w.editable = False
                    w.entry = cgi.escape(a)
                else:
                    w = Entry(t)
                    w.part_text_set("guide", "Enter here")
                    w.size_hint_align = FILL_HORIZ
                    w.size_hint_weight = EXPAND_HORIZ
                    w.single_line = True
                    w.entry = cgi.escape(a)
                l = Label(t)
                l.text = k.replace("_", " ").capitalize()
                l.size_hint_align = 0.0, 0.0
                l.size_hint_weight = EXPAND_HORIZ
                l.show()
                t.pack(l, 0, i, 1, 1)
                #w.size_hint_min = scale * 150, scale * 25
                t.pack(w, 1, i, 1, 1)
                w.show()
                widgets[k] = w
                i += 1
            except TypeError:
                pass #print("Error {}".format(k))

        save_btn = Button(self)
        save_btn.text = "Apply session settings"
        save_btn.callback_clicked_add(self.apply_settings, widgets, session)
        save_btn.show()
        self.box.pack_end(save_btn)
コード例 #39
0
ファイル: commit.py プロジェクト: druonysus/egitu
    def __init__(self, app):
        self.app = app

        Popup.__init__(self, app.win)
        self.part_text_set('title,text', 'Discard local changes')
        self.part_content_set('title,icon', Icon(self, standard='user-trash'))

        # main table
        tb = Table(self, padding=(0,4),
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        self.content = tb
        tb.show()

        # sep
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_BOTH)
        tb.pack(sep, 0, 0, 1, 1)
        sep.show()

        # warning label
        en = Entry(self, editable=False,
                   text='<warning>WARNING: This operation is not reversible!</warning><br>' \
                        'Selected files (or ALL files, if nothing is selected) will be ' \
                        'reverted to the state of the last commit.',
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        tb.pack(en, 0, 1, 1, 1)
        en.show()

        # changes list
        r = Rectangle(self.evas, size_hint_min=(300,200),
                      size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        li = List(self, multi_select=True,
                  size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        li.callback_selected_add(self._list_selection_changed_cb)
        li.callback_unselected_add(self._list_selection_changed_cb)
        tb.pack(li, 0, 2, 1, 1)
        tb.pack(r, 0, 2, 1, 1)

        for path in sorted(self.app.repo.status.changes):
            mod, staged, name, new_name = self.app.repo.status.changes[path]
            icon = Icon(self, standard='git-mod-'+mod)
            check = Check(self, text='', state=staged, disabled=True)
            label = '{} → {}'.format(name, new_name) if new_name else name
            it = li.item_append(label, icon, check)
            it.data['mod'] = mod

        li.go()
        li.show()
        self.file_list = li

        # delete untracked check
        ck = Check(self, text='Also delete untracked files', state=True,
                   size_hint_expand=EXPAND_BOTH, size_hint_align=(0.0,0.5))
        tb.pack(ck, 0, 3, 1, 1)
        ck.show()
        self.untracked_chk = ck

        # sep
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_BOTH)
        tb.pack(sep, 0, 4, 1, 1)
        sep.show()

        # buttons
        bt = Button(self, text='Close')
        bt.callback_clicked_add(lambda b: self.delete())
        self.part_content_set('button1', bt)
        bt.show()

        bt = Button(self, text="Discard EVERYTHING!",
                    content=Icon(self, standard='user-trash'))
        bt.callback_clicked_add(self._confirm_clicked_cb)
        self.part_content_set('button2', bt)
        bt.show()
        self.confirm_btn = bt

        #
        self.show()
コード例 #40
0
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()
コード例 #41
0
ファイル: gui.py プロジェクト: DaveMDS/egitu
    def __init__(self, app):
        self.app = app

        Popup.__init__(self, app.win)

        # title
        self.part_text_set('title,text', 'Recent Repositories')
        self.part_content_set('title,icon', SafeIcon(self, 'egitu'))

        # main table
        tb = Table(self, padding=(0,4), 
                   size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        self.content = tb
        tb.show()

        # sep
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_BOTH)
        tb.pack(sep, 0, 0, 1, 1)
        sep.show()

        # recent list
        itc = GenlistItemClass(item_style='no_icon',
                               text_get_func=self._gl_text_get)

        li = Genlist(self, homogeneous=True,
                     size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        li.callback_selected_add(self._recent_selected_cb)

        recents = recent_history_get()
        if recents:
            for path in recents:
                li.item_append(itc, path)
        else:
            item = li.item_append(itc, None)
            item.disabled = True
        li.show()

        r = Rectangle(self.evas, color=(0,0,0,0), size_hint_min=(300,200),
                      size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        tb.pack(r, 0, 1, 1, 1)
        tb.pack(li, 0, 1, 1, 1)

        # sep
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_BOTH)
        tb.pack(sep, 0, 2, 1, 1)
        sep.show()

        # buttons
        bt = Button(self, text='Close')
        bt.callback_clicked_add(lambda b: self.delete())
        self.part_content_set('button1', bt)

        bt = Button(self, text='Clone')
        bt.callback_clicked_add(self._clone_btn_cb)
        self.part_content_set('button2', bt)

        bt = Button(self, text='Open')
        bt.callback_clicked_add(self._load_btn_cb)
        self.part_content_set('button3', bt)

        #
        self.show()
コード例 #42
0
    def __init__(self, parent_widget, *args, **kwargs):
        Box.__init__(self, parent_widget, *args, **kwargs)

        self.cancelCallback = None
        self.actionCallback = None

        self.__first_run = True
        self.use_theme = False
        self.override_theme_font_size = True
        self.override_font_size = 14
        self.theme_data = None
        self.default_font = 'Sans'
        self.default_font_style = 'Regular'
        self.default_font_size = 14
        self.selected_font = self.default_font
        self.selected_font_style = self.default_font_style
        self.selected_font_size = self.default_font_size
        self.font_style_str = self.get_text_style(self.selected_font,
                                                  self.selected_font_style,
                                                  self.selected_font_size)
        self.preview_text = 'abcdefghijk ABCDEFGHIJK'
        # Font size min and max
        self.fs_min = 8
        self.fs_max = 72

        lb = Label(self,
                   text="<br><hilight><i>Select Font</i></hilight>",
                   size_hint_weight=EXPAND_HORIZ,
                   size_hint_align=FILL_BOTH)
        lb.show()
        self.pack_end(lb)
        sp = Separator(self,
                       horizontal=True,
                       size_hint_weight=EXPAND_HORIZ,
                       size_hint_align=FILL_HORIZ)
        sp.show()
        self.pack_end(sp)
        # A horizontal box to hold our font list and font styles
        fontBox = Box(self,
                      horizontal=True,
                      homogeneous=True,
                      size_hint_weight=EXPAND_BOTH,
                      size_hint_align=FILL_BOTH)
        fontBox.show()
        self.pack_end(fontBox)
        # A vertical box to hold label and list of font families
        vBoxFL = Box(self,
                     size_hint_weight=EXPAND_BOTH,
                     size_hint_align=FILL_BOTH)
        vBoxFL.show()
        fontBox.pack_end(vBoxFL)
        # A vertical box to hold label and list of font styles
        vBoxFS = Box(self,
                     size_hint_weight=EXPAND_BOTH,
                     size_hint_align=FILL_BOTH)
        vBoxFS.show()
        fontBox.pack_end(vBoxFS)
        # Generate our needed font data
        #now =time.time()
        fonts = []
        fonts_raw = self.evas.font_available_list()
        # populate with default font families
        #   see elm_font_available_hash_add Function in EFL
        f_families = ['Sans', 'Serif', 'Monospace']
        f_styles = ['Regular', 'Italic', 'Bold', 'Bold Italic']
        fonts_raw += [i + ':style=' + s for i in f_families for s in f_styles]

        self.fonts_hash = {}
        for font in fonts_raw:
            a = font_properties_get(font)
            # if font name contains a '-' a.name will replace with '\\-'
            #   This needs removed to properly display the name
            fn = a.name.replace('\\', '')
            fonts.append(fn)
            if fn in self.fonts_hash:
                self.fonts_hash.setdefault(fn, []).append(a.styles[0])
            else:
                self.fonts_hash[fn] = [a.styles[0]]

        # Deal with some problematic special cases
        for a, s in self.fonts_hash.items():
            #print(a,s)
            if s:
                if len(s) == 1:
                    s[0] = s[0].rstrip()
                    if s[0] == u'regular':
                        s[0] = u'Regular'
                    if s[0] == u'Medium Italic':
                        self.fonts_hash.setdefault(a,
                                                   []).append(u'Bold Italic')
                    elif s[0] == u'Italic':
                        if a != u'Romande ADF Script Std':
                            self.fonts_hash.setdefault(a,
                                                       []).append(u'Regular')
                            self.fonts_hash.setdefault(a, []).append(u'Bold')
                        self.fonts_hash.setdefault(a,
                                                   []).append(u'Bold Italic')
                    else:
                        self.fonts_hash.setdefault(a, []).append(u'Italic')
                        self.fonts_hash.setdefault(a, []).append(u'Bold')
                        self.fonts_hash.setdefault(a,
                                                   []).append(u'Bold Italic')
                elif len(s) == 2:
                    if any(u'Oblique' in w for w in s):
                        if a not in {
                                u'Baskervald ADF Std Heavy',
                                u'Latin Modern Roman Demi'
                        }:
                            self.fonts_hash.setdefault(a, []).append(u'Bold')
                            self.fonts_hash.setdefault(
                                a, []).append(u'Bold Oblique')
                    elif any(u'Italic' in w for w in s):
                        self.fonts_hash.setdefault(a, []).append(u'Bold')
                        self.fonts_hash.setdefault(a,
                                                   []).append(u'Bold Italic')
                    else:
                        self.fonts_hash.setdefault(a, []).append(u'Italic')
                        self.fonts_hash.setdefault(a,
                                                   []).append(u'Bold Italic')
                elif len(s) == 3 and set(s) == {
                        u'Bold', u'Oblique', u'Medium'
                }:
                    # case GWMonospace
                    self.fonts_hash.setdefault(a, []).append(u'Bold Oblique')
                elif len(s) == 3 and set(s) == {
                        u'Italic', u'Regular', u'Bold'
                }:
                    # Case Eden Mills
                    self.fonts_hash.setdefault(a, []).append(u'Bold Italic')
                elif len(s) < 4:
                    print("may need fixed Font style for %s: %s" % (a, s))
        #print(self.fonts_hash)

        # for some strange reason many fonts are displayed multiple times. The following lines remove
        # all duplicates and then sort them alphabetically.
        # FIXME: Is this still true
        fonts = list(set(fonts))
        fonts.sort(cmp=locale.strcoll)

        # Elm List for holding font options
        self.font_list = List(self,
                              size_hint_align=FILL_BOTH,
                              size_hint_weight=EXPAND_BOTH,
                              mode=ELM_LIST_LIMIT)
        #self.font_list.callback_selected_add(self.__font_demo_name_set)
        for font in fonts:
            self.font_list.item_append(font.replace('\\', ''))
            if font == self.selected_font:
                font_it = self.font_list.last_item_get()
        #print  (time.time()- now)
        self.font_list.go()
        self.font_list.show()

        font_family_label = Label(self)
        font_family_label.text = "<br><b>Font:</b>"
        font_family_label.show()
        vBoxFL.pack_end(font_family_label)
        vBoxFL.pack_end(self.font_list)

        # Elm List for hold font styles
        self.font_style = List(self,
                               size_hint_align=FILL_BOTH,
                               size_hint_weight=EXPAND_BOTH,
                               mode=ELM_LIST_LIMIT)
        #self.font_style.callback_selected_add(self.__font_demo_style_set)

        self.__reset_font_style_list(font_it.text_get())

        self.font_style.go()
        self.font_style.show()

        font_style_label = Label(self)
        font_style_label.text = "<br><b>Style:</b>"
        font_style_label.show()
        vBoxFS.pack_end(font_style_label)
        vBoxFS.pack_end(self.font_style)

        # A table to hold font size Spinner and set theme default Check
        tb = Table(self,
                   homogeneous=True,
                   size_hint_weight=EXPAND_HORIZ,
                   size_hint_align=FILL_HORIZ)
        self.pack_end(tb)
        tb.show()

        # spinner to choose the font size
        self.font_sizer = Spinner(self)
        self.font_sizer.min_max_set(self.fs_min, self.fs_max)
        self.font_sizer.value_set(self.selected_font_size)
        #self.font_sizer.callback_changed_add(self.__font_demo_size_set)
        self.font_sizer.show()
        # Label for Spinner
        font_sizer_label = Label(self)
        font_sizer_label.text = "Font Size:  "
        font_sizer_label.show()

        size_box = Box(self,
                       size_hint_weight=EXPAND_HORIZ,
                       size_hint_align=FILL_HORIZ)
        size_box.horizontal_set(True)
        size_box.pack_end(font_sizer_label)
        size_box.pack_end(self.font_sizer)
        size_box.show()
        tb.pack(size_box, 33, 0, 34, 34)

        self.use_theme_ck = Check(self,
                                  text="Theme Default   ",
                                  size_hint_weight=EXPAND_HORIZ,
                                  size_hint_align=(1, 0.5))
        self.use_theme_ck.callback_changed_add(self.__use_theme_checked)
        self.use_theme_ck.show()
        tb.pack(self.use_theme_ck, 67, 0, 33, 34)

        # Entry to hold sample text
        self.font_demo = Entry(self,
                               single_line=True,
                               editable=False,
                               context_menu_disabled=True,
                               text=self.preview_text,
                               scrollable=True,
                               size_hint_weight=EXPAND_HORIZ,
                               size_hint_align=FILL_HORIZ)
        self.font_demo.show()

        demo_box = Frame(self,
                         size_hint_align=FILL_BOTH,
                         text="Preview:",
                         content=self.font_demo)
        demo_box.show()

        # Fixme: move this shit
        font_it.selected_set(True)
        font_it.show()
        # Ensure focus is on Font List
        self.font_list.focus_set(True)
        self.pack_end(demo_box)

        # cancel and OK buttons
        ok_button = Button(self)
        ok_button.text = "OK"
        ok_button.callback_pressed_add(self.__ok_button_pressed)
        ok_button.show()

        cancel_button = Button(self)
        cancel_button.text = "Cancel"
        cancel_button.callback_pressed_add(self.__cancel_button_pressed)
        cancel_button.show()

        # box for buttons
        button_box = Box(self)
        button_box.horizontal_set(True)
        button_box.show()
        button_box.pack_end(cancel_button)
        button_box.pack_end(ok_button)
        self.pack_end(button_box)
コード例 #43
0
ファイル: gui.py プロジェクト: DaveMDS/egitu
    def populate(self):
        # main vertical box
        box = Box(self, size_hint_weight = EXPAND_BOTH)
        self.resize_object_add(box)
        box.show()

        ### header
        fr = Frame(self, style='outdent_bottom', size_hint_weight=EXPAND_HORIZ,
                   size_hint_align=FILL_BOTH)
        box.pack_end(fr)
        fr.show()

        tb = Table(self, padding=(3,3),
                   size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
        fr.content = tb
        tb.show()

        # main menu button
        bt = MainMenuButton(self.app)
        tb.pack(bt, 0, 0, 1, 1)
        bt.show()

        # editable description entry
        self.caption_label = EditableDescription(self.app)
        tb.pack(self.caption_label, 1, 0, 1, 1)
        self.caption_label.show()

        # status label + button
        lb = Entry(self, editable=False, line_wrap=ELM_WRAP_NONE)
        lb.text_style_user_push("DEFAULT='align=center'")
        tb.pack(lb, 2, 0, 1, 1)
        lb.show()
        self.status_label = lb

        # branch selector
        self.branch_selector = Hoversel(self, text='HEAD', disabled=True,
                                        content=SafeIcon(self, 'git-branch'))
        self.branch_selector.callback_selected_add(self.branch_selected_cb)
        tb.pack(self.branch_selector, 3, 0, 1, 1)
        self.branch_selector.show()

        # pull button
        bt = Button(self, text='Pull', disabled=True,
                    content=SafeIcon(self, 'git-pull'))
        bt.callback_clicked_add(self.app.action_pull)
        tb.pack(bt, 4, 0, 1, 1)
        bt.show()
        self.pull_btn = bt

        # push button
        bt = Button(self, text='Push', disabled=True,
                    content=SafeIcon(self, 'git-push'))
        bt.callback_clicked_add(self.app.action_push)
        tb.pack(bt, 5, 0, 1, 1)
        bt.show()
        self.push_btn = bt

        ### Tree panes
        panes1 = Panes(self, content_left_min_size=200, content_left_size=0.0,
                      size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        box.pack_end(panes1)
        panes1.show()

        # the sidebar on the left
        self.sidebar = Sidebar(self, self.app)
        panes1.part_content_set('left', self.sidebar)

        ### Main content (left + right panes)
        panes2 = Panes(self, content_left_size=0.5,
                       size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        panes1.part_content_set('right', panes2)
        panes2.show()

        # the dag graph in the center
        self.graph = DagGraph(self, self.app)
        panes2.part_content_set('left', self.graph)

        # the diff viewer on the right
        self.diff_view = DiffViewer(self, self.app)
        self.diff_view.size_hint_weight = EXPAND_BOTH
        self.diff_view.size_hint_align = 0.0, 0.0
        panes2.part_content_set('right', self.diff_view)

        #
        self.show()
コード例 #44
0
    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()
コード例 #45
0
ファイル: remotes.py プロジェクト: DaveMDS/egitu
    def __init__(self, app):
        self.app = app

        DialogWindow.__init__(self, app.win, 'egitu-remotes', 'Remotes',
                              autodel=True, size=(600,400))

        # main vertical box (inside a padding frame)
        fr = Frame(self, style='pad_medium', size_hint_weight=EXPAND_BOTH)
        self.resize_object_add(fr)
        fr.show()

        box = Box(fr, padding=(6,6))
        fr.content = box
        box.show()

        # panes
        panes = Panes(box, content_left_size=0.25,
                      size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        box.pack_end(panes)
        panes.show()

        ### remotes List (on the left)
        li = List(panes)
        li.callback_selected_add(self._list_selected_cb)
        panes.part_content_set('left', li)
        li.show()
        self.remotes_list = li

        ### remote info (on the right)
        tb = Table(self, padding=(4, 4))
        panes.part_content_set('right', tb)
        tb.show()

        # url
        lb = Label(self, text='URL', size_hint_align=(0.0,0.5))
        tb.pack(lb, 0, 0, 1, 1)
        lb.show()

        en = Entry(self, single_line=True, scrollable=True,
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        en.callback_changed_user_add(lambda e: \
                                setattr(self.save_url_btn, 'disabled', False))
        tb.pack(en, 1, 0, 1, 1)
        en.show()
        self.url_entry = en

        # fetch
        lb = Label(self, text='Fetch', size_hint_align=(0.0,0.5))
        tb.pack(lb, 0, 1, 1, 1)
        lb.show()

        en = Entry(self, single_line=True, scrollable=True, editable=False,
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        tb.pack(en, 1, 1, 1, 1)
        en.show()
        self.fetch_entry = en

        # save button
        bt = Button(self, text='Save', disabled=True,
                    size_hint_expand=EXPAND_VERT, size_hint_fill=FILL_VERT)
        bt.callback_clicked_add(self._save_url_clicked_cb)
        tb.pack(bt, 2, 0, 1, 1)
        bt.show()
        self.save_url_btn = bt

        # big info entry
        en = Entry(panes, scrollable=True, editable=False,
                   line_wrap=ELM_WRAP_NONE,
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        en.callback_clicked_add(self._info_clicked_cb)
        tb.pack(en, 0, 2, 3, 1)
        en.show()
        self.info_entry = en

        ### buttons bar
        hbox = Box(box, horizontal=True,
                   size_hint_expand=EXPAND_HORIZ, size_hint_fill=FILL_BOTH)
        box.pack_end(hbox)
        hbox.show()

        bt = Button(hbox, text='Add')
        bt.callback_clicked_add(lambda b: RemoteAddPopup(self, self.app.repo))
        hbox.pack_end(bt)
        bt.show()

        bt = Button(hbox, text='Remove')
        bt.callback_clicked_add(self._remove_btn_cb)
        hbox.pack_end(bt)
        bt.show()

        bt = Button(hbox, text='Refresh')
        bt.callback_clicked_add(lambda b: self.restart_dialog())
        hbox.pack_end(bt)
        bt.show()

        sep = Separator(hbox, size_hint_expand=EXPAND_HORIZ)
        hbox.pack_end(sep)

        bt = Button(hbox, text='Close')
        bt.callback_clicked_add(lambda b: self.delete())
        hbox.pack_end(bt)
        bt.show()

        # populate and show the dialog window
        self.restart_dialog()
        self.show()
コード例 #46
0
def photocam_clicked(obj):
    win = StandardWindow("photocam",
                         "Photocam test",
                         autodel=True,
                         size=(600, 600))
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    # Photocam widget
    pc = Photocam(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(pc)
    pc.show()

    # table for buttons
    tb = Table(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(tb)
    tb.show()

    # zoom out btn
    bt = Button(win,
                text="Z -",
                size_hint_weight=EXPAND_BOTH,
                size_hint_align=(0.1, 0.1))
    bt.callback_clicked_add(_cb_zoom_out, pc)
    tb.pack(bt, 0, 0, 1, 1)
    bt.show()

    # select file btn
    bt = FileselectorButton(win,
                            text="Select Photo File",
                            size_hint_weight=EXPAND_BOTH,
                            size_hint_align=(0.5, 0.1))
    bt.callback_file_chosen_add(lambda fs, path: pc.file_set(path))
    tb.pack(bt, 1, 0, 1, 1)
    bt.show()

    # zoom in btn
    bt = Button(win,
                text="Z +",
                size_hint_weight=EXPAND_BOTH,
                size_hint_align=(0.9, 0.1))
    bt.callback_clicked_add(_cb_zoom_in, pc)
    tb.pack(bt, 2, 0, 1, 1)
    bt.show()

    # progressbar for remote loading
    pb = Progressbar(win,
                     unit_format="loading %.2f %%",
                     size_hint_weight=EXPAND_BOTH,
                     size_hint_align=FILL_BOTH)
    tb.pack(pb, 1, 1, 1, 1)

    # Fit btn
    bt = Button(win,
                text="Fit",
                size_hint_weight=EXPAND_BOTH,
                size_hint_align=(0.1, 0.9))
    bt.callback_clicked_add(
        lambda b: pc.zoom_mode_set(ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT))
    tb.pack(bt, 0, 2, 1, 1)
    bt.show()

    # load remote url
    bt = Button(win,
                text="Load remote URL (27MB)",
                size_hint_weight=EXPAND_BOTH,
                size_hint_align=(0.5, 0.9))
    bt.callback_clicked_add(lambda b: pc.file_set(remote_url))
    tb.pack(bt, 1, 2, 1, 1)
    bt.show()

    pc.callback_download_start_add(_cb_pc_download_start, pb)
    pc.callback_download_done_add(_cb_pc_download_done, pb)
    pc.callback_download_progress_add(_cb_pc_download_progress, pb)
    pc.callback_download_error_add(_cb_pc_download_error, pb)

    # Fill btn
    bt = Button(win,
                text="Fill",
                size_hint_weight=EXPAND_BOTH,
                size_hint_align=(0.9, 0.9))
    bt.callback_clicked_add(
        lambda b: pc.zoom_mode_set(ELM_PHOTOCAM_ZOOM_MODE_AUTO_FILL))
    tb.pack(bt, 2, 2, 1, 1)
    bt.show()

    # show the win
    win.show()