예제 #1
0
def main():
    """
    launches the main event loop
    long live to the (hidden) leap window!
    """
    import sys
    from leap.utils import leap_argparse
    parser, opts = leap_argparse.init_leapc_args()
    debug = getattr(opts, 'debug', False)

    #XXX get debug level and set logger accordingly
    if debug:
        logger.debug('args: ', opts)

    app = QApplication(sys.argv)

    if not QSystemTrayIcon.isSystemTrayAvailable():
        QMessageBox.critical(None, "Systray",
                             "I couldn't detect any \
system tray on this system.")
        sys.exit(1)
    if not debug:
        QApplication.setQuitOnLastWindowClosed(False)

    window = LeapWindow(opts)
    window.show()
    sys.exit(app.exec_())
    def __init__(self, parent=None):
        super(PigeonFeather, self).__init__(parent)

        # Check that environment supports systemtray
        if not QSystemTrayIcon.isSystemTrayAvailable():
            print('FATAL: There is no system tray')
            sys.exit(1)

        # Make sure that we can load an icon list
        try:
            with open('code2iconlist.pkl', 'rb') as iconList:
                self.codeToIconList = pickle.load(iconList)
        except (IOError, pickle.PickleError):
            print('FATAL: Could not not load code2iconlist')
            sys.exit(1)

        # See if balloon messages are supported
        #print('Desktop support balloon messages = ' + \
        #    str(QSystemTrayIcon.supportsMessages()))

        # Set the user config fle
        self.USER_CONFIG = os.path.expanduser('~/.pigeonfeather')

        # Load preferences
        self.loadConfig()

        # Class properties
        self.trayIcon = QSystemTrayIcon(self)

        # Weather Dialog and Configure Dialog
        self.weatherDialog = WeatherDialog(self)
        self.configureDialog = ConfigureDialog(self)

        # Set up the application
        self.setup()
예제 #3
0
def show(main_window):
    """Show a system tray icon with a small icon."""
    _fix_unity_systray()
    icon = QIcon(multiplatform.get_path("encuentro/logos/icon-192.png"))
    sti = QSystemTrayIcon(icon, main_window)
    if not sti.isSystemTrayAvailable():
        logger.warning("System tray not available.")
        return

    def showhide(_):
        """Show or hide the main window."""
        if main_window.isVisible():
            main_window.hide()
        else:
            main_window.show()

    _menu = QMenu(main_window)
    _act = _menu.addAction("Mostrar/Ocultar")
    _act.triggered.connect(showhide)
    _act = _menu.addAction("Acerca de")
    _act.triggered.connect(main_window.open_about_dialog)
    _act = _menu.addAction("Salir")
    _act.triggered.connect(main_window.on_close)
    sti.setContextMenu(_menu)
    sti.show()
예제 #4
0
def show(main_window):
    """Show a system tray icon with a small icon."""
    _fix_unity_systray()
    icon = QIcon(multiplatform.get_path("encuentro/logos/icon-192.png"))
    sti = QSystemTrayIcon(icon, main_window)
    if not sti.isSystemTrayAvailable():
        logger.warning("System tray not available.")
        return

    def showhide(_):
        """Show or hide the main window."""
        if main_window.isVisible():
            main_window.hide()
        else:
            main_window.show()

    _menu = QMenu(main_window)
    _act = _menu.addAction("Mostrar/Ocultar")
    _act.triggered.connect(showhide)
    _act = _menu.addAction("Acerca de")
    _act.triggered.connect(main_window.open_about_dialog)
    _act = _menu.addAction("Salir")
    _act.triggered.connect(main_window.on_close)
    sti.setContextMenu(_menu)
    sti.show()
예제 #5
0
def main():
    global app, aboutData

    import setproctitle
    setproctitle.setproctitle("iosshy")

    from PyQt4.QtCore import QCoreApplication, QTranslator, QLocale, QSettings
    from PyQt4.QtGui import QApplication, QSystemTrayIcon, QImage

    from tunneldialog import TunnelDialog

    try:
        from PyKDE4.kdecore import ki18n, KAboutData, KCmdLineArgs
        from PyKDE4.kdeui import KApplication, KIcon

        aboutData = KAboutData(
            name, #appName
            name, #catalogName
            ki18n(name), #programName
            version,
            ki18n(description), #shortDescription
            KAboutData.License_BSD, #licenseKey
            ki18n("© 2010 Massimiliano Torromeo"), #copyrightStatement
            ki18n(""), #text
            url #homePageAddress
        )
        aboutData.setBugAddress("http://github.com/mtorromeo/iosshy/issues")
        aboutData.addAuthor(
            ki18n("Massimiliano Torromeo"), #name
            ki18n("Main developer"), #task
            "*****@*****.**" #email
        )
        aboutData.setProgramLogo(QImage(":icons/network-server.png"))

        KCmdLineArgs.init(sys.argv, aboutData)

        app = KApplication()
        app.setWindowIcon(KIcon("network-server"))

        if app.isSessionRestored():
            sys.exit(0)
    except ImportError:
        app = QApplication(sys.argv)
        app.setOrganizationName("MTSoft")
        app.setApplicationName(name)


    if QSystemTrayIcon.isSystemTrayAvailable():
        translator = QTranslator()
        qmFile = "tunneller_%s.qm" % QLocale.system().name()
        if os.path.isfile(qmFile):
            translator.load(qmFile)
        app.installTranslator(translator)

        dialog = TunnelDialog()
        sys.exit(app.exec_())
    else:
        print "System tray not available. Exiting."
        sys.exit(1)
예제 #6
0
 def isTrayAvailable(self):
     if TrayEngine in ("KDE", "Qt"):
         return QSystemTrayIcon.isSystemTrayAvailable()
     elif TrayEngine == "AppIndicator":
         # Ubuntu/Unity always has a systray
         return True
     else:
         return False
예제 #7
0
파일: cloudapp.py 프로젝트: impiza/cloudapp
def main():
    app = QApplication(sys.argv)
        
    if not QSystemTrayIcon.isSystemTrayAvailable():
        QMessageBox.critical(None, "Systray", "I couldn't detect any system tray on this system.")
        return -1
    mainWidget = DropWidget()
    mainWidget.show()
    sys.exit(app.exec_())
예제 #8
0
 def __init__(self):
     if QSystemTrayIcon.isSystemTrayAvailable():
         QSystemTrayIcon.__init__(self)
         
         iconPath = os.path.join("i18n","images","us_en","bloop.png")
         self.setIcon(QIcon(QPixmap(iconPath)))
         self.initContextMenu()
         self.show()
         self.show()
예제 #9
0
class Example(QtGui.QMainWindow):

    
def __init__(self):
super(Example, self).__init__()


