コード例 #1
0
ファイル: quote.py プロジェクト: jyr/opentumblr-qt
    def OnPost(self):
        self.quote = unicode(self.te_quote.toPlainText()).encode('utf-8')
        if self.te_source.document().isEmpty():
            self.te_source = ''
        else:            
            self.source = unicode(self.te_source.toPlainText()).encode('utf-8')
        if self.advanced.te_tags.document().isEmpty():
            self.tags = ''
        else:
            self.tags = unicode(self.advanced.te_tags.toPlainText()).encode('utf-8')
        self.tags = string.replace(self.tags,' ', ',')
        self.date = self.advanced.le_date.text()

        if self.advanced.cb_publish.currentText() == 'private':
            self.private = 1
        else:
            self.private = 0

        if self.quote:
            #self.format = None
            self.api = Api(self.api.name, self.api.email, self.api.password, self.private, self.date, self.tags)
            try:
                self.post = self.api.write_quote(self.quote, self.source)
            except:
                print 'posteado en blog principal'
            self.close()
        else:
            QtGui.QMessageBox.warning(self,'Error','Quote is required',QtGui.QMessageBox.Ok)
コード例 #2
0
ファイル: text.py プロジェクト: jyr/opentumblr-qt
    def OnPost(self):
        if self.le_title.text().isEmpty():
            self.le_title = ''
        else:            
            self.title = unicode(self.le_title.text()).encode('utf-8')
        
        self.body = unicode(self.te_post.toPlainText())
        if self.advanced.te_tags.toPlainText().isEmpty():
            self.tags = ''
        else:
            self.tags = unicode(self.advanced.te_tags.toPlainText()).encode('utf-8')
        self.tags = string.replace(self.tags,' ', ',')
        self.date = self.advanced.le_date.text()

        if self.advanced.cb_publish.currentText() == 'private':
            self.private = 1
        else:
            self.private = 0
        #print self.cb_publishing.GetValue()
        if self.advanced.cb_publish.currentText() == 'add to queue':
            self.date = 'on.2'

        if self.body:
            #self.format = None
            self.api = Api(self.api.name, self.api.email, self.api.password, self.private, self.date, self.tags)
            try:
                self.post = self.api.write_regular(self.title, self.body)
            except:
                print 'posteado en blog principal'
                #print 'Posteado en ' % self.post
                #assert False,dir(self.post.values)
            self.close()
        else:
            QtGui.QMessageBox.warning(self,'Error','Text Post is required',QtGui.QMessageBox.Ok)
コード例 #3
0
ファイル: link.py プロジェクト: jyr/opentumblr-qt
    def OnPost(self):
        if self.le_title.text().isEmpty():
            self.title = ''
        else:
            self.title = unicode(self.le_title.text()).encode('utf-8')        
        if  self.te_description.toPlainText().isEmpty():
            self.te_description = ''
        else:
            self.description = unicode(self.te_description.toPlainText()).encode('utf-8')
        if self.advanced.te_tags.toPlainText().isEmpty():
            self.tags = ''
        else:
            self.tags = unicode(self.advanced.te_tags.toPlainText()).encode('utf-8')
        self.tags = string.replace(self.tags,' ', ',')
        self.date = self.advanced.le_date.text()
        self.urllink = self.le_URL.text()

        if self.advanced.cb_publish.currentText() == 'private':
            self.private = 1
        else:
            self.private = 0

        if self.urllink:
            #self.format = None
            self.api = Api(self.api.name, self.api.email, self.api.password, self.private, self.date, self.tags)
            try:
                self.post = self.api.write_link(self.title,self.urllink,self.description)
            except:
                print 'posteado en blog principal'
            self.close()
        else:
            QtGui.QMessageBox.warning(self,'Error','URL is required',QtGui.QMessageBox.Ok)
