本文整理汇总了Python中PyQt4.QtGui.QSystemTrayIcon.isSystemTrayAvailable方法的典型用法代码示例。如果您正苦于以下问题:Python QSystemTrayIcon.isSystemTrayAvailable方法的具体用法?Python QSystemTrayIcon.isSystemTrayAvailable怎么用?Python QSystemTrayIcon.isSystemTrayAvailable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QSystemTrayIcon
的用法示例。
在下文中一共展示了QSystemTrayIcon.isSystemTrayAvailable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import isSystemTrayAvailable [as 别名]
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()
示例2: show
# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import isSystemTrayAvailable [as 别名]
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()
示例3: main
# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import isSystemTrayAvailable [as 别名]
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_())
示例4: main
# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import isSystemTrayAvailable [as 别名]
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 protected]" #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)
示例5: isTrayAvailable
# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import isSystemTrayAvailable [as 别名]
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
示例6: main
# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import isSystemTrayAvailable [as 别名]
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_())
示例7: __init__
# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import isSystemTrayAvailable [as 别名]
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()
示例8: Example
# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import isSystemTrayAvailable [as 别名]
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 ")
示例9: showAbout
# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import isSystemTrayAvailable [as 别名]
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 © 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_())
示例10: __init__
# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import isSystemTrayAvailable [as 别名]
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)
#.........这里部分代码省略.........
示例11: Example
# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import isSystemTrayAvailable [as 别名]
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')
#.........这里部分代码省略.........
示例12: Example
# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import isSystemTrayAvailable [as 别名]
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)
#.........这里部分代码省略.........
示例13: main
# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import isSystemTrayAvailable [as 别名]
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_())
示例14: MainUI
# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import isSystemTrayAvailable [as 别名]
#.........这里部分代码省略.........
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])
示例15: Example
# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import isSystemTrayAvailable [as 别名]
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)
#.........这里部分代码省略.........