Exemple #1
0
 def confirmSave( self, ourCallback=None ):
     self.confirmPopup = Popup(self.mainWindow, size_hint_weight=EXPAND_BOTH)
     self.confirmPopup.part_text_set("title,text","File Unsaved")
     if self.mainEn.file_get()[0]:
         self.confirmPopup.text = "Save changes to '%s'?" % self.mainEn.file_get()[0].split("/")[len(self.mainEn.file_get()[0].split("/"))-1]
     else:
         self.confirmPopup.text = "Save changes to 'Untitlted'?"
     # Close without saving button
     no_btt = Button(self.mainWindow)
     no_btt.text = "No"
     no_btt.callback_clicked_add(self.closePopup, self.confirmPopup)
     if ourCallback is not None:
         no_btt.callback_clicked_add(ourCallback, True)
     no_btt.show()
     # cancel close request
     cancel_btt = Button(self.mainWindow)
     cancel_btt.text = "Cancel"
     cancel_btt.callback_clicked_add(self.closePopup, self.confirmPopup)
     cancel_btt.show()
     # Save the file and then close button
     sav_btt = Button(self.mainWindow)
     sav_btt.text = "Yes"
     sav_btt.callback_clicked_add(self.saveFile)
     sav_btt.callback_clicked_add(self.closePopup, self.confirmPopup)
     sav_btt.show()
     
     # add buttons to popup
     self.confirmPopup.part_content_set("button1", no_btt)
     self.confirmPopup.part_content_set("button2", cancel_btt)
     self.confirmPopup.part_content_set("button3", sav_btt)
     self.confirmPopup.show()
Exemple #2
0
    def confirmSave(self, ourCallback=None):
        self.confirmPopup = Popup(self.mainWindow,
                                  size_hint_weight=EXPAND_BOTH)
        self.confirmPopup.part_text_set("title,text", "File Unsaved")
        current_file = self.mainEn.file[0]
        current_file = \
            os.path.basename(current_file) if current_file else "Untitled"
        self.confirmPopup.text = "Save changes to '%s'?" % (current_file)
        # Close without saving button
        no_btt = Button(self.mainWindow)
        no_btt.text = "No"
        no_btt.callback_clicked_add(self.closePopup, self.confirmPopup)
        if ourCallback is not None:
            no_btt.callback_clicked_add(ourCallback, True)
        no_btt.show()
        # cancel close request
        cancel_btt = Button(self.mainWindow)
        cancel_btt.text = "Cancel"
        cancel_btt.callback_clicked_add(self.closePopup, self.confirmPopup)
        cancel_btt.show()
        # Save the file and then close button
        sav_btt = Button(self.mainWindow)
        sav_btt.text = "Yes"
        sav_btt.callback_clicked_add(self.saveFile)
        sav_btt.callback_clicked_add(self.closePopup, self.confirmPopup)
        sav_btt.show()

        # add buttons to popup
        self.confirmPopup.part_content_set("button1", no_btt)
        self.confirmPopup.part_content_set("button2", cancel_btt)
        self.confirmPopup.part_content_set("button3", sav_btt)
        self.confirmPopup.show()
Exemple #3
0
    def confirmSave(self, ourCallback=None):
        self.confirmPopup = Popup(self.mainWindow,
                                  size_hint_weight=EXPAND_BOTH)
        self.confirmPopup.part_text_set("title,text", "File Unsaved")
        current_file = self.mainEn.file[0]
        current_file = \
            os.path.basename(current_file) if current_file else "Untitled"
        self.confirmPopup.text = "Save changes to '%s'?" % (current_file)
        # Close without saving button
        no_btt = Button(self.mainWindow)
        no_btt.text = "No"
        no_btt.callback_clicked_add(self.closePopup, self.confirmPopup)
        if ourCallback is not None:
            no_btt.callback_clicked_add(ourCallback, True)
        no_btt.show()
        # cancel close request
        cancel_btt = Button(self.mainWindow)
        cancel_btt.text = "Cancel"
        cancel_btt.callback_clicked_add(self.closePopup, self.confirmPopup)
        cancel_btt.show()
        # Save the file and then close button
        sav_btt = Button(self.mainWindow)
        sav_btt.text = "Yes"
        sav_btt.callback_clicked_add(self.saveFile)
        sav_btt.callback_clicked_add(self.closePopup, self.confirmPopup)
        sav_btt.show()

        # add buttons to popup
        self.confirmPopup.part_content_set("button1", no_btt)
        self.confirmPopup.part_content_set("button2", cancel_btt)
        self.confirmPopup.part_content_set("button3", sav_btt)
        self.confirmPopup.show()
Exemple #4
0
    def __init__(self):
        StandardWindow.__init__(self, "ex4", "Align Example", size=(300, 200))
        self.callback_delete_request_add(lambda o: elm.exit())

        ourButton = Button(self)
        ourButton.size_hint_weight = EXPAND_BOTH
        ourButton.size_hint_align = (0, 0)
        ourButton.text = "Button 1"
        ourButton.show()

        ourButton2 = Button(self)
        ourButton2.size_hint_weight = EXPAND_BOTH
        ourButton2.size_hint_align = FILL_BOTH
        ourButton2.text = "Button 2"
        ourButton2.show()

        ourButton3 = Button(self)
        ourButton3.size_hint_weight = EXPAND_BOTH
        ourButton3.size_hint_align = (1, 1)
        ourButton3.text = "Button 3"
        ourButton3.show()

        ourBox = Box(self)
        ourBox.size_hint_weight = EXPAND_BOTH
        ourBox.pack_end(ourButton)
        ourBox.pack_end(ourButton2)
        ourBox.pack_end(ourButton3)
        ourBox.show()

        self.resize_object_add(ourBox)
Exemple #5
0
    def confirmSave(self, ourCallback=None):
        self.confirmPopup = Popup(self.mainWindow,
                                  size_hint_weight=EXPAND_BOTH)
        self.confirmPopup.part_text_set("title,text", "File Unsaved")
        if self.mainEn.file_get()[0]:
            self.confirmPopup.text = "Save changes to '%s'?" % self.mainEn.file_get(
            )[0].split("/")[len(self.mainEn.file_get()[0].split("/")) - 1]
        else:
            self.confirmPopup.text = "Save changes to 'Untitlted'?"
        # Close without saving button
        no_btt = Button(self.mainWindow)
        no_btt.text = "No"
        no_btt.callback_clicked_add(self.closePopup, self.confirmPopup)
        if ourCallback is not None:
            no_btt.callback_clicked_add(ourCallback, True)
        no_btt.show()
        # cancel close request
        cancel_btt = Button(self.mainWindow)
        cancel_btt.text = "Cancel"
        cancel_btt.callback_clicked_add(self.closePopup, self.confirmPopup)
        cancel_btt.show()
        # Save the file and then close button
        sav_btt = Button(self.mainWindow)
        sav_btt.text = "Yes"
        sav_btt.callback_clicked_add(self.saveFile)
        sav_btt.callback_clicked_add(self.closePopup, self.confirmPopup)
        sav_btt.show()

        # add buttons to popup
        self.confirmPopup.part_content_set("button1", no_btt)
        self.confirmPopup.part_content_set("button2", cancel_btt)
        self.confirmPopup.part_content_set("button3", sav_btt)
        self.confirmPopup.show()
 def __init__(self):
     StandardWindow.__init__(self, "ex4", "Align Example", size=(300, 200))
     self.callback_delete_request_add(lambda o: elm.exit())
     
     ourButton = Button(self)
     ourButton.size_hint_weight = EXPAND_BOTH
     ourButton.size_hint_align = (0, 0)
     ourButton.text = "Button 1"
     ourButton.show()
     
     ourButton2 = Button(self)
     ourButton2.size_hint_weight = EXPAND_BOTH
     ourButton2.size_hint_align = FILL_BOTH
     ourButton2.text = "Button 2"
     ourButton2.show()
     
     ourButton3 = Button(self)
     ourButton3.size_hint_weight = EXPAND_BOTH
     ourButton3.size_hint_align = (1, 1)
     ourButton3.text = "Button 3"
     ourButton3.show()
     
     ourBox = Box(self)
     ourBox.size_hint_weight = EXPAND_BOTH
     ourBox.pack_end(ourButton)
     ourBox.pack_end(ourButton2)
     ourBox.pack_end(ourButton3)
     ourBox.show()
     
     self.resize_object_add(ourBox)