コード例 #4
0
        def OnAuthTumblr(self):
                self.User = self.le_mail.text()                
                self.Password = self.le_password.text()
                self.Blog = self.le_url.text()	
                self.error = None
                if not self.User.isEmpty() | self.Password.isEmpty() | self.Blog.isEmpty():
                    self.api = Api(self.Blog,self.User,self.Password)

                    try:
                        self.auth = self.api.auth_check()
                        #Abrir la ventana del dashboard
                        dashboard = Dashboard(self)                                                                  
                        self.hide()
                        dashboard.show()                                
                        #print 'Te haz logueado'
                    except TumblrAuthError:	    		
                        self.error = errors['403']
                    except urllib2.HTTPError:
                        self.error = errors['404']
                    except urllib2.URLError:
                        self.error = errors['urlopen']
                    finally:
                        if self.error != None:
                            QtGui.QMessageBox.warning(self,'Error','Occurrio un error: \n' + self.error,QtGui.QMessageBox.Ok)			    
                else:
                    QtGui.QMessageBox.warning(self,'Error','Todos los Campos son necesarios',QtGui.QMessageBox.Ok)		
コード例 #5
0
ファイル: video.py プロジェクト: ialex/opentumblr-qt
    def OnPost(self):
        self.embed = unicode(self.te_videourl.toPlainText()).encode("utf-8")
        if self.te_caption.te_post.toPlainText().isEmpty():
            self.caption = ""
        else:
            self.caption = unicode(self.te_caption.te_post.toPlainText()).encode("utf-8")
        if self.advanced.te_tags.toPlainText().isEmpty():
            self.tags = ""
        else:
            self.tags = unicode(self.advanced.te_tags.toPlainText()).encode("utf-8")
        self.tags = string.replace(self.tags, " ", ",")
        self.date = self.advanced.le_date.text()

        if self.advanced.cb_publish.currentText() == "private":
            self.private = 1
        else:
            self.private = 0

        if self.embed:
            # self.format = None
            self.api = Api(self.api.name, self.api.email, self.api.password, self.private, self.date, self.tags)
            try:
                self.post = self.api.write_video(self.embed, self.caption)
            except:
                print "posteado en el blog primario"
            self.close()
        else:
            QtGui.QMessageBox.warning(self, "Error", "Embeded Video is required", QtGui.QMessageBox.Ok)
コード例 #6
0
ファイル: audio.py プロジェクト: ialex/opentumblr-qt
    def OnPost(self):
        self.data = unicode(self.le_file.text()).encode('utf-8')
        if not self.data:
            self.data =None

        self.source = unicode(self.le_audiourl.text()).encode('utf-8')
        if not self.source:
            self.source = None    	
        if self.te_description.te_post.toPlainText().isEmpty():
            self.caption = ''
        else:
            self.caption = unicode(self.te_description.te_post.toPlainText()).encode('utf-8')
        if self.advanced.te_tags.document().isEmpty():
            self.tags = ''
        else:
            self.tags = unicode(self.advanced.te_tags.toPlainText()).encode('utf-8')
        self.tags = string.replace(self.tags,' ', ',')
        self.date = self.advanced.le_date.text()

        if self.advanced.cb_publish.currentText() == 'private':
            self.private = 1
        else:
            self.private = 0

        if self.data or self.source:
            #self.format = None
            self.api = Api(self.api.name, self.api.email, self.api.password, self.private, self.date, self.tags)
            try:
                self.post = self.api.write_audio(self.data, self.source, self.caption)
            except:
                print "posteado en blog principal"
            self.close()
        else:
            QtGui.QMessageBox.warning(self,"Error","Audio is required",QtGui.QMessageBox.Ok)
