当前位置: 首页>>代码示例>>Python>>正文


Python QtGui.QApplication类代码示例

本文整理汇总了Python中python_qt_binding.QtGui.QApplication的典型用法代码示例。如果您正苦于以下问题:Python QApplication类的具体用法?Python QApplication怎么用?Python QApplication使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QApplication类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_application

 def create_application(self, argv):
     from python_qt_binding.QtCore import Qt
     from python_qt_binding.QtGui import QApplication
     # QApplication.setAttribute(Qt.AA_X11InitThreads, True)
     app = QApplication(argv)
     app.setAttribute(Qt.AA_DontShowIconsInMenus, False)
     return app
开发者ID:ethz-asl,项目名称:qt_gui_core,代码行数:7,代码来源:main.py

示例2: main

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_()
开发者ID:awesomebytes,项目名称:multimaster_fkie,代码行数:34,代码来源:__init__.py

示例3: on_launch_selection_activated

 def on_launch_selection_activated(self, activated):
     '''
     Tries to load the launch file, if one was activated.
     '''
     selected = self._launchItemsFromIndexes(self.xmlFileView.selectionModel().selectedIndexes(), False)
     for item in selected:
         try:
             lfile = self.launchlist_model.expandItem(item.name, item.path, item.id)
             self.searchPackageLine.setText('')
             if lfile is not None:
                 if item.isLaunchFile():
                     nm.settings().launch_history_add(item.path)
                     key_mod = QApplication.keyboardModifiers()
                     if key_mod & Qt.ShiftModifier:
                         self.load_as_default_signal.emit(item.path, None)
                     elif key_mod & Qt.ControlModifier:
                         self.launchlist_model.setPath(os.path.dirname(item.path))
                     else:
                         self.load_signal.emit(item.path, [], None)
                 elif item.isProfileFile():
                     nm.settings().launch_history_add(item.path)
                     key_mod = QApplication.keyboardModifiers()
                     if key_mod & Qt.ControlModifier:
                         self.launchlist_model.setPath(os.path.dirname(item.path))
                     else:
                         self.load_profile_signal.emit(item.path)
                 elif item.isConfigFile():
                     self.edit_signal.emit([lfile])
         except Exception as e:
             rospy.logwarn("Error while load launch file %s: %s" % (item, utf8(e)))
             MessageBox.warning(self, "Load error",
                                'Error while load launch file:\n%s' % item.name,
                                "%s" % utf8(e))
开发者ID:zhouchengming1,项目名称:multimaster_fkie,代码行数:33,代码来源:launch_files_widget.py

示例4: expandItem

 def expandItem(self, path_item, path, item_id):
     '''
     Returns for the given item and path the file path if this is a file. Otherwise the
     folder will be expanded and None will be returned.
     @param path_item: the list item
     @type path_item: C{str}
     @param path: the real path of the item
     @type path: C{str}
     @return: path of the launch file or None
     @rtype: C{str}
     @raise Exception if no path to given item was found
     '''
     if path_item == '..':
         goto_path = os.path.dirname(path)
         key_mod = QApplication.keyboardModifiers()
         if key_mod & Qt.ControlModifier:
             goto_path = None
         root_path, items = self._moveUp(goto_path)
     elif os.path.isfile(path):
         return path
     elif item_id == LaunchItem.RECENT_FILE or item_id == LaunchItem.LAUNCH_FILE:
         raise Exception("Invalid file path: %s", path)
     else:
         key_mod = QApplication.keyboardModifiers()
         onestep = False
         if key_mod & Qt.ControlModifier:
             onestep = True
         root_path, items = self._moveDown(path, onestep)
     self._setNewList((root_path, items))
     return None
开发者ID:zhouchengming1,项目名称:multimaster_fkie,代码行数:30,代码来源:launch_list_model.py

示例5: main

def main():
    app = QApplication(sys.argv)
    
    test_g = MainWidget()
    test_g.show()
    
    return app.exec_()
开发者ID:Jacky-Fabbros,项目名称:kimeo,代码行数:7,代码来源:test.py

示例6: __init__

 def __init__(self, img):
     splash_pix = QPixmap(img)
     self.splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
     self.splash.setMask(splash_pix.mask())
     self.splash.show()
     for i in range(100):
         time.sleep(0.01)
         QApplication.processEvents()
开发者ID:kindsenior,项目名称:rtmros_common,代码行数:8,代码来源:hrpsys_dashboard.py

示例7: main

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
开发者ID:fkie,项目名称:multimaster_fkie,代码行数:58,代码来源:__init__.py

示例8: copy_to_clipboard

 def copy_to_clipboard(self, indexes):
     '''
     Copy the selected path to the clipboard
     '''
     mimeData = QMimeData()
     text = ''
     for index in indexes:
         if index.isValid():
             item = self.itemFromIndex(index)
             prev = '%s\n' % text if text else ''
             text = '%sfile://%s' % (prev, item.path)
     mimeData.setData('text/plain', text.encode('utf-8'))
     QApplication.clipboard().setMimeData(mimeData)
开发者ID:zhouchengming1,项目名称:multimaster_fkie,代码行数:13,代码来源:launch_list_model.py

示例9: paint

    def paint(self, painter, option, index):
        if index.column() in [0,3]:
            return super(GroupsDelegate, self).paint(painter, option, index)

        button = QStyleOptionButton()
        r = option.rect
        x = r.left() + r.width() - 30
        y = r.top()+ 2
        w = 28
        h = 14
        button.rect = QRect(x,y,w,h)
        button.text = '+' if index.column() == 1 else '-'
        button.state = QStyle.State_Enabled

        QApplication.style().drawControl(QStyle.CE_PushButton, button, painter)