self.path=sys.path[0]
f=open('%s/ACCESS_KEY'% self.path,'r')
f1=open('%s/ACCESS_SECRET'% self.path,'r')
f2=open('%s/user_info'% self.path)
self.user_name=f2.readline().strip('\n')
self.user_id=f2.readline().strip('\n')
self.a=f.readline().strip('\n')
self.b=f1.readline().strip('\n')
f.close()
f1.close()
f2.close()
self.initUI()

def initUI(self):

self.icon=QSystemTrayIcon()
self.icon.isSystemTrayAvailable()
self.icon.setIcon( QtGui.QIcon('%s/web.png'% self.path) )
self.icon.setToolTip ( 'dubbleclick to maximize')
self.icon.show()
self.icon.activated.connect(self.activate)
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
                self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
self.setGeometry(300, 300, 1500, 1000)
frame = QtGui.QFrame(parent=self)
                frame.setStyleSheet("QFrame {background: rgba(0,0,0,50%)}")
box=QtGui.QHBoxLayout()

self.edit = QtGui.QLineEdit()
         self.edit.setStyleSheet("background: rgba(0,0,0,100%); "" font-weight : bold;" "color: rgb(250,250,250);""border:5px solid ")
예제 #10
0
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.saved_account_state = None

        notification_center = NotificationCenter()
        notification_center.add_observer(self, name='SIPApplicationWillStart')
        notification_center.add_observer(self, name='SIPApplicationDidStart')
        notification_center.add_observer(self, name='SIPAccountGotMessageSummary')
        notification_center.add_observer(self, name='SIPAccountGotPendingWatcher')
        notification_center.add_observer(self, name='BlinkSessionNewOutgoing')
        notification_center.add_observer(self, name='BlinkSessionDidReinitializeForOutgoing')
        notification_center.add_observer(self, name='FileTransferNewIncoming')
        notification_center.add_observer(self, name='FileTransferNewOutgoing')
        notification_center.add_observer(self, sender=AccountManager())

        icon_manager = IconManager()

        self.pending_watcher_dialogs = []

        self.mwi_icons = [QIcon(Resources.get('icons/mwi-%d.png' % i)) for i in xrange(0, 11)]
        self.mwi_icons.append(QIcon(Resources.get('icons/mwi-many.png')))

        with Resources.directory:
            self.setupUi()

        self.setWindowTitle('Blink')
        self.setWindowIconText('Blink')

        geometry = QSettings().value("main_window/geometry")
        if geometry:
            self.restoreGeometry(geometry)

        self.default_icon_path = Resources.get('icons/default-avatar.png')
        self.default_icon = QIcon(self.default_icon_path)
        self.last_icon_directory = Path('~').normalized
        self.set_user_icon(icon_manager.get('avatar'))

        self.active_sessions_label.hide()
        self.enable_call_buttons(False)
        self.conference_button.setEnabled(False)
        self.hangup_all_button.setEnabled(False)
        self.sip_server_settings_action.setEnabled(False)
        self.search_for_people_action.setEnabled(False)
        self.history_on_server_action.setEnabled(False)
        self.main_view.setCurrentWidget(self.contacts_panel)
        self.contacts_view.setCurrentWidget(self.contact_list_panel)
        self.search_view.setCurrentWidget(self.search_list_panel)

        # System tray
        if QSystemTrayIcon.isSystemTrayAvailable() and not os.getenv('XDG_CURRENT_DESKTOP', '').lower().startswith('unity'):
            self.system_tray_icon = QSystemTrayIcon(QIcon(Resources.get('icons/blink.png')), self)
            self.system_tray_icon.activated.connect(self._SH_SystemTrayIconActivated)
            menu = QMenu(self)
            menu.addAction(QAction("Show", self, triggered=self._AH_SystemTrayShowWindow))
            menu.addAction(QAction(QIcon(Resources.get('icons/application-exit.png')), "Quit", self, triggered=self._AH_QuitActionTriggered))
            self.system_tray_icon.setContextMenu(menu)
            self.system_tray_icon.show()
        else:
            self.system_tray_icon = None

        # Accounts
        self.account_model = AccountModel(self)
        self.enabled_account_model = ActiveAccountModel(self.account_model, self)
        self.server_tools_account_model = ServerToolsAccountModel(self.account_model, self)
        self.identity.setModel(self.enabled_account_model)

        # Contacts
        self.contact_model = ContactModel(self)
        self.contact_search_model = ContactSearchModel(self.contact_model, self)
        self.contact_list.setModel(self.contact_model)
        self.search_list.setModel(self.contact_search_model)

        # Sessions (audio)
        self.session_model = AudioSessionModel(self)
        self.session_list.setModel(self.session_model)
        self.session_list.selectionModel().selectionChanged.connect(self._SH_SessionListSelectionChanged)

        # History
        self.history_manager = HistoryManager()

        # Windows, dialogs and panels
        self.about_panel = AboutPanel(self)
        self.conference_dialog = ConferenceDialog(self)
        self.contact_editor_dialog = ContactEditorDialog(self)
        self.google_contacts_dialog = GoogleContactsDialog(self)
        self.filetransfer_window = FileTransferWindow()
        self.preferences_window = PreferencesWindow(self.account_model, None)
        self.server_tools_window = ServerToolsWindow(self.server_tools_account_model, None)

        # Signals
        self.account_state.stateChanged.connect(self._SH_AccountStateChanged)
        self.account_state.clicked.connect(self._SH_AccountStateClicked)
        self.activity_note.editingFinished.connect(self._SH_ActivityNoteEditingFinished)
        self.add_contact_button.clicked.connect(self._SH_AddContactButtonClicked)
        self.add_search_contact_button.clicked.connect(self._SH_AddContactButtonClicked)
        self.audio_call_button.clicked.connect(self._SH_AudioCallButtonClicked)
        self.video_call_button.clicked.connect(self._SH_VideoCallButtonClicked)
        self.chat_session_button.clicked.connect(self._SH_ChatSessionButtonClicked)
        self.back_to_contacts_button.clicked.connect(self.search_box.clear) # this can be set in designer -Dan
        self.conference_button.makeConference.connect(self._SH_MakeConference)
        self.conference_button.breakConference.connect(self._SH_BreakConference)

        self.contact_list.selectionModel().selectionChanged.connect(self._SH_ContactListSelectionChanged)
        self.contact_model.itemsAdded.connect(self._SH_ContactModelAddedItems)
        self.contact_model.itemsRemoved.connect(self._SH_ContactModelRemovedItems)

        self.display_name.editingFinished.connect(self._SH_DisplayNameEditingFinished)
        self.hangup_all_button.clicked.connect(self._SH_HangupAllButtonClicked)

        self.identity.activated[int].connect(self._SH_IdentityChanged)
        self.identity.currentIndexChanged[int].connect(self._SH_IdentityCurrentIndexChanged)

        self.mute_button.clicked.connect(self._SH_MuteButtonClicked)

        self.search_box.textChanged.connect(self._SH_SearchBoxTextChanged)
        self.search_box.returnPressed.connect(self._SH_SearchBoxReturnPressed)
        self.search_box.shortcut.activated.connect(self.search_box.setFocus)

        self.search_list.selectionModel().selectionChanged.connect(self._SH_SearchListSelectionChanged)

        self.server_tools_account_model.rowsInserted.connect(self._SH_ServerToolsAccountModelChanged)
        self.server_tools_account_model.rowsRemoved.connect(self._SH_ServerToolsAccountModelChanged)

        self.session_model.sessionAdded.connect(self._SH_AudioSessionModelAddedSession)
        self.session_model.sessionRemoved.connect(self._SH_AudioSessionModelRemovedSession)
        self.session_model.structureChanged.connect(self._SH_AudioSessionModelChangedStructure)

        self.silent_button.clicked.connect(self._SH_SilentButtonClicked)
        self.switch_view_button.viewChanged.connect(self._SH_SwitchViewButtonChangedView)

        # Blink menu actions
        self.about_action.triggered.connect(self.about_panel.show)
        self.add_account_action.triggered.connect(self.preferences_window.show_add_account_dialog)
        self.manage_accounts_action.triggered.connect(self.preferences_window.show_for_accounts)
        self.help_action.triggered.connect(partial(QDesktopServices.openUrl, QUrl(u'http://icanblink.com/help-qt.phtml')))
        self.preferences_action.triggered.connect(self.preferences_window.show)
        self.auto_accept_chat_action.triggered.connect(self._AH_AutoAcceptChatActionTriggered)
        self.received_messages_sound_action.triggered.connect(self._AH_ReceivedMessagesSoundActionTriggered)
        self.answering_machine_action.triggered.connect(self._AH_EnableAnsweringMachineActionTriggered)
        self.release_notes_action.triggered.connect(partial(QDesktopServices.openUrl, QUrl(u'http://icanblink.com/changelog-qt.phtml')))
        self.quit_action.triggered.connect(self._AH_QuitActionTriggered)

        # Call menu actions
        self.redial_action.triggered.connect(self._AH_RedialActionTriggered)
        self.join_conference_action.triggered.connect(self.conference_dialog.show)
        self.history_menu.aboutToShow.connect(self._SH_HistoryMenuAboutToShow)
        self.history_menu.triggered.connect(self._AH_HistoryMenuTriggered)
        self.output_devices_group.triggered.connect(self._AH_AudioOutputDeviceChanged)
        self.input_devices_group.triggered.connect(self._AH_AudioInputDeviceChanged)
        self.alert_devices_group.triggered.connect(self._AH_AudioAlertDeviceChanged)
        self.video_devices_group.triggered.connect(self._AH_VideoDeviceChanged)
        self.mute_action.triggered.connect(self._SH_MuteButtonClicked)
        self.silent_action.triggered.connect(self._SH_SilentButtonClicked)

        # Tools menu actions
        self.sip_server_settings_action.triggered.connect(self._AH_SIPServerSettings)
        self.search_for_people_action.triggered.connect(self._AH_SearchForPeople)
        self.history_on_server_action.triggered.connect(self._AH_HistoryOnServer)

        # Window menu actions
        self.chat_window_action.triggered.connect(self._AH_ChatWindowActionTriggered)
        self.transfers_window_action.triggered.connect(self._AH_TransfersWindowActionTriggered)
        self.logs_window_action.triggered.connect(self._AH_LogsWindowActionTriggered)
        self.received_files_window_action.triggered.connect(self._AH_ReceivedFilesWindowActionTriggered)
        self.screenshots_window_action.triggered.connect(self._AH_ScreenshotsWindowActionTriggered)
