Example #1
0
 def gotOAuthRequestToken(self, request_token):
     creds = self.twitter.credentials
     creds['oauth_token'] = request_token.getToken()
     creds['oauth_token_secret'] = request_token.getTokenSecret()
     self.twitter._log_creds()
     self.twitter._awaiting_resume=True
     browser.open_url(request_token.getAuthorizationURL())
Example #2
0
def search(get_q, answers, driver=-1):
    q = get_q()
    q = q.replace(QUOTE, ' ')
    print('Google:',
          Back.GREEN + Fore.BLACK + q + Back.RESET + Fore.RESET + NEWLINE)

    url = get_search_url(q)
    browser.open_url(url, driver)

    return extract_results(answers, driver)
Example #3
0
def reverse_search_image(image):
    global saved_plain, saved_formatted

    image.save(TEMP_PATH)
    multipart = {
        'encoded_image': (TEMP_PATH, open(TEMP_PATH, 'rb')),
        'image_content': ''
    }

    response = requests.post(GOOGLE_REVERSE_IMAGE,
                             files=multipart,
                             allow_redirects=False)
    url = response.headers['Location']

    browser.open_url(url)

    saved_plain, saved_formatted = extract_results(None)
Example #4
0
    def __init__(self, ui):
        self.ui = ui
        self.tutorialMap = OrderedDict({})
        layout_height = 0

        self.screen = Screen(name=szTutorial)

        # screen menu layout
        self.screenMenuLayout = BoxLayout(orientation="horizontal",
                                          size_hint=(1, None),
                                          height="35dp")
        btn_console = Button(text="Console",
                             background_color=[1.5, 0.8, 0.8, 2])
        btn_editor = Button(text="Code Editor",
                            background_color=[0.8, 1.5, 0.8, 2])
        btn_tutorial = Button(text="Python Tutorial",
                              background_color=[0.8, 0.8, 1.5, 2])
        btn_console.bind(on_release=lambda inst: self.ui.setMode(szConsole))
        btn_editor.bind(on_release=lambda inst: self.ui.setMode(szEditor))
        self.screenMenuLayout.add_widget(btn_console)
        self.screenMenuLayout.add_widget(btn_editor)
        self.screenMenuLayout.add_widget(btn_tutorial)
        self.screen.add_widget(self.screenMenuLayout)

        self.tutorialSV = ScrollView(size_hint=(1, None),
                                     size=(W,
                                           H - self.screenMenuLayout.size[1]),
                                     pos=(0, self.screenMenuLayout.top))
        with self.tutorialSV.canvas.before:
            Color(0.1, 0.1, 0.2, 1)
            Rectangle(size=WH)
        self.tutorialLayout = BoxLayout(orientation="vertical",
                                        size_hint_y=None)

        self.tutorialSV.add_widget(self.tutorialLayout)
        self.screen.add_widget(self.tutorialSV)

        # add title header
        image = Image(source=pythonLogo,
                      allow_stretch=True,
                      keep_ratio=True,
                      size_hint_x=None)
        label_Title = Label(text="Python Tutorials",
                            font_size="30dp",
                            bold=True,
                            color=[1.0, 0.7, 0.4, 1])
        titleLayout = BoxLayout(orientation="horizontal",
                                padding=[metrics.dp(20), 0, 0, 0],
                                size_hint=(1, 50.0 / 30.0))
        titleLayout.add_widget(image)
        titleLayout.add_widget(label_Title)
        self.tutorialLayout.add_widget(titleLayout)
        layout_height += metrics.dp(50)

        # add python tutorial url
        url = "https://docs.python.org/2.7/tutorial"
        btn_url = Button(text="Excepts from {}".format(url), font_size="13dp")
        btn_url.bind(on_release=lambda inst: browser.open_url(url))
        self.tutorialLayout.add_widget(btn_url)
        layout_height += metrics.dp(30)

        # add my comment
        self.tutorialLayout.add_widget(
            Label(text="I will update more tutorial.",
                  font_size="15dp",
                  color=[1.0, 0.85, 0.7, 1]))
        self.tutorialLayout.add_widget(Label(text=" ", font_size="12dp"))
        layout_height += metrics.dp(50)

        # create tutorial buttons
        fileList = {}
        for dirpath, dirnames, filenames in os.walk(tutorialDir):
            filenames.sort()
            fileList[dirpath] = filenames
        keys = fileList.keys()
        keys.sort()
        for dirpath in fileList:
            # add category label
            if fileList[dirpath]:
                label_category = Label(text=os.path.split(dirpath)[-1],
                                       font_size="18dp",
                                       halign="left",
                                       bold=True,
                                       color=[1.0, 0.85, 0.7, 1],
                                       size_hint_y=40.0 / 30.0)
                self.tutorialLayout.add_widget(label_category)
                layout_height += metrics.dp(40)
                # add tutorials
                for filename in fileList[dirpath]:
                    # load tutorial file
                    f = open(os.path.join(dirpath, filename), "r")
                    lines = list(f)
                    f.close()
                    desc = "".join(lines)
                    # add a button
                    btn = Button(text=desc[:desc.find("\n")],
                                 font_size="15dp",
                                 size_hint_y=1,
                                 background_color=[0.8, 0.8, 1.5, 1])
                    btn.bind(on_release=self.chooseTutorial)
                    self.tutorialMap[btn] = desc
                    self.tutorialLayout.add_widget(btn)
                    layout_height += metrics.dp(30)
        # refresh height
        self.tutorialLayout.height = layout_height