Exemple #7
0
    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()
 def __init__(self, canvas, exit_func):
     n = Popup(canvas)
     n.part_text_set("title,text", "Confirm exit")
     n.text = "Are you sure you wish to exit Epour?"
     b = Button(canvas)
     b.text = "Yes"
     b.callback_clicked_add(lambda x: exit_func())
     n.part_content_set("button1", b)
     b = Button(canvas)
     b.text = "No"
     b.callback_clicked_add(lambda x: n.delete())
     n.part_content_set("button2", b)
     n.show()
    def __init__(self):
        StandardWindow.__init__(self, "ex7", "Naviframe", size=(300, 200))
        self.callback_delete_request_add(lambda o: elm.exit())

        staticImage = staticImage = Image(self)
        staticImage.size_hint_weight = EXPAND_BOTH
        staticImage.file_set("images/logo.png")
        staticImage.tooltip_text_set("A picture!")
        staticImage.show()

        ourLabel = ourLabel = Label(self)
        ourLabel.size_hint_weight = EXPAND_BOTH
        ourLabel.text = "Hey look some text!"
        ourLabel.show()

        self.nf = Naviframe(self)
        self.nf.size_hint_weight = EXPAND_BOTH
        self.nf.size_hint_align = FILL_BOTH
        self.nf.show()

        buttonOne = Button(self)
        buttonOne.size_hint_weight = EXPAND_BOTH
        buttonOne.text = "Show image"
        buttonOne.callback_clicked_add(self.buttonPressed, staticImage)
        buttonOne.show()

        buttonTwo = Button(self)
        buttonTwo.size_hint_weight = EXPAND_BOTH
        buttonTwo.text = "Show label"
        buttonTwo.callback_clicked_add(self.buttonPressed, ourLabel)
        buttonTwo.show()

        buttonBox = Box(self)
        buttonBox.size_hint_weight = EXPAND_HORIZ
        buttonBox.horizontal_set(True)
        buttonBox.pack_end(buttonOne)
        buttonBox.pack_end(buttonTwo)
        buttonBox.show()

        mainBox = Box(self)
        mainBox.size_hint_weight = EXPAND_BOTH
        mainBox.pack_end(self.nf)
        mainBox.pack_end(buttonBox)
        mainBox.show()

        self.nf.item_simple_push(staticImage)

        self.resize_object_add(mainBox)
    def __init__(self):
        StandardWindow.__init__(self, "ex7", "Naviframe", size=(300, 200))
        self.callback_delete_request_add(lambda o: elm.exit())

        staticImage = staticImage = Image(self)
        staticImage.size_hint_weight = EXPAND_BOTH
        staticImage.file_set("images/logo.png")
        staticImage.tooltip_text_set("A picture!")
        staticImage.show()
        
        ourLabel = ourLabel = Label(self)
        ourLabel.size_hint_weight = EXPAND_BOTH
        ourLabel.text = "Hey look some text!"
        ourLabel.show()
        
        self.nf = Naviframe(self)
        self.nf.size_hint_weight = EXPAND_BOTH
        self.nf.size_hint_align = FILL_BOTH
        self.nf.show()
        
        buttonOne = Button(self)
        buttonOne.size_hint_weight = EXPAND_BOTH
        buttonOne.text = "Show image"
        buttonOne.callback_clicked_add(self.buttonPressed, staticImage)
        buttonOne.show()
        
        buttonTwo = Button(self)
        buttonTwo.size_hint_weight = EXPAND_BOTH
        buttonTwo.text = "Show label"
        buttonTwo.callback_clicked_add(self.buttonPressed, ourLabel)
        buttonTwo.show()
        
        buttonBox = Box(self)
        buttonBox.size_hint_weight = EXPAND_HORIZ
        buttonBox.horizontal_set(True)
        buttonBox.pack_end(buttonOne)
        buttonBox.pack_end(buttonTwo)
        buttonBox.show()
        
        mainBox = Box(self)
        mainBox.size_hint_weight = EXPAND_BOTH
        mainBox.pack_end(self.nf)
        mainBox.pack_end(buttonBox)
        mainBox.show()
        
        self.nf.item_simple_push(staticImage)
        
        self.resize_object_add(mainBox)
Exemple #11
0
    def __init__(self, parent, session):
        Frame.__init__(self, parent)

        self.session = session

        self.size_hint_align = FILL_HORIZ
        self.text = "Listen port (range)"

        port = session.listen_port()

        b = Box(parent)
        b.size_hint_weight = EXPAND_HORIZ

        lp = self.lp = RangeSpinners(
            parent,
            low=session.conf.getint("Settings", "listen_low"),
            high=session.conf.getint("Settings", "listen_high"),
            minim=0,
            maxim=65535)
        lp.show()
        b.pack_end(lp)

        save = Button(parent)
        save.text = "Apply"
        save.callback_clicked_add(self.save_cb)
        save.show()
        b.pack_end(save)

        b.show()

        self.content = b