コード例 #7
0
ファイル: text.py プロジェクト: ialex/opentumblr-qt
class Text(Text_widget):
    def __init__(self,parent=None):
        super(Text_widget,self).__init__(parent)        
        self.setupUi(self)
        self.api = parent.api
        
        #Conectar eventos
        QtCore.QObject.connect(self.bt_cancel, QtCore.SIGNAL('clicked()'), self.OnCancel)
        QtCore.QObject.connect(self.bt_post, QtCore.SIGNAL('clicked()'), self.OnPost)
        
    def OnCancel(self):
        self.hide()
    
    def OnPost(self):
        if self.le_title.text().isEmpty():
            self.le_title = ''
        else:            
            self.title = unicode(self.le_title.text()).encode('utf-8')
        
        self.body = unicode(self.te_post.te_post.toPlainText())
        if self.advanced.te_tags.toPlainText().isEmpty():
            self.tags = ''
        else:
            self.tags = unicode(self.advanced.te_tags.toPlainText()).encode('utf-8')
        self.tags = string.replace(self.tags,' ', ',')
        self.date = self.advanced.le_date.text()

        if self.advanced.cb_publish.currentText() == 'private':
            self.private = 1
        else:
            self.private = 0
        #print self.cb_publishing.GetValue()
        if self.advanced.cb_publish.currentText() == 'add to queue':
            self.date = 'on.2'

        if self.body:
            #self.format = None
            self.api = Api(self.api.name, self.api.email, self.api.password, self.private, self.date, self.tags)                        
            try:                
                self.post = self.api.write_regular(self.title, self.body)
            except:
                print 'posteado en blog principal'
                #print 'Posteado en ' % self.post
                #assert False,dir(self.post.values)
            self.close()
        else:
            QtGui.QMessageBox.warning(self,'Error','Text Post is required',QtGui.QMessageBox.Ok)
    
    def OnCopy():
        self.le_title.text
    
    def closeEvent(self,event):
        event.ignore()
        self.hide()
コード例 #8
0
class Cliente_Opentumblr(Main_widget):
    def __init__(self,parent=None):
        super(Main_widget, self).__init__(parent)
        self.setupUi()                             
        #Conectar eventos
        self.connect(self.bt_login, QtCore.SIGNAL('clicked()'),self.OnAuthTumblr)                                                    
        self.rememberme.setCheckState(QtCore.Qt.Unchecked)                                                        
        
        if(QtCore.QFile().exists(QtCore.QDir().homePath() + '/.opentumblr')):
            file = open(QtCore.QDir().homePath() + '/.opentumblr','r')
            self.le_mail.setText(file.readline())                                                
            self.le_url.setText(file.readline())
                                                                                    

    def OnAuthTumblr(self):
        self.User = self.le_mail.text().trimmed()                
        self.Password = self.le_password.text()
        self.Blog = self.le_url.text().trimmed()        
        self.error = None
        if not self.User.isEmpty() | self.Password.isEmpty() | self.Blog.isEmpty():
            self.api = Api(self.Blog,self.User,self.Password)

            try:
                self.auth = self.api.auth_check()
                                                 
                if QtGui.QSystemTrayIcon.isSystemTrayAvailable():
                    self.hide()
                    tray = TumblrTray(self)
                else:
                    dashboard = Dashboard(self)                                                                  
                    self.hide()
                    dashboard.show()
                 
                                               
                if self.rememberme.checkState() == 2:
                    file = open(QtCore.QDir().homePath() + '/.opentumblr','w')
                    file.write(self.le_mail.text())
                    file.write(self.le_url.text())
                             
            except TumblrAuthError:	    		
                self.error = errors['403']
            except urllib2.HTTPError:
                self.error = errors['404']
            except urllib2.URLError:
                self.error = errors['urlopen']
            finally:
                if self.error != None:
                    QtGui.QMessageBox.warning(self,'Error','Occurrio un error: \n' + self.error,QtGui.QMessageBox.Ok)			    
        else:
            QtGui.QMessageBox.warning(self,'Error','Todos los Campos son necesarios',QtGui.QMessageBox.Ok)		            