Example #5
0
def search_image(q, driver=-1):
    url = GOOGLE_IMAGE + quote(q)
    browser.open_url(url, driver)
Example #6
0
 def __init__(self, ui):
   self.ui = ui
   self.tutorialMap = OrderedDict({})
   layout_height = 0
   
   self.screen = Screen(name=szTutorial)
   
   # screen menu layout
   self.screenMenuLayout = BoxLayout(orientation="horizontal", size_hint=(1, None), height="35dp")
   btn_console = Button(text="Console", background_color=[1.5,0.8,0.8,2])
   btn_editor = Button(text="Code Editor", background_color=[0.8,1.5,0.8,2])
   btn_tutorial = Button(text="Python Tutorial", background_color=[0.8,0.8,1.5,2])
   btn_console.bind(on_release=lambda inst:self.ui.setMode(szConsole))
   btn_editor.bind(on_release=lambda inst:self.ui.setMode(szEditor))
   self.screenMenuLayout.add_widget(btn_console)
   self.screenMenuLayout.add_widget(btn_editor)
   self.screenMenuLayout.add_widget(btn_tutorial)
   self.screen.add_widget(self.screenMenuLayout)
   
   self.tutorialSV = ScrollView(size_hint=(1, None), size=(W,H - self.screenMenuLayout.size[1]), pos=(0, self.screenMenuLayout.top))
   with self.tutorialSV.canvas.before:
     Color(0.1, 0.1, 0.2, 1)
     Rectangle(size=WH)
   self.tutorialLayout = BoxLayout(orientation="vertical", size_hint_y = None)
   
   self.tutorialSV.add_widget(self.tutorialLayout)
   self.screen.add_widget(self.tutorialSV)
   
   # add title header
   image = Image(source=pythonLogo, allow_stretch=True, keep_ratio=True, size_hint_x=None)
   label_Title = Label(text = "Python Tutorials", font_size="30dp", bold=True, color=[1.0,0.7,0.4,1])
   titleLayout = BoxLayout(orientation="horizontal", padding=[metrics.dp(20),0,0,0], size_hint=(1, 50.0/30.0)) 
   titleLayout.add_widget(image)
   titleLayout.add_widget(label_Title)
   self.tutorialLayout.add_widget(titleLayout)
   layout_height += metrics.dp(50)
   
   # add python tutorial url
   url = "https://docs.python.org/2.7/tutorial"
   btn_url = Button(text="Excepts from {}".format(url), font_size="13dp")
   btn_url.bind(on_release=lambda inst:browser.open_url(url))
   self.tutorialLayout.add_widget(btn_url)
   layout_height += metrics.dp(30)
   
   # add my comment
   self.tutorialLayout.add_widget(Label(text="I will update more tutorial.", font_size="15dp", color=[1.0,0.85,0.7,1]))
   self.tutorialLayout.add_widget(Label(text=" ", font_size="12dp"))
   layout_height += metrics.dp(50)
   
   # create tutorial buttons
   fileList = {}
   for dirpath, dirnames, filenames in os.walk(tutorialDir):
     filenames.sort()
     fileList[dirpath] = filenames
   keys = fileList.keys()
   keys.sort()
   for dirpath in fileList:
     # add category label
     if fileList[dirpath]:
       label_category = Label(text = os.path.split(dirpath)[-1], font_size="18dp", halign="left", bold=True, color=[1.0,0.85,0.7,1], size_hint_y=40.0/30.0)
       self.tutorialLayout.add_widget(label_category)
       layout_height += metrics.dp(40)
       # add tutorials
       for filename in fileList[dirpath]:
         # load tutorial file
         f = open(os.path.join(dirpath, filename), "r")
         lines = list(f)
         f.close()
         desc = "".join(lines)
         # add a button
         btn = Button(text=desc[:desc.find("\n")], font_size="15dp", size_hint_y=1, background_color=[0.8, 0.8, 1.5, 1])
         btn.bind(on_release = self.chooseTutorial)
         self.tutorialMap[btn] = desc
         self.tutorialLayout.add_widget(btn)
         layout_height += metrics.dp(30)
   # refresh height
   self.tutorialLayout.height = layout_height