예제 #11
0
class Example(QtGui.QMainWindow):

    
	def __init__(self):
	        super(Example, self).__init__()
		

		self.path=sys.path[0]
		f=open('%s/ACCESS_KEY'% self.path,'r')
		f1=open('%s/ACCESS_SECRET'% self.path,'r')
		f2=open('%s/user_info'% self.path)
		self.user_name=f2.readline().strip('\n')
		self.user_id=f2.readline().strip('\n')
		self.a=f.readline().strip('\n')
		self.b=f1.readline().strip('\n')
		f.close()
		f1.close()
		f2.close()
		self.initUI()
		
	def initUI(self):   
		
		self.icon=QSystemTrayIcon()
		self.icon.isSystemTrayAvailable() 
		self.icon.setIcon( QtGui.QIcon('%s/web.png'% self.path) )
		self.icon.setToolTip ( 'dubbleclick to maximize')
		self.icon.show()
		self.icon.activated.connect(self.activate)
		self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
                self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
		self.setGeometry(300, 300, 1500, 1000)
		frame = QtGui.QFrame(parent=self)
                frame.setStyleSheet("QFrame {background: rgba(0,0,0,50%)}")
		box=QtGui.QHBoxLayout()
		
		self.edit = QtGui.QLineEdit()
        	self.edit.setStyleSheet("background: rgba(0,0,0,100%); "" font-weight : bold;" "color:  rgb(250,250,250);""border:5px solid ")
		self.edit.setToolTip('please  <b>Enter your tweet here </b> ')
		self.edit.returnPressed.connect(self.returnPressed)
                box.addWidget(self.edit)	
		
		frame.setLayout(box)
	

		qbtn1 = QtGui.QPushButton('quit', self)
	        qbtn1.clicked.connect(self.close)
		qbtn1.setStyleSheet( "background: rgba(0,0,0,100%); "" font-weight : bold;" "color:  rgb(250,250,250);""border:5px solid ")
	        box.addWidget(qbtn1)
		self.statusBar().setStyleSheet("background: rgba(0,0,0,100%);"" font-weight : bold;" "color:  rgb(250,250,250)")
		self.statusBar().showMessage('Press Enter to send Tweet and press ESC to minimize to tray ')

		
		self.setCentralWidget(frame)  
		self.setWindowIcon(QtGui.QIcon('%s/web.png' % self. path)) 
		

	        self.setWindowTitle('Tweet Fast ')
		self.center()    
	        self.show()
		self.twitter_auth()
		
	def twitter_auth(self):
		
		CONSUMER_KEY = 'VQLDtkDTlbAmT95m5cMsYQ'
		CONSUMER_SECRET = 'bAC0BF69qiEVARJlfFJZZCDQ9mrcqofq16ilQ4OjU'      
		ACCESS_KEY=self.a
		ACCESS_SECRET=self.b
		self.auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
		self.auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
	        

	def keyPressEvent(self, e):
		if e.key() == QtCore.Qt.Key_Escape:
			print 'Escape wass pressed '
			self.icon.show()
			
                        self.hide()
	def activate(self,reason ):
			print reason 
			if reason==2:
				self.show()
	
	def center(self):
        
	        qr = self.frameGeometry()
	        cp = QtGui.QDesktopWidget().availableGeometry().center()
	        qr.moveCenter(cp)
	        self.move(qr.topLeft())

	def returnPressed(self):
		path=sys.path[0]
		tweet = self.edit.text()
		api = tweepy.API(self.auth)
		self.statusBar().showMessage('Sending... ')
		api.update_status(tweet) 
		self.statusBar().showMessage('Your Tweet was send ')
		n = pynotify.Notification(" @ %s "% self.user_name , "your tweet was send ","%s/%s.jpg" % (path,self.user_id))
                n.set_hint('x', 200)
                n.set_hint('y', 400)
                pynotify.init('n')		
                n.show()
		self.statusBar().showMessage('Press Enter to send Tweet and press ESC to minimize to tray ')
		self.edit.clear()