コード例 #9
0
ファイル: link.py プロジェクト: ialex/opentumblr-qt
class Link(Link_widget):
    def __init__(self,parent=None):
        super(Link,self).__init__(parent)        
        self.setupUi(self)
        self.api = parent.api
        #Conectar eventos
        self.connect(self.bt_cancel, QtCore.SIGNAL('clicked()'), self.OnCancel)
        self.connect(self.bt_post, QtCore.SIGNAL('clicked()'), self.OnPost)

    def OnCancel(self):
        self.hide()

    def OnPost(self):
        if self.le_title.text().isEmpty():
            self.title = ''
        else:
            self.title = unicode(self.le_title.text()).encode('utf-8')        
        if  self.te_description.te_post.toPlainText().isEmpty():
            self.te_description = ''
        else:
            self.description = unicode(self.te_description.te_post.toPlainText()).encode('utf-8')
        if self.advanced.te_tags.toPlainText().isEmpty():
            self.tags = ''
        else:
            self.tags = unicode(self.advanced.te_tags.toPlainText()).encode('utf-8')
        self.tags = string.replace(self.tags,' ', ',')
        self.date = self.advanced.le_date.text()
        self.urllink = self.le_URL.text()

        if self.advanced.cb_publish.currentText() == 'private':
            self.private = 1
        else:
            self.private = 0

        if self.urllink:
            #self.format = None
            self.api = Api(self.api.name, self.api.email, self.api.password, self.private, self.date, self.tags)
            try:
                self.post = self.api.write_link(self.title,self.urllink,self.description)
            except:
                print 'posteado en blog principal'
            self.close()
        else:
            QtGui.QMessageBox.warning(self,'Error','URL is required',QtGui.QMessageBox.Ok)
    
    def closeEvent(self,event):
        event.ignore()
        self.hide()
コード例 #10
0
ファイル: video.py プロジェクト: ialex/opentumblr-qt
class Video(Video_widget):
    def __init__(self, parent=None):
        super(Video, self).__init__(parent)
        self.setupUi(self)
        self.api = parent.api
        # Conectar eventos
        self.connect(self.bt_cancel, QtCore.SIGNAL("clicked()"), self.OnCancel)
        self.connect(self.bt_post, QtCore.SIGNAL("clicked()"), self.OnPost)

    def OnCancel(self):
        self.hide()

    def OnPost(self):
        self.embed = unicode(self.te_videourl.toPlainText()).encode("utf-8")
        if self.te_caption.te_post.toPlainText().isEmpty():
            self.caption = ""
        else:
            self.caption = unicode(self.te_caption.te_post.toPlainText()).encode("utf-8")
        if self.advanced.te_tags.toPlainText().isEmpty():
            self.tags = ""
        else:
            self.tags = unicode(self.advanced.te_tags.toPlainText()).encode("utf-8")
        self.tags = string.replace(self.tags, " ", ",")
        self.date = self.advanced.le_date.text()

        if self.advanced.cb_publish.currentText() == "private":
            self.private = 1
        else:
            self.private = 0

        if self.embed:
            # self.format = None
            self.api = Api(self.api.name, self.api.email, self.api.password, self.private, self.date, self.tags)
            try:
                self.post = self.api.write_video(self.embed, self.caption)
            except:
                print "posteado en el blog primario"
            self.close()
        else:
            QtGui.QMessageBox.warning(self, "Error", "Embeded Video is required", QtGui.QMessageBox.Ok)

    def closeEvent(self, event):
        event.ignore()
        self.hide()
