Пример #1
0
def main():
    Topics_List = getAllTopics()
    pub.topic = dmenu.show(Topics_List)

    if pub.topic not in Topics_List:
        prompt = 'Would you like to save this topic for future use (y/n)?: '
        choice = dmenu.show([], prompt=prompt)
        if choice.lower() == 'y':
            DB.execute('INSERT INTO topics VALUES (?)', (pub.topic, ))
            DB_Connection.commit()

    pub.LatexDoc = latex.LatexDoc()
    keyhooks.start()
Пример #2
0
def show(iters, defs=None, prompt='Choose: '):
    try:
        r = dmenu.show(iters, prompt=prompt)
        if not r: sys.exit()
        return r
    except:
        raise Exception
Пример #3
0
def getWeight():
    import dmenu
    weight = dmenu.show('',
                        lines=25,
                        case_insensitive=False,
                        prompt="Enter your weight 🎂")
    return weight
Пример #4
0
def dmenu_show(command_list: list, config: DmenuConfig = None):
    if config is None:
        config = DmenuConfig()
    return dmenu.show(command_list,
                      font=config.font,
                      case_insensitive=config.case_insensitive,
                      foreground_selected=config.color_selected_foreground,
                      background=config.color_bar_background,
                      lines=config.lines)
Пример #5
0
def get_selection(seq, prompt, lines=5, case_insensitive=True, font=None):
    if in_xsession:
        return dmenu.show(seq,
                          prompt=prompt,
                          lines=lines,
                          case_insensitive=case_insensitive,
                          font=font)
    else:
        fzf = FzfPrompt()
        return fzf.prompt(seq, '--cycle')[0]
Пример #6
0
 def __init__(self):
     self.current_user = "******"
     menu_prompt = ["Exit", "Poweroff", "Hibernate", "Reboot"]
     self.choices = ["NO", "YES"]
     prompt = dmenu.show(menu_prompt,
                         lines=20,
                         prompt="What Would like me to do ??")
     if prompt == menu_prompt[0]:
         self.exit()
     if prompt == menu_prompt[1]:
         self.poweroff()
     if prompt == menu_prompt[2]:
         self.hibernate()
     if prompt == menu_prompt[3]:
         self.reboot()
Пример #7
0
def prompt(entries, unless_stupid=True, allow_unknown_values=False, **kwargs):
    """
    Prompts the end user to make a choice
    @param entries: Iterable of choices to select from
    @param unless_stupid: If True and allow_unknown_values is False, do not prompt the user if there is only one choice
    @param allow_unknown_values: If False, it will raise InvalidValue if the user inputs a value not in the entities iterable
    @param kwargs: Other named arguments to be forwarded to dmenu
    @return: The selected value
    @raise InvalidValue: If allow_unknown_values is False and a value not in the entities was entered
    """
    if unless_stupid and not allow_unknown_values and len(entries) == 1:
        return entries[0]
    value = dmenu.show(entries,
                       bottom=True,
                       fast=True,
                       case_insensitive=True,
                       **kwargs)
    if not allow_unknown_values and value not in entries:
        raise InvalidValue(value)
    return value
Пример #8
0
        def bullet():
            prompt = "Note (major): " if bullet.major else "Note (minor): "
            note = dmenu.show([], prompt=prompt)
            if not note:
                return

            if not self.DateIsSet:
                pub.LatexDoc.setDate()
                pub.LatexDoc.replace('ITEMIZE', ITEMIZE)
                self.DateIsSet = True

            if bullet.major:
                pub.LatexDoc.replace('ITEM', ITEM % note)
                pub.LatexDoc.deleteEndRange('% SUB %', [])
            else:
                if '% SUB %' not in open(pub.LatexDoc.texFile).read():
                    pub.LatexDoc.replace('ITEM', SUBITEMIZE)

                pub.LatexDoc.replace('SUB', SUB % note)

            pub.LatexDoc.compile()
Пример #9
0
def prompt(known_inputs, display_prompt="", delay=0.5):
    """
    prompt user for input by loading dmenu

    :param known_inputs: input choices we allow
           ["0) Example Station", "2) Second Station"]
    :param display_prompt: any additional information to pass
    :param delay: how long to wait before showing prompt (default 0.5 seconds)
           a delay that is too low will react poorly with hotkeys

    :return: user selection

    """

    time.sleep(delay)
    (BLACK, GREEN) = ("#000000", "#00EE00")
    selection = dmenu.show(known_inputs, bottom=True,
                           prompt="pbd: {}".format(display_prompt),
                           foreground=GREEN, background=BLACK,
                           background_selected=BLACK,
                           foreground_selected=GREEN,
                           case_insensitive=True)
    return selection