예제 #12
0
파일: main.py 프로젝트: PyAr/wefree
class MainUI(QMainWindow):
    """Main UI."""

    def __init__(self, app_quit):
        super(MainUI, self).__init__()
        self.app_quit = app_quit
        self.wifi = WifiInterfaces()
        logger.debug("Main UI started ok")
        self.sti = None
        self.load_icons()
        self.iconize()
        self.wifi.connect_signals(self.refresh_menu_items, self.update_connected_state)
        #QtCore.QTimer.singleShot(1500, self.timer)

    #def timer(self):
        #print("Hello madafaka")
        #QtCore.QTimer.singleShot(1500, self.start)

    def open_about_dialog(self):
        """Show the about dialog."""
        QMessageBox.about(self, "WeFreed networks Inc.", ABOUT_TEXT)

    def icon_for_signal(self, signal):
        level_index = bisect(SIGNAL_BREAKPOINTS, signal.level)
        if signal.has_db_passwords():
            icons = self.icons['wefree']
        else:
            if signal.encrypted:
                lock = 'lock-'
            else:
                lock = ''
            if not signal.encrypted or signal.has_password():
                icons = self.icons[lock+'signals']
            else:
                icons = self.icons['lock-signals-unknown']

        return icons[SIGNALS_IMGS[level_index]]

    def build_menu(self, signals):
        """Build the menu."""
        def action_cmp(a,b):
            aText = a.text().upper()
            bText = b.text().upper()
            if aText == bText: return 0
            if aText < bText: return -1
            return 1

        menu = QMenu(self)

        connected = False
        # the signals
        signal_actions = []
        for signal in signals:
            icon = self.icon_for_signal(signal)

            if signal.is_connected():
                connected = True

            when_triggered = (lambda sign: lambda:self.please_connect(sign))(signal)
            action = QAction(icon, signal.ssid, self, triggered = when_triggered)
            signal_actions.append(action)

        signal_actions.sort(cmp = action_cmp)
        menu.addActions(signal_actions)

        self.update_connected_state(connected)

        # the bottom part
        menu.addSeparator()
        menu.addAction(QAction("Share...",        self, triggered=self.share_keys))
        menu.addAction(QAction("Update Database", self, triggered=self.update_database))
        menu.addAction(QAction("Rescan",          self, triggered=self.rescan_networks))
        menu.addAction(QAction("Quit",            self, triggered=self.app_quit))
        menu.addAction(QAction("WTF?",            self, triggered=self.open_about_dialog))
        return menu

    def please_connect(self, signal):
        logger.debug("Requested connection %s" % signal.ssid)
        if not signal.has_password() and signal.encrypted:
            self.get_password_for(signal)
        else:
            self.wifi.connect(signal)

    def get_password_for(self, signal):
        logger.debug("Need password for %s" % signal.ssid)

        d = AddPasswordDialog(self, self.wifi, signal)
        d.show()

    def share_keys(self):
        to_commit = self.wifi.get_known_networks()
        to_commit = ShareOwnPasswords(self, to_commit).exec_()
        for ap in to_commit:
            PM.add_new_ap(ap)
            PM.report_success_ap(ap, auto_location = False)

    def rescan_networks(self):
        self.wifi.force_rescan()

    def refresh_menu_items(self, *args):
        """Refresh."""
        signals = self.wifi.get_signals()

        menu = self.build_menu(signals)
        self.sti.setContextMenu(menu)

        bssids = [signal.bssid for signal in signals]
        GEO.refresh_seen_bssids(bssids)

    update_done_signal = QtCore.pyqtSignal()

    def update_database(self):
        class UpdateFromServerTask(QtCore.QThread):
            update_done_signal = self.update_done_signal
            def run(self):
                PM.get_passwords_from_server()
                self.update_done_signal.emit()

        self.update_done_signal.connect(self.update_database_done)
        self.update_task = UpdateFromServerTask()
        self.update_task.start()

    def update_database_done(self):
        self.refresh_menu_items()
        self.update_task = None

    def load_icons(self):
        self.icons = dict()
        self.icons['wefree'] = dict()
        self.icons['signals'] = dict()
        self.icons['lock-signals'] = dict()
        self.icons['lock-signals-unknown'] = dict()

        for strength in SIGNALS_IMGS:
            self.icons['wefree'][strength]                 = QIcon(":/imgs/wefree-192.%d.png" % strength)
            self.icons['signals'][strength]                = QIcon(":/imgs/signals.%d.png" % strength)
            self.icons['lock-signals'][strength]           = QIcon(":/imgs/lock-signals.%d.png" % strength)
            self.icons['lock-signals-unknown'][strength]   = QIcon(":/imgs/lock-signals-unknown.%d.png" % strength)

    def iconize(self):
        """Show a system tray icon with a small icon."""

        self.sti = QSystemTrayIcon(self.icons['wefree'][0], self)
        if not self.sti.isSystemTrayAvailable():
            logger.warning("System tray not available.")
            return

        self.refresh_menu_items()
        self.sti.show()

    def update_connected_state(self, connected):
        if connected:
            self.sti.setIcon(self.icons['wefree'][100])
        else:
            self.sti.setIcon(self.icons['wefree'][0])
