コード例 #1
0
ファイル: gui.py プロジェクト: Mad-Halfling/ubersquare
    def __init__(self, parent=None):
        super(SettingsDialog, self).__init__(parent)
        self.setWindowTitle("Settings")

        self.cw = QWidget(self)
        self.setCentralWidget(self.cw)

        layout = QGridLayout(self.cw)
        layout.setContentsMargins(22, 22, 22, 22)

        notice = "Yo'll need to link your facebook/twitter account from the foursquare website for these setting to have any effect."
        notice += "  The foursquare API does not offer any means for applications to do this."
        label = QLabel(notice)
        label.setWordWrap(True)

        self.tw = QCheckBox("Post to Twitter")
        self.fb = QCheckBox("Post to Facebook")

        broadcast = foursquare.config_get("broadcast")
        if broadcast:
            if not ", " in broadcast:
                self.tw.setChecked("twitter" in broadcast)
                self.fb.setChecked("facebook" in broadcast)

        self.saveButton = QPushButton("Save")
        self.connect(self.saveButton, SIGNAL("clicked()"), self.save)

        layout.addWidget(label, 0, 0)
        layout.addWidget(self.tw, 1, 0)
        layout.addWidget(self.fb, 2, 0)
        layout.addWidget(self.saveButton, 3, 0)
        layout.setRowStretch(4, 3)
コード例 #2
0
def fetch_token():
	code = foursquare.config_get("code")
	url = "https://foursquare.com/oauth2/access_token?client_id=" + foursquare.CLIENT_ID + "&client_secret=" + foursquare.CLIENT_SECRET + "&grant_type=authorization_code&redirect_uri=" + foursquare.CALLBACK_URI + "&code=" + code
	url = urllib.urlopen(url)
	response = url.read()
	response = json.loads(response, "UTF-8")
	foursquare.config_set("access_token", response['access_token'])
	foursquare.init()
コード例 #3
0
 def get_ll(self, venue=None):
     ll = foursquare.config_get("last_ll")
     if not ll:
         ll = foursquare.get_last_ll()
     if venue:
         lat = "%2.8f" % venue["location"]["lat"]
         lng = "%2.8f" % venue["location"]["lng"]
         foursquare.config_set("last_ll", lat + "," + lng)
     return ll
コード例 #4
0
    def __init__(self):
        super(LocationProviderSelector, self).__init__()
        self.setModel(LocationProviderModel())

        # This restores the last selected provider
        previousIndex = foursquare.config_get("locationProvider")
        if not previousIndex:
            previousIndex = 0
        else:
            previousIndex = int(previousIndex)
        self.setCurrentIndex(previousIndex)
        LocationProvider().select(previousIndex)
コード例 #5
0
ファイル: checkins.py プロジェクト: Mad-Halfling/ubersquare
    def __init__(self, parent, venue):
        super(CheckinConfirmation, self).__init__(parent)
        self.setWindowTitle("Checkin")
        self.centralWidget = QWidget()

        #Main Layout
        layout = QGridLayout()
        #layout.setSpacing(0)
        self.setLayout(layout)


        text = "You're checking in @<b>" + venue['name'] + "</b>"
        if 'address' in venue['location']:
            text += ", " + venue['location']['address']
        text += "."
        textLabel = QLabel(text, self)
        textLabel.setWordWrap(True)

        okButton = QPushButton("Ok")
        self.connect(okButton, SIGNAL("clicked()"), self.accept)
        cancelButton = QPushButton("Cancel")
        self.connect(cancelButton, SIGNAL("clicked()"), self.reject)

        # TODO: make this a separate widget
        #----
        self.tw = QCheckBox("Twitter")
        self.fb = QCheckBox("Facebook")

        broadcast = foursquare.config_get("broadcast")
        if broadcast:
            if not ", " in broadcast:
                self.tw.setChecked("twitter" in broadcast)
                self.fb.setChecked("facebook" in broadcast)
        #----

        layout.addWidget(textLabel, 0, 0, 1, 3)
        layout.addWidget(self.tw, 1, 0)
        layout.addWidget(self.fb, 1, 1)
        layout.addWidget(okButton, 1, 2)
コード例 #6
0
ファイル: gui.py プロジェクト: Mad-Halfling/ubersquare
def start():
    app = QApplication(sys.argv)

    token_present = foursquare.config_get("access_token") != None

    if not token_present:
        msgBox = QMessageBox()
        msgBox.setText("Hi! It looks like this is the first run!\n\nI'm going to open a browser window now, and I need you to authorize me so I can get data/do your check-ins, etc.")
        msgBox.setWindowTitle("First run")
        msgBox.addButton("Ok", QMessageBox.AcceptRole)
        msgBox.addButton("Cancel", QMessageBox.RejectRole)
        msgBox.exec_()
        if msgBox.buttonRole(msgBox.clickedButton()) == QMessageBox.AcceptRole:
            foursquare_auth.fetch_code()
            foursquare_auth.fetch_token()
            token_present = True
            d = QMessageBox()
            d.setWindowTitle("Image cache")
            d.setText("In order to save bandwidth, category images are cached.  To download these images for a first time, click \"Update image cache\". This'll take some time, but will <b>really</b> speed up searches.")
            d.addButton("Ok", QMessageBox.YesRole)
            d.exec_()

    if token_present:
        try:
            foursquare.get_user("self", foursquare.CacheOrGet)
        except IOError:
            d = QMessageBox()
            d.setWindowTitle("Network Error")
            d.setText("I couldn't connect to foursquare to retrieve data. Make sure yo're connected to the internet, and try again (keep in mind that it may have been just a network glitch).")
            d.addButton("Ok", QMessageBox.YesRole)
            d.exec_()

        main_window = MainWindow()
        main_window.show()

    sys.exit(app.exec_())