Пример #10
0
def save_local():
    save_name = dmenu.show([''], prompt='type the filename (widout extension)')
    os.system("mv /tmp/screenshot.png /home/philip/pics/screenshots/" +
              save_name + ".png")
Пример #11
0
import dmenu
import urllib.request
import re

search_keyword = input("Inserisci cosa vuoi cercare: ")
html = urllib.request.urlopen("https://www.youtube.com/results?search_query=" + search_keyword.replace(" ", "%"))
video_ids = re.findall(r"watch\?v=(\S{11})", html.read().decode())

dmenu.show(video_ids, lines=10)

#video_ids_len = len(video_ids)

#for i in range(video_ids_len):
    #print("https://www.youtube.com/watch?v=" + video_ids[i])
Пример #12
0
def upload():
    client_id = "8e98531fa1631f6"
    PATH = "/tmp/screenshot.png"
    im = pyimgur.Imgur(client_id)
    uploaded_image = im.upload_image(PATH, title="Uploaded with PyImgur")
    print(uploaded_image.link)
    os.system("rm /tmp/screenshot.png")


def save_local():
    save_name = dmenu.show([''], prompt='type the filename (widout extension)')
    os.system("mv /tmp/screenshot.png /home/philip/pics/screenshots/" +
              save_name + ".png")


os.system("gnome-screenshot -a -f /tmp/screenshot.png 2> /dev/null")

if dmenu.show(['local', 'imgur']) == 'imgur':
    try:
        upload()
    except:
        if dmenu.show(['yes', 'no'],
                      prompt='could not upload to upload to Imgur! save local?'
                      ) == 'yes':
            save_local()
        else:
            os.system("rm /tmp/screenshot.png")
            exit()
else:
    save_local()
Пример #13
0
 def exit(self):
     confirme = dmenu.show(self.choices, prompt="Choose ?", lines=2)
     if confirme == self.choices[1]:
         os.system(f"killall -u {self.current_user}")
Пример #14
0
# ARGUMENTS                                                                        #
#----------------------------------------------------------------------------------#
pageSelect = False
episodeSelect = True
download = False
search = False
if (len(sys.argv) > 0):
    for i in range(len(sys.argv)):
        arg = str(sys.argv[i])
        if arg == "-p":
            pageSelect = True
        if arg == "-l":
            #auto select last episode
            episodeSelect = False

entry = dmenu.show(["New", "Search"])
if entry == "Search":
    search = True
elif entry == "New":
    search = False
else:
    exit()

entry = dmenu.show(["Download", "Stream"])
if entry == "Download":
    download = True
elif entry == "Stream":
    download = False
else:
    exit()
Пример #15
0
    path = os.path.realpath(path)
    url = path_to_url(path)

    if os.path.isfile(path):
        dirname = os.path.dirname(url)
        filename = os.path.basename(url)
        display_folder_and_select(dirname, filename)
    else:
        display_folder(url)


str_json = open("/home/danilo/scripts/list_favority_files.json", "r").read()
favority_files = json.loads(str_json)
list_to_show = []
idx = 0

for item in favority_files:
    list_to_show.append("{idx}  - {str}".format(idx=idx,
                                                str=item.replace("\n",
                                                                 ' ')[:300]))
    idx = idx + 1

option = dmenu.show(list_to_show,
                    case_insensitive=True,
                    lines=20,
                    bottom=True,
                    monitor=3,
                    font='Monospace-16:normal')
idx = int(option[:3])
thunar_open_file(favority_files[idx])
Пример #16
0
def get_password():
    password = dmenu.show([], foreground='#feca1e', background='#feca1e')
    if not password:
        sys.exit(1)
    return password
Пример #17
0
 def poweroff(self):
     confirme = dmenu.show(self.choices, prompt="Choose ?", lines=2)
     if confirme == self.choices[1]:
         os.system("systemctl poweroff")
Пример #18
0
 def hibernate(self):
     confirme = dmenu.show(self.choices, prompt="Choose ?", lines=2)
     if confirme == self.choices[1]:
         os.system("systemctl hibernate")
Пример #19
0
 def reboot(self):
     confirme = dmenu.show(self.choices, prompt="Choose ?", lines=2)
     if confirme == self.choices[1]:
         os.system("systemctl reboot ")
Пример #20
0
def select(options):
    return dmenu.show(options, lines=MAX_LINES, case_insensitive=True)
Пример #21
0
def makeChoice(scratch):
    print(scratch.choices)
    choice = dmenu.show(scratch.choices)
    scratch.sensor.__setitem__("text-response", str(choice))
    scratch.broadcast("process-choice")