本文整理汇总了Python中python_qt_binding.QtGui.QApplication.exec_方法的典型用法代码示例。如果您正苦于以下问题:Python QApplication.exec_方法的具体用法?Python QApplication.exec_怎么用?Python QApplication.exec_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类python_qt_binding.QtGui.QApplication
的用法示例。
在下文中一共展示了QApplication.exec_方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from python_qt_binding.QtGui import QApplication [as 别名]
# 或者: from python_qt_binding.QtGui.QApplication import exec_ [as 别名]
def main():
app = QApplication(sys.argv)
test_g = MainWidget()
test_g.show()
return app.exec_()
示例2: main
# 需要导入模块: from python_qt_binding.QtGui import QApplication [as 别名]
# 或者: from python_qt_binding.QtGui.QApplication import exec_ [as 别名]
def main(name):
try:
from python_qt_binding.QtGui import QApplication
except:
print >> sys.stderr, "please install 'python_qt_binding' package!!"
sys.exit(-1)
masteruri = init_cfg_path()
parser = init_arg_parser()
args = rospy.myargv(argv=sys.argv)
parsed_args = parser.parse_args(args[1:])
# Initialize Qt
global app
app = QApplication(sys.argv)
# decide to show main or echo dialog
global main_form
if parsed_args.echo:
main_form = init_echo_dialog(name, masteruri, parsed_args.echo[0], parsed_args.echo[1], parsed_args.hz)
else:
main_form = init_main_window(name, masteruri, parsed_args.file)
# resize and show the qt window
if not rospy.is_shutdown():
os.chdir(PACKAGE_DIR) # change path to be able to the images of descriptions
main_form.resize(1024, 720)
screen_size = QApplication.desktop().availableGeometry()
if main_form.size().width() >= screen_size.width() or main_form.size().height() >= screen_size.height()-24:
main_form.showMaximized()
else:
main_form.show()
exit_code = -1
rospy.on_shutdown(finish)
exit_code = app.exec_()
示例3: main
# 需要导入模块: from python_qt_binding.QtGui import QApplication [as 别名]
# 或者: from python_qt_binding.QtGui.QApplication import exec_ [as 别名]
def main(name):
'''
Start the NodeManager or EchoDialog.
:param name: the name propagated to the rospy.init_node()
:type name: str
'''
try:
from python_qt_binding.QtGui import QApplication
except:
try:
from python_qt_binding.QtWidgets import QApplication
except:
print >> sys.stderr, "please install 'python_qt_binding' package!!"
sys.exit(-1)
init_settings()
parser = init_arg_parser()
args = rospy.myargv(argv=sys.argv)
parsed_args = parser.parse_args(args[1:])
if parsed_args.muri:
masteruri = parsed_args.muri[0]
hostname = NameResolution.get_ros_hostname(masteruri)
os.environ['ROS_MASTER_URI'] = masteruri
if hostname:
os.environ['ROS_HOSTNAME'] = hostname
masteruri = settings().masteruri()
# Initialize Qt
global _QAPP
_QAPP = QApplication(sys.argv)
# decide to show main or echo dialog
global _MAIN_FORM
try:
if parsed_args.echo:
_MAIN_FORM = init_echo_dialog(name, masteruri, parsed_args.echo[0],
parsed_args.echo[1], parsed_args.hz,
parsed_args.ssh)
else:
_MAIN_FORM = init_main_window(name, masteruri, parsed_args.file)
except Exception as err:
sys.exit("%s" % err)
exit_code = 0
# resize and show the qt window
if not rospy.is_shutdown():
# change path for access to the images of descriptions
os.chdir(settings().PACKAGE_DIR)
# _MAIN_FORM.resize(1024, 720)
screen_size = QApplication.desktop().availableGeometry()
if (_MAIN_FORM.size().width() >= screen_size.width() or
_MAIN_FORM.size().height() >= screen_size.height() - 24):
_MAIN_FORM.showMaximized()
else:
_MAIN_FORM.show()
exit_code = -1
rospy.on_shutdown(finish)
exit_code = _QAPP.exec_()
return exit_code
示例4: run
# 需要导入模块: from python_qt_binding.QtGui import QApplication [as 别名]
# 或者: from python_qt_binding.QtGui.QApplication import exec_ [as 别名]
def run(gui,debug=False):
"""
@param gui: The gui to render and execute
"""
if debug:
str_traverse = StringTraverse()
gui.traverse(str_traverse)
rospy.init_node("guiname")
code_traverse = pyqtTraverse()
app = QApplication(sys.argv)
gui.traverse(code_traverse)
sys.exit(app.exec_())
示例5: main
# 需要导入模块: from python_qt_binding.QtGui import QApplication [as 别名]
# 或者: from python_qt_binding.QtGui.QApplication import exec_ [as 别名]
def main(name, anonymous=False):
masteruri = init_cfg_path()
args = rospy.myargv(argv=sys.argv)
# decide to show main or echo dialog
if len(args) >= 4 and args[1] == '-t':
name = ''.join([name, '_echo'])
anonymous = True
try:
from python_qt_binding.QtGui import QApplication
except:
print >> sys.stderr, "please install 'python-pyside' package!!"
sys.exit(-1)
rospy.init_node(name, anonymous=anonymous, log_level=rospy.DEBUG)
setTerminalName(rospy.get_name())
setProcessName(rospy.get_name())
# Initialize Qt
global app
app = QApplication(sys.argv)
# decide to show main or echo dialog
import main_window, echo_dialog
global main_form
if len(args) >= 4 and args[1] == '-t':
show_hz_only = (len(args) > 4 and args[4] == '--hz')
main_form = echo_dialog.EchoDialog(args[2], args[3], show_hz_only, masteruri)
else:
local_master = init_globals(masteruri)
#start the gui
main_form = main_window.MainWindow(args, not local_master)
if not rospy.is_shutdown():
os.chdir(PACKAGE_DIR) # change path to be able to the images of descriptions
main_form.show()
exit_code = -1
rospy.on_shutdown(finish)
exit_code = app.exec_()
示例6: __init__
# 需要导入模块: from python_qt_binding.QtGui import QApplication [as 别名]
# 或者: from python_qt_binding.QtGui.QApplication import exec_ [as 别名]
def __init__(self, qTextPanel):
self.textPanel = qTextPanel;
def setText(self, theStr):
self.textPanel.clear();
self.textPanel.setText(theStr);
def getText(self):
# Get text field text as plain text, and convert
# unicode to ascii, ignoring errors:
#return self.toPlainText().encode('ascii', 'ignore');
return self.textPanel.toPlainText().encode('utf-8');
def textCursor(self):
return self.textPanel.textCursor();
def getCursorPos(self):
return self.textCursor().position;
def isEmpty(self):
return len(self.textPanel.toPlainText()) == 0;
if __name__ == '__main__':
app = QApplication(sys.argv);
ui = MarkupManagementUI();
ui.show();
app.exec_();
sys.exit();
示例7: print
# 需要导入模块: from python_qt_binding.QtGui import QApplication [as 别名]
# 或者: from python_qt_binding.QtGui.QApplication import exec_ [as 别名]
)
except:
print (
"Will attempt to start SpeakEasy in ROS mode. If fail, switch to local mode. Possibly a few seconds delay..."
)
speakeasyController = SpeakEasyController(scriptDir, unix_sig_notify_read_socket=rsock, stand_alone=None)
else:
try:
rospy.loginfo(
"Will attempt to start SpeakEasy in ROS mode. If fail, switch to local mode. Possibly a few seconds delay..."
)
except:
print (
"Will attempt to start SpeakEasy in ROS mode. If fail, switch to local mode. Possibly a few seconds delay..."
)
speakeasyController = SpeakEasyController(scriptDir, unix_sig_notify_read_socket=rsock, stand_alone=None)
# Attach Unix signals USR1/USR2 to the sigusr1_2_handler().
# (These signals are separate from the Qt signals!):
signal.signal(signal.SIGUSR1, sigusr1_2_handler)
signal.signal(signal.SIGUSR2, sigusr1_2_handler)
# Unix signals are delivered to Qt only when Qt
# leaves its event loop. Force that to happen
# every half second:
timer = QTimer()
timer.start(500)
timer.timeout.connect(lambda: None)
# Enter Qt application main loop
sys.exit(app.exec_())
示例8: QAction
# 需要导入模块: from python_qt_binding.QtGui import QApplication [as 别名]
# 或者: from python_qt_binding.QtGui.QApplication import exec_ [as 别名]
a2 = QAction('add v', tb)
a2.do = add_vertical
a2.triggered.connect(a2.do)
tb.addAction(a2)
def save(self):
global mw, settings
settings.setValue('state', mw.saveState())
print('saved')
def restore(self):
global mw, settings
if settings.contains('state'):
restored = mw.restoreState(settings.value('state'))
if restored:
print('restored')
else:
print('restore failed')
a3 = QAction('save', tb)
a3.do = save
a3.triggered.connect(a3.do)
tb.addAction(a3)
a4 = QAction('restore', tb)
a4.do = restore
a4.triggered.connect(a4.do)
tb.addAction(a4)
app.exec_()
开发者ID:dirk-thomas,项目名称:issue_qt_restore_state_orientation,代码行数:32,代码来源:qt_restore_state_orientation.py
示例9: main
# 需要导入模块: from python_qt_binding.QtGui import QApplication [as 别名]
# 或者: from python_qt_binding.QtGui.QApplication import exec_ [as 别名]
#.........这里部分代码省略.........
setup_logging(options.log_config)
logger = logging.getLogger(__name__)
import mhlinphone_wrapper
from linphone import linphone
from wrappers import common
from lp_rpc_server import lp_rpc_server
from lp_config import LPConfig
from python_qt_binding.QtGui import QApplication
from python_qt_binding.QtGui import QWidget
from python_qt_binding.QtGui import QDesktopWidget
app = QApplication(sys.argv)
preview_widget=QWidget()
view_widget=QWidget()
for w in [preview_widget,view_widget]:
w.setBaseSize(300,300)
w.show()
wid = w.winId()
print("WID %s %s" % (hex(wid), int(wid)))
screen = QDesktopWidget()
preview_widget.move(screen.width() - preview_widget.width(), 0)
view_widget.move(screen.width() - view_widget.width(), screen.height() - view_widget.height())
config=None
if options.config_file:
config = LPConfig(options.config_file)
linphone_wrap = mhlinphone_wrapper.MHLinphoneWrapper(rc_config_file=options.linphonerc,
config=config)
linphone_wrap.init()
if options.xmlrpcsrv:
rpc_funcs = lp_rpc_server.MHLPFuncs(linphone_wrap,
quit_func=quit_app, show_func=show)
addr, port = (options.xmlrpcsrv + ':8000').split(':')[:2]
rpc_server = lp_rpc_server.LPRpcServer(linphone_wrap, addr, int(port),
rpc_funcs)
rpc_server.start_in_thread()
else:
rpc_server = None
if options.auto_answer:
linphone_wrap.register_callback(linphone_wrap.EVT.INCOMING,
auto_answer)
linphone_wrap.set_vvideo(int(view_widget.winId()))
linphone_wrap.set_pvideo(int(preview_widget.winId()))
linphone_wrap.register_callback(linphone_wrap.EVT.RMT_PREVIEW_SNAPSHOT, unzip_test)
addr = linphone_wrap.config.get('test.address')
port = linphone_wrap.config.get('test.port')
rpc_client = xmlrpclib.ServerProxy('http://'+addr+':'+str(port)+'/MH_LP')
def dirfind(str, *objs):
ret = []
if not objs:
objs = dir(linphone)
for obj in objs:
ret.extend([ (obj, v) for v in dir(obj) if str in v.lower() ])
return ret
def start(fname): #open file under win
os.system('cmd /c start ' + fname)
if options.cli:
from mh_cli import CLI
namespace = dict(
dirfind=dirfind,
start=start,
linphone=linphone,
os=os,
app=app,
preview_widget=preview_widget,
view_widget=view_widget,
mhlinphone_wrapper=mhlinphone_wrapper,
lin=linphone_wrap,
args=args,
options=options,
logger=logger,
rpc_server=rpc_server,
rpc_client=rpc_client,
remote_sip_addr=linphone_wrap.config.get('test.remote_sip_addr'),
local_sip_addr=linphone_wrap.config.get('local_sip_addr'),
item=item,
sce= Scenarios,
auto_ans= auto_answer,
)
cli = CLI(options, namespace=namespace)
cli.run_as_thread(daemon=False)
exitcode = app.exec_()
sys.exit(exitcode)