开发者ID:nasnysom,项目名称:conman,代码行数:15,代码来源:conman.py

示例10: closeEvent

 def closeEvent(self, event):
     if self.sub is not None:
         self.sub.unregister()
         del self.sub
     try:
         self.ssh_output_file.close()
         self.ssh_error_file.close()
         # send Ctrl+C to remote process
         self.ssh_input_file.write("%s\n" % chr(3))
         self.ssh_input_file.close()
     except:
         pass
     self.finished_signal.emit(self.topic)
     if self.parent() is None:
         QApplication.quit()
开发者ID:fkie,项目名称:multimaster_fkie,代码行数:15,代码来源:echo_dialog.py

示例11: run

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_())
开发者ID:AliquesTomas,项目名称:FroboMind,代码行数:16,代码来源:QuickUi.py

示例12: keyPressEvent

 def keyPressEvent(self, event):
     '''
     Defines some of shortcuts for navigation/management in launch
     list view or topics view.
     '''
     key_mod = QApplication.keyboardModifiers()
     if not self.xmlFileView.state() == QAbstractItemView.EditingState:
         # remove history file from list by pressing DEL
         if event == QKeySequence.Delete:
             selected = self._launchItemsFromIndexes(self.xmlFileView.selectionModel().selectedIndexes(), False)
             for item in selected:
                 nm.settings().launch_history_remove(item.path)
                 self.launchlist_model.reloadCurrentPath()
         elif not key_mod and event.key() == Qt.Key_F4 and self.editXmlButton.isEnabled():
             # open selected launch file in xml editor by F4
             self.on_edit_xml_clicked()
         elif event == QKeySequence.Find:
             # set focus to filter box for packages
             self.searchPackageLine.setFocus(Qt.ActiveWindowFocusReason)
         elif event == QKeySequence.Paste:
             # paste files from clipboard
             self.launchlist_model.paste_from_clipboard()
         elif event == QKeySequence.Copy:
             # copy the selected items as file paths into clipboard
             selected = self.xmlFileView.selectionModel().selectedIndexes()
             indexes = []
             for s in selected:
                 indexes.append(self.launchlist_proxyModel.mapToSource(s))
             self.launchlist_model.copy_to_clipboard(indexes)
     if self.searchPackageLine.hasFocus() and event.key() == Qt.Key_Escape:
         # cancel package filtering on pressing ESC
         self.launchlist_model.show_packages(False)
         self.searchPackageLine.setText('')
         self.xmlFileView.setFocus(Qt.ActiveWindowFocusReason)
     QDockWidget.keyReleaseEvent(self, event)
开发者ID:zhouchengming1,项目名称:multimaster_fkie,代码行数:35,代码来源:launch_files_widget.py

示例13: paint

    def paint(self, painter, option, index):
        '''
        Use the QTextDokument to represent the HTML text.
        @see: U{http://www.pyside.org/docs/pyside/PySide/QtGui/QAbstractItemDelegate.html#PySide.QtGui.QAbstractItemDelegate}
        '''
        options = QStyleOptionViewItem(option)
        self.initStyleOption(options, index)

        style = QApplication.style() if options.widget is None else options.widget.style()

        doc = QTextDocument()
        doc.setHtml(self.toHTML(options.text))
        doc.setTextWidth(option.rect.width())

        options.text = ''
        style.drawControl(QStyle.CE_ItemViewItem, options, painter)

        ctx = QAbstractTextDocumentLayout.PaintContext()

        # Highlighting text if item is selected
        # if (optionV4.state and QStyle::State_Selected):
        #  ctx.palette.setColor(QPalette::Text, optionV4.palette.color(QPalette::Active, QPalette::HighlightedText));

        textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options, options.widget)
        painter.save()
        painter.translate(QPoint(textRect.topLeft().x(), textRect.topLeft().y() - 3))
        painter.setClipRect(textRect.translated(-textRect.topLeft()))
        doc.documentLayout().draw(painter, ctx)

        painter.restore()
开发者ID:fkie,项目名称:multimaster_fkie,代码行数:30,代码来源:html_delegate.py

示例14: paste_from_clipboard

 def paste_from_clipboard(self):
     '''
     Copy the file or folder to new position...
     '''
     if QApplication.clipboard().mimeData().hasText() and self.currentPath:
         text = QApplication.clipboard().mimeData().text()
         if text.startswith('file://'):
             path = text.replace('file://', '')
             basename = os.path.basename(text)
             ok = True
             if os.path.exists(os.path.join(self.currentPath, basename)):
                 basename, ok = QInputDialog.getText(None, 'File exists', 'New name (or override):', QLineEdit.Normal, basename)
             if ok and basename:
                 if os.path.isdir(path):
                     shutil.copytree(path, os.path.join(self.currentPath, basename))
                 elif os.path.isfile(path):
                     shutil.copy2(path, os.path.join(self.currentPath, basename))
                 self.reloadCurrentPath()
开发者ID:zhouchengming1,项目名称:multimaster_fkie,代码行数:18,代码来源:launch_list_model.py

示例15: main

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_()
开发者ID:markusachtelik,项目名称:multimaster_fkie,代码行数:40,代码来源:__init__.py


注:本文中的python_qt_binding.QtGui.QApplication类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。