예제 #13
0
class Example(QtGui.QMainWindow):
    def __init__(self):
        super(Example, self).__init__()

        self.path = sys.path[0]
        f = open("%s/ACCESS_KEY" % self.path, "r")
        f1 = open("%s/ACCESS_SECRET" % self.path, "r")
        f2 = open("%s/user_info" % self.path)
        self.user_name = f2.readline().strip("\n")
        self.user_id = f2.readline().strip("\n")
        self.a = f.readline().strip("\n")
        self.b = f1.readline().strip("\n")
        f.close()
        f1.close()
        f2.close()
        self.initUI()

    def initUI(self):

        self.icon = QSystemTrayIcon()
        self.icon.isSystemTrayAvailable()
        self.icon.setIcon(QtGui.QIcon("%s/me.jpg" % self.path))
        self.icon.setToolTip("dubbleclick untuk maximize")
        self.icon.show()
        self.icon.activated.connect(self.activate)
        self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
        self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
        self.setGeometry(150, 150, 500, 200)
        frame = QtGui.QFrame(parent=self)
        frame.setStyleSheet("QFrame {background: rgba(0,0,0,50%)}")
        box = QtGui.QHBoxLayout()

        self.edit = QtGui.QLineEdit()
        self.edit.setStyleSheet(
            "background: rgba(0,0,0,100%); " " font-weight : bold;" "color:  rgb(250,250,250);" "border:5px solid "
        )
        self.edit.setToolTip("Tolong  <b>Massukan tweet Anda di sini </b> ")
        self.edit.returnPressed.connect(self.returnPressed)
        box.addWidget(self.edit)

        frame.setLayout(box)

        qbtn1 = QtGui.QPushButton("keluar", self)
        qbtn1.clicked.connect(self.close)
        qbtn1.setStyleSheet(
            "background: rgba(0,0,0,100%); " " font-weight : bold;" "color:  rgb(250,250,250);" "border:5px solid "
        )
        box.addWidget(qbtn1)
        self.statusBar().setStyleSheet(
            "background: rgba(0,0,0,100%);" " font-weight : bold;" "color:  rgb(250,250,250)"
        )
        self.statusBar().showMessage("Tekan enter untuk mengirim twitter, ESC untuk minimize")

        self.setCentralWidget(frame)
        self.setWindowIcon(QtGui.QIcon("%s/me.jpg" % self.path))

        self.setWindowTitle("Twitter Client With PyQt4")
        self.center()
        self.show()
        self.twitter_auth()

    def twitter_auth(self):

        CONSUMER_KEY = "gYMpKX6YWDP5rBwvCcriQ"
        CONSUMER_SECRET = "ulK4WA6gtB5FekyPYRrOXVCxeqvwP66leFfNq5DY"
        ACCESS_KEY = self.a
        ACCESS_SECRET = self.b
        self.auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
        self.auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)

    def keyPressEvent(self, e):
        if e.key() == QtCore.Qt.Key_Escape:
            print "Escape wass pressed "
            self.icon.show()

            self.hide()

    def activate(self, reason):
        print reason
        if reason == 2:
            self.show()

    def center(self):

        qr = self.frameGeometry()
        cp = QtGui.QDesktopWidget().availableGeometry().center()
        qr.moveCenter(cp)
        self.move(qr.topLeft())

    def returnPressed(self):
        path = sys.path[0]
        tweet = self.edit.text()
        api = tweepy.API(self.auth)
        self.statusBar().showMessage("Mengirim . ..  ")
        api.update_status(tweet)
        self.statusBar().showMessage("Twitter Anda terkirim ! ")
        n = pynotify.Notification(
            " @ %s " % self.user_name, "twitter Anda terkirim ", "%s/%s.jpg" % (path, self.user_id)
        )
        n.set_hint("x", 200)
        n.set_hint("y", 400)
        pynotify.init("n")
        n.show()
        self.statusBar().showMessage("Tekan enter untuk mengirim dan tekan ESC untuk minimize ")
        self.edit.clear()