コード例 #11
0
ファイル: quote.py プロジェクト: jyr/opentumblr-qt
class Quote(Quote_widget):
    def __init__(self,parent=None):
        super(Quote,self).__init__(parent)        
        self.setupUi()
        self.api = parent.api
        #Conectar eventos
        self.connect(self.bt_cancel, QtCore.SIGNAL('clicked()'), self.OnCancel)
        self.connect(self.bt_post, QtCore.SIGNAL('clicked()'), self.OnPost)

    def OnCancel(self):
        self.close()

    def OnPost(self):
        self.quote = unicode(self.te_quote.toPlainText()).encode('utf-8')
        if self.te_source.document().isEmpty():
            self.te_source = ''
        else:            
            self.source = unicode(self.te_source.toPlainText()).encode('utf-8')
        if self.advanced.te_tags.document().isEmpty():
            self.tags = ''
        else:
            self.tags = unicode(self.advanced.te_tags.toPlainText()).encode('utf-8')
        self.tags = string.replace(self.tags,' ', ',')
        self.date = self.advanced.le_date.text()

        if self.advanced.cb_publish.currentText() == 'private':
            self.private = 1
        else:
            self.private = 0

        if self.quote:
            #self.format = None
            self.api = Api(self.api.name, self.api.email, self.api.password, self.private, self.date, self.tags)
            try:
                self.post = self.api.write_quote(self.quote, self.source)
            except:
                print 'posteado en blog principal'
            self.close()
        else:
            QtGui.QMessageBox.warning(self,'Error','Quote is required',QtGui.QMessageBox.Ok)
コード例 #12
0
ファイル: photo.py プロジェクト: jyr/opentumblr-qt
    def OnPost(self):
        #Source == An URL - Data == A Path to the file on your Computer
        self.source = unicode(self.le_imageurl.text()).encode('utf-8')        
        if not self.source:
            self.source = None    

        self.data = unicode(self.le_file.text()).encode('utf-8')        
        if not self.data:
            self.data = None
        
        if self.te_caption.toPlainText().isEmpty():
            self.caption = ''
        else:
            self.caption = unicode(self.te_caption.toPlainText()).encode('utf-8')
        if self.le_link.text().isEmpty():
            self.click = ''
        else:
            self.click  = unicode(self.le_link.text()).encode('utf-8')
        if self.advanced.te_tags.document().isEmpty():
            self.tags = ''
        else:
            self.tags = unicode(self.advanced.te_tags.toPlainText()).encode('utf-8')
        self.tags = string.replace(self.tags,' ', ',')
        self.date = self.advanced.le_date.text()

        if self.advanced.cb_publish.currentText() == 'private':
            self.private = 1
        else:
            self.private = 0
        
        if self.source or self.data:
            #self.format = None
            self.api = Api(self.api.name, self.api.email, self.api.password, self.private, self.date, self.tags)
            try:
                self.post = self.api.write_photo(self.source, self.data, self.caption, self.click)
            except:            
                print "posteado en blog principal"
            self.close()
        else:
            QtGui.QMessageBox.warning(self,"Error","Photo is required",QtGui.QMessageBox.Ok)
コード例 #13
0
class Cliente_Opentumblr(Main_widget):
        def __init__(self,parent=None):
                super(Main_widget, self).__init__(parent)
                self.setupUi()                             
                #Conectar eventos
                QtCore.QObject.connect(self.bt_login, QtCore.SIGNAL('clicked()'),self.OnAuthTumblr)                

                #Debug properties                                                                      
                #self.le_mail.setText('*****@*****.**')                                                
                #self.le_url.setText('http://ialex.tumblr.com')

        def OnAuthTumblr(self):
                self.User = self.le_mail.text()                
                self.Password = self.le_password.text()
                self.Blog = self.le_url.text()	
                self.error = None
                if not self.User.isEmpty() | self.Password.isEmpty() | self.Blog.isEmpty():
                    self.api = Api(self.Blog,self.User,self.Password)

                    try:
                        self.auth = self.api.auth_check()
                        #Abrir la ventana del dashboard
                        dashboard = Dashboard(self)                                                                  
                        self.hide()
                        dashboard.show()                                
                        #print 'Te haz logueado'
                    except TumblrAuthError:	    		
                        self.error = errors['403']
                    except urllib2.HTTPError:
                        self.error = errors['404']
                    except urllib2.URLError:
                        self.error = errors['urlopen']
                    finally:
                        if self.error != None:
                            QtGui.QMessageBox.warning(self,'Error','Occurrio un error: \n' + self.error,QtGui.QMessageBox.Ok)			    
                else:
                    QtGui.QMessageBox.warning(self,'Error','Todos los Campos son necesarios',QtGui.QMessageBox.Ok)		