Exemple #12
0
 def buildSubs(self):
     self.subWin = Window("lifetracker", ELM_WIN_DIALOG_BASIC, self, size=(300, 300))
     self.subWin.title = "Life Tracker Assignment"
     bg = Background(self.subWin, size_hint_weight=EXPAND_BOTH)
     bg.show()
     self.subWin.resize_object_add(bg)
     self.subWin.callback_delete_request_add(lambda o: elm.exit())
     self.ourWin = Window("lifetracker", ELM_WIN_DIALOG_BASIC, self, size=(300, 300))
     self.ourWin.title = "Life Tracker Key Strokes"
     bg = Background(self.ourWin, size_hint_weight=EXPAND_BOTH)
     bg.show()
     self.ourWin.resize_object_add(bg)
     self.ourWin.callback_delete_request_add(lambda o: elm.exit())
     self.ourWin.elm_event_callback_add(self.eventsCb)
     
     self.ourLife = ourLabel = Entry(self.ourWin, editable=False)
     ourLabel.size_hint_weight = EXPAND_BOTH
     ourLabel.size_hint_align = FILL_BOTH
     ourLabel.text_style_user_push("DEFAULT='font_size=20'")
     ourLabel.text = "Up and Down for Their Life, Left and Right for Mine"
     ourLabel.show()
     
     self.ourEntry = ourEntry = Entry(self.subWin)
     ourEntry.size_hint_weight = EXPAND_HORIZ
     ourEntry.size_hint_align = (-1, 0)
     ourEntry.single_line_set(True)
     ourEntry.text_style_user_push("DEFAULT='font_size=50'")
     ourEntry.callback_activated_add(self.ourLifeUpdate)
     ourEntry.text = "20"
     ourEntry.show()
     
     self.theirEntry = theirEntry = Entry(self.subWin)
     theirEntry.size_hint_weight = EXPAND_HORIZ
     theirEntry.size_hint_align = (-1, 0)
     theirEntry.single_line_set(True)
     theirEntry.text_style_user_push("DEFAULT='font_size=50'")
     theirEntry.callback_activated_add(self.theirLifeUpdate)
     theirEntry.text = "20"
     theirEntry.show()
     
     resetBtn = Button(self.subWin)
     resetBtn.text = "Reset life totals"
     resetBtn.callback_pressed_add(self.resetLifeTotals)
     resetBtn.show()
     
     entryBox = Box(self.subWin)
     entryBox.size_hint_weight = EXPAND_HORIZ
     entryBox.pack_end(ourEntry)
     entryBox.pack_end(theirEntry)
     entryBox.pack_end(resetBtn)
     entryBox.show()
     
     self.ourWin.resize_object_add(ourLabel)
     self.subWin.resize_object_add(entryBox)
     
     self.ourWin.show()
     self.subWin.show()
     
     self.ourWin.center(True, True)
     self.subWin.center(True, True)
Exemple #13
0
    def addPackage(self, pak):
        row = []

        ourCheck = Check(self)
        ourCheck.data['packageName'] = pak.name
        ourCheck.callback_changed_add(self.app.checkChange)
        ourCheck.show()
        row.append(ourCheck)

        ourName = Button(self, style="anchor", size_hint_weight=EXPAND_HORIZ,
                         size_hint_align=FILL_HORIZ)
        ourName.text = pak.name
        ourName.data["packageDes"] = pak.candidate.description
        ourName.callback_pressed_add(self.packagePressed)
        ourName.show()
        row.append(ourName)

        ourVersion = Label(self, size_hint_weight=EXPAND_HORIZ,
                           size_hint_align=(0.1, 0.5))
        ourVersion.text = pak.installed.version
        ourVersion.show()
        row.append(ourVersion)

        newVersion = Label(self, size_hint_weight=EXPAND_HORIZ,
                           size_hint_align=(0.1, 0.5))
        newVersion.text = pak.candidate.version
        newVersion.show()
        row.append(newVersion)

        self.app.packagesToUpdate[pak.name] = {'check':ourCheck, 'selected':False}
        self.packageList.row_pack(row, sort=False)
Exemple #14
0
    def select_torrent(self):
        sel = Fileselector(self.win)
        sel.expandable = False
        sel.path_set(os.path.expanduser("~"))
        sel.size_hint_weight_set(1.0, 1.0)
        sel.size_hint_align_set(-1.0, -1.0)
        sel.show()

        sf = Frame(self.win)
        sf.size_hint_weight_set(1.0, 1.0)
        sf.size_hint_align_set(-1.0, -1.0)
        sf.text = "Select torrent file"
        sf.content = sel
        sf.show()

        magnet = Entry(self.win)
        magnet.single_line = True
        magnet.scrollable = True
        if hasattr(magnet, "cnp_selection_get"):
            magnet.cnp_selection_get(ELM_SEL_TYPE_CLIPBOARD,
                                     ELM_SEL_FORMAT_TEXT)
        else:
            import pyperclip
            t = pyperclip.paste()
            if t is not None and t.startswith("magnet:"):
                magnet.entry = t
        magnet.show()

        mf = Frame(self.win)
        mf.size_hint_weight_set(1.0, 0.0)
        mf.size_hint_align_set(-1.0, 0.0)
        mf.text = "Or enter magnet URI here"
        mf.content = magnet
        mf.show()

        mbtn = Button(self.win)
        mbtn.text = "Done"
        mbtn.show()
        mbox = Box(self.win)
        mbox.size_hint_weight_set(1.0, 0.0)
        mbox.size_hint_align_set(-1.0, 0.0)
        mbox.horizontal = True
        mbox.pack_end(mf)
        mbox.pack_end(mbtn)
        mbox.show()

        box = Box(self.win)
        box.size_hint_weight = (1.0, 1.0)
        box.size_hint_align = (-1.0, -1.0)
        box.pack_end(sf)
        box.pack_end(mbox)
        box.show()

        inwin = InnerWindow(self.win)
        inwin.content = box
        sel.callback_done_add(self.add_torrent_cb)
        sel.callback_done_add(lambda x, y: inwin.delete())
        mbtn.callback_clicked_add(self.add_magnet_uri_cb, magnet)
        mbtn.callback_clicked_add(lambda x: inwin.delete())
        inwin.activate()
    def __init__(self, parent, session):
        Frame.__init__(self, parent)

        self.session = session

        self.size_hint_align = FILL_HORIZ
        self.text = "Listen port (range)"

        port = session.listen_port()

        b = Box(parent)
        b.size_hint_weight = EXPAND_HORIZ

        lp = self.lp = RangeSpinners(
            parent,
            low = session.conf.getint("Settings", "listen_low"),
            high = session.conf.getint("Settings", "listen_high"),
            minim = 0, maxim = 65535)
        lp.show()
        b.pack_end(lp)

        save = Button(parent)
        save.text = "Apply"
        save.callback_clicked_add(self.save_cb)
        save.show()
        b.pack_end(save)

        b.show()

        self.content = b
    def __init__(self):
        StandardWindow.__init__(self,
                                "ex2",
                                "Hello Elementary",
                                size=(300, 200))
        self.callback_delete_request_add(lambda o: elm.exit())

        ourLabel = Label(self)
        ourLabel.size_hint_weight = EXPAND_BOTH
        ourLabel.text = "Hello Elementary!"
        ourLabel.show()

        ourButton = Button(self)
        ourButton.size_hint_weight = EXPAND_BOTH
        ourButton.text = "Goodbye Elementary"
        ourButton.callback_clicked_add(self.buttonPressed)
        ourButton.show()

        ourBox = Box(self)
        ourBox.size_hint_weight = EXPAND_BOTH
        ourBox.pack_end(ourLabel)
        ourBox.pack_end(ourButton)
        ourBox.show()

        self.resize_object_add(ourBox)