예제 #14
0
def main():
    """
    launches the main event loop
    long live to the (hidden) leap window!
    """
    import sys
    from leap.util import leap_argparse
    parser, opts = leap_argparse.init_leapc_args()
    debug = getattr(opts, 'debug', False)

    # XXX get severity from command line args
    if debug:
        level = logging.DEBUG
    else:
        level = logging.WARNING

    logger = logging.getLogger(name='leap')
    logger.setLevel(level)
    console = logging.StreamHandler()
    console.setLevel(level)
    formatter = logging.Formatter(
        '%(asctime)s '
        '- %(name)s - %(levelname)s - %(message)s')
    console.setFormatter(formatter)
    logger.addHandler(console)

    logger.info('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
    logger.info('LEAP client version %s', VERSION)
    logger.info('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
    logfile = getattr(opts, 'log_file', False)
    if logfile:
        logger.debug('setting logfile to %s ', logfile)
        fileh = logging.FileHandler(logfile)
        fileh.setLevel(logging.DEBUG)
        fileh.setFormatter(formatter)
        logger.addHandler(fileh)

    logger.info('Starting app')
    app = QApplication(sys.argv)

    # launch polkit-auth agent if needed
    if platform.system() == "Linux":
        polkit.check_if_running_polkit_auth()

    # To test:
    # $ LANG=es ./app.py
    locale = QtCore.QLocale.system().name()
    qtTranslator = QtCore.QTranslator()
    if qtTranslator.load("qt_%s" % locale, ":/translations"):
        app.installTranslator(qtTranslator)
    appTranslator = QtCore.QTranslator()
    if appTranslator.load("leap_client_%s" % locale, ":/translations"):
        app.installTranslator(appTranslator)

    # needed for initializing qsettings
    # it will write .config/leap/leap.conf
    # top level app settings
    # in a platform independent way
    app.setOrganizationName("leap")
    app.setApplicationName("leap")
    app.setOrganizationDomain("leap.se")

    # XXX we could check here
    # if leap-client is already running, and abort
    # gracefully in that case.

    if not QSystemTrayIcon.isSystemTrayAvailable():
        QMessageBox.critical(None, "Systray",
                             "I couldn't detect"
                             "any system tray on this system.")
        sys.exit(1)
    if not debug:
        QApplication.setQuitOnLastWindowClosed(False)

    window = LeapWindow(opts)

    # this dummy timer ensures that
    # control is given to the outside loop, so we
    # can hook our sigint handler.
    timer = QtCore.QTimer()
    timer.start(500)
    timer.timeout.connect(lambda: None)

    sigint_window = partial(sigint_handler, window, logger=logger)
    signal.signal(signal.SIGINT, sigint_window)

    if debug:
        # we only show the main window
        # if debug mode active.
        # if not, it will be set visible
        # from the systray menu.
        window.show()
        if sys.platform == "darwin":
            window.raise_()

    # run main loop
    sys.exit(app.exec_())
예제 #15
0
    self.setIcon(QIcon(self.kbMap[self.currentOpt]))
###############################################################################
  def showAbout(self):
    QMessageBox.about(self.nxkbConfig, "About NeutraXkbSwich",
        """<h2>{} {}</h2>
        <p>A Python/PyQt4 tool to globally switch between X keyboard layouts.</p>
        <p>Copyright &copy; 2014 - Abdalla Saeed Abdalla Alothman<br />
        Kuwait - July 17, 2014<br />
        <a href="mailto:[email protected]">[email protected]</a>
        </p>
        <h3>Credits</h3>
        <p>Application Icon: <a href="http://www.pinterest.com/pin/188517934376093096/">Say Cheese (Finger Art, at Tumblr)</a>
        <br />
        Flag Icons: <a href="http://kampongboy92.deviantart.com/art/World-Flags-63208143">World Flags, by kampongboy92</a>
        </p>
        <p><b>{}</b> is currently using Python {} with Qt {} and PyQt {} on your system ({}).</p>""".format(self.progName,
          self.version, self.progName, platform.python_version(), QT_VERSION_STR, PYQT_VERSION_STR, platform.system()))
###############################################################################
if __name__ == "__main__":
  sys.settrace
  import signal
  signal.signal(signal.SIGINT, signal.SIG_DFL)
  kbswitcher = QApplication(sys.argv)
  if not QSystemTrayIcon.isSystemTrayAvailable():
    from PyQt4.QtGui import QMessageBox
    QMessageBox.critical(None, "XKBSwitcher",
        "No current system tray is served on this desktop.\nTry running a panel with a system tray \(e.g. razor-panel or tint2.\)")
    sys.exit(1)
  xbswitcher = NeutraXkbSwitch()
  sys.exit(kbswitcher.exec_())
예제 #16
0
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.saved_account_state = None

        notification_center = NotificationCenter()
        notification_center.add_observer(self, name='SIPApplicationWillStart')
        notification_center.add_observer(self, name='SIPApplicationDidStart')
        notification_center.add_observer(self, name='SIPAccountGotMessageSummary')
        notification_center.add_observer(self, name='SIPAccountGotPendingWatcher')
        notification_center.add_observer(self, name='BlinkSessionNewOutgoing')
        notification_center.add_observer(self, name='BlinkSessionDidReinitializeForOutgoing')
        notification_center.add_observer(self, name='BlinkFileTransferNewIncoming')
        notification_center.add_observer(self, name='BlinkFileTransferNewOutgoing')
        notification_center.add_observer(self, name='DocumentSharingFileTransferCompleted')
        notification_center.add_observer(self, sender=AccountManager())

        icon_manager = IconManager()

        self.pending_watcher_dialogs = []

        self.mwi_icons = [QIcon(Resources.get('icons/mwi-%d.png' % i)) for i in xrange(0, 11)]
        self.mwi_icons.append(QIcon(Resources.get('icons/mwi-many.png')))

        with Resources.directory:
            self.setupUi()

        self.setWindowTitle('Blink')
        self.setWindowIconText('Blink')

        geometry = QSettings().value("main_window/geometry")
        if geometry:
            self.restoreGeometry(geometry)

        self.default_icon_path = Resources.get('icons/default-avatar.png')
        self.default_icon = QIcon(self.default_icon_path)
        self.last_icon_directory = Path('~').normalized
        self.set_user_icon(icon_manager.get('avatar'))

        self.active_sessions_label.hide()
        self.enable_call_buttons(False)
        self.conference_button.setEnabled(False)
        self.hangup_all_button.setEnabled(False)
        self.sip_server_settings_action.setEnabled(False)
        self.search_for_people_action.setEnabled(False)
        self.history_on_server_action.setEnabled(False)
        self.main_view.setCurrentWidget(self.contacts_panel)
        self.contacts_view.setCurrentWidget(self.contact_list_panel)
        self.search_view.setCurrentWidget(self.search_list_panel)

        # System tray
        if QSystemTrayIcon.isSystemTrayAvailable():
            self.system_tray_icon = QSystemTrayIcon(QIcon(Resources.get('icons/blink.png')), self)
            self.system_tray_icon.activated.connect(self._SH_SystemTrayIconActivated)
            menu = QMenu(self)
            menu.addAction(QAction("Show", self, triggered=self._AH_SystemTrayShowWindow))
            menu.addAction(QAction(QIcon(Resources.get('icons/application-exit.png')), "Quit", self, triggered=self._AH_QuitActionTriggered))
            self.system_tray_icon.setContextMenu(menu)
            self.system_tray_icon.show()
        else:
            self.system_tray_icon = None

        # Accounts
        self.account_model = AccountModel(self)
        self.enabled_account_model = ActiveAccountModel(self.account_model, self)
        self.server_tools_account_model = ServerToolsAccountModel(self.account_model, self)
        self.identity.setModel(self.enabled_account_model)

        # Contacts
        self.contact_model = ContactModel(self)
        self.contact_search_model = ContactSearchModel(self.contact_model, self)
        self.contact_list.setModel(self.contact_model)
        self.search_list.setModel(self.contact_search_model)

        # Sessions (audio)
        self.session_model = AudioSessionModel(self)
        self.session_list.setModel(self.session_model)
        self.session_list.selectionModel().selectionChanged.connect(self._SH_SessionListSelectionChanged)

        # History
        self.history_manager = HistoryManager()

        # Windows, dialogs and panels
        self.about_panel = AboutPanel(self)
        self.conference_dialog = ConferenceDialog(self)
        self.contact_editor_dialog = ContactEditorDialog(self)
        self.google_contacts_dialog = GoogleContactsDialog(self)
        self.filetransfer_window = FileTransferWindow()
        self.preferences_window = PreferencesWindow(self.account_model, None)
        self.server_tools_window = ServerToolsWindow(self.server_tools_account_model, None)

        self.documents_window = DocumentsWindow()

        # Signals
        self.account_state.stateChanged.connect(self._SH_AccountStateChanged)
        self.account_state.clicked.connect(self._SH_AccountStateClicked)
        self.activity_note.editingFinished.connect(self._SH_ActivityNoteEditingFinished)
        self.add_contact_button.clicked.connect(self._SH_AddContactButtonClicked)
        self.add_search_contact_button.clicked.connect(self._SH_AddContactButtonClicked)
        self.audio_call_button.clicked.connect(self._SH_AudioCallButtonClicked)
        self.video_call_button.clicked.connect(self._SH_VideoCallButtonClicked)
        self.chat_session_button.clicked.connect(self._SH_ChatSessionButtonClicked)
        self.share_document_button.clicked.connect(self._SH_ShareDocumentButtonClicked)
        self.back_to_contacts_button.clicked.connect(self.search_box.clear) # this can be set in designer -Dan
        self.conference_button.makeConference.connect(self._SH_MakeConference)
        self.conference_button.breakConference.connect(self._SH_BreakConference)

        self.contact_list.selectionModel().selectionChanged.connect(self._SH_ContactListSelectionChanged)
        self.contact_model.itemsAdded.connect(self._SH_ContactModelAddedItems)
        self.contact_model.itemsRemoved.connect(self._SH_ContactModelRemovedItems)

        self.display_name.editingFinished.connect(self._SH_DisplayNameEditingFinished)
        self.hangup_all_button.clicked.connect(self._SH_HangupAllButtonClicked)

        self.identity.activated[int].connect(self._SH_IdentityChanged)
        self.identity.currentIndexChanged[int].connect(self._SH_IdentityCurrentIndexChanged)

        self.mute_button.clicked.connect(self._SH_MuteButtonClicked)

        self.search_box.textChanged.connect(self._SH_SearchBoxTextChanged)
        self.search_box.returnPressed.connect(self._SH_SearchBoxReturnPressed)
        self.search_box.shortcut.activated.connect(self.search_box.setFocus)

        self.search_list.selectionModel().selectionChanged.connect(self._SH_SearchListSelectionChanged)

        self.server_tools_account_model.rowsInserted.connect(self._SH_ServerToolsAccountModelChanged)
        self.server_tools_account_model.rowsRemoved.connect(self._SH_ServerToolsAccountModelChanged)

        self.session_model.sessionAdded.connect(self._SH_AudioSessionModelAddedSession)
        self.session_model.sessionRemoved.connect(self._SH_AudioSessionModelRemovedSession)
        self.session_model.structureChanged.connect(self._SH_AudioSessionModelChangedStructure)

        self.silent_button.clicked.connect(self._SH_SilentButtonClicked)
        self.switch_view_button.viewChanged.connect(self._SH_SwitchViewButtonChangedView)

        # Blink menu actions
        self.about_action.triggered.connect(self.about_panel.show)
        self.add_account_action.triggered.connect(self.preferences_window.show_add_account_dialog)
        self.manage_accounts_action.triggered.connect(self.preferences_window.show_for_accounts)
        self.help_action.triggered.connect(partial(QDesktopServices.openUrl, QUrl(u'http://icanblink.com/help-qt.phtml')))
        self.preferences_action.triggered.connect(self.preferences_window.show)
        self.auto_accept_chat_action.triggered.connect(self._AH_AutoAcceptChatActionTriggered)
        self.received_messages_sound_action.triggered.connect(self._AH_ReceivedMessagesSoundActionTriggered)
        self.answering_machine_action.triggered.connect(self._AH_EnableAnsweringMachineActionTriggered)
        self.release_notes_action.triggered.connect(partial(QDesktopServices.openUrl, QUrl(u'http://icanblink.com/changelog-qt.phtml')))
        self.quit_action.triggered.connect(self._AH_QuitActionTriggered)

        # Call menu actions
        self.redial_action.triggered.connect(self._AH_RedialActionTriggered)
        self.join_conference_action.triggered.connect(self.conference_dialog.show)
        self.history_menu.aboutToShow.connect(self._SH_HistoryMenuAboutToShow)
        self.history_menu.triggered.connect(self._AH_HistoryMenuTriggered)
        self.output_devices_group.triggered.connect(self._AH_AudioOutputDeviceChanged)
        self.input_devices_group.triggered.connect(self._AH_AudioInputDeviceChanged)
        self.alert_devices_group.triggered.connect(self._AH_AudioAlertDeviceChanged)
        self.video_devices_group.triggered.connect(self._AH_VideoDeviceChanged)
        self.mute_action.triggered.connect(self._SH_MuteButtonClicked)
        self.silent_action.triggered.connect(self._SH_SilentButtonClicked)

        # Tools menu actions
        self.sip_server_settings_action.triggered.connect(self._AH_SIPServerSettings)
        self.search_for_people_action.triggered.connect(self._AH_SearchForPeople)
        self.history_on_server_action.triggered.connect(self._AH_HistoryOnServer)

        # Window menu actions
        self.chat_window_action.triggered.connect(self._AH_ChatWindowActionTriggered)
        self.transfers_window_action.triggered.connect(self._AH_TransfersWindowActionTriggered)
        self.logs_window_action.triggered.connect(self._AH_LogsWindowActionTriggered)
        self.received_files_window_action.triggered.connect(self._AH_ReceivedFilesWindowActionTriggered)
        self.screenshots_window_action.triggered.connect(self._AH_ScreenshotsWindowActionTriggered)
        self.documents_window_action.triggered.connect(self._AH_DocumentsWindowActionTriggered)
예제 #17
0
파일: main.py 프로젝트: denmehta/ats
class Example(QtGui.QWidget):
    def __init__(self):
            super(Example, self).__init__()        
            self.initUI()
    def openApex(self):
        
        if self.call_id:
            webbrowser.open("http://tca-db1.astrakhan.businesscar.ru:8080/apex/f?p=999:1:0::NO:1:P1_ID_CUSTOMER:"+self.customer_id)
     
    def openCrm(self):
        
        if self.customer_id:
           
            webbrowser.open("http://tca-crm/sugar/index.php?action=ajaxui#ajaxUILoc=index.php%3Fmodule%3DCalls%26offset%3D15%26stamp%3D1395146164095815300%26return_module%3DCalls%26action%3DDetailView%26record%3D"+self.call_id)
    
    
 
    def initUI(self):              
        self.icon=QSystemTrayIcon()
        r=self.icon.isSystemTrayAvailable()
        self.customer_id=""
        self.call_id = ""
        self.icon.setIcon( QtGui.QIcon('w:\icon.png') )
        self.icon.show()
        self.setGeometry(350, 30, 640, 480)
        self.setWindowIcon(QtGui.QIcon('w:\icon.png'))          
        self.setWindowTitle(u'CallCenter')    
        self.show()
        self.icon.activated.connect(self.activate)
        self.show()        
        self.icon.menu = QtGui.QMenu()
        exitAction = self.icon.menu.addAction(u"Выход")
        self.icon.setContextMenu(self.icon.menu)
        self.connect(exitAction, QtCore.SIGNAL('triggered()'),QtGui.qApp, QtCore.SLOT('quit()'))
        
        general_groupbox = QtGui.QGroupBox(u"Общая информация",self)
        general_groupbox.show()
        
        self.title_label = RedLabel(u"Название:")
        surname_label = QtGui.QLabel(u"Фамилия:")
        name_label = QtGui.QLabel(u"Имя:")
        secondName_label = QtGui.QLabel(u"Отчество:")
        clientType_label = RedLabel(u"Тип клиента:")
        gender_label = RedLabel(u"Пол:")
        burthday_label = RedLabel(u"Дата рождения:")
        regDate_label = QtGui.QLabel(u"Дата рег-ции:")
        
        
        phone_label = QtGui.QLabel(u"Тел.:")
        mobilePhone_label = QtGui.QLabel(u"Моб. тел.:")
        fax_label = QtGui.QLabel(u"Факс:")
        indexCity_label = QtGui.QLabel(u"Индекс\Город:")
        address_label = QtGui.QLabel(u"Адрес:")
        
        
        
        self.phone_text = LineEdit()
        mobilePhone_text = LineEdit()
        fax_text = LineEdit()
        indexCity_text = LineEdit()
        address_text = LineEdit()
        
        
        
        
        
        self.title_text = LineEdit()
        surname_text = LineEdit()
        name_text = LineEdit()
        secondName_text = LineEdit()
        clientType_text = LineEdit()
        clientCode_text = LineEdit()
        brunch_text = LineEdit()
        transport_text = LineEdit()
        paymentType_text = LineEdit()
        maxSale_text = LineEdit()
        gender_text = LineEdit()
        burthday_text = LineEdit()
        regDate_text = LineEdit()
        lastVisit_text = LineEdit()
        
       
       
       
       
        general_layoutBox = QtGui.QGridLayout(self)
        general_layoutBox.setSpacing(10)
        general_layoutBox.setColumnMinimumWidth(0,0)
        general_layoutBox.addWidget(self.title_label,0,0)
        general_layoutBox.addWidget(self.title_text,0,1)
        general_layoutBox.addWidget(surname_label)  
        general_layoutBox.addWidget(surname_text)  
        general_layoutBox.addWidget(name_label)         
        general_layoutBox.addWidget(name_text)
        general_layoutBox.addWidget(secondName_label)    
        general_layoutBox.addWidget(secondName_text)
        general_layoutBox.addWidget(clientType_label)         
        general_layoutBox.addWidget(clientType_text) 
        general_layoutBox.addWidget(gender_label)        
        general_layoutBox.addWidget(gender_text)  
        general_layoutBox.addWidget(burthday_label)          
        general_layoutBox.addWidget(burthday_text) 
        general_layoutBox.addWidget(regDate_label)         
        general_layoutBox.addWidget(regDate_text)    
        general_groupbox.setLayout(general_layoutBox)
        
        
        personal_groupbox = QtGui.QGroupBox(u"Персональные настройки",self)
        personal_groupbox.show()
        self.apex_button = QtGui.QPushButton(u"Подробно")
        self.apex_button.resize(100,50)
        self.apex_button.hide()
        self.connect(self.apex_button, QtCore.SIGNAL('clicked()'), self.openApex)
        
        
        self.crm_button = QtGui.QPushButton(u"CRM")
        self.crm_button.resize(100,50)
        self.crm_button.hide()
        self.connect(self.crm_button, QtCore.SIGNAL('clicked()'), self.openCrm)
        
        
        grid = QtGui.QGridLayout(self)
        grid.addWidget(lastVisit_text,0,0)
        grid.addWidget(self.apex_button)
        grid.addWidget(self.crm_button)
        # grid.addStretch(1)
        
        
        personal_groupbox.setLayout(grid)
        
        
        
        address_layoutBox = QtGui.QGridLayout(self)
        address_layoutBox.setSpacing(10)
        address_layoutBox.setColumnMinimumWidth(0,0)
        address_layoutBox.addWidget(phone_label,0,0)
        address_layoutBox.addWidget(self.phone_text,0,1)
        address_layoutBox.addWidget(mobilePhone_label)
        address_layoutBox.addWidget(mobilePhone_text)
        address_layoutBox.addWidget(fax_label)
        address_layoutBox.addWidget(fax_text)
        address_layoutBox.addWidget(indexCity_label)
        address_layoutBox.addWidget(indexCity_text)
        address_layoutBox.addWidget(address_label)
        address_layoutBox.addWidget(address_text)
        
        
        
        
        
        
        address_groupbox = QtGui.QGroupBox(u"Адрес",self)
        address_groupbox.setLayout( address_layoutBox)
        address_groupbox.show()
        
        
        
        
        
        
        
        
        vertbox = QtGui.QGridLayout(self)
        vertbox.setColumnMinimumWidth(1,0)

        vertbox.addWidget(general_groupbox,0,0)
        vertbox.addWidget(personal_groupbox,0,1,1,50)
        vertbox.addWidget(address_groupbox,1,0,10,50)
        
        
        self.udpSocket = QtNetwork.QUdpSocket()
        self.udpSocket.bind(14541)
        self.udpSocket.readyRead.connect(self.recieveCall)
        
    def recieveCall(self):
        # self.title_text.setText(self.udpSocket.readDatagram())
         while self.udpSocket.hasPendingDatagrams():
            datagram, host, port = self.udpSocket.readDatagram(self.udpSocket.pendingDatagramSize())
 
            try:
                datagram = str(datagram, encoding='ascii')
            except TypeError:
                pass
            
            data = datagram.split(',')
            phone = data[0]
            self.customer_id = data[1] 
            self.call_id = data[2]
            self.phone_text.setText(phone)
            self.apex_button.show()
            self.crm_button.show()
            self.title_text.setText(self.getCustomer(self.customer_id))
    
    def getCustomer(self,customer_id):
        db = MySQLdb.connect(host="10.36.100.245",user="******", passwd="tcaadmin36", db="sugarcrm")
        cursormsql = db.cursor()
        db.set_character_set('utf8')
        cursormsql.execute('SET NAMES utf8;')
        cursormsql.execute('SET CHARACTER SET utf8;')
        cursormsql.execute('SET character_set_connection=utf8;')

        cursormsql.execute("""SELECT name FROM accounts WHERE id = %s""" ,(customer_id,))
        results = cursormsql.fetchone()
        return unicode(results[0],"utf-8")
        
        

            # webbrowser.open("http://tca-db1.astrakhan.businesscar.ru:8080/apex/f?p=999:1:0::NO:1:P1_ID_CUSTOMER:"+self.customer_id)
             
    def closeEvent(self, event):
 
 
            reply = QtGui.QMessageBox.question(self, u'Сообщение',u"Вы действительно хотите выйти?", QtGui.QMessageBox.Yes |
            QtGui.QMessageBox.No, QtGui.QMessageBox.No)
 
            if reply == QtGui.QMessageBox.Yes:
                event.accept()
            else:
                self.icon.show()
 
                self.hide()
 
 
                event.ignore()      
    def activate(self,reason ):
        # print reason
        if reason==2:
            self.show()
 
 
 
    def __icon_activated(self, reason):
              if reason == QtGui.QSystemTrayIcon.DoubleClick:
                self.show()