コード例 #14
0
    def OnAuthTumblr(self):
        self.User = self.le_mail.text().trimmed()                
        self.Password = self.le_password.text()
        self.Blog = self.le_url.text().trimmed()        
        self.error = None
        if not self.User.isEmpty() | self.Password.isEmpty() | self.Blog.isEmpty():
            self.api = Api(self.Blog,self.User,self.Password)

            try:
                self.auth = self.api.auth_check()
                                                 
                if QtGui.QSystemTrayIcon.isSystemTrayAvailable():
                    self.hide()
                    tray = TumblrTray(self)
                else:
                    dashboard = Dashboard(self)                                                                  
                    self.hide()
                    dashboard.show()
                 
                                               
                if self.rememberme.checkState() == 2:
                    file = open(QtCore.QDir().homePath() + '/.opentumblr','w')
                    file.write(self.le_mail.text())
                    file.write(self.le_url.text())
                             
            except TumblrAuthError:	    		
                self.error = errors['403']
            except urllib2.HTTPError:
                self.error = errors['404']
            except urllib2.URLError:
                self.error = errors['urlopen']
            finally:
                if self.error != None:
                    QtGui.QMessageBox.warning(self,'Error','Occurrio un error: \n' + self.error,QtGui.QMessageBox.Ok)			    
        else:
            QtGui.QMessageBox.warning(self,'Error','Todos los Campos son necesarios',QtGui.QMessageBox.Ok)		            
コード例 #15
0
ファイル: photo.py プロジェクト: jyr/opentumblr-qt
class Photo(Photo_widget):
    def __init__(self,parent=None):
        super(Photo_widget,self).__init__(parent)        
        self.setupUi()
        self.api = parent.api
        #Conectar eventos
        self.connect(self.bt_cancel, QtCore.SIGNAL("clicked()"), self.OnCancel)
        self.connect(self.bt_post, QtCore.SIGNAL("clicked()"), self.OnPost)
        self.connect(self.bt_browse, QtCore.SIGNAL("clicked()"), self.OnBrowse)
        self.connect(self.lb_useurl, QtCore.SIGNAL("linkActivated(QString)"), self.OnUseUrl)
        
    def OnCancel(self):
        self.close()
    
    def OnPost(self):
        #Source == An URL - Data == A Path to the file on your Computer
        self.source = unicode(self.le_imageurl.text()).encode('utf-8')        
        if not self.source:
            self.source = None    

        self.data = unicode(self.le_file.text()).encode('utf-8')        
        if not self.data:
            self.data = None
        
        if self.te_caption.toPlainText().isEmpty():
            self.caption = ''
        else:
            self.caption = unicode(self.te_caption.toPlainText()).encode('utf-8')
        if self.le_link.text().isEmpty():
            self.click = ''
        else:
            self.click  = unicode(self.le_link.text()).encode('utf-8')
        if self.advanced.te_tags.document().isEmpty():
            self.tags = ''
        else:
            self.tags = unicode(self.advanced.te_tags.toPlainText()).encode('utf-8')
        self.tags = string.replace(self.tags,' ', ',')
        self.date = self.advanced.le_date.text()

        if self.advanced.cb_publish.currentText() == 'private':
            self.private = 1
        else:
            self.private = 0
        
        if self.source or self.data:
            #self.format = None
            self.api = Api(self.api.name, self.api.email, self.api.password, self.private, self.date, self.tags)
            try:
                self.post = self.api.write_photo(self.source, self.data, self.caption, self.click)
            except:            
                print "posteado en blog principal"
            self.close()
        else:
            QtGui.QMessageBox.warning(self,"Error","Photo is required",QtGui.QMessageBox.Ok)
        
    def OnBrowse(self):
        ImageDialog = QtGui.QFileDialog(self)
        filename = ImageDialog.getOpenFileName(self,"Select an Image",QtCore.QDir.homePath(),"Image Files (*.png *.jpg *.jpeg *.gif *.bmp)")        
        self.le_file.setText(filename)
    
    def OnUseUrl(self,text):
        self.le_file.setText("")
        self.le_file.setVisible(False)
        self.bt_browse.setVisible(False)
        self.le_imageurl.setVisible(True)
        self.lb_photo.setText("<big>Photo URL</big>")
        self.lb_useurl.setVisible(False)
        self.le_imageurl.setFocus()
        
        
        