Exemple #17
0
    def addTab(self, widget, tabName, canClose=True, disabled=False):
        self.tabs.append(widget)

        btn = Button(self.buttonBox, style="anchor", size_hint_align=ALIGN_LEFT)
        btn.text = tabName
        btn.data["widget"] = widget
        btn.disabled = disabled
        btn.callback_clicked_add(self.showTab, widget)
        btn.show()

        icn = Icon(self.buttonBox)
        icn.standard_set("gtk-close")
        icn.show()

        cls = Button(self.buttonBox, content=icn, style="anchor", size_hint_align=ALIGN_LEFT)
        cls.data["widget"] = widget
        cls.callback_clicked_add(self.closeTab)
        cls.disabled = disabled
        if canClose:
            cls.show()

        sep = Separator(self.buttonBox, size_hint_align=ALIGN_LEFT)
        sep.show()

        self.buttonBox.pack_end(btn)
        self.buttonBox.pack_end(cls)
        self.buttonBox.pack_end(sep)

        #Arguments go: btn, cls, sep
        widget.data["close"] = cls
        widget.data["button"] = btn
        widget.data["sep"] = sep
        
        self.showTab(widget=widget)
    def select_torrent(self):
        sel = Fileselector(self.win)
        sel.expandable = False
        sel.path_set(os.path.expanduser("~"))
        sel.size_hint_weight_set(1.0, 1.0)
        sel.size_hint_align_set(-1.0, -1.0)
        sel.show()

        sf = Frame(self.win)
        sf.size_hint_weight_set(1.0, 1.0)
        sf.size_hint_align_set(-1.0, -1.0)
        sf.text = "Select torrent file"
        sf.content = sel
        sf.show()

        magnet = Entry(self.win)
        magnet.single_line = True
        magnet.scrollable = True
        if hasattr(magnet, "cnp_selection_get"):
            magnet.cnp_selection_get(ELM_SEL_TYPE_CLIPBOARD, ELM_SEL_FORMAT_TEXT)
        else:
            import pyperclip
            t = pyperclip.paste()
            if t is not None and t.startswith("magnet:"):
                    magnet.entry = t
        magnet.show()

        mf = Frame(self.win)
        mf.size_hint_weight_set(1.0, 0.0)
        mf.size_hint_align_set(-1.0, 0.0)
        mf.text = "Or enter magnet URI here"
        mf.content = magnet
        mf.show()

        mbtn = Button(self.win)
        mbtn.text = "Done"
        mbtn.show()
        mbox = Box(self.win)
        mbox.size_hint_weight_set(1.0, 0.0)
        mbox.size_hint_align_set(-1.0, 0.0)
        mbox.horizontal = True
        mbox.pack_end(mf)
        mbox.pack_end(mbtn)
        mbox.show()

        box = Box(self.win)
        box.size_hint_weight = (1.0, 1.0)
        box.size_hint_align = (-1.0, -1.0)
        box.pack_end(sf)
        box.pack_end(mbox)
        box.show()

        inwin = InnerWindow(self.win)
        inwin.content = box
        sel.callback_done_add(self.add_torrent_cb)
        sel.callback_done_add(lambda x, y: inwin.delete())
        mbtn.callback_clicked_add(self.add_magnet_uri_cb, magnet)
        mbtn.callback_clicked_add(lambda x: inwin.delete())
        inwin.activate()
    def __init__(self):
        win = StandardWindow("Testing", "Elementary Sorted Table")
        # pylint: disable=no-member
        win.callback_delete_request_add(lambda o: elm.exit())
        # Build the titles for the table. The titles is a list of tuples
        #   with the following format:
        #       ( <str - Header Text>, <Bool - Sortable> )'''
        titles = []
        for i in range(COLUMNS):
            titles.append(("Column " + str(i), True if i != 2 else False))

        # Create our sorted list object
        slist = SortedList(win,
                           titles=titles,
                           size_hint_weight=EXPAND_BOTH,
                           size_hint_align=FILL_BOTH)

        # Populate the rows in our table
        for _i in range(ROWS):
            # Each row is a list with the number of elements
            #   that must equal the number of headers
            row = []
            for j in range(COLUMNS):
                # Row elements can be ANY elementary object
                if j == 0:
                    # For the first column in each row, we will create a button
                    #    that will delete the row when pressed
                    btn = Button(slist,
                                 size_hint_weight=EXPAND_BOTH,
                                 size_hint_align=FILL_BOTH)
                    btn.text = "Delete row"
                    btn.callback_clicked_add(
                        lambda x, y=row: slist.row_unpack(y, delete=True))
                    btn.show()
                    # Add the btn created to our row
                    row.append(btn)
                else:
                    # For each other row create a label with a random number
                    data = random.randint(0, ROWS * COLUMNS)
                    label = Label(slist,
                                  size_hint_weight=EXPAND_BOTH,
                                  size_hint_align=FILL_BOTH)
                    label.text = str(data)
                    # For integer data we also need to assign value to "sort_data"
                    #     because otherwise things get sorted as text
                    label.data["sort_data"] = data
                    label.show()
                    # Append our label to the row
                    row.append(label)
            # Add the row into the SortedList
            slist.row_pack(row, sort=False)

        # Show the list
        slist.show()
        win.resize_object_add(slist)
        win.resize(600, 400)
        win.show()
 def __init__(self, canvas, title, text):
     n = Popup(canvas)
     n.part_text_set("title,text", title)
     n.text = text
     b = Button(canvas)
     b.text = "OK"
     b.callback_clicked_add(lambda x: n.delete())
     n.part_content_set("button1", b)
     n.show()
    def __init__( self ):
        win = StandardWindow("Testing", "Elementary Sorted Table")
        win.callback_delete_request_add(lambda o: elm.exit())

        """Build the titles for the table. The titles is a list of tuples with the following format:
        
        ( <String - Header Text>, <Bool - Sortable> )"""
        titles = []
        for i in range(COLUMNS):
            titles.append(
                    ("Column " + str(i), True if i != 2 else False)
                    )

        #Create our sorted list object
        slist = SortedList(win, titles=titles, size_hint_weight=EXPAND_BOTH,
            size_hint_align=FILL_BOTH)

        #Populate the rows in our table
        for i in range(ROWS):
            #Each row is a list with the number of elements that must equal the number of headers
            row = []
            for j in range(COLUMNS):
                #Row elements can be ANY elementary object
                if j == 0:
                    #For the first column in each row, we will create a button that will delete the row when pressed
                    btn = Button(slist, size_hint_weight=EXPAND_BOTH,
                                size_hint_align=FILL_BOTH)
                    btn.text = "Delete row"
                    btn.callback_clicked_add(
                        lambda x, y=row: slist.row_unpack(y, delete=True)
                        )
                    btn.show()
                    #Add the btn created to our row
                    row.append(btn)
                else:
                    #For each other row create a label with a random number
                    data = random.randint(0, ROWS*COLUMNS)
                    lb = Label(slist, size_hint_weight=EXPAND_BOTH,
                                size_hint_align=FILL_BOTH)
                    lb.text=str(data)
                    """For integer data we also need to assign value to "sort_data" because otherwise things get sorted as text"""
                    lb.data["sort_data"] = data
                    lb.show()
                    #Append our label to the row
                    row.append(lb)
            #Add the row into the SortedList
            slist.row_pack(row, sort=False)
        
        #Show the list
        slist.show()
        
        win.resize_object_add(slist)

        win.resize(600, 400)
        win.show()
    def __init__(self, parent, h):
        Box.__init__(self, parent)

        filelist = Genlist(self)
        filelist.size_hint_align = -1.0, -1.0
        filelist.size_hint_weight = 1.0, 1.0

        self.populate(filelist, h)

        filelist.callback_activated_add(self.item_activated_cb)
        filelist.show()

        sel_all = Button(self)
        sel_all.text = "Select all"
        sel_all.callback_clicked_add(self.select_all_cb, filelist, h, True)
        sel_all.show()

        sel_none = Button(self)
        sel_none.text = "Select none"
        sel_none.callback_clicked_add(self.select_all_cb, filelist, h, False)
        sel_none.show()

        xbtn = Button(self)
        xbtn.text = "Close"
        xbtn.callback_clicked_add(lambda x: parent.item_pop())
        xbtn.show()

        btn_box = Box(self)
        btn_box.horizontal = True
        btn_box.pack_end(sel_all)
        btn_box.pack_end(sel_none)
        btn_box.pack_end(xbtn)
        btn_box.show()

        self.pack_end(filelist)
        self.pack_end(btn_box)
        self.show()
Exemple #23
0
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()
    def __init__(self, parent_widget, titles=None, *args, **kwargs):
        Box.__init__(self, parent_widget, *args, **kwargs)

        self.outPut = Entry(self,
                            size_hint_weight=EXPAND_BOTH,
                            size_hint_align=FILL_BOTH)
        self.outPut.editable_set(False)
        self.outPut.scrollable_set(True)
        self.outPut.callback_changed_add(self.changedCb)
        self.outPut.show()

        frame = Frame(self,
                      size_hint_weight=EXPAND_HORIZ,
                      size_hint_align=FILL_HORIZ)
        frame.text = "Input:"
        frame.autocollapse_set(True)
        frame.collapse_go(True)
        frame.show()

        bx = Box(self,
                 size_hint_weight=EXPAND_HORIZ,
                 size_hint_align=FILL_HORIZ)
        bx.horizontal = True
        bx.show()

        frame.content = bx

        self.inPut = Entry(self,
                           size_hint_weight=EXPAND_BOTH,
                           size_hint_align=FILL_BOTH)
        self.inPut.single_line_set(True)
        self.inPut.callback_activated_add(self.enterPressed)
        self.inPut.show()

        enterButton = Button(self)
        enterButton.text = "Execute"
        enterButton.callback_pressed_add(self.enterPressed)
        enterButton.show()

        bx.pack_end(self.inPut)
        bx.pack_end(enterButton)

        self.pack_end(self.outPut)
        self.pack_end(frame)

        self.cmd_exe = None
        self.done_cb = None
Exemple #25
0
    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)
Exemple #26
0
    def __init__(self, parent_widget, *args, **kwargs):
        Box.__init__(self, parent_widget, *args, **kwargs)

        self.output = Entry(self,
                            size_hint_weight=EXPAND_BOTH,
                            size_hint_align=FILL_BOTH)
        self.output.editable_set(False)
        self.output.scrollable_set(True)
        self.output.callback_changed_add(self.cb_changed)
        self.output.show()

        frame = Frame(self,
                      size_hint_weight=EXPAND_HORIZ,
                      size_hint_align=FILL_HORIZ)
        frame.text = 'Input:'
        frame.autocollapse_set(True)
        frame.collapse_go(True)
        frame.show()

        hbx = Box(self,
                  size_hint_weight=EXPAND_HORIZ,
                  size_hint_align=FILL_HORIZ)
        hbx.horizontal = True
        hbx.show()

        frame.content = hbx

        self.input = Entry(self,
                           size_hint_weight=EXPAND_BOTH,
                           size_hint_align=FILL_BOTH)
        self.input.single_line_set(True)
        self.input.callback_activated_add(self.cb_enter)
        self.input.show()

        enter_btn = Button(self)
        enter_btn.text = 'Execute'
        enter_btn.callback_pressed_add(self.cb_enter)
        enter_btn.show()

        hbx.pack_end(self.input)
        hbx.pack_end(enter_btn)

        self.pack_end(self.output)
        self.pack_end(frame)

        self.cmd_exe = None
        self.done_cb = None
    def __init__(self, parent, session):
        self.session = session

        Frame.__init__(self, parent)
        self.size_hint_align = -1.0, 0.0
        self.text = "Encryption settings"

        pes = self.pes = session.get_pe_settings()

        b = Box(parent)

        enc_values = lt.enc_policy.disabled, lt.enc_policy.enabled, lt.enc_policy.forced
        enc_levels = lt.enc_level.plaintext, lt.enc_level.rc4, lt.enc_level.both

        inc = self.inc = ActSWithLabel(parent,
            "Incoming encryption", enc_values, pes.in_enc_policy)
        b.pack_end(inc)
        inc.show()

        out = self.out = ActSWithLabel(parent,
            "Outgoing encryption", enc_values, pes.out_enc_policy)
        b.pack_end(out)
        out.show()

        lvl = self.lvl = ActSWithLabel(parent,
            "Allowed encryption level", enc_levels, pes.allowed_enc_level)
        b.pack_end(lvl)
        lvl.show()

        prf = self.prf = Check(parent)
        prf.style = "toggle"
        prf.text = "Prefer RC4 ecryption"
        prf.state = pes.prefer_rc4
        b.pack_end(prf)
        prf.show()

        a_btn = Button(parent)
        a_btn.text = "Apply"
        a_btn.callback_clicked_add(self.apply)
        b.pack_end(a_btn)
        a_btn.show()

        b.show()
        self.content = b
Exemple #28
0
    def __init__(self, parent, session):
        self.session = session

        Frame.__init__(self, parent)
        self.size_hint_align = -1.0, 0.0
        self.text = "Encryption settings"

        pes = self.pes = session.get_pe_settings()

        b = Box(parent)

        enc_values = lt.enc_policy.disabled, lt.enc_policy.enabled, lt.enc_policy.forced
        enc_levels = lt.enc_level.plaintext, lt.enc_level.rc4, lt.enc_level.both

        inc = self.inc = ActSWithLabel(parent, "Incoming encryption",
                                       enc_values, pes.in_enc_policy)
        b.pack_end(inc)
        inc.show()

        out = self.out = ActSWithLabel(parent, "Outgoing encryption",
                                       enc_values, pes.out_enc_policy)
        b.pack_end(out)
        out.show()

        lvl = self.lvl = ActSWithLabel(parent, "Allowed encryption level",
                                       enc_levels, pes.allowed_enc_level)
        b.pack_end(lvl)
        lvl.show()

        prf = self.prf = Check(parent)
        prf.style = "toggle"
        prf.text = "Prefer RC4 ecryption"
        prf.state = pes.prefer_rc4
        b.pack_end(prf)
        prf.show()

        a_btn = Button(parent)
        a_btn.text = "Apply"
        a_btn.callback_clicked_add(self.apply)
        b.pack_end(a_btn)
        a_btn.show()

        b.show()
        self.content = b
    def add(self, widget, name, can_close=True, disabled=False):
        '''Add a tab to the tabbed box'''
        self.tabs.append(widget)

        btn = Button(self.button_bx,
                     style="anchor",
                     size_hint_align=ALIGN_LEFT)
        btn.text = name
        btn.data["widget"] = widget
        btn.disabled = disabled
        btn.callback_clicked_add(self.show_tab, widget)
        btn.show()

        icn = Icon(self.button_bx)
        icn.standard_set("gtk-close")
        icn.show()

        cls = Button(self.button_bx,
                     content=icn,
                     style="anchor",
                     size_hint_align=ALIGN_LEFT)
        cls.data["widget"] = widget
        cls.callback_clicked_add(self.cb_close_btn)
        cls.disabled = disabled
        if can_close:
            cls.show()

        sep = Separator(self.button_bx, size_hint_align=ALIGN_LEFT)
        sep.show()

        self.button_bx.pack_end(btn)
        self.button_bx.pack_end(cls)
        self.button_bx.pack_end(sep)

        # Arguments go: btn, cls, sep
        widget.data["close"] = cls
        widget.data["button"] = btn
        widget.data["sep"] = sep

        self.show_tab(widget=widget)
    def __init__(self, parent_widget, titles=None, *args, **kwargs):
        Box.__init__(self, parent_widget, *args, **kwargs)

        self.outPut = Entry(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        self.outPut.editable_set(False)
        self.outPut.scrollable_set(True)
        self.outPut.callback_changed_add(self.changedCb)
        self.outPut.show()

        frame = Frame(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ)
        frame.text = "Input:"
        frame.autocollapse_set(True)
        frame.collapse_go(True)
        frame.show()

        bx = Box(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ)
        bx.horizontal = True
        bx.show()

        frame.content = bx

        self.inPut = Entry(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        self.inPut.single_line_set(True)
        self.inPut.callback_activated_add(self.enterPressed)
        self.inPut.show()

        enterButton = Button(self)
        enterButton.text = "Execute"
        enterButton.callback_pressed_add(self.enterPressed)
        enterButton.show()

        bx.pack_end(self.inPut)
        bx.pack_end(enterButton)

        self.pack_end(self.outPut)
        self.pack_end(frame)

        self.cmd_exe = None
        self.done_cb = None
    def __init__(self):
        StandardWindow.__init__(self, "ex2", "Hello Elementary", size=(300, 200))
        self.callback_delete_request_add(lambda o: elm.exit())

        ourLabel = Label(self)
        ourLabel.size_hint_weight = EXPAND_BOTH
        ourLabel.text = "Hello Elementary!"
        ourLabel.show()
        
        ourButton = Button(self)
        ourButton.size_hint_weight = EXPAND_BOTH
        ourButton.text = "Goodbye Elementary"
        ourButton.callback_clicked_add(self.buttonPressed)
        ourButton.show()
        
        ourBox = Box(self)
        ourBox.size_hint_weight = EXPAND_BOTH
        ourBox.pack_end(ourLabel)
        ourBox.pack_end(ourButton)
        ourBox.show()
        
        self.resize_object_add(ourBox)
Exemple #32
0
    def addPackage(self, pak):
        row = []

        ourCheck = Check(self)
        ourCheck.data['packageName'] = pak.name
        ourCheck.callback_changed_add(self.app.checkChange)
        ourCheck.show()
        row.append(ourCheck)

        ourName = Button(self,
                         style="anchor",
                         size_hint_weight=EXPAND_HORIZ,
                         size_hint_align=FILL_HORIZ)
        ourName.text = pak.name
        ourName.data["packageDes"] = pak.candidate.description
        ourName.callback_pressed_add(self.packagePressed)
        ourName.show()
        row.append(ourName)

        ourVersion = Label(self,
                           size_hint_weight=EXPAND_HORIZ,
                           size_hint_align=(0.1, 0.5))
        ourVersion.text = pak.installed.version
        ourVersion.show()
        row.append(ourVersion)

        newVersion = Label(self,
                           size_hint_weight=EXPAND_HORIZ,
                           size_hint_align=(0.1, 0.5))
        newVersion.text = pak.candidate.version
        newVersion.show()
        row.append(newVersion)

        self.app.packagesToUpdate[pak.name] = {
            'check': ourCheck,
            'selected': False
        }
        self.packageList.row_pack(row, sort=False)
Exemple #33
0
    def __init__(self,
                 command=None,
                 win=None,
                 start_callback=None,
                 end_callback=None,
                 *args,
                 **kwargs):
        if not win:
            nowindow = True
            win = self.win = Window("esudo", ELM_WIN_DIALOG_BASIC)
            win.title = "eSudo"
            win.borderless = True
            win.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND
            win.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
            win.resize(300, 200)
            win.callback_delete_request_add(lambda o: elementary.exit())
            win.layer_set(11)
            #~ win.fullscreen = True
            win.show()
            win.activate()

            bg = Background(win)
            bg.size_hint_weight = 1.0, 1.0
            win.resize_object_add(bg)
            bg.show()

            self.embedded = False
        else:
            nowindow = False
            self.embedded = True

        self.cmd = command
        self.start_cb = start_callback if callable(start_callback) else None
        self.end_cb = end_callback if callable(end_callback) else None
        self.args = args
        self.kwargs = kwargs

        #--------eSudo Window
        bz = Box(win)
        if nowindow:
            bz.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0
        else:
            bz.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND
        bz.size_hint_align = evas.EVAS_HINT_FILL, 0.0
        bz.show()

        if nowindow:
            lbl = Label(win)
            lbl.style = "marker"
            lbl.color = 170, 170, 170, 255
            lbl.size_hint_align = 0.5, 0.0
            lbl.scale = 2.0
            lbl.text = "<b>eSudo</b>"
            bz.pack_end(lbl)
            lbl.show()

            sep = Separator(win)
            sep.horizontal = True
            bz.pack_end(sep)
            sep.show()

        fr = Frame(win)
        fr.text = "Command:"
        fr.size_hint_align = evas.EVAS_HINT_FILL, 0.0
        bz.pack_end(fr)
        fr.show()

        if nowindow:
            sep = Separator(win)
            sep.horizontal = True
            bz.pack_end(sep)
            sep.show()

        self.cmdline = cmdline = Entry(win)
        cmdline.elm_event_callback_add(self.entry_event)
        cmdline.single_line = True
        if self.cmd:
            cmdline.text = self.cmd
            cmdline.editable = False
        fr.content = cmdline
        cmdline.scrollable_set(True)
        cmdline.show()

        if nowindow:
            fr = Frame(win)
            fr.text = "Password:"******"<b>Password:</b>"
            lb.size_hint_align = 0.0, 0.5
            bz1.pack_end(lb)
            lb.show()

        en = self.en = Entry(win)
        en.name = "password"
        en.elm_event_callback_add(self.entry_event)
        en.single_line = True
        en.password = True
        en.show()

        if nowindow:
            fr.content = en
        else:
            bz1.pack_end(en)

        sep = Separator(win)
        sep.horizontal = True
        bz.pack_end(sep)
        sep.show()

        btnb = Box(win)
        btnb.horizontal = True
        btnb.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0
        btnb.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
        bz.pack_end(btnb)
        btnb.show()

        bt = Button(win)
        bt.text = "Cancel"
        bt.callback_clicked_add(self.esudo_cancel, en)
        bt.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
        bt.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0
        btnb.pack_end(bt)
        bt.show()

        bt = Button(win)
        bt.text = "OK"
        bt.callback_clicked_add(self.password_check, en)
        bt.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
        bt.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0
        btnb.pack_end(bt)
        bt.show()

        self.iw = iw = InnerWindow(win)
        iw.content = bz
        iw.show()
        iw.activate()
        if self.cmd:
            en.focus = True
    def __init__(self, parent, h):
        if not h.is_valid():
            Information(parent.win, "Invalid torrent handle.")
            return

        if not h.has_metadata():
            Information(parent.win, "Torrent contains no metadata.")
            return

        i = h.get_torrent_info()

        InnerWindow.__init__(self, parent.win)

        box = Box(self)
        box.size_hint_align = -1.0, -1.0
        box.size_hint_weight = 1.0, 1.0

        tname = Label(self)
        tname.size_hint_align = -1.0, 0.5
        tname.line_wrap = ELM_WRAP_CHAR
        tname.ellipsis = True
        tname.text = "{}".format(cgi.escape(i.name()))
        tname.show()
        box.pack_end(tname)

        for func in i.comment, i.creation_date, i.creator:
            try:
                w = func()
            except Exception as e:
                log.debug(e)
            else:
                if w:
                    f = Frame(self)
                    f.size_hint_align = -1.0, 0.0
                    f.text = func.__name__.replace("_", " ").capitalize()
                    l = Label(self)
                    l.ellipsis = True
                    l.text = cgi.escape(str(w))
                    l.show()
                    f.content = l
                    f.show()
                    box.pack_end(f)

        tpriv = Check(self)
        tpriv.size_hint_align = 0.0, 0.0
        tpriv.text = "Private"
        tpriv.tooltip_text_set("Whether this torrent is private.<br> \
            i.e., it should not be distributed on the trackerless network<br> \
            (the kademlia DHT).")
        tpriv.disabled = True
        tpriv.state = i.priv()

        magnet_uri = lt.make_magnet_uri(h)

        f = Frame(self)
        f.size_hint_align = -1.0, 0.0
        f.text = "Magnet URI"
        me_box = Box(self)
        me_box.horizontal = True
        me = Entry(self)
        me.size_hint_align = -1.0, 0.0
        me.size_hint_weight = 1.0, 0.0
        #me.editable = False
        me.entry = magnet_uri
        me_box.pack_end(me)
        me.show()
        me_btn = Button(self)
        me_btn.text = "Copy"
        if hasattr(me, "cnp_selection_set"):
            me_btn.callback_clicked_add(
                lambda x: me.top_widget.cnp_selection_set(
                    ELM_SEL_TYPE_CLIPBOARD, ELM_SEL_FORMAT_TEXT, me.text))
        else:
            import pyperclip
            me_btn.callback_clicked_add(lambda x: pyperclip.copy(magnet_uri))
        me_btn.show()
        me_box.pack_end(me_btn)
        me_box.show()
        f.content = me_box
        f.show()
        box.pack_end(f)

        fl_btn = Button(self)
        fl_btn.text = "Files ->"
        fl_btn.callback_clicked_add(self.file_list_cb, h)

        xbtn = Button(self)
        xbtn.text_set("Close")
        xbtn.callback_clicked_add(lambda x: self.delete())

        for w in tpriv, fl_btn, xbtn:
            w.show()
            box.pack_end(w)

        box.show()

        nf = self.nf = Naviframe(self)
        nf.item_simple_push(box)

        self.content_set(nf)
        self.activate()
Exemple #35
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)
    def __init__(self, parent, method):
        Popup.__init__(self, parent)
        self._method = method
        self._param_entry = None
        self._return_entry = None

        # title
        self.part_text_set('title,text', 'Method: %s()' % method.name)
        self.show()

        # content is vbox
        vbox = Box(parent)
        vbox.show()
        self.content = vbox

        # params label + entry
        if len(method.params) > 0:
            label = Label(parent)
            label.size_hint_align = 0.0, 0.5
            label.text = 'Params: ' + method.params_str
            label.show()
            vbox.pack_end(label)

            en = Entry(parent)
            self._param_entry = en
            en.editable = True
            en.scrollable = True
            en.single_line = True
            en.entry = ''
            en.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND
            en.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
            en.show()
            vbox.pack_end(en)

            sp = Separator(win)
            sp.horizontal = True
            sp.show()
            vbox.pack_end(sp)
        
        # returns label + entry
        label = Label(parent)
        label.size_hint_align = 0.0, 0.5
        label.text = 'Returns: '
        label.text += method.returns_str if method.returns_str else 'None'
        label.show()
        vbox.pack_end(label)

        en = Entry(parent)
        self._return_entry = en
        en.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND
        en.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
        en.editable = False
        en.scrollable = True
        en.disabled = True
        en.single_line = True # TODO this is wrong, but the only way to show the entry :/
        en.entry = '<br> <br> <br>'
        en.show()
        vbox.pack_end(en)

        # pretty print check button
        def pretty_output_clicked_cb(chk):
            options.pretty_output = chk.state
        ch = Check(parent)
        ch.size_hint_align = 0.0, 0.5
        ch.text = "Prettify output (loosing type infos)"
        ch.state = options.pretty_output
        ch.callback_changed_add(pretty_output_clicked_cb)
        ch.show()
        vbox.pack_end(ch)

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

        btn = Button(parent)
        btn.text = 'Clear output'
        btn.callback_clicked_add(lambda b: self._return_entry.entry_set(''))
        self.part_content_set('button2', btn)

        btn = Button(parent)
        btn.text = 'Run method'
        btn.callback_clicked_add(self.run_clicked_cb)
        self.part_content_set('button3', btn)
Exemple #37
0
    def __init__(self, parent, method):
        Popup.__init__(self, parent)
        self._method = method
        self._param_entry = None
        self._return_entry = None

        # title
        self.part_text_set('title,text', 'Method: %s()' % method.name)
        self.show()

        # content is vbox
        vbox = Box(parent)
        vbox.show()
        self.content = vbox

        # params label + entry
        if len(method.params) > 0:
            label = Label(parent)
            label.size_hint_align = 0.0, 0.5
            label.text = 'Params: ' + method.params_str
            label.show()
            vbox.pack_end(label)

            en = Entry(parent)
            self._param_entry = en
            en.editable = True
            en.scrollable = True
            en.single_line = True
            en.entry = ''
            en.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND
            en.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
            en.show()
            vbox.pack_end(en)

            sp = Separator(win)
            sp.horizontal = True
            sp.show()
            vbox.pack_end(sp)

        # returns label + entry
        label = Label(parent)
        label.size_hint_align = 0.0, 0.5
        label.text = 'Returns: '
        label.text += method.returns_str if method.returns_str else 'None'
        label.show()
        vbox.pack_end(label)

        en = Entry(parent)
        self._return_entry = en
        en.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND
        en.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
        en.editable = False
        en.scrollable = True
        en.disabled = True
        en.single_line = True  # TODO this is wrong, but the only way to show the entry :/
        en.entry = '<br> <br> <br>'
        en.show()
        vbox.pack_end(en)

        # pretty print check button
        def pretty_output_clicked_cb(chk):
            options.pretty_output = chk.state

        ch = Check(parent)
        ch.size_hint_align = 0.0, 0.5
        ch.text = "Prettify output (loosing type infos)"
        ch.state = options.pretty_output
        ch.callback_changed_add(pretty_output_clicked_cb)
        ch.show()
        vbox.pack_end(ch)

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

        btn = Button(parent)
        btn.text = 'Clear output'
        btn.callback_clicked_add(lambda b: self._return_entry.entry_set(''))
        self.part_content_set('button2', btn)

        btn = Button(parent)
        btn.text = 'Run method'
        btn.callback_clicked_add(self.run_clicked_cb)
        self.part_content_set('button3', btn)
    def __init__(self, parent, method):
        StandardWindow.__init__(self, "espionage", "Method", autodel=True)
        self._method = method
        self._param_entry = None
        self._return_entry = None

        # content is vbox (with surrounding pad frame)
        pad = Frame(self, style='pad_medium')
        pad.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
        pad.size_hint_align = EVAS_HINT_FILL, EVAS_HINT_FILL
        self.resize_object_add(pad)
        pad.show()

        vbox = Box(self)
        vbox.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
        vbox.size_hint_align = EVAS_HINT_FILL, EVAS_HINT_FILL
        pad.content = vbox
        vbox.show()

        # title
        f = "font_size=16 align=0.5 font_weight=Bold"
        en = Entry(self, text='<font %s>%s()</>' % (f, method.name))
        en.size_hint_weight = EVAS_HINT_EXPAND, 0.0
        en.size_hint_align = EVAS_HINT_FILL, 0.0
        en.editable = False
        vbox.pack_end(en)
        en.show()

        # params label + entry
        if len(method.params) > 0:
            label = Entry(self, editable=False)
            label.size_hint_weight = EVAS_HINT_EXPAND, 0.0
            label.size_hint_align = EVAS_HINT_FILL, 0.0
            pars = colored_params(method.params, omit_braces=True)
            label.text = 'Params: %s' % (pars if method.params else 'None')
            vbox.pack_end(label)
            label.show()

            en = Entry(self, editable=True, scrollable=True, single_line=True)
            en.size_hint_weight = EVAS_HINT_EXPAND, 0.0
            en.size_hint_align = EVAS_HINT_FILL, 0.0
            self._param_entry = en
            vbox.pack_end(en)
            en.show()

        # returns label + entry
        label = Entry(self, editable=False)
        label.size_hint_weight = EVAS_HINT_EXPAND, 0.0
        label.size_hint_align = EVAS_HINT_FILL, 0.0
        rets = colored_params(method.returns, omit_braces=True)
        label.text = 'Returns: %s' % (rets if method.returns else 'None')
        vbox.pack_end(label)
        label.show()

        en = Entry(self, editable=False, scrollable=True)
        en.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
        en.size_hint_align = EVAS_HINT_FILL, EVAS_HINT_FILL
        self._return_entry = en
        vbox.pack_end(en)
        en.show()

        # pretty print check button
        def pretty_output_clicked_cb(chk):
            options.pretty_output = chk.state

        ch = Check(self)
        ch.size_hint_align = 0.0, 0.5
        ch.text = "Prettify output (loosing type infos)"
        ch.state = options.pretty_output
        ch.callback_changed_add(pretty_output_clicked_cb)
        ch.show()
        vbox.pack_end(ch)

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

        # buttons
        hbox = Box(self, horizontal=True)
        hbox.size_hint_weight = EVAS_HINT_EXPAND, 0.0
        hbox.size_hint_align = EVAS_HINT_FILL, 0.5
        vbox.pack_end(hbox)
        hbox.show()

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

        btn = Button(self)
        btn.text = 'Clear output'
        btn.callback_clicked_add(lambda b: self._return_entry.entry_set(''))
        hbox.pack_end(btn)
        btn.show()

        btn = Button(self)
        btn.text = 'Run method'
        btn.callback_clicked_add(self.run_clicked_cb)
        hbox.pack_end(btn)
        btn.show()

        # show the window
        self.resize(300, 300)
        self.show()
Exemple #39
0
    def __init__(self,
                 command=None, win=None,
                 start_callback=None, end_callback=None,
                 *args, **kwargs):
        if not win:
            nowindow = True
            win = self.win = Window("esudo", ELM_WIN_DIALOG_BASIC)
            win.title = "eSudo"
            win.borderless = True
            win.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND
            win.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
            win.resize(300, 200)
            win.callback_delete_request_add(lambda o: elementary.exit())
            win.layer_set(11)
            #~ win.fullscreen = True
            win.show()
            win.activate()

            bg = Background(win)
            bg.size_hint_weight = 1.0, 1.0
            win.resize_object_add(bg)
            bg.show()

            self.embedded = False
        else:
            nowindow = False
            self.embedded = True

        self.cmd = command
        self.start_cb = start_callback if callable(start_callback) else None
        self.end_cb = end_callback if callable(end_callback) else None
        self.args = args
        self.kwargs = kwargs

#--------eSudo Window
        bz = Box(win)
        if nowindow:
            bz.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0
        else:
            bz.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND
        bz.size_hint_align = evas.EVAS_HINT_FILL, 0.0
        bz.show()

        if nowindow:
            lbl = Label(win)
            lbl.style = "marker"
            lbl.color = 170, 170, 170, 255
            lbl.size_hint_align = 0.5, 0.0
            lbl.scale = 2.0
            lbl.text = "<b>eSudo</b>"
            bz.pack_end(lbl)
            lbl.show()

            sep = Separator(win)
            sep.horizontal = True
            bz.pack_end(sep)
            sep.show()

        fr = Frame(win)
        fr.text = "Command:"
        fr.size_hint_align = evas.EVAS_HINT_FILL, 0.0
        bz.pack_end(fr)
        fr.show()

        if nowindow:
            sep = Separator(win)
            sep.horizontal = True
            bz.pack_end(sep)
            sep.show()

        self.cmdline = cmdline = Entry(win)
        cmdline.elm_event_callback_add(self.entry_event)
        cmdline.single_line = True
        if self.cmd:
            cmdline.text = self.cmd
            cmdline.editable = False
        fr.content = cmdline
        cmdline.scrollable_set(True)
        cmdline.show()

        if nowindow:
            fr = Frame(win)
            fr.text = "Password:"******"<b>Password:</b>"
            lb.size_hint_align = 0.0, 0.5
            bz1.pack_end(lb)
            lb.show()

        en = self.en = Entry(win)
        en.name = "password"
        en.elm_event_callback_add(self.entry_event)
        en.single_line = True
        en.password = True
        en.show()

        if nowindow:
            fr.content = en
        else:
            bz1.pack_end(en)

        sep = Separator(win)
        sep.horizontal = True
        bz.pack_end(sep)
        sep.show()

        btnb = Box(win)
        btnb.horizontal = True
        btnb.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0
        btnb.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
        bz.pack_end(btnb)
        btnb.show()

        bt = Button(win)
        bt.text = "Cancel"
        bt.callback_clicked_add(self.esudo_cancel, en)
        bt.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
        bt.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0
        btnb.pack_end(bt)
        bt.show()

        bt = Button(win)
        bt.text = "OK"
        bt.callback_clicked_add(self.password_check, en)
        bt.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
        bt.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0
        btnb.pack_end(bt)
        bt.show()

        self.iw = iw = InnerWindow(win)
        iw.content = bz
        iw.show()
        iw.activate()
        if self.cmd:
            en.focus = True
    def __init__(self, parent, session):
        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)
Exemple #41
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)