コード例 #16
0
ファイル: audio.py プロジェクト: ialex/opentumblr-qt
class Audio(Audio_widget):
    def __init__(self,parent=None,api=None):
        super(Audio,self).__init__(parent)        
        self.setupUi(self)
        self.api = api        
        
        #Conectar eventos 
        self.connect(self.bt_cancel, QtCore.SIGNAL('clicked()'), self.OnCancel)
        self.connect(self.bt_post, QtCore.SIGNAL('clicked()'), self.OnPost)
        self.connect(self.lb_useurl, QtCore.SIGNAL("linkActivated(QString)"), self.OnUseUrl)
        self.connect(self.bt_browse, QtCore.SIGNAL("clicked()"), self.OnBrowse)

    def OnCancel(self):
        self.hide()

    def OnPost(self):
        self.data = unicode(self.le_file.text()).encode('utf-8')
        if not self.data:
            self.data =None

        self.source = unicode(self.le_audiourl.text()).encode('utf-8')
        if not self.source:
            self.source = None    	
        if self.te_description.te_post.toPlainText().isEmpty():
            self.caption = ''
        else:
            self.caption = unicode(self.te_description.te_post.toPlainText()).encode('utf-8')
        if self.advanced.te_tags.document().isEmpty():
            self.tags = ''
        else:
            self.tags = unicode(self.advanced.te_tags.toPlainText()).encode('utf-8')
        self.tags = string.replace(self.tags,' ', ',')
        self.date = self.advanced.le_date.text()

        if self.advanced.cb_publish.currentText() == 'private':
            self.private = 1
        else:
            self.private = 0

        if self.data or self.source:
            #self.format = None
            self.api = Api(self.api.name, self.api.email, self.api.password, self.private, self.date, self.tags)
            try:
                self.post = self.api.write_audio(self.data, self.source, self.caption)
            except:
                print "posteado en blog principal"
            self.close()
        else:
            QtGui.QMessageBox.warning(self,"Error","Audio is required",QtGui.QMessageBox.Ok)

    def OnBrowse(self):
        ImageDialog = QtGui.QFileDialog(self)
        filename = ImageDialog.getOpenFileName(self,'Select an Audio File',QtCore.QDir.homePath(),'Audio Files (*.MP3 *.AIFF *.mp3 *.aiff)')        
        self.le_file.setText(filename)

    def OnUseUrl(self,href):
        if href == 'willUseURL':
            self.lb_useurl.setText(' <strong>MP3s only.</strong> The file will be streamed from this URL, <strong>not</strong> hosted by Tumblr. <a href=willUseFile>Upload a file instead</a>')
            self.le_file.setVisible(False)
            self.le_audiourl.setVisible(True)
            self.bt_browse.setVisible(False)            
            self.le_file.setText('')
        else:
            self.lb_useurl.setText('<a href=willUseURL>Use an externally hosted audio file</a>')
            self.le_file.setVisible(True)
            self.le_audiourl.setVisible(False)
            self.bt_browse.setVisible(True)            
            self.le_audiourl.setText('')
    
    def closeEvent(self,event):
            event.ignore()
